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.

86 lines
2.5 KiB

2 years ago
<style lang="scss" scoped>
2 years ago
.container{
2 years ago
background:#F6F6F6;
2 years ago
padding:14px 0;
min-height:100%;
2 years ago
}
</style>
<template>
2 years ago
<view class="container">
2 years ago
<u-form class="card inline" errorType="toast" :model="formData" ref="form" :rules="rules" labelWidth="auto">
2 years ago
<d-form
v-for="(v,k) in fields"
:key="k"
v-bind="v"
:required="!!rules[k]"
:field="k"
2 years ago
:value="({dateRange:fields.date.value})[v.type||'text']||formData[k]"
2 years ago
@input="formData[k]=$event"
@selectRDate="selectDate"
@imgs="fields[k].value=$event"/>
2 years ago
</u-form>
2 years ago
<button class="cu-btn round bg-green shadow submit" @click="sumbit">保存</button>
2 years ago
</view>
</template>
<script>
import dForm from '@/components/form.vue'
export default{
components:{dForm},
data(){
return{
fields:{
2 years ago
plantBaseName:{label:"基地名称"},
plotNumber:{label:"地块编号"},
plotName:{label:"地块名称"},
2 years ago
drawArea:{label:"地块面积(亩)",type:'digit'},
realityArea:{label:"实际面积",type:'digit'},
2 years ago
image:{label:"地块图片",type:"upImg",num:3},
2 years ago
date:{label:"使用日期",type:"dateRange",value:[]},
jw:{label:"经/纬度"},
2 years ago
address:{label:"详细地址",type:"textarea"},
2 years ago
},
formData:{
2 years ago
plantBaseName:"",
plotNumber:"",
plotName:"",
drawArea:0,
2 years ago
realityArea:0,
2 years ago
image:[],
beginTime:"",
endTime:"",
longitude:"",
latitude:"",
address:"",
2 years ago
},
rules:{
2 years ago
plantBaseName:{required:true, message:"基地名称必填!", trigger:"blue"},
plotNumber:{required:true, message:"地块编号必填!", trigger:"blue"},
plotName:{required:true, message:"地块名称必填!", trigger:"blue"},
drawArea:{required:true, message:"地块面积必填!", trigger:"blue"},
realityArea:{required:true, message:"实际面积必填!", trigger:"blue"},
image:{required:true, type:"array",min:1, message:"地块图片必填!", trigger:"blue"},
date:{required:true,validator:(rule,val,call)=>{
if(!this.fields.date.value[0])call(new Error('请选择开始时间!'));
else if(!this.fields.date.value[1])call(new Error('请选择结束时间!'));
else call()
}, trigger:"blue"}
2 years ago
},
}
},
methods:{
selectDate(e){
switch(e.type){
case "start":this.fields.date.value[0]=e.value;break;
case 'end':this.fields.date.value[1]=e.value;break;
}
2 years ago
},
sumbit(){
this.$refs.form.validate().then(async valid=>{
if(valid){
}
})
2 years ago
}
},
}
</script>