jsy-app/components/custom-index-mp/custom-index-mp.vue

232 lines
4.3 KiB
Vue
Raw Normal View History

2024-12-02 17:19:21 +08:00
<template>
<u-popup :show="open" mode="bottom" @close="close" closeable>
2024-12-03 09:57:05 +08:00
<view class="lock">
2024-12-02 18:38:17 +08:00
<view class="title">土壤墒情
2025-02-11 16:32:15 +08:00
<view class="iconfont icon-shuaxin" @click="refreshSoilTilth"></view>
2024-12-02 18:38:17 +08:00
</view>
<view class="list-title ">
<view class="fixed">
<view></view>
2025-01-23 10:26:07 +08:00
<view>深度(cm)</view>
<view>湿度(%)</view>
<view>温度()</view>
2024-12-02 18:38:17 +08:00
</view>
</view>
2024-12-03 09:57:05 +08:00
</view>
<view class="list-box" style="padding-top: 108px;">
2024-12-02 18:38:17 +08:00
<view class="card">
2024-12-03 12:41:26 +08:00
<uni-collapse v-if="list.length">
<uni-collapse-item title-border="none" :border="false" :open="true" v-for="item in list">
2024-12-02 18:38:17 +08:00
<template v-slot:title>
<view class="fixed" style="justify-content: space-between;">
2025-01-16 09:46:32 +08:00
<view>位置{{item.name}}</view>
<view>{{item.time}}</view>
2024-12-02 18:38:17 +08:00
</view>
</template>
<view class="list-content">
2025-01-16 09:46:32 +08:00
<view class="fixed" v-for="data in item.data">
<view>{{data.lv}}</view>
2025-02-11 16:32:15 +08:00
<view>{{data.depth}}</view>
<view>{{data.humidity}}</view>
<view>{{data.temperature}}</view>
2024-12-02 18:38:17 +08:00
</view>
</view>
</uni-collapse-item>
</uni-collapse>
2024-12-03 12:41:26 +08:00
<u-empty mode="data" style="height: 50vh;" v-else />
2024-12-02 18:38:17 +08:00
</view>
</view>
2024-12-02 17:19:21 +08:00
</u-popup>
</template>
<script>
2025-01-16 09:46:32 +08:00
import {
2025-02-11 16:32:15 +08:00
getMpDeviceList,
mpRefresh
2025-01-16 09:46:32 +08:00
} from "@/api/controlMpInterface.js"
2024-12-02 17:19:21 +08:00
export default {
name: "Mp",
components: {},
props: {},
data() {
return {
title: "土壤墒情",
open: false,
2025-01-16 09:46:32 +08:00
landId: null,
mpId: null,
2024-12-03 12:41:26 +08:00
list: [],
2024-12-02 17:19:21 +08:00
}
},
created() {},
mounted() {},
methods: {
/**
* 显示方法
2025-01-16 09:46:32 +08:00
* @param land 地块
* @param mpId 墒情id
2024-12-02 17:19:21 +08:00
*/
2025-01-16 09:46:32 +08:00
async show(land, mpId = null) {
if (!land) {
return;
}
this.landId = land.id;
this.mpId = mpId;
2024-12-02 17:19:21 +08:00
this.open = true;
2024-12-03 12:41:26 +08:00
this.getList();
2024-12-02 17:19:21 +08:00
},
close() {
this.open = false;
2024-12-03 12:41:26 +08:00
},
getList() {
this.list = [];
2025-01-16 09:46:32 +08:00
const query = {
landId: this.landId,
id: this.mpId
}
getMpDeviceList(query).then((res) => {
let list = {};
res.data.forEach(item => {
if (!list[item.name]) {
list[item.name] = {
time: null,
data: [],
};
}
list[item.name].time = item.time;
list[item.name].data.push(item);
});
if (Object.keys(list).length != 0) {
for (var key in list) {
this.list.push({
name: key,
time: list[key].time,
data: list[key].data
})
}
}
});
2024-12-03 12:41:26 +08:00
},
2025-02-11 16:32:15 +08:00
refreshSoilTilth() {
let refresh = [];
this.list.forEach(item => {
if (refresh.findIndex(x => x.deviceCode == item.deviceCode) == -1) {
let mp = {
deviceCode: item.deviceCode,
lv: item.floors
};
refresh.push(mp);
}
});
mpRefresh(refresh).then((res) => {
});
}
2024-12-02 17:19:21 +08:00
}
}
</script>
<style lang="scss" scoped>
2024-12-03 10:27:21 +08:00
::v-deep.u-popup__content__close--top-right {
z-index: 11;
}
2024-12-02 18:38:17 +08:00
.u-popup__content {
background: transparent;
2024-12-02 17:19:21 +08:00
2024-12-03 10:27:21 +08:00
2024-12-03 09:57:05 +08:00
.lock {
position: fixed;
width: 100%;
height: 108px;
z-index: 10;
background-color: #f3f3f3;
2024-12-03 10:27:21 +08:00
2024-12-03 09:57:05 +08:00
.title {
font-size: 34rpx;
position: relative;
text-align: center;
padding: 15px 0;
.icon-shuaxin {
position: absolute;
top: 15px;
right: 40px;
}
}
}
2024-12-02 18:38:17 +08:00
.list-box {
2024-12-03 09:57:05 +08:00
border-radius: 10px 10px 0 0;
2024-12-02 18:38:17 +08:00
width: 100vw;
min-height: 50vh;
max-height: calc(100vh - 100px);
background-color: #f3f3f3;
padding: 10px;
overflow-y: auto;
}
.card {
background-color: transparent;
.uni-collapse {
background-color: transparent;
border-radius: 10px;
}
::v-deep.uni-collapse-item__title {
background-color: #39ac4f;
color: #fff;
padding: 10px;
border-radius: 10px;
.uni-collapse-item__title-arrow {
width: 40px;
.uni-icons {
color: #fff !important;
}
}
}
::v-deep.uni-collapse-item__wrap {
background: transparent !important;
}
}
.list-title,
.list-content {
background: #fff;
border-radius: 10px;
margin-bottom: 10px;
box-shadow: 0 1px 9px rgb(209, 209, 209, 0.5);
.fixed {
view {
font-size: 30rpx;
padding: 10px 0;
text-align: center;
flex: 1;
}
}
}
2024-12-03 09:57:05 +08:00
.list-title {
margin: 0 10px;
}
2024-12-02 18:38:17 +08:00
.list-content {
margin-bottom: 0;
.fixed {
view {
font-size: 28rpx;
border-bottom: 1px solid #f3f3f3;
}
}
}
}
2024-12-02 17:19:21 +08:00
</style>