Browse Source

添加农事 修改害虫保存数据

master
邓宏 2 years ago
parent
commit
082b08dd7a
  1. 2
      pages/home/news.vue
  2. 9
      pages/home/newsDetail.vue
  3. 5
      pages/massif/add_farming.vue
  4. 23
      pages/massif/mana/farmRecord.vue
  5. 18
      pages/massif/pestRecord.vue
  6. 16
      pages/massif/pestType.vue
  7. 2
      router/home.js

2
pages/home/news.vue

@ -190,7 +190,7 @@
</view>
</d-search>
<scroll-view scroll-y>
<view class="card" @click="$u.route({url:'/pages/home/newsDetail'})">
<view class="card" @click="$u.route({url:'/pages/home/newsDetail',params:{intoPage:'news'}})">
<view class="info">
<text class="plant-xitongxiaoxi"/>
<view>

9
pages/home/newsDetail.vue

@ -75,7 +75,14 @@ export default {
data(){
return{
eventChannel:null,
}
}
},
onLoad(options){
this.eventChannel=this.getOpenerEventChannel()
uni.setNavigationBarTitle({
title:({farming:"农事记录",news:"消息详情"})[options.intoPage]
})
},
}
</script>

5
pages/massif/add_farming.vue

@ -208,7 +208,7 @@
<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}}({{formData.farmPests.pestName}})
过程:{{formData.farmPests.growthProcessLabel}}病虫害部位:{{formData.farmPests.pestSite}}症状{{formData.farmPests.symptomLabel}}({{formData.farmPests.pestName.map(v=>v.name).join(',')}})
</view>
</view>
<u-form class="inline" errorType="toast" :model="formData" :rules="rules" ref="form" labelWidth="auto">
@ -355,7 +355,8 @@ export default {
method:"post",
body:{
...this.formData,
images: this.fields.images.value
images: this.fields.images.value,
farmPests: Object.assign(this.formData.farmPests||{},{pestName:this.formData.farmPests?.pestName?.map?.(v=>v.id).join(",")||''})
}
})
if(res.statu){

23
pages/massif/mana/farmRecord.vue

@ -138,10 +138,10 @@
<text class="add" @click="toAdd">+添加农事</text>
</view>
<scroll-view scroll-y @scrolltolower="search">
<view class="card" v-for="(v,k) in list" :key="k">
<view class="card" v-for="(v,k) in list" :key="k" @click="toDetail(v.id)">
<template v-if="v.inputName">
<view class="name">
<text>{{v.type}}</text> <text>{{v.inputName}}</text> <text>{{v.inputTotal||0}}{{v.unit}}</text>
<text>{{v.type}}</text> <text>{{v.inputName}}</text> <text>{{v.inputTotal||0}}{{v.unit}}</text> <text class="plant-youbian"/>
</view>
<view class="tabs" v-if="v.growthProcess">
<text class="germinate">{{v.growthProcess}}</text>
@ -233,7 +233,26 @@ export default {
})
}
}
},
async toDetail(id){
var res=await request("/api/plantFarming/queryFarmDetailByFarmId",{
params:{id}
})
if(res.statu){
uni.navigateTo({
url:`/pages/home/newsDetail?id=${id}&intoPage=farming`,
success(res){
// res.ev
}
})
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取农事详情失败!",
showCancel:false,
})
}
},
}
}
</script>

18
pages/massif/pestRecord.vue

