TraceabilityAPP/pages/landDetail/tudi.vue

386 lines
7.9 KiB
Vue
Raw Normal View History

2023-11-25 16:18:54 +08:00
<template>
<view class="box">
<view class="content">
<view class="video" @click="navto('/pages/live/live')">
<!-- <u--image :src="url" width="100%" height="300rpx"></u--image> -->
2023-11-27 18:23:17 +08:00
<u-swiper :list="dataobj.datapic" width="100%" height="300rpx"></u-swiper>
2023-11-25 16:18:54 +08:00
</view>
<view class="time">
<u-icon name="clock"></u-icon>
<text>刷新时间: {{getNowTimeFn()}} </text>
</view>
<view class="add-thing" @click="showPicker=true">
记农事
</view>
<landInfo :info='dataobj'></landInfo>
<view class="">
<view class="tit" style="font-size: 33.29rpx;margin: 20rpx 0;">
操作信息
</view>
2023-11-27 18:23:17 +08:00
<view class="" v-if="dataList1.length>0">
<view class="thing-card" v-for="(item,index) in dataList1" :key="index">
<view class="head">
2023-11-25 16:18:54 +08:00
<view class="">
2023-11-27 18:23:17 +08:00
{{item.type_text}}
2023-11-25 16:18:54 +08:00
</view>
2023-11-27 18:23:17 +08:00
<view class="" @click="navtoForm(item,item.type)">
农事查看
2023-11-25 16:18:54 +08:00
</view>
2023-11-27 18:23:17 +08:00
</view>
<view class="card_body">
<view class="left">
<u--image @click="perviewFn(item.detail.pic[0])" radius='10' :src="item.detail.pic[0]" width="200rpx"
2023-11-27 18:23:17 +08:00
height="200rpx"></u--image>
2023-11-25 16:18:54 +08:00
</view>
2023-11-27 18:23:17 +08:00
<view class="right">
<view class="" v-if="item.type==5">
<view class="">
参与人员: {{item.detail.user}}
</view>
</view>
<view class="" v-else>
<view class="" v-if="!item.detail.type">
<view class="">
{{item.type_text.slice(0, -2)}}种类:{{item.detail.kind}}
</view>
<view class="">
{{item.type_text.slice(0, -2)}}品种: {{item.detail.breed}}
</view>
<view class="">
{{item.type_text.slice(0, -2)}}面积: {{item.detail.area}}
</view>
2023-11-27 18:23:17 +08:00
</view>
<view class="" v-if="item.detail.type&&item.detail.type==1">
{{item.type_text.slice(0, -2)}}方式:{{item.detail.type==0?"喷灌":item.detail.type==1?"滴灌":"沟灌"}}
2023-11-27 18:23:17 +08:00
</view>
<view class="">
参与人员: {{item.detail.user}}
</view>
<view class="" v-if="item.detail.start_date">
开始日期: {{item.detail.start_date}}
</view>
<view class="" v-if="item.detail.end_date">
结束日期: {{item.detail.end_date}}
2023-11-27 18:23:17 +08:00
</view>
2023-11-27 18:23:17 +08:00
</view>
2023-11-25 16:18:54 +08:00
</view>
</view>
</view>
2023-11-27 18:23:17 +08:00
2023-11-25 16:18:54 +08:00
</view>
2023-11-27 18:23:17 +08:00
<view class="coneng-detail" v-else>
<view class="">
<image src="@/static/img/zw.png" mode="aspectFit"></image>
<view class="">
暂无数据
</view>
</view>
</view>
2023-11-25 16:18:54 +08:00
</view>
</view>
<!-- 组件 -->
<view class="">
<u-picker keyName="label" :show="showPicker" @cancel="showPicker=false" @confirm="confirm"
:columns="columns"></u-picker>
</view>
</view>
</template>
<script setup>
import landInfo from "@/components/plant/landInfo.vue"
import {
ref,
reactive
} from "vue"
import {
plantlist,
2023-11-27 18:23:17 +08:00
plantdetail,
2023-11-25 16:18:54 +08:00
actionlist,
landdetail
} from '@/api/api.js'
2023-11-25 16:18:54 +08:00
import {
2023-11-27 18:23:17 +08:00
onLoad,
onShow
2023-11-25 16:18:54 +08:00
} from "@dcloudio/uni-app"
const list = reactive([{
id: 1,
url: 'https://ceshi-worker-task.lihaink.cn//uploads//images//20231121//202311211336582b7920656.jpg',
},
{
id: 1,
url: 'https://ceshi-worker-task.lihaink.cn//uploads//images//20231121//202311211336582b7920656.jpg',
},
{
id: 1,
url: 'https://ceshi-worker-task.lihaink.cn//uploads//images//20231121//202311211336582b7920656.jpg',
},
{
id: 1,
url: 'https://ceshi-worker-task.lihaink.cn//uploads//images//20231121//202311211336582b7920656.jpg',
},
])
const dataList1 = reactive([])
const dataobj = reactive({})
const typeID = ref('')
2023-11-27 18:23:17 +08:00
2023-11-25 16:18:54 +08:00
const showPicker = ref(false)
const columns = reactive([
[{
label: '施肥',
route: "/pages/husbandryForm/fertilize"
}, {
label: '除草',
route: "/pages/husbandryForm/weeding"
}, {
label: '灌溉',
route: "/pages/husbandryForm/irrigate"
}, {
label: '除虫',
route: "/pages/husbandryForm/Pest"
}, {
label: '收获',
route: "/pages/husbandryForm/harvest"
}]
]);
onLoad((query) => {
2023-11-27 18:23:17 +08:00
let data = query.data
// console.log(data); // 输出:{ name: 'John', age: 25 }
// Object.assign(dataobj, data);
typeID.value = query.data;
// getlist1()
// getlist2();
2023-11-25 16:18:54 +08:00
});
2023-11-27 18:23:17 +08:00
onShow(() => {
getlist3();
getlist2();
2023-11-25 16:18:54 +08:00
2023-11-27 18:23:17 +08:00
})
const getlist1 = (id,a,b) => {
2023-11-25 16:18:54 +08:00
landdetail({
2023-11-27 18:23:17 +08:00
land_id: id
2023-11-25 16:18:54 +08:00
}).then((res) => {
2023-11-25 16:18:54 +08:00
if (res.code == 1) {
2023-11-27 18:23:17 +08:00
res.data.kind = a
res.data.datapic=b
2023-11-25 16:18:54 +08:00
Object.assign(dataobj, res.data);
2023-11-25 16:18:54 +08:00
}
});
};
2023-11-27 18:23:17 +08:00
const getlist3 = () => {
plantdetail({
plant_id: typeID.value
}).then((res) => {
if (res.code == 1) {
getlist1(res.data.id, res.data.kind,res.data.pic)
}
});
};
2023-11-25 16:18:54 +08:00
const getlist2 = () => {
actionlist({
plant_id: typeID.value
}).then((res) => {
if (res.code == 1) {
dataList1.splice(0, dataList1.length, ...res.data);
}
});
};
const navto = (url) => {
uni.navigateTo({
url
})
}
const navtoForm = (item, type) => {
// console.log(item, type)
2023-11-25 16:18:54 +08:00
switch (type) {
2023-11-27 18:23:17 +08:00
2023-11-25 16:18:54 +08:00
// 施肥
case 1:
2023-11-27 18:23:17 +08:00
2023-11-25 16:18:54 +08:00
uni.navigateTo({
url: '/pages/husbandryForm/fertilize?task=' + encodeURIComponent(JSON.stringify(item))
})
break;
// 除草
case 2:
uni.navigateTo({
url: '/pages/husbandryForm/weeding?task=' + encodeURIComponent(JSON.stringify(item))
})
2023-11-27 18:23:17 +08:00
break;
2023-11-25 16:18:54 +08:00
// 灌溉
case 3:
uni.navigateTo({
url: '/pages/husbandryForm/irrigate?task=' + encodeURIComponent(JSON.stringify(item))
})
break;
// 除虫
case 4:
uni.navigateTo({
url: '/pages/husbandryForm/Pest?task=' + encodeURIComponent(JSON.stringify(item))
})
break;
// 收获
case 5:
uni.navigateTo({
url: '/pages/husbandryForm/harvest?task=' + encodeURIComponent(JSON.stringify(item))
})
break;
}
}
const confirm = (e) => {
showPicker.value = false
2023-11-27 18:23:17 +08:00
2023-11-25 16:18:54 +08:00
uni.navigateTo({
url: e.value[0].route + '?id=' + typeID.value
})
}
const getNowTimeFn = () => {
const now = new Date();
const hour = now.getHours();
const minute = now.getMinutes();
const formattedHour = hour < 10 ? '0' + hour : hour;
const formattedMinute = minute < 10 ? '0' + minute : minute;
const currentTime = formattedHour + ':' + formattedMinute;
return currentTime
}
const perviewFn = (url) => {
2023-11-25 16:18:54 +08:00
uni.previewImage({
urls: [url]
})
}
</script>
<style lang="scss" scoped>
.box {
width: 750rpx;
min-height: 100vh;
background-color: $theme-bg-color;
padding: 0;
.content {
width: 693.93rpx;
margin: auto;
padding-top: 20rpx;
}
// padding: 20rpx;
.time {
display: flex;
font-size: 26.29rpx;
color: #737373;
margin-top: 10rpx;
}
.video {
// margin-top: 10rpx;
}
.add-thing {
width: 266.36rpx;
height: 66.59rpx;
border-radius: 42.06rpx 42.06rpx 42.06rpx 42.06rpx;
border: 1px solid $theme-main-color;
margin: 20rpx auto;
line-height: 66rpx;
text-align: center;
color: $theme-main-color;
}
}
2023-11-27 18:23:17 +08:00
.coneng-detail {
width: 478rpx;
height: 341rpx;
background: #FFFFFF;
border-radius: 6px 6px 6px 6px;
opacity: 1;
font-size: 25rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 400;
color: #737373;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
margin: 70rpx auto;
image {
width: 280rpx;
height: 142rpx;
margin-bottom: 20rpx;
}
}
2023-11-25 16:18:54 +08:00
.thing-card {
width: 693.93rpx;
box-sizing: border-box;
background-color: #fff;
border-radius: 20rpx;
overflow: hidden;
margin-bottom: 30rpx;
.head {
height: 90rpx;
border-radius: 20rpx 20rpx 0 0;
background-color: $theme-main-color;
display: flex;
justify-content: space-between;
line-height: 90rpx;
color: white;
padding: 0 30rpx;
}
.card_body {
padding: 20rpx;
display: flex;
// justify-content: space-between;
.right {
display: flex;
justify-content: space-between;
flex-direction: column;
margin-left: 40rpx;
}
}
}
</style>