jsy-app/pages/fourmonitor/weatherstation.vue

332 lines
8.3 KiB
Vue
Raw Normal View History

2024-12-19 12:41:30 +08:00
<template>
2024-12-20 10:50:22 +08:00
<custom-nav-bar :left="true" title="气象站"></custom-nav-bar>
2025-01-16 18:46:15 +08:00
<view class="header-section">
</view>
<view class="content-section">
<view class="card">
<view class="cards-title">
2025-01-16 18:47:31 +08:00
2025-01-16 18:46:15 +08:00
<view class="title-r">
2025-01-16 18:47:31 +08:00
<view class="iconfont icon-lishijilu icon" @click="openH(item)"></view>查看历史
2025-01-16 18:46:15 +08:00
</view>
2024-12-19 12:41:30 +08:00
</view>
2025-01-16 18:46:15 +08:00
<view class="content">
<view class="cards-content">
<view class="txt-list" @click="taskdetails">
<view class="list2">
<view>
<text class="iconfont icon-fengli icon"></text>
2025-01-17 14:24:40 +08:00
<text>风力</text>{{itemProperty.wc===null?"--":itemProperty.wc}}
2025-01-16 18:46:15 +08:00
</view>
<view>
<text class="iconfont icon-fengsu icon"></text>
2025-01-17 14:24:40 +08:00
<text>风速</text>{{itemProperty.ws===null?"--":itemProperty.ws}}m/s
2025-01-16 18:46:15 +08:00
</view>
<view>
<text class="iconfont icon-fengxiang icon"></text>
2025-01-17 14:24:40 +08:00
<text>风向</text>{{itemProperty.wd===null?"--":itemProperty.wd}}
2025-01-16 18:46:15 +08:00
</view>
<view>
<text class="iconfont icon-daqiyali icon"></text>
2025-01-17 14:24:40 +08:00
<text>大气压力</text>{{itemProperty.p===null?"--":itemProperty.p}}hpa
2025-01-16 18:46:15 +08:00
</view>
<view>
<text class="iconfont icon-wd icon"></text>
2025-01-17 14:24:40 +08:00
<text>温度</text>{{itemProperty.t===null?"--":itemProperty.t}}
2025-01-16 18:46:15 +08:00
</view>
<view>
<text class="iconfont icon-shidu icon"></text>
2025-01-17 14:24:40 +08:00
<text>湿度</text>{{itemProperty.h===null?"--":itemProperty.h}}%
2025-01-16 18:46:15 +08:00
</view>
<view>
<text class="iconfont icon-dqyl icon"></text>
2025-01-17 14:24:40 +08:00
<text>当前雨量</text>{{itemProperty.rt===null?"--":itemProperty.rt}}mm
2025-01-16 18:46:15 +08:00
</view>
<view>
<text class="iconfont icon-jyl icon"></text>
2025-01-17 14:24:40 +08:00
<text>瞬时雨量</text>{{itemProperty.ri===null?"--":itemProperty.ri}}mm
2025-01-16 18:46:15 +08:00
</view>
<view>
<text class="iconfont icon-ljyl icon"></text>
2025-01-17 14:24:40 +08:00
<text>累计雨量</text>{{itemProperty.r===null?"--":itemProperty.r}}mm
2025-01-16 18:46:15 +08:00
</view>
<view>
<text class="iconfont icon-sb icon"></text>
2025-01-17 14:24:40 +08:00
<text>设备状态</text>{{itemProperty.s =="online"?"在线":"离线" }}
2025-01-16 18:46:15 +08:00
</view>
</view>
2024-12-19 12:41:30 +08:00
</view>
2025-01-16 18:46:15 +08:00
</view>
2024-12-19 12:41:30 +08:00
</view>
2025-01-16 18:46:15 +08:00
</view>
</view>
<u-popup :show="showDeviceLog" mode="center">
<view class="dialog-container">
<view class="dialog-title">
<text>气象站历史记录</text>
<u-icon name="reload" size="20" class="reload-btn" @click="reload"></u-icon>
<u-icon name="close" size="20" class="close-btn" @click="closeLog"></u-icon>
2024-12-19 12:41:30 +08:00
</view>
2025-01-16 18:46:15 +08:00
<view class="dialog-body">
<view class="logs-data-box" style="width:90vw">
<view class="logs-container">
<view class="logs-item" v-for="itemHistory in listData" :key="item.id">
<view class="row">
<view class="left">
<text class="label">设备编号</text>
<text class="text">{{ itemHistory.deviceCode }}</text>
</view>
<view class="right">
<text class="label">温度</text>
<text class="text">{{ itemHistory.temperature }}</text>
</view>
</view>
<view class="row">
<view class="left">
<text class="label">湿度</text>
<text class="text">{{ itemHistory.humidity}}%</text>
</view>
<view class="right">
<text class="label">大气压力</text>
<text class="text">{{ itemHistory.pressure }}kPa</text>
</view>
</view>
<view class="row">
<view class="left">
<text class="label">风级</text>
<text class="text">{{ itemHistory.windClass}}</text>
2024-12-19 18:12:16 +08:00
</view>
2025-01-16 18:46:15 +08:00
<view class="right">
<text class="label">风向</text>
<text class="text">{{ itemHistory.windDirection }}kPa</text>
2024-12-19 18:12:16 +08:00
</view>
2025-01-16 18:46:15 +08:00
</view>
<view class="row">
<view class="left">
<text class="label">当前雨量</text>
<text class="text">{{ itemHistory.rainCurrent}}</text>
2024-12-19 18:12:16 +08:00
</view>
2025-01-16 18:46:15 +08:00
<view class="right">
<text class="label">累计雨量</text>
<text class="text">{{ itemHistory.rainFall }}kPa</text>
2024-12-19 18:12:16 +08:00
</view>
2025-01-16 18:46:15 +08:00
</view>
<view class="row">
<view class="full-line">
<text class="label">记录时间</text>
<text class="text">{{ itemHistory.createTime }}</text>
2024-12-19 18:12:16 +08:00
</view>
</view>
</view>
</view>
2025-01-16 18:46:15 +08:00
<uni-pagination :pageCount="query.pageSize" :curPageNum="query.pageNum" :totalNum="total"
@pageClick="pageTurning"></uni-pagination>
2024-12-19 12:41:30 +08:00
</view>
</view>
2025-01-16 18:46:15 +08:00
</view>
</u-popup>
2024-12-19 12:41:30 +08:00
</template>
2025-01-16 18:46:15 +08:00
<script>
2024-12-19 12:41:30 +08:00
import {
2024-12-19 18:12:16 +08:00
getOutDeviceHistoryList
} from "@/api/system/device_agricultural"
export default {
data() {
return {
item: {},
itemProperty: {},
showDeviceLog: false,
total: 0,
listData: [],
query: {
pageNum: 1,
pageSize: 10,
deviceCode: null
2024-12-19 22:23:23 +08:00
},
mqttConnected: false, // mqtt链接状态
topics: []
2024-12-19 18:12:16 +08:00
}
},
onLoad(option) {
if (option.item != null) {
this.item = JSON.parse(decodeURIComponent(option.item));
if (this.item) {
this.itemProperty = this.item.deviceData;
this.query.deviceCode = this.item.deviceCode;
2024-12-19 22:23:23 +08:00
let topic = "jsy/iot/push/outProduct/" + this.item.deviceCode;
this.topics.push(topic);
this.mqttSubscribes(this.topics);
2025-01-07 10:02:41 +08:00
getApp().on("mqtt", "mqtt_head", function(e) {
2024-12-19 22:23:23 +08:00
if (e.type == "state") {
2025-01-03 13:09:20 +08:00
this.mqttConnected = e.connected;
2024-12-19 22:23:23 +08:00
} else if (e.type == "msg") {
this.itemProperty = e.data;
}
});
2024-12-19 18:12:16 +08:00
}
}
2025-01-07 10:02:41 +08:00
},
onUnload() {
getApp().off("mqtt", "mqtt_head");
2024-12-19 18:12:16 +08:00
},
methods: {
2024-12-19 22:23:23 +08:00
mqttSubscribes(topics) {
getApp().mqttSubscribes(topics);
},
mqttUnSubscribes(topics) {
getApp().mqttUnsubscribes(topics);
},
2024-12-19 18:12:16 +08:00
queryList(str) {
if (str == "into") {
this.query.pageNum = 1;
}
if (str == "pre") {
this.query.pageNum = this.query.pageNum - 1
}
if (str == "next") {
this.query.pageNum = this.query.query.pageNum + 1
}
getOutDeviceHistoryList(this.query).then(res => {
this.listData = res.rows;
this.total = res.total;
})
},
//打开历史界面
openH(item) {
this.showDeviceLog = true
this.queryList("into");
},
reload() {
uni.$emit("reloadlogs")
},
//关闭历史记录
closeLog() {
this.showDeviceLog = false;
},
pageTurning(flag) {
if (flag === 0) {
if (this.query.pageNum - 1 === 0) return
this.queryList("pre")
2024-12-19 12:41:30 +08:00
}
2024-12-19 18:12:16 +08:00
if (flag === 1) {
if (this.query.pageNum + 1 > Math.ceil(this.total / this.query.pageSize)) return
this.queryList("next")
}
2025-01-16 18:46:15 +08:00
2024-12-19 18:12:16 +08:00
}
2024-12-19 12:41:30 +08:00
}
}
</script>
<style lang="scss">
2025-01-16 18:46:15 +08:00
.header-section {
2024-12-19 12:41:30 +08:00
width: 100%;
2025-01-16 18:46:15 +08:00
padding: 10px 0px 30px 0px;
background-color: #39ac4f;
border-radius: 0 0 30px 30px;
2024-12-19 12:41:30 +08:00
}
2025-01-16 18:46:15 +08:00
.content-section {
position: relative;
top: -50px;
2024-12-19 12:41:30 +08:00
}
2025-01-16 18:46:15 +08:00
.list2 {
view {
margin: 10px 0;
color: #39ac4f;
font-weight: bold;
2025-01-17 14:24:40 +08:00
text:nth-child(2) {min-width: 80px;display: inline-block;
2025-01-16 18:46:15 +08:00
color: #333;
font-weight: normal;
}
2024-12-19 12:41:30 +08:00
2025-01-16 18:46:15 +08:00
}
2024-12-19 12:41:30 +08:00
}
2025-01-16 18:46:15 +08:00
2024-12-19 12:41:30 +08:00
// 弹窗
.dialog-container {
width: 90vw;
height: 90vh;
overflow: hidden;
2025-01-16 18:46:15 +08:00
2024-12-19 12:41:30 +08:00
.dialog-title {
width: 100%;
height: 34px;
font-size: 16px;
line-height: 34px;
text-align: center;
font-weight: bold;
border-bottom: 1px solid #999;
position: relative;
2025-01-16 18:46:15 +08:00
2024-12-19 12:41:30 +08:00
.reload-btn {
position: absolute;
top: 50%;
right: 56px;
transform: translateY(-50%);
}
2025-01-16 18:46:15 +08:00
2024-12-19 12:41:30 +08:00
.close-btn {
position: absolute;
top: 50%;
right: 10px;
transform: translateY(-50%);
}
}
2025-01-16 18:46:15 +08:00
2024-12-19 12:41:30 +08:00
.dialog-body {
height: calc(100% - 35px);
overflow: hidden;
position: relative;
background-color: #f7f7f7;
2025-01-16 18:46:15 +08:00
2024-12-19 12:41:30 +08:00
//扫码的弹窗
.scancode-device-info {
height: 100%;
padding: 0 20px;
overflow-x: hidden;
overflow-y: auto;
display: flex;
flex-direction: column;
justify-content: space-evenly;
2025-01-16 18:46:15 +08:00
&>view {
2024-12-19 12:41:30 +08:00
width: 100%;
line-height: 40px;
font-size: 18px;
color: gray;
2025-01-16 18:46:15 +08:00
2024-12-19 12:41:30 +08:00
.label {
display: inline-block;
width: 30%;
color: black;
margin-right: 2px;
white-space: nowrap;
}
}
}
}
2025-01-16 18:46:15 +08:00
2024-12-19 12:41:30 +08:00
.control-panel {
height: 100px;
display: flex;
align-items: center;
flex-wrap: nowrap;
justify-content: space-evenly;
2025-01-16 18:46:15 +08:00
&>view {
2024-12-19 12:41:30 +08:00
padding: 6px 10px;
color: #007acc;
font-size: 14px;
border: 1px solid #ccc;
border-radius: 4px;
}
}
}
</style>