Browse Source

修改多选表单

master
邓宏 2 years ago
parent
commit
f64614d240
  1. 7
      pages/massif/pestRecord.vue
  2. 2
      uni_modules/d-form/components/d-form/d-form.vue

7
pages/massif/pestRecord.vue

@ -14,8 +14,9 @@
:field="k" :field="k"
v-bind="v" v-bind="v"
:required="!!rules[k]" :required="!!rules[k]"
:value="/^$/.test(v.type)?fields[k].value:formData[k]" :value="/^checkBox$/.test(v.type)?fields[k].value:formData[k]"
@input="formData[k]=$event" @input="formData[k]=$event"
@checkBox="fields[k].value=$event;formData[k]=$event.join(',')"
@select="formData[k]=$event[0].value" @select="formData[k]=$event[0].value"
@imgs="fields[k].value=$event"/> @imgs="fields[k].value=$event"/>
</u-form> </u-form>
@ -29,7 +30,7 @@ export default {
return{ return{
fields:{ fields:{
growthProcess:{label:"作物生长过程",type:"select-tab",dictCode:"growth_process"}, growthProcess:{label:"作物生长过程",type:"select-tab",dictCode:"growth_process"},
pestSite:{label:"病虫害部位",type:"checkBox",columns:[{label:"根",value:"根"},{label:"茎",value:"茎"},{label:"叶",value:"叶"}]}, pestSite:{label:"病虫害部位",type:"checkBox",value:[],columns:[{label:"根",value:"根"},{label:"茎",value:"茎"},{label:"叶",value:"叶"}]},
symptom:{label:"显著症状",type:"select-tab",dictCode:"symptom"}, symptom:{label:"显著症状",type:"select-tab",dictCode:"symptom"},
medicationArea:{label:"农资作用面积",type:"digit",suffix:"亩"}, medicationArea:{label:"农资作用面积",type:"digit",suffix:"亩"},
pic:{label:"凭证",type:"upImg",value:""}, pic:{label:"凭证",type:"upImg",value:""},
@ -45,7 +46,7 @@ export default {
}, },
rules:{ rules:{
growthProcess:{required:true,message:"请选择作物生长过程!",trigger:['blur','change']}, growthProcess:{required:true,message:"请选择作物生长过程!",trigger:['blur','change']},
pestSite:{required:true,message:"请选择病虫害部位!",type:"array",trigger:['blur','change']}, pestSite:{required:true,message:"请选择病虫害部位!",trigger:['blur','change']},
symptom:{required:true,message:"请选择显著症状!",trigger:['blur','change']}, symptom:{required:true,message:"请选择显著症状!",trigger:['blur','change']},
medicationArea:{required:true,message:"请输入农资作用面积!",type:"number",trigger:['blur','change']}, medicationArea:{required:true,message:"请输入农资作用面积!",type:"number",trigger:['blur','change']},
pic:{required:true,validator:(rule,val,call)=>{ pic:{required:true,validator:(rule,val,call)=>{

2
uni_modules/d-form/components/d-form/d-form.vue

@ -302,7 +302,7 @@
</u-radio-group> </u-radio-group>
</view> </view>
<view v-else-if="type=='checkBox'" class="checkBox"> <view v-else-if="type=='checkBox'" class="checkBox">
<u-checkbox-group :value="value" @change="$emit('input',$event)" > <u-checkbox-group :value="value" @change="$emit('checkBox',$event)" >
<u-checkbox :customStyle="{marginRight: '30rpx'}" v-for="(v, k) in columns" :key="k" activeColor="#D9F6E9" iconColor="#10C176" :label="v.label" :name="v.value" /> <u-checkbox :customStyle="{marginRight: '30rpx'}" v-for="(v, k) in columns" :key="k" activeColor="#D9F6E9" iconColor="#10C176" :label="v.label" :name="v.value" />
</u-checkbox-group> </u-checkbox-group>
</view> </view>

Loading…
Cancel
Save