Browse Source

选择害虫 联调添加害虫接口

master
邓宏 2 years ago
parent
commit
19e0290eca
  1. 2
      pages/baseMana/formReacord.vue
  2. 36
      pages/massif/pestType.vue

2
pages/baseMana/formReacord.vue

@ -122,7 +122,7 @@
</style> </style>
<template> <template>
<view class="container flex"> <view class="container flex">
<d-search v-model="searchVal.search" :selectVal="searchVal.value" :list="typeList" @select="searchVal.value=$event" @search="clean();search()"/> <d-search :btn="false" v-model="searchVal.search" :selectVal="searchVal.value" :list="typeList" @select="searchVal.value=$event" @search="clean();search()"/>
<view class="date-range"> <view class="date-range">
<picker mode="date" class="plant-youbian" :class="{noData:!searchVal.startTime}" :end="searchVal.endTime" @change="searchVal.startTime=$event.detail.value;clean();search()" >{{searchVal.startTime||"请选择开始时间"}}</picker> <picker mode="date" class="plant-youbian" :class="{noData:!searchVal.startTime}" :end="searchVal.endTime" @change="searchVal.startTime=$event.detail.value;clean();search()" >{{searchVal.startTime||"请选择开始时间"}}</picker>

36
pages/massif/pestType.vue

@ -76,6 +76,17 @@
} }
} }
} }
.addPest{
position:absolute;
bottom:0;
left:0;
width:100%;
background:#fff;
color:#333;
height:60rpx;
padding:0 20rpx;
}
} }
</style> </style>
<template> <template>
@ -98,13 +109,17 @@
<view class="tabs"> <view class="tabs">
<text v-for="(v,k) in agrProd" :class="{active:searchVal.value==v.value}" :key="k" @click="agrSearch(v.value)">{{v.label}}</text> <text v-for="(v,k) in agrProd" :class="{active:searchVal.value==v.value}" :key="k" @click="agrSearch(v.value)">{{v.label}}</text>
</view> </view>
<view class="title">害虫种类 <button class="cu-btn round sm" v-if="searchVal.value">自定义+</button></view> <view class="title">害虫种类 <button class="cu-btn round sm" v-if="searchVal.value" @click="show=true">自定义+</button></view>
<scroll-view scroll-y> <scroll-view scroll-y>
<view class="items"> <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==v}" v-for="(v,k) in list" :key="k" @click="select=v">{{v}}</text>
</view> </view>
<u-empty :show="list.length<=0" text="为查询到相关信息" width="70%" icon="/static/noData.png"/> <u-empty :show="list.length<=0" text="为查询到相关信息" width="70%" icon="/static/noData.png"/>
</scroll-view> </scroll-view>
<u-overlay :show="show" @click="show=false">
<input class="addPest" placeholder="请输入" @click.stop="" :focus="show" @blur="show=false" @confirm="addPest($event.detail.value)"/>
</u-overlay>
</view> </view>
</template> </template>
<script> <script>
@ -121,6 +136,7 @@ export default {
}, },
select:"", select:"",
eventChannel:null, eventChannel:null,
show:false,
} }
}, },
computed:{ computed:{
@ -210,6 +226,24 @@ export default {
}) })
} }
}, },
async addPest(e){
var res=await request("/common/api/dict/AddCategory",{
method:"post",
body:{
pid: typeof this.searchVal.value=='string'?this.searchVal.value:this.cropList.find(v=>v.pest==this.searchVal.value).value,
name:e
}
})
if(res.statu){
this.list.push(e)
}else{
uni.showModal({
title:"提示",
content:"添加害虫失败!",
showCancel:false,
})
}
},
} }
} }
</script> </script>
Loading…
Cancel
Save