|
|
@ -12,7 +12,8 @@ |
|
|
|
</style> |
|
|
|
<template> |
|
|
|
<view class="container"> |
|
|
|
<u-form class="card inline" errorType="toast" :model="formData" :rules="rules" labelWidth="auto"> |
|
|
|
<!-- errorType="toast" --> |
|
|
|
<u-form class="card inline" :model="{...formData,images:fields.images.value}" :rules="rules" ref="form" labelWidth="auto"> |
|
|
|
<d-form |
|
|
|
v-for="(v,k) in fields" |
|
|
|
:key="k" |
|
|
@ -20,11 +21,11 @@ |
|
|
|
:field="k" |
|
|
|
:required="!!rules[k]" |
|
|
|
:value="/^select$/.test(v.type)?fields[k].value:formData[k]" |
|
|
|
@select="select" |
|
|
|
@select="$set(fields.plantType, 'value', $event.indexs);formData.plantType=$event.value[1].value" |
|
|
|
@input="formData[k]=$event" |
|
|
|
@imgs="fields[k].value=$event"/> |
|
|
|
</u-form> |
|
|
|
<button class="cu-btn round bg-green shadow submit">确认提交</button> |
|
|
|
<button class="cu-btn round bg-green shadow submit" @click="submit">确认提交</button> |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
<script> |
|
|
@ -34,7 +35,7 @@ export default { |
|
|
|
return{ |
|
|
|
fields:{ |
|
|
|
varietyName:{label:"品种名称"}, |
|
|
|
plantType:{label:"作物类型",type:"select",columns:[],value:[]}, |
|
|
|
plantType:{label:"作物类型",type:"select",columns:[[]],value:[null,null]}, |
|
|
|
plantArea:{label:"种植面积(亩)",type:"digit"}, |
|
|
|
startTime:{label:"种植开始日期",type:"calendar"}, |
|
|
|
harvestTime:{label:"预估采收日期",type:"calendar"}, |
|
|
@ -63,36 +64,81 @@ export default { |
|
|
|
principal:"", |
|
|
|
principalId:"", |
|
|
|
productIntroduce:"", |
|
|
|
plotId: "", // 给我传下地块id |
|
|
|
}, |
|
|
|
rules:{ |
|
|
|
varietyName: {required:true, message:"必填!", trigger:"blur"}, |
|
|
|
plantType: {required:true, message:"必填!", trigger:"blur"}, |
|
|
|
plantArea: {required:true, message:"必填!", trigger:"blur"}, |
|
|
|
startTime: {required:true, message:"必填!", trigger:"blur"}, |
|
|
|
harvestTime: {required:true, message:"必填!", trigger:"blur"}, |
|
|
|
images: {required:true, message:"必填!", trigger:"blur"}, |
|
|
|
plantStandard: {required:true, message:"必填!", trigger:"blur"}, |
|
|
|
plantBatch: {required:true, message:"必填!", trigger:"blur"}, |
|
|
|
principal: {required:true, message:"必填!", trigger:"blur"}, |
|
|
|
principalId: {required:true, message:"必填!", trigger:"blur"}, |
|
|
|
varietyName: {required:true, message:"品种名称必填!", trigger:"blur"}, |
|
|
|
plantType: {required:true, message:"作物类型必选!", trigger:"blur"}, |
|
|
|
plantArea: {required:true, type:"number", message:"种植面积必填!", trigger:"blur"}, |
|
|
|
startTime: {required:true, message:"种植开始日期必选!", trigger:"blur"}, |
|
|
|
harvestTime: {required:true, message:"预估采收日期必选!", trigger:"blur"}, |
|
|
|
images: {required:true, message:"产品图片必选!", trigger:"blur"}, |
|
|
|
plantStandard: {required:true, message:"种植标准必填!", trigger:"blur"}, |
|
|
|
plantBatch: {required:true, message:"种植批次号必填!", trigger:"blur"}, |
|
|
|
principal: {required:true, message:"负责人必填!", trigger:"blur"}, |
|
|
|
principalId: {required:true, message:"负责人身份证必填!", trigger:"blur"}, |
|
|
|
}, |
|
|
|
eventChannel:null, |
|
|
|
} |
|
|
|
}, |
|
|
|
onLoad(){ |
|
|
|
onLoad(options){ |
|
|
|
this.eventChannel=this.getOpenerEventChannel() |
|
|
|
this.init() |
|
|
|
setTimeout(() => { |
|
|
|
this.fields.plantType.columns=[[{label:"1",value:1,item:[{label:'1-1',value:'1-1'}]},{label:2,value:2,item:[{label:'2-1',value:'2-1'}]}]] |
|
|
|
}, 1000); |
|
|
|
|
|
|
|
options.plotId && (this.formData.plotId=options.plotId) |
|
|
|
options.id && this.getDetail(options.id) |
|
|
|
}, |
|
|
|
methods:{ |
|
|
|
async init(){ |
|
|
|
var res=await request("/sys/category/loadTreeData",{ |
|
|
|
params:{pid:"",pcode:"B06",} |
|
|
|
var res=await request("/api/plantPlan/getType") |
|
|
|
if(res.statu){ |
|
|
|
this.fields.plantType.columns=[res.data] |
|
|
|
}else{ |
|
|
|
uni.showModal({ |
|
|
|
title:"提示", |
|
|
|
content:res.msg||"获取作物类型下拉选项失败!", |
|
|
|
showCancel:false, |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
submit(){ |
|
|
|
this.$refs.form.validate().then(async valid=>{ |
|
|
|
if(valid){ |
|
|
|
var res=await request("/api/plantPlan/add",{ |
|
|
|
method:"post", |
|
|
|
body:{ |
|
|
|
...this.formData, |
|
|
|
images:this.fields.images.value |
|
|
|
} |
|
|
|
}) |
|
|
|
if(res.statu){ |
|
|
|
this.eventChannel.emit("update") |
|
|
|
uni.navigateBack() |
|
|
|
}else{ |
|
|
|
uni.showModal({ |
|
|
|
title:"提示", |
|
|
|
content:res.msg||"保存失败!", |
|
|
|
showCancel:false, |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
select(e){ |
|
|
|
console.log(e,'-------------e-----------------') |
|
|
|
async getDetail(id){ |
|
|
|
var res=await request("/api/plantPlan/queryById",{ |
|
|
|
params:{id} |
|
|
|
}) |
|
|
|
if(res.statu){ |
|
|
|
this.formData=res.data |
|
|
|
this.fields.images.value=res.data.images.join(',') |
|
|
|
}else{ |
|
|
|
uni.showModal({ |
|
|
|
title:"提示", |
|
|
|
content:res.msg||"获取种植计划详情失败!", |
|
|
|
showCancel:false, |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |