|
|
@ -7,11 +7,14 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
&>.u-tabs{ |
|
|
|
margin:0 30rpx; |
|
|
|
flex-shrink: 0; |
|
|
|
&/deep/ .u-tabs__wrapper__nav__line{ |
|
|
|
box-shadow:0 4rpx 6rpx 2rpx rgba(16,193,118,0.1); |
|
|
|
} |
|
|
|
} |
|
|
|
&>.tabs{ |
|
|
|
flex-shrink: 0; |
|
|
|
margin:10rpx 30rpx 0; |
|
|
|
background:#EEFBF5; |
|
|
|
border-radius: 8rpx; |
|
|
@ -27,27 +30,45 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
&>.title{ |
|
|
|
flex-shrink: 0; |
|
|
|
color:#333; |
|
|
|
margin:30rpx; |
|
|
|
display:flex; |
|
|
|
align-items: center; |
|
|
|
&:before{ |
|
|
|
content:"*"; |
|
|
|
color:#EE263A; |
|
|
|
} |
|
|
|
button{ |
|
|
|
margin-left:auto; |
|
|
|
background:#10C176; |
|
|
|
color:#fff; |
|
|
|
box-shadow: 4rpx 4rpx 6rpx rgba(0,0,0,0.1); |
|
|
|
font-size:24rpx; |
|
|
|
} |
|
|
|
} |
|
|
|
&>.items{ |
|
|
|
scroll-view{ |
|
|
|
flex-grow: 1; |
|
|
|
height:1rpx; |
|
|
|
margin:0 30rpx; |
|
|
|
width:calc(100% - 60rpx); |
|
|
|
.items{ |
|
|
|
display:flex; |
|
|
|
flex-wrap: wrap; |
|
|
|
margin:30rpx; |
|
|
|
margin-right:-30rpx; |
|
|
|
text{ |
|
|
|
background:#eee; |
|
|
|
background:rgba(238, 238, 238, 0.6); |
|
|
|
color:#999; |
|
|
|
height:54rpx; |
|
|
|
line-height: 54rpx; |
|
|
|
border-radius: 54rpx; |
|
|
|
font-size:24rpx; |
|
|
|
margin:0 30rpx 20rpx 0; |
|
|
|
width:calc(100%/4 - 30rpx); |
|
|
|
min-width:calc(100%/4 - 30rpx); |
|
|
|
box-sizing: border-box; |
|
|
|
padding:0 10rpx; |
|
|
|
text-align: center; |
|
|
|
transition: all 0.3s; |
|
|
|
&.active{ |
|
|
|
background:#10C176; |
|
|
|
color:#fff; |
|
|
@ -55,44 +76,136 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
</style> |
|
|
|
<template> |
|
|
|
<view class="container"> |
|
|
|
<view class="container flex"> |
|
|
|
<d-navbar style="--bg:#10C176;--c:#fff;" isBack text="添加农事"> |
|
|
|
<button slot="right" class="cu-btn round" @click="submit">提交</button> |
|
|
|
</d-navbar> |
|
|
|
|
|
|
|
<d-search background="#eee"/> |
|
|
|
<u-tabs :list="cropList" activeStyle="color:#10C176" lineWidth="60rpx" lineHeight="8rpx" inactiveStyle="color:#333" lineColor="#10C176"></u-tabs> |
|
|
|
<d-search background="#eee" v-model="searchVal.search" @search="inputSearch"/> |
|
|
|
<u-tabs |
|
|
|
:list="cropList" |
|
|
|
:current="cropCurrent" |
|
|
|
activeStyle="color:#10C176" |
|
|
|
keyName="label" |
|
|
|
lineWidth="60rpx" |
|
|
|
lineHeight="8rpx" |
|
|
|
inactiveStyle="color:#333" |
|
|
|
lineColor="#10C176" |
|
|
|
@change="cropCurrent=$event.index"/> |
|
|
|
<view class="tabs"> |
|
|
|
<text>玉米</text> |
|
|
|
<text class="active">水稻</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 class="title">害虫类型</view> |
|
|
|
<view class="title">害虫种类 <button class="cu-btn round sm" v-if="searchVal.value">自定义+</button></view> |
|
|
|
<scroll-view scroll-y> |
|
|
|
<view class="items"> |
|
|
|
<text class="active">黄地老虎</text> |
|
|
|
<text v-for="k in 20" :key="k">黄地老虎</text> |
|
|
|
<text>自定义+</text> |
|
|
|
<text :class="{active:select==v}" v-for="(v,k) in list" :key="k" @click="select=v">{{v}}</text> |
|
|
|
</view> |
|
|
|
<u-empty :show="list.length<=0" text=" " width="70%" icon="/static/noData.png"/> |
|
|
|
</scroll-view> |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
<script> |
|
|
|
import request from '@/common/request' |
|
|
|
export default { |
|
|
|
data(){ |
|
|
|
return{ |
|
|
|
cropList:[ |
|
|
|
{name:'粮食作物',}, |
|
|
|
{name:'油料作物',}, |
|
|
|
{name:'经济作物',}, |
|
|
|
{name:'药用作物',}, |
|
|
|
{name:'牧草',}, |
|
|
|
{name:'树林'}, |
|
|
|
] |
|
|
|
cropList:[], |
|
|
|
cropCurrent:0, |
|
|
|
list:[], |
|
|
|
searchVal:{ |
|
|
|
value:"",//选择的农产品 |
|
|
|
search:"", |
|
|
|
}, |
|
|
|
select:"", |
|
|
|
eventChannel:null, |
|
|
|
} |
|
|
|
}, |
|
|
|
computed:{ |
|
|
|
agrProd(){ |
|
|
|
return this.cropList?.[this.cropCurrent]?.children||[] |
|
|
|
}, |
|
|
|
}, |
|
|
|
onLoad(){ |
|
|
|
this.eventChannel=this.getOpenerEventChannel() |
|
|
|
this.init() |
|
|
|
}, |
|
|
|
methods:{ |
|
|
|
submit(){ |
|
|
|
async init(){ |
|
|
|
var res=await request("/common/api/dict/categoryValue",{ |
|
|
|
method:"post", |
|
|
|
params:{code:"B09"} |
|
|
|
}) |
|
|
|
if(res.statu){ |
|
|
|
this.cropList=res.data.map(v=>({...v,children:v.children.length>0?v.children:[{label:"全部",value:'all'}]})) |
|
|
|
this.agrSearch(res.data[0]?.children?.[0]?.value||"") |
|
|
|
}else{ |
|
|
|
uni.showModal({ |
|
|
|
title:"提示", |
|
|
|
content:res.msg||"获取种植计划选项失败!", |
|
|
|
showCancel:false, |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
async inputSearch(){ |
|
|
|
if(this.searchVal.search){ |
|
|
|
this.searchVal.value="" |
|
|
|
this.select="" |
|
|
|
|
|
|
|
var res=await request("/api/plantFarming/getPestByLike",{ |
|
|
|
params: { |
|
|
|
value: '',//选择的农产品 |
|
|
|
search: this.searchVal.search, |
|
|
|
} |
|
|
|
}) |
|
|
|
if(res.statu){ |
|
|
|
this.list=res.data |
|
|
|
}else{ |
|
|
|
this.list=[] |
|
|
|
uni.showModal({ |
|
|
|
title:"提示", |
|
|
|
content:res.msg||"获取种植计划选项失败!", |
|
|
|
showCancel:false, |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
async agrSearch(id){ |
|
|
|
if(id){ |
|
|
|
this.searchVal={ value:id, search:"" } |
|
|
|
this.select="" |
|
|
|
|
|
|
|
var res=await request("/api/plantFarming/getPestByLike",{ |
|
|
|
params: { |
|
|
|
value: id,//选择的农产品 |
|
|
|
search:"", |
|
|
|
} |
|
|
|
}) |
|
|
|
if(res.statu){ |
|
|
|
this.list=res.data |
|
|
|
}else{ |
|
|
|
this.list=[] |
|
|
|
uni.showModal({ |
|
|
|
title:"提示", |
|
|
|
content:res.msg||"获取种植计划选项失败!", |
|
|
|
showCancel:false, |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
submit(){ |
|
|
|
if(this.select){ |
|
|
|
this.eventChannel.emit("type", this.select) |
|
|
|
uni.navigateBack() |
|
|
|
}else{ |
|
|
|
uni.showModal({ |
|
|
|
title:"提示", |
|
|
|
content:"请选择害虫类型!", |
|
|
|
showCancel:false, |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
} |
|
|
|
} |
|
|
|