Browse Source

农事操作 修改病虫害表单赋值

master
邓宏 2 months ago
parent
commit
752ebc6a40
  1. 37
      pages/massif/add_farming.vue
  2. 85
      pages/massif/mana/farmRecord.vue

37
pages/massif/add_farming.vue

@ -213,8 +213,8 @@
</view> -->
<u-form class="inline" errorType="toast" :model="formData" :rules="rules" ref="form" labelWidth="auto">
<template v-if="/^用药$/.test(formData.farmingType)">
<d-form label="防治类型" type="select" :value="[formData.pestsType]" @select="formData.pestsType=$event.slice(-1)[0].value" :columns="[[{label:'病害',value:'病害'},{label:'虫害',value:'虫害'}]]"/>
<d-form label="防治对象" type="navigate" :value="formData.pests" :btnFun="pestsFun"/>
<d-form label="防治类型" type="radio" v-model="formData.pestsType" @select="formData.pestsType=$event.slice(-1)[0].value" :columns="[{label:'病害',value:'病害'},{label:'虫害',value:'虫害'}]"/>
<d-form label="防治对象" type="select" :value="[formData.pests]" :columns="[pests]" @select="formData.pests=$event[0].value"/>
<d-form label="农资作用面积" type="digit" v-model="formData.roleArea" suffix="亩"/>
</template>
<d-form
@ -240,6 +240,7 @@ export default {
data(){
return{
typeList:[],
pests:[],
fields:{
principal:{label:"操作人",styleType:"parallel", disabled:true},
farmingTime:{label:"操作日期",styleType:"parallel",type:"calendar"},
@ -280,14 +281,42 @@ export default {
}
},
watch:{
'formData.pestsType'(n,o){
async 'formData.pestsType'(n,o){
if(n){
this.formData.pests=''
// this.formData.pests=''
//
var res=await request("/suyuan/farmingApi/queryPestDetail",{
method:"post",
body:{
pestsType: n,
plantType: n=='病害'?this.massif.plantType:'',
detailName:'',
}
})
if(res.statu){
this.pests=res.data.map(v=>({value:v.label,label:v.label}))
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取农事类型失败!",
showCancel:false,
})
}
}
}
},
onLoad(options){
this.eventChannel=this.getOpenerEventChannel()
this.eventChannel.on("detail", e=>{
this.formData={
...e,
images:e?.images?.split?.(',')?.filter(v=>v)||[],
inputList: e?.inputList?.map?.(v=>({...v, unit:(v.specDescribe.match(/\d+(\w+)\/./)||[])[1]}))||[]
}
this.fields.images.value=e.images
this.fields.farmingPlanId.value=[e.farmingPlanId]
this.saveInput=e?.inputList?.map?.(v=>({...v}))
})
this.formData.plotId=options.plotId
this.init()
this.getMassifDetail()

85
pages/massif/mana/farmRecord.vue

@ -117,6 +117,24 @@
}
}
}
&>.footer{
margin:10rpx -32rpx -32rpx;
background:#eee;
height:60rpx;
display: flex;
align-items: center;
justify-content: space-around;
button{
font-size:24rpx;
padding:0;
height:100%;
color:#999;
&:before{
color:#FFB000;
margin-right:10rpx;
}
}
}
}
}
}
@ -126,10 +144,10 @@
<view class="head">
<image mode="aspectFit" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAXhJREFUOE+dk7FLw1AQxr+LbSyInQuODiIW+hc4iZP/QCfBpXmmUHR26eRopdT0ZRLX7k7FybmgKAUJjrZriTqY2Jy80IQ0aik5eMO7++7H4953hFRYlrWlaZoAcEBEG6rMzG8AboMgkKZpviRbKLo0m81cqVQ6B3BKRLk0eAb6JqIWgDPDMHyVCwHtdnu1UCj0mXn3r8Z0jpnvPc/bbzQaXyHAtm0JwFimOdIwsxRCHFOn09nJ5/OPAFaiYrVaxWAwgOM4i5hT3/crJKVsEdFJUlmr1UKAOouCmS/Jtu0hgO2MgKECfABYywIA8KkALoD1jIB3BXgCUE4DRqMRxuPx3Ahc150bLDM/K8CFMk9SqX6hWCz+mt9kMkGv14vzQRC0qNvtljVNe0h+45J+mBJRJTSSlPKKiMwlG0MZM1tCiHpsZV3X+0SUzcrRPui6rl5yBED75zUBM197nldXexAvU1I8s/YhgD0Am7PaK4A7Zr4RQijjxfEDDjS1T8RMzc4AAAAASUVORK5CYII="/>
<text class="title">农资使用情况</text>
<text class="add" @click="toAdd">+添加农事</text>
<text class="add" @click="toAdd()">+添加农事</text>
</view>
<scroll-view scroll-y @scrolltolower="search">
<view class="card" v-for="(v,k) in list" :key="k" @click="toDetail(v)">
<view class="card" v-for="(v,k) in list" :key="k">
<template v-if="v.inputName">
<view class="name">
<text>{{v.type}}</text> <text>{{v.inputName}}</text> <text>{{v.inputTotal||0}}{{v.unit}}</text> <text class="plant-youbian"/>
@ -145,8 +163,13 @@
<view v-else class="detail">
<text>{{v.type}}</text> <text>负责人{{v.principal}}</text> <text>记录日期{{new Date(v.time).format('yyyy-MM-dd')}}</text>
</view>
<view class="footer">
<button class="cu-btn txt XP-bianji1" @click="toAdd(v)">编辑</button>
<button class="cu-btn txt XP-shanchu1" @click="del(k)">删除</button>
</view>
</view>
<u-empty v-if="list.length<=0" text="未查询到相关信息" width="70%" icon="/static/noData.png"/>
<view style="border:0.5rpx solid transparent;"/>
</scroll-view>
</view>
</template>
@ -183,25 +206,26 @@ export default {
this.search()
},
methods:{
toAdd(){
toAdd(v){
uni.navigateTo({
url:`/pages/massif/add_farming?plotId=${this.plotId}`,
events:{update: e=>{
this.$provise.emit('addFarming')
this.total=0
this.list=[]
this.searchVal.pageNo=1
this.search()
}}
this.search('refresh')
}},
success:res=>{
if(v){
res.eventChannel.emit("detail", v)
}
}
})
},
reSearch(){
this.list=[]
this.total=0
this.searchVal.pageNo=1
this.search()
},
async search(){
async search(type){
if(type=='refresh'){
this.list=[]
this.total=0
this.searchVal.pageNo=1
}
if(this.total==0 || this.list.length<this.total){
var res=await request("/api/plantFarming/listFarmByPlotId",{
params: {
@ -224,11 +248,32 @@ export default {
}
}
},
toDetail(e){
uni.navigateTo({
url:`/pages/home/newsDetail?intoPage=farming`,
success(res){
res.eventChannel.emit("detail",{...e,images: (e.images||'').split(',').filter(v=>v)})
del(index){
uni.showModal({
title:"提示",
content:"确定删除?",
success:async e=>{
if(e.confirm){
var res=await request("/suyuan/farmingApi/delete",{
method:"delete",
params:{id:this.list[index].id}
})
if(res.statu){
uni.showToast({title:"删除成功!",icon:"success"})
if(this.list.length>this.searchVal.pageSize+3){
this.list.splice(index, 1)
this.total--
}else{
this.search('refresh')
}
}else{
uni.showModal({
title:"提示",
content:res.msg||"删除失败!",
showCancel:false,
})
}
}
}
})
},

Loading…
Cancel
Save