TraceabilityAPP/pages/detail/plant.vue

545 lines
12 KiB
Vue
Raw Normal View History

2023-10-20 18:45:15 +08:00
<template>
<view class="content">
2023-10-25 19:55:18 +08:00
<imgCard :imgUrl='landDeatil.pic' text='地址'></imgCard>
2023-10-20 18:45:15 +08:00
<view class="bad-info">
<view class="" style="display: flex;align-items: center;">
<u--image :src="urlFn('sj')" style="margin: 0 5rpx;" width="28.04rpx" height="28.04rpx"></u--image>
<text>刷新时间:{{dateFn()}}</text>
</view>
2023-10-26 19:02:26 +08:00
<view style="display: flex;"
@click="navgo(`/pages/allPlant/index?crop_id=${landDeatil.crop_id}&land_id=${landDeatil.land_id}`)">
2023-10-25 19:55:18 +08:00
查看历史记录 <u--image src="/static/img/CKGD.png" style="margin-left: 5rpx;" width="31.54rpx"
2023-10-23 17:57:19 +08:00
height="31.54rpx"></u--image>
2023-10-20 18:45:15 +08:00
</view>
</view>
2023-10-23 17:57:19 +08:00
<view class="up-plant-btn" @click="updateImgFn">
2023-10-20 18:45:15 +08:00
上传新的种植情况
2023-10-28 18:28:10 +08:00
<!-- {{crop_id}} -->
2023-10-20 18:45:15 +08:00
</view>
2023-10-28 18:28:10 +08:00
<landInfo :land_id='landDeatil.land_id' @getcropid='getcropidFn'></landInfo>
2023-10-27 19:26:03 +08:00
<view class="circumstance" v-for="(item,index) in tableDate" :key="index">
<!-- {{index}} -->
<!-- {{tableDate}}
dsfdsf -->
2023-10-26 19:02:26 +08:00
<view class="card-tit">
<view class="">
{{index}}
</view>
2023-10-28 18:28:10 +08:00
<view class="updata-btn"
2023-10-30 19:09:40 +08:00
@click="navgo(`/pages/growRecord/index?type=1&crop_id=${crop_id}&land_id=${landDeatil.land_id}&title=${index}`)">
2023-10-26 19:02:26 +08:00
更新{{index.slice(0,-2)}}
</view>
</view>
2023-10-30 19:09:40 +08:00
<!-- {{item.action_record}} -->
2023-10-27 19:26:03 +08:00
<myTable :tit='`查看${index.slice(0,-2)}`' :dataList="item.action_record"
2023-10-30 19:09:40 +08:00
:route='`/pages/records/index?land_id=${landDeatil.land_id}&crop_id=${crop_id}&index=${index}`'>
2023-10-26 19:02:26 +08:00
</myTable>
2023-10-27 19:26:03 +08:00
</view>
2023-10-21 18:02:06 +08:00
2023-10-20 18:45:15 +08:00
<view class="data">
<view class="tit">
<view class="" style="display: flex;justify-content: space-between;font-size: 29.79rpx;">
<view class="">
土地监测数据
</view>
2023-10-23 17:57:19 +08:00
<view style="display: flex;align-items: center;" @click="navgo('/pages/profile/index')">
查看全部检测记录 <u--image src="/static/img/CKGD.png" style="margin-left: 5rpx;" width="31.54rpx"
height="31.54rpx"></u--image>
2023-10-20 18:45:15 +08:00
</view>
</view>
<view class="tit-b">
<u--image :src="urlFn('sj')" style="margin: 0 5rpx;" width="28.04rpx" height="28.04rpx"></u--image>
<text>刷新时间:{{dateFn()}}</text>
</view>
</view>
<view class="data-cont">
<view class="data-cont-li center" v-for="(item,index) in data " :key="index">
<view style="margin:0 20rpx">
<view class="center">
<!-- <img :src="urlFn('B')" :style="img(38.55,38.55,5)" alt=""> -->
<u--image :src="urlFn(item.icon)" style="margin: 0 5rpx;" width="38.55rpx"
height="38.54rpx"></u--image>
{{item.tit}}
</view>
<view class="b-cls">
<view class="" :style="{color:item.flag?'#0095FF':''}">
<text style=" font-size: 70.09rpx;">
{{baseData[item.cont]}}
</text>{{item.dw}}
</view>
<view class="" style="display: flex;align-items: center;" v-if="item.flag">
<u--image :src="urlFn('D')" style="margin: 0 5rpx;" width="31.54rpx" height="31.54rpx">
</u--image>
<text style="color: #0095FF;">5</text>
</view>
</view>
</view>
</view>
</view>
</view>
2023-10-31 18:40:32 +08:00
<!-- {{landDeatil.ripe_time}} -->
<view class="ripe-btn" v-if="landDeatil.ripe_time" @click="allripeFn">
2023-10-25 19:55:18 +08:00
标记为全部收获
</view>
2023-10-31 18:40:32 +08:00
<view class="ripe-btn" v-else @click="showPop=true">
标记为成熟
</view>
2023-10-25 19:55:18 +08:00
<!-- 组件 -->
<!-- navgo('/pages/index/index' -->
<u-popup :show="showPop" :round="20" mode="bottom" @close="showPop=false" @open="showPop=true">
<view class="mark">
<view class="head">
<view class="">
农作物成熟标记
</view>
<view class="" @tap="showPop=false">
2023-10-26 19:02:26 +08:00
<u--image :src="urlFn('GBAN')" style="margin: 0 5rpx;" width="49.07rpx" height="49.07rpx">
</u--image>
2023-10-25 19:55:18 +08:00
</view>
</view>
<view class="mark-li">
<view class="">
种植类型:
</view>
<view class="">
{{landDeatil.crop_name}}
</view>
</view>
<view class="mark-li">
<view class="">
种植品牌:
</view>
<view class="">
{{landDeatil.crop_brand}}
</view>
</view>
<view class="mark-li">
<view class="">
本期溯源码:
</view>
<view class="">
{{landDeatil.source_code}}
</view>
</view>
<view class="mark-li">
<view class="">
成熟日期:
</view>
<view class="">
2023-10-26 19:02:26 +08:00
{{dateFn()}}
2023-10-25 19:55:18 +08:00
</view>
</view>
<view class="mark-li" style="display: block;border: 0;">
<view class="">
预计产量:
</view>
<view class="" style="margin-top: 20rpx;">
<up-input placeholder="请输入内容" border="surround" v-model="crop_yield"></up-input>
</view>
</view>
<view class="ripe-btn" @tap="markFn">
确认
</view>
</view>
</u-popup>
2023-10-20 18:45:15 +08:00
</view>
</template>
2023-10-25 19:55:18 +08:00
<script setup>
import {
landInfoAPI,
addLandCropPicAPI,
landCropRecordListAPI,
landEnvDataCurrAPI,
2023-10-28 18:28:10 +08:00
setLandCropRipeAPI,
2023-10-31 18:40:32 +08:00
ediLandCropRecordAPI,
landCropAllRipeAPI
2023-10-25 19:55:18 +08:00
} from "@/api/plant.js"
2023-10-23 17:57:19 +08:00
import myTable from "@/components/myTable/index.vue"
import imgCard from "@/components/imgCard.vue"
2023-10-25 19:55:18 +08:00
import uplodeImg from "@/utils/uplodeImg.js"
import landInfo from "@/components/plant/landInfo.vue"
2023-10-26 19:02:26 +08:00
import {
actionsAPI
} from "@/api/animal.js"
2023-10-20 18:45:15 +08:00
import {
2023-10-25 19:55:18 +08:00
ref,
reactive
} from "vue"
import {
2023-10-28 18:28:10 +08:00
onLoad,
onShow
2023-10-25 19:55:18 +08:00
} from "@dcloudio/uni-app"
const crop_yield = ref("")
const showPop = ref(false)
2023-10-27 19:26:03 +08:00
const tableDate = reactive({})
2023-10-25 19:55:18 +08:00
const landDeatil = reactive({})
const data = reactive([{
tit: "土壤温度",
icon: 'TRWD',
dw: "℃",
cont: 'soil_temp',
flag: false,
}, {
tit: "土壤湿度",
icon: 'TRSD',
dw: "%RH",
cont: 'soil_mois',
}, {
tit: "磷含量",
icon: 'FX',
cont: 'k_content',
dw: "%",
}, {
tit: "氮含量",
icon: 'FS',
dw: "mg/l",
cont: 'n_content',
}, {
tit: "钾含量",
icon: 'JYL',
dw: "%",
cont: 'p_content',
2023-10-20 18:45:15 +08:00
},
2023-10-25 19:55:18 +08:00
], )
const baseData = reactive({})
2023-10-28 18:28:10 +08:00
const crop_id = ref(0)
const getcropidFn = (e) => {
crop_id.value = e.cropid
}
onShow(async () => {
let res = await landInfoAPI({
user_id: 307,
land_id: land_id.value
})
objFn(res.data, landDeatil)
})
const land_id = ref(0)
2023-10-25 19:55:18 +08:00
onLoad(async (options) => {
2023-10-28 18:28:10 +08:00
land_id.value = options.land_id
2023-10-25 19:55:18 +08:00
let res = await landInfoAPI({
user_id: 307,
land_id: options.land_id
})
objFn(res.data, landDeatil)
2023-10-27 19:26:03 +08:00
// let res2 = await landCropRecordListAPI({
// crop_id: landDeatil.crop_id
// })
let res2 = await actionsAPI({
2023-10-30 19:09:40 +08:00
type: 1,
crop_id: landDeatil.crop_id
2023-10-25 19:55:18 +08:00
})
objFn(res2.data, tableDate)
let res3 = await landEnvDataCurrAPI({
user_id: 307,
})
objFn(res3.data, baseData)
}, )
const updateImgFn = () => {
let image = ""
uplodeImg().then(res => {
image = res.data.image
landDeatil.pic = image
addLandCropPicAPI({
crop_id: landDeatil.crop_id,
pic: image
}).then(res2 => {
console.log(res2)
2023-10-20 18:45:15 +08:00
})
2023-10-25 19:55:18 +08:00
})
}
const navgo = (url) => {
uni.navigateTo({
url
})
}
const dateFn = () => {
var today = new Date();
// 获取年、月、日
var year = today.getFullYear();
var month = today.getMonth() + 1; // 月份从0开始需要加1
var day = today.getDate();
// 构建日期字符串
var dateStr = year + '-' + month + '-' + day;
return dateStr
// 输出日期字符串
}
const backFn = () => {
uni.navigateBack()
}
const urlFn = (name) => {
return `/static/img/${name}.png`
}
const img = (w, h, m) => {
return `width:${w}rpx;height:${h};margin:0 ${m}rpx `
}
2023-10-30 19:09:40 +08:00
2023-10-25 19:55:18 +08:00
const markFn = () => {
setLandCropRipeAPI({
crop_id: landDeatil.crop_id,
crop_yield: Number(crop_yield.value)
2023-10-30 19:09:40 +08:00
}).then(res => {
showPop.value = false
2023-10-25 19:55:18 +08:00
})
}
const objFn = (res, data) => {
for (let key in res) {
data[key] = res[key]
2023-10-20 18:45:15 +08:00
}
2023-10-25 19:55:18 +08:00
2023-10-20 18:45:15 +08:00
}
2023-10-30 19:09:40 +08:00
const allripeFn = () => {
2023-10-31 18:40:32 +08:00
landCropAllRipeAPI({
crop_id: crop_id.value
})
2023-10-30 19:09:40 +08:00
uni.navigateTo({
url: '/pages/index/index'
})
}
2023-10-27 18:38:25 +08:00
// actionsAPI({
// type: 1
// }).then(res => {
// for (let key in res.data) {
// actionList[key] = (res.data)[key]
// }
// })
2023-10-20 18:45:15 +08:00
</script>
<style lang="scss" scoped>
.content {
padding: 30rpx;
// background-color: grey;
background-color: #EBF1EF;
}
.head-img {
border-radius: 21.03rpx 21.03rpx 21.03rpx 21.03rpx;
margin: 0 auto;
position: relative;
.poisition {
opacity: 0.7;
position: absolute;
width: 380.26rpx;
height: 71rpx;
background-color: #FFFFFF;
left: 43rpx;
bottom: 36rpx;
border-radius: 21.03rpx 21.03rpx 21.03rpx 21.03rpx;
display: flex;
align-items: center;
font-size: 29.79rpx;
.dw-cls {
margin: 0 5rpx;
}
}
}
.bad-info {
display: flex;
// background-color: red;
justify-content: space-between;
align-items: center;
margin: 20rpx 0;
color: #737373;
width: 693.93rpx;
font-size: 26.29rpx;
.tit-b {
color: red;
}
}
.up-plant-btn {
width: 371.5rpx;
height: 66.59rpx;
color: #00A15E;
margin: 40rpx auto;
border: 1px solid #00A15E;
font-weight: bold;
border-radius: 42.06rpx 42.06rpx 42.06rpx 42.06rpx;
display: flex;
align-items: center;
justify-content: center;
}
.data {
.tit {
.tit-b {
color: #B3B3B3;
font-size: 26.29rpx;
display: flex;
align-items: center;
}
}
.data-alanys {
// background-color: blue;
float: right;
color: white;
}
.data-cont {
// margin: 20rpx;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
margin-top: 30rpx;
box-sizing: border-box;
// padding: 70rpx;
.data-cont-li {
border-radius: 21.03rpx 21.03rpx 21.03rpx 21.03rpx;
width: 310.94rpx;
height: 212.03rpx;
background-color: white;
margin-bottom: 20rpx;
}
}
}
.center {
display: flex;
align-items: center;
}
.b-cls {
display: flex;
align-items: flex-end;
width: 250rpx;
justify-content: space-between;
color: #4CC593;
}
.card {
.tit {
display: flex;
justify-content: space-between;
padding-bottom: 20rpx;
border-bottom: 1px solid #EBF1EF;
}
.card-li {
margin-top: 20rpx;
display: flex;
justify-content: space-between;
}
}
2023-10-23 17:57:19 +08:00
.grow-record-tit {
display: flex;
justify-content: space-between;
margin-bottom: 20rpx;
align-items: center;
font-size: 26.29rpx;
2023-10-20 18:45:15 +08:00
2023-10-23 17:57:19 +08:00
.updata-btn {
width: 192.76rpx;
height: 57.83rpx;
border: 1px solid #00A15E;
color: #00A15E;
2023-10-20 18:45:15 +08:00
display: flex;
2023-10-23 17:57:19 +08:00
justify-content: center;
align-items: center;
border-radius: 31.54rpx 31.54rpx 31.54rpx 31.54rpx;
2023-10-20 18:45:15 +08:00
}
}
2023-10-23 17:57:19 +08:00
2023-10-20 18:45:15 +08:00
.ripe-btn {
width: 588.79rpx;
height: 84.11rpx;
background-color: #00A15E;
color: white;
display: flex;
justify-content: center;
align-items: center;
margin: 0 auto;
border-radius: 42.06rpx 42.06rpx 42.06rpx 42.06rpx;
background: linear-gradient(to right, #00A15E, #4CC593);
}
2023-10-25 19:55:18 +08:00
.mark {
// padding: 30rpx;
padding: 30rpx;
.head {
display: flex;
justify-content: space-between;
align-items: center;
}
.mark-li {
display: flex;
justify-content: space-between;
margin: 40rpx;
border-bottom: 1px solid #EBF1EF;
padding-bottom: 20rpx;
}
}
2023-10-26 19:02:26 +08:00
.circumstance {
width: 693.93rpx;
margin: 0 auto;
margin-bottom: 43rpx;
.card-tit {
display: flex;
justify-content: space-between;
margin-bottom: 28rpx;
}
.updata-btn {
font-size: 26.29rpx;
width: 192.76rpx;
height: 57.83rpx;
border: 1px solid #00A15E;
color: #00A15E;
display: flex;
justify-content: center;
align-items: center;
border-radius: 31.54rpx 31.54rpx 31.54rpx 31.54rpx;
}
.check {
font-size: 29.79rpx;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
}
.tab {
height: 500rpx;
background-color: red;
}
}
2023-10-20 18:45:15 +08:00
</style>