Browse Source

添加农事 修改 操作表单显示

master
邓宏 2 years ago
parent
commit
129a1f6367
  1. 35
      pages/massif/add_farming.vue
  2. 20
      pages/massif/pestRecord.vue
  3. 48
      uni_modules/d-form/components/d-form/d-form.vue

35
pages/massif/add_farming.vue

@ -38,15 +38,24 @@
.card{
margin-top:0;
&>.item{
display:flex;
align-items:center;
border-bottom:2rpx solid rgba(216, 216, 216, 0.4);
height:70rpx;
.title{
margin-right:auto;
padding-bottom:10rpx;
.tabulation{
display:flex;
align-items:center;
height:70rpx;
.title{
margin-right:auto;
}
.record{
color:#FBA83C;
}
}
.record{
color:#FBA83C;
.value{
background:#F7F7F7;
border-radius: 24rpx;
color:#333;
padding:20rpx 30rpx;
}
}
.plant-dikuaimianji{
@ -190,7 +199,12 @@
<view class="card">
<view v-if="/^3$|^5$/.test(formData.farmingType)" class="item" @click="toPestRecord">
<text class="title">操作</text> <text class="record">病虫害记录</text><text class="plant-youbian"/>
<view class="tabulation">
<text class="title">操作</text> <text class="record">病虫害记录</text><text class="plant-youbian"/>
</view>
<view class="value" v-if="formData.farmPests">
过程:{{formData.farmPests.growthProcessLabel}}病虫害部位:{{formData.farmPests.pestSite}}症状{{formData.farmPests.symptomLabel}}
</view>
</view>
<u-form class="inline" errorType="toast" :model="formData" :rules="rules" ref="form" labelWidth="auto">
<d-form
@ -380,7 +394,10 @@ export default {
toPestRecord(){
uni.navigateTo({
url:"/pages/massif/pestRecord",
events:{addPest: e=>this.formData.farmPests=e}
events:{addPest: e=>this.formData.farmPests=e},
success:(res)=>{
res.eventChannel.emit("detail",{...(this.formData.farmPests||{})})
}
})
},
},

20
pages/massif/pestRecord.vue

@ -17,7 +17,7 @@
:value="/^checkBox$/.test(v.type)?fields[k].value:formData[k]"
@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;fields[k].value=$event[0].label"
@imgs="fields[k].value=$event"/>
</u-form>
<button class="cu-btn round bg-green shadow submit" @click="sumbit">保存</button>
@ -29,8 +29,8 @@ export default {
data(){
return{
fields:{
growthProcess:{label:"作物生长过程",type:"select-tab",dictCode:"growth_process"},
pestSite:{label:"病虫害部位",type:"checkBox",value:[],columns:[{label:"根",value:"根"},{label:"茎",value:"茎"},{label:"叶",value:"叶"}]},
growthProcess:{label:"作物生长过程",type:"select-tab",dictCode:"growth_process"},
symptom:{label:"显著症状",type:"select-tab",dictCode:"symptom"},
medicationArea:{label:"农资作用面积",type:"digit",suffix:"亩"},
pic:{label:"凭证",type:"upImg",value:""},
@ -38,7 +38,7 @@ export default {
},
formData:{
growthProcess:'',
pestSite:[],
pestSite:'',
symptom:"",
medicationArea:"",
pic:[],
@ -59,6 +59,16 @@ export default {
},
onLoad(){
this.eventChannel=this.getOpenerEventChannel()
this.eventChannel.on("detail",e=>{
this.fields.pic.value=e.pic||''
this.fields.pestSite.value=e?.pestSite?.split?.(",")?.filter?.(v=>v)||[]
this.fields.growthProcess.value=e?.growthProcessLabel||""
this.fields.symptom.value=e?.symptomLabel||""
this.formData=Object.assign(this.formData,{
...e,
pic:e?.pic?.split?.(",")?.filter?.(v=>v)||[]
})
})
},
methods:{
sumbit(){
@ -66,7 +76,9 @@ export default {
if(valid){
this.eventChannel.emit("addPest",{
...this.formData,
pic:this.fields.pic.value
pic:this.fields.pic.value,
growthProcessLabel:this.fields.growthProcess.value,
symptomLabel:this.fields.symptom.value,
})
uni.navigateBack()
}

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

@ -1,5 +1,6 @@
<style lang="scss" scoped>
.d-form{
margin:20rpx 0;
&>.u-form-item{
position:relative;
&.tip{
@ -171,7 +172,7 @@
}
&/deep/ {
.u-form-item__body{
padding:0 0 20rpx 0;
padding:0;
}
.u-form-item__body__left{
.u-form-item__body__left__content{
@ -185,27 +186,28 @@
margin-left:0!important;
}
}
&.parallel{
&/deep/ .u-form-item__body{
flex-direction: row!important;
border-bottom:2rpx solid rgba(216, 216, 216, 0.4);
padding:0rpx 0;
&>.u-form-item__body__right{
.u-input{
margin:0;
background:transparent!important;
input{
text-align: right!important;
}
}
&.parallel{
margin:0;
&/deep/ .u-form-item__body{
flex-direction: row!important;
border-bottom:2rpx solid rgba(216, 216, 216, 0.4);
padding:0rpx 0;
&>.u-form-item__body__right{
.u-input{
margin:0;
background:transparent!important;
input{
text-align: right!important;
}
.calendar{
background:transparent;
margin:0;
height:80rpx;
justify-content: flex-end;
text.plant-rili{
margin-left:10rpx;
}
}
.calendar{
background:transparent;
margin:0;
height:80rpx;
justify-content: flex-end;
text.plant-rili{
margin-left:10rpx;
}
}
}
@ -271,8 +273,8 @@
}
</style>
<template>
<view class="d-form">
<u-form-item :class="{tip:!!tip, parallel:styleType=='parallel'}" :label="label" :prop="field" :required="required">
<view class="d-form" :class="{parallel:styleType=='parallel'}">
<u-form-item :class="{tip:!!tip}" :label="label" :prop="field" :required="required">
<view v-if="/^text$|^number$|^digit$|^password$/.test(type)" class="textinput">
<u-input :placeholder="placeholder||`请输入${label}`" :type="type" :disabled="disabled" :value="value" @input="$emit('input',$event)" @blur="/^number$|^digit$/.test(type) && $emit('input', parseFloat($event)||'')">
<text v-if="suffix" slot="suffix" style="color:#999;">{{suffix}}</text>

Loading…
Cancel
Save