@ -14,7 +14,7 @@
:field="k"
v-bind="v"
:required="!!rules[k]"
:value="/^checkBox$/.test(v.type)?fields[k].value:formData[k]"
:value="/^checkBox$|^navigate$/.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;fields[k].value=$event[0].label"
@ -32,7 +32,16 @@ export default {
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"},
pestName:{label:"害虫名称",type:"navigate",btnFun:()=>uni.navigateTo({url:"/pages/massif/pestType",events:{type:e=>this.formData.pestName=e}})},
pestName:{label:"害虫名称",type:"navigate",value:"",btnFun:()=>uni.navigateTo({
url:"/pages/massif/pestType",
events:{type:e=>{
this.formData.pestName=e
this.fields.pestName.value=e.map(v=>v.name).join(",")
}},
success:res=>{
res.eventChannel.emit("ids",this.formData.pestName)
}
})},
medicationArea:{label:"农资作用面积",type:"digit",suffix:"亩"},
pic:{label:"凭证",type:"upImg",value:""},
description:{label:"病虫害描述",type:"textarea"},
@ -41,7 +50,7 @@ export default {
growthProcess:'',
pestSite:'',
symptom:"",
pestName:"",
pestName:[],
medicationArea:"",
pic:[],
description:"",
@ -50,7 +59,7 @@ export default {
growthProcess:{required:true,message:"请选择作物生长过程!",trigger:['blur','change']},
pestSite:{required:true,message:"请选择病虫害部位!",trigger:['blur','change']},
symptom:{required:true,message:"请选择显著症状!",trigger:['blur','change']},
pestName:{required:true,message:"请选择害虫!",trigger:['blur','change']},
pestName:{required:true,message:"请选择害虫!",type:"array",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("请选择凭证!"));
@ -67,6 +76,7 @@ export default {
this.fields.pestSite.value=e?.pestSite?.split?.(",")?.filter?.(v=>v)||[]
this.fields.growthProcess.value=e?.growthProcessLabel||""
this.fields.symptom.value=e?.symptomLabel||""
this.fields.pestName.value=e?.pestName?.map(v=>v.name).join(',')
this.formData=Object.assign(this.formData,{
...e,
pic:e?.pic?.split?.(",")?.filter?.(v=>v)||[]

16
pages/massif/pestType.vue

@ -112,7 +112,7 @@
<view class="title">害虫种类 <button class="cu-btn round sm" v-if="searchVal.value" @click="show=true">自定义+</button></view>
<scroll-view scroll-y>
<view class="items">
<text :class="{active:select==v}" v-for="(v,k) in list" :key="k" @click="select=v">{{v}}</text>
<text :class="{active:select.some(i=>i.id==v.id)}" v-for="(v,k) in list" :key="k" @click="selectPest(v)">{{v.name}}</text>
</view>
<u-empty :show="list.length<=0" text="为查询到相关信息" width="70%" icon="/static/noData.png"/>
</scroll-view>
@ -134,7 +134,7 @@ export default {
value:"",//
search:"",
},
select:"",
select:[],
eventChannel:null,
show:false,
}
@ -146,6 +146,7 @@ export default {
},
onLoad(){
this.eventChannel=this.getOpenerEventChannel()
this.eventChannel.on("ids",e=>this.select=e)
this.init()
},
methods:{
@ -168,7 +169,6 @@ export default {
async inputSearch(){
if(this.searchVal.search){
this.searchVal.value=""
this.select=""
var res=await request("/api/plantFarming/getPestByLike",{
params: {
@ -191,7 +191,6 @@ export default {
async agrSearch(e){
if(e){
this.searchVal={ value:e, search:"" }
this.select=""
if(typeof e=='string'){
var res=await request("/api/plantFarming/getPestByLike",{
params: {
@ -215,7 +214,7 @@ export default {
}
},
submit(){
if(this.select){
if(this.select.length>0){
this.eventChannel.emit("type", this.select)
uni.navigateBack()
}else{
@ -244,6 +243,13 @@ export default {
})
}
},
selectPest(e){
if(this.select.some(v=>v.id==e.id)){
this.select=this.select.filter(v=>v.id!=e.id)
}else{
this.select.push(e)
}
},
}
}
</script>

2
router/home.js

@ -80,7 +80,7 @@ module.exports=[
{
path:"pages/home/newsDetail",
style:{
navigationBarTitleText:"消息详情",
navigationBarTitleText:"",
navigationBarBackgroundColor:"#10C176",
navigationBarTextStyle:"white",
"app-plus":{

Loading…
Cancel
Save