You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.3 KiB
76 lines
2.3 KiB
2 years ago
|
<style lang="scss">
|
||
|
.container{
|
||
|
min-height:100%;
|
||
|
background:#f6f6f6;
|
||
|
padding:30rpx 0;
|
||
|
|
||
|
}
|
||
|
</style>
|
||
|
<template>
|
||
|
<view class="container">
|
||
|
<u-form class="card inline" errorType="toast" :model="formData" :rules="rules" ref="form" labelWidth="auto">
|
||
|
<d-form
|
||
|
v-for="(v,k) in fields" :key="k"
|
||
|
:field="k"
|
||
|
v-bind="v"
|
||
|
:required="!!rules[k]"
|
||
|
:value="/^$/.test(v.type)?fields[k].value:formData[k]"
|
||
|
@input="formData[k]=$event"
|
||
|
@select="formData[k]=$event[0].value"
|
||
|
@imgs="fields[k].value=$event"/>
|
||
|
</u-form>
|
||
|
<button class="cu-btn round bg-green shadow submit" @click="sumbit">保存</button>
|
||
|
</view>
|
||
|
</template>
|
||
|
<script>
|
||
|
import request from '@/common/request'
|
||
|
export default {
|
||
|
data(){
|
||
|
return{
|
||
|
fields:{
|
||
|
growthProcess:{label:"作物生长过程",type:"select-tab",dictCode:"growth_process"},
|
||
|
pestSite:{label:"病虫害部位",type:"checkBox",columns:[{label:"根",value:"根"},{label:"茎",value:"茎"},{label:"叶",value:"叶"}]},
|
||
|
symptom:{label:"显著症状",type:"select-tab",dictCode:"symptom"},
|
||
|
medicationArea:{label:"农资作用面积",type:"digit",suffix:"亩"},
|
||
|
pic:{label:"凭证",type:"upImg",value:""},
|
||
|
description:{label:"病虫害描述",type:"textarea"},
|
||
|
},
|
||
|
formData:{
|
||
|
growthProcess:'',
|
||
|
pestSite:[],
|
||
|
symptom:"",
|
||
|
medicationArea:"",
|
||
|
pic:[],
|
||
|
description:"",
|
||
|
},
|
||
|
rules:{
|
||
|
growthProcess:{required:true,message:"请选择作物生长过程!",trigger:['blur','change']},
|
||
|
pestSite:{required:true,message:"请选择病虫害部位!",type:"array",trigger:['blur','change']},
|
||
|
symptom:{required:true,message:"请选择显著症状!",trigger:['blur','change']},
|
||
|
medicationArea:{required:true,message:"请输入农资作用面积!",type:"number",trigger:['blur','change']},
|
||
|
pic:{required:true,validator:(rule,val,call)=>{
|
||
|
if(!this.fields.pic.value)call(new Error("请选择凭证!"));
|
||
|
else call()
|
||
|
},trigger:['blur','change']},
|
||
|
},
|
||
|
eventChannel:null,
|
||
|
}
|
||
|
},
|
||
|
onLoad(){
|
||
|
this.eventChannel=this.getOpenerEventChannel()
|
||
|
},
|
||
|
methods:{
|
||
|
sumbit(){
|
||
|
this.$refs.form.validate().then(async valid=>{
|
||
|
if(valid){
|
||
|
this.eventChannel.emit("addPest",{
|
||
|
...this.formData,
|
||
|
pic:this.fields.pic.value
|
||
|
})
|
||
|
uni.navigateBack()
|
||
|
}
|
||
|
})
|
||
|
},
|
||
|
},
|
||
|
}
|
||
|
</script>
|