224 lines
8.4 KiB
Vue
Raw Normal View History

2023-08-02 17:25:58 +08:00
<template>
<view class="card">
<view class="title">开设店铺</view>
<u--form labelPosition="left" :model="formData" :rules="rules" ref="breedingForm">
<u-form-item labelWidth="auto" label="有无门面" required prop="shop_front" borderBottom>
<u-radio-group :disabled="readonly" v-model="formData.shop_front" style="margin: 16rpx;">
<u-radio :customStyle="{marginRight: '16px'}"
v-for="(item, index) in [{value:1,label:'有'},{value:0,label:'无'}]" :key="index" :label="item.label"
:name="item.value">
</u-radio>
</u-radio-group>
</u-form-item>
<u-form-item labelWidth="auto" label="门面面积" required prop="area" borderBottom>
<u--input :readonly="readonly" v-model="formData.area" placeholder="请输入门面面积"></u--input>
</u-form-item>
<u-form-item labelWidth="auto" label="经营地点" required prop="place" borderBottom>
<u--input :readonly="readonly" v-model="formData.place" placeholder="请输入经营地点"></u--input>
</u-form-item>
<picker :range="storeTypeList" :disabled="readonly" mode="selector" @change="changeType">
<u-form-item labelWidth="auto" label="经营类型" required prop="type" borderBottom>
<u--input :value="storeTypeList[formData.type]" placeholder="请选择经营类型" disabled
disabledColor="#fff"></u--input>
<u-icon slot="right" name="arrow-right"></u-icon>
</u-form-item>
</picker>
<u-form-item labelWidth="auto" label="门面环境" required prop="environment" borderBottom>
<u--input :readonly="readonly" v-model="formData.environment" placeholder="请输入门面环境"></u--input>
</u-form-item>
<u-form-item labelWidth="auto" label="服务对象" required prop="service" borderBottom>
<u--input :readonly="readonly" v-model="formData.service" placeholder="请输入服务对象"></u--input>
</u-form-item>
<u-form-item labelWidth="auto" label="有无营业资质" required prop="qualification" borderBottom>
<u-radio-group :disabled="readonly" v-model="formData.qualification" style="margin: 16rpx;">
<u-radio :customStyle="{marginRight: '16px'}"
v-for="(item, index) in [{value:1,label:'有'},{value:0,label:'无'}]" :key="index" :label="item.label"
:name="item.value">
</u-radio>
</u-radio-group>
</u-form-item>
<u-form-item labelWidth="auto" label="有无进货渠道" required prop="stock" borderBottom>
<u-radio-group :disabled="readonly" v-model="formData.stock" style="margin: 16rpx;">
<u-radio :customStyle="{marginRight: '16px'}"
v-for="(item, index) in [{value:1,label:'有'},{value:0,label:'无'}]" :key="index" :label="item.label"
:name="item.value">
</u-radio>
</u-radio-group>
</u-form-item>
<u-form-item labelWidth="auto" label="店铺规模" required prop="scale" borderBottom>
<u--input :readonly="readonly" v-model="formData.scale" placeholder="请输入店铺规模"></u--input>
</u-form-item>
<u-form-item labelWidth="auto" label="商品来源" required prop="source" borderBottom>
<u--input :readonly="readonly" v-model="formData.source" placeholder="请输入商品来源"></u--input>
</u-form-item>
<u-form-item labelWidth="auto" label="有无线上展示" required prop="online_display" borderBottom>
<u-radio-group :disabled="readonly" v-model="formData.online_display" style="margin: 16rpx;">
<u-radio :customStyle="{marginRight: '16px'}"
v-for="(item, index) in [{value:1,label:'有'},{value:0,label:'无'}]" :key="index" :label="item.label"
:name="item.value">
</u-radio>
</u-radio-group>
</u-form-item>
<u-form-item labelWidth="auto" label="有无品牌" required prop="brand" borderBottom>
<u-radio-group :disabled="readonly" v-model="formData.brand" style="margin: 16rpx;">
<u-radio :customStyle="{marginRight: '16px'}"
v-for="(item, index) in [{value:1,label:'有'},{value:0,label:'无'}]" :key="index" :label="item.label"
:name="item.value">
</u-radio>
</u-radio-group>
</u-form-item>
<u-form-item labelWidth="auto" label="库存情况" required prop="repertory" borderBottom>
<u-radio-group :disabled="readonly" v-model="formData.repertory" style="margin: 16rpx;">
<u-radio :customStyle="{marginRight: '16px'}"
v-for="(item, index) in [{value:1,label:'有'},{value:0,label:'无'}]" :key="index" :label="item.label"
:name="item.value">
</u-radio>
</u-radio-group>
</u-form-item>
<u-form-item labelWidth="auto" labelPosition="top" label="经营诉求" required prop="appeal" borderBottom>
<u--textarea :disabled="readonly" v-model="formData.appeal" autoHeight placeholder="请输入经营诉求" border="surround"
count></u--textarea>
</u-form-item>
</u--form>
</view>
</template>
<script>
export default {
props: {
readonly: {
type: Boolean,
default: false
},
datas: {
type: Object,
default: null
}
},
data() {
return {
storeTypeList: ['超市', '生鲜', '饭店', '五金', '杂货', '服装', '文具', '其他'],
formData: {
shop_front: '', //有无门面
area: '',
place: '',
type: '',
environment: '',
service: '',
qualification: '',
stock: '',
scale: '',
online_display: '',
brand: '',
repertory: '',
appeal: '',
},
rules: {
}
}
},
created() {
this.initRules();
if (this.$props.readonly && this.$props.datas) {
this.formData = this.$props.datas;
console.log(this.formData);
let keys = Object.keys(this.formData);
keys.forEach(item => {
if (!isNaN(this.formData[item])) this.formData[item] = +this.formData[item];
})
console.log(this.formData);
}
},
watch: {
datas(newValue, oldValue) {
if (this.$props.readonly && newValue) {
this.formData = this.$props.datas;
let keys = Object.keys(this.formData);
keys.forEach(item => {
if (!isNaN(this.formData[item])) this.formData[item] = +this.formData[item];
})
}
}
},
methods: {
// 初始化校验
initRules() {
let arr = Object.keys(this.formData);
arr.forEach(key => {
this.rules[key] = {
validator: (rule, value, callback) => {
this.$refs.breedingForm.clearValidate(rule.field);
value.trim() !== '' ? callback() : callback('不能为空');
},
trigger: ['change', 'blur']
}
})
},
// 校验
async validate() {
return await this.$refs.breedingForm.validate();
},
// 选择经营类型
changeType(e) {
let index = e.currentTarget.dataset.index;
this.formData.type = e.detail.value;
},
// 选择时间
changeDate(e) {
let data = e.currentTarget.dataset;
this.formData[data.value] = e.detail.value;
},
},
}
</script>
<style lang="scss">
.card{
background-color: #fff;
margin: 28rpx;
padding: 28rpx;
border-radius: 14rpx;
}
.title {
font-weight: 500;
font-size: 34rpx;
&::before {
width: 8rpx;
height: 26rpx;
border-radius: 4rpx;
background-color: #3175f9;
content: "";
display: inline-block;
margin-right: 8rpx;
}
}
.delete {
margin: 22rpx 0;
// margin-bottom: 40rpx;
width: 100%;
height: 64rpx;
line-height: 64rpx;
background: #f56c6c;
border-radius: 14rpx;
font-size: 28rpx;
color: #fff;
text-align: center;
}
.plus {
margin: 22rpx 0;
// margin-bottom: 40rpx;
width: 100%;
height: 64rpx;
line-height: 64rpx;
background: $theme-oa-color;
border-radius: 14rpx;
font-size: 28rpx;
color: #fff;
text-align: center;
}
2023-07-29 15:41:50 +08:00
</style>