You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

285 lines
6.8 KiB

2 years ago
<style lang="scss" scoped>
.plant_plan{
2 years ago
height:100%;
display:flex;
flex-direction: column;
scroll-view{
flex-grow: 1;
height:1rpx;
2 years ago
padding-top:30rpx;
2 years ago
.card{
2 years ago
margin-top:0;
2 years ago
&>.info{
display:flex;
&>.u-transition{
position:relative;
margin-right:20rpx;
&:before{
content:attr(data-type);
position:absolute;
z-index: 30;
top:0;
left:0;
border-radius: 20rpx 20rpx 20rpx 0;
background:rgba(60, 84, 44, 0.5);
color:#fff;
padding:6rpx 2rpx;
min-width:80rpx;
text-align: center;
}
2 years ago
}
2 years ago
&>.detail{
flex-grow: 1;
width:1rpx;
.name{
display:flex;
margin-bottom: 6rpx;
text{
&:first-child{
flex-shrink: 0;
font-size:20rpx;
color:#fff;
background:#10C176;
height:40rpx;
width:80rpx;
line-height: 40rpx;
text-align: center;
border-radius: 6rpx;
margin-right:12rpx;
}
&:nth-child(2){
font-weight: bold;
flex-grow: 1;
}
2 years ago
}
2 years ago
}
.batch,.recovery{
font-size:24rpx;
color:var(--c);
margin-bottom:6rpx;
}
.mu{
display:flex;
align-items: center;
justify-content: space-between;
&>text{
color:#10C176;
font-size:32rpx;
font-weight: bold;
&:after{
content:"亩";
}
}
button{
margin:-20rpx 0!important;
padding:20rpx;
height: auto;
background: transparent;
2 years ago
}
}
}
2 years ago
}
&>.date{
border-top:2rpx solid rgba(216, 216, 216, 0.5);
margin-top:6rpx;
padding-top:12rpx;
display:flex;
align-items: center;
text{
flex-shrink: 0;
color:#999;
2 years ago
font-size:24rpx;
2 years ago
margin-right:auto;
&.over{
background:#F7F7F7;
border-radius: 8rpx;
height:48rpx;
line-height: 48rpx;
padding:0 20rpx;
margin:0 0 0 auto;
2 years ago
}
}
2 years ago
button{
margin:0 0 0 20rpx;
color:rgba(var(--c),1);
background:rgba(var(--c),0.15);
2 years ago
height:48rpx;
2 years ago
font-size:24rpx;
padding:0 16rpx;
min-width:100rpx;
2 years ago
}
2 years ago
}
}
}
&>button{
2 years ago
flex-shrink: 0;
margin:20rpx auto!important;
}
2 years ago
}
</style>
<template>
<view class="plant_plan">
2 years ago
<scroll-view scroll-y @scrolltolower="search">
<view class="card" v-for="(v,k) in list" :key="k">
<view class="info" @click="reDetail(v.id)">
<u-image :data-type="v.plantType" radius="20rpx" width="170rpx" height="140rpx" mode="aspectFill" :src="`${host}/${v.images}`">
2 years ago
<view slot="error" style="font-size: 24rpx;">加载失败</view>
</u-image>
<view class="detail">
<view class="name">
<text>{{v.plantStandard}}</text> <text class="over">{{v.varietyName}}</text> <text class="plant-youbian"/>
</view>
<view class="batch" style="--c:#999;">种植批次号{{v.plantBatch}}</view>
<view class="recovery" style="--c:#FFC760;">已采收{{v.harvested}}kg</view>
<view class="mu">
<text>{{v.plantArea}}</text>
<button class="cu-btn bg-white sm plant-shanchu" v-if="v.status!=2" @click.stop="del(k)">删除</button>
</view>
2 years ago
</view>
2 years ago
</view>
<view class="date">
<text>预估采收时间{{v.harvestTime}}</text>
2 years ago
<template v-if="v.status==1">
<button class="cu-btn" style="--c:255, 196, 87;" @click.stop="finishPlant(k)">结束种植</button>
<button class="cu-btn" style="--c:153, 153, 153;" @click.stop="toAdd(v.id)">采收</button>
</template>
<template v-else-if="v.status==2">
<button v-if="v.plantType=='水果'" class="cu-btn" style="--c:16, 193, 118;" @click.stop="">复制当前计划</button>
<text class="over">已结束</text>
</template>
2 years ago
</view>
</view>
2 years ago
<u-empty v-if="list.length==0" text="为查询到相关信息" width="70%" icon="/static/noData.png"/>
2 years ago
</scroll-view>
2 years ago
<button class="cu-btn round bg-green shadow submit" @click="addPlant">+新增种植计划</button>
2 years ago
</view>
</template>
<script>
import request,{host} from '@/common/request'
2 years ago
export default {
name:"plantPlan",
props:{
2 years ago
plotId:{
type:String,
default:""
}
},
2 years ago
data(){
return{
searchVal:{
pageNo:1,
pageSize:4
},
total:0,
list:[],
2 years ago
host:host("imgUrl"),
}
},
created(){
this.search()
},
methods:{
clean(){
this.list=[]
this.total=0
this.searchVal.pageNo=1
},
async search(){
if(this.total==0||this.list.length<this.total){
var res=await request('/api/plantPlan/list',{
params: {
...this.searchVal,
2 years ago
plotId: this.plotId
}
})
if(res.statu){
this.list=this.list.concat(res.data.records)
this.total=res.data.total
this.searchVal.pageNo++
if(this.list.length==this.total)uni.showToast({title:"加载完成!",icon:"none"})
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取地块列表失败!",
showCancel:false,
})
}
}
},
addPlant(){
uni.navigateTo({
2 years ago
url:`/pages/massif/plant_plan?plotId=${this.plotId}`,
2 years ago
events:{ update:()=> {this.clean();this.search()} }
})
},
reDetail(id){
uni.navigateTo({
url:`/pages/massif/plant_plan?id=${id}`,
event:{update:()=> {this.clean();this.search()} }
})
},
//结束种植
finishPlant(index){
uni.showModal({
title:"提示",
content:"确定结束种植!",
success: async e=>{
if(e.confirm){
var res=await request("/api/plantPlan/finishPlant",{
params:{plantPlanId:this.list[index].id}
})
if(res.statu){
uni.showToast({title:"结束成功!",duration:1500})
this.list[index].status=2
}else{
uni.showModal({
title:"提示",
content:res.msg||"结束种植失败!",
showCancel:false,
})
}
}
}
})
},
2 years ago
//跳转新增采收页面
toAdd(plantId){
uni.navigateTo({
url:`/pages/massif/plant_info?plantId=${plantId}&plotId=${this.plotId}`,
2 years ago
events:{ toRecovery:()=> this.$emit("trigger",{tabIndex:2,plantId}) }
2 years ago
})
},
del(index){
uni.showModal({
title:"提示",
content:"确定删除!",
success: async e=>{
if(e.confirm){
var res=await request("/api/plantPlan/deletePlantPlanSchedule",{
method:"delete",
params:{id: this.list[index].id}
})
if(res.statu){
uni.showToast({title:"删除成功!",icon:"success"})
if(this.list.length>this.searchVal.pageNo+3)this.list.splice(index,1);
else{
this.list=[]
this.total=0
this.searchVal.pageNo=1
this.search()
}
}else{
uni.showModal({
title:"提示",
content:res.msg||"删除失败!",
showCancel:false,
})
}
}
}
})
},
2 years ago
}
}
</script>