|
@@ -9,8 +9,8 @@
|
|
|
</div>
|
|
|
<div class="content">
|
|
|
<div class="name">温度</div>
|
|
|
- <div class="num">24.1℃</div>
|
|
|
- <div class="time">记录时间:2024年8月19日 13:55:24</div>
|
|
|
+ <div class="num">{{ deviceDataInfo.temperature }}</div>
|
|
|
+ <div class="time">记录时间:{{ deviceDataInfo.time }}</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="equipment-list-data-item humidity hc-flex">
|
|
@@ -19,8 +19,8 @@
|
|
|
</div>
|
|
|
<div class="content">
|
|
|
<div class="name">湿度</div>
|
|
|
- <div class="num">24.1%</div>
|
|
|
- <div class="time">记录时间:2024年8月19日 13:55:24</div>
|
|
|
+ <div class="num">{{ deviceDataInfo.humidity }}</div>
|
|
|
+ <div class="time">记录时间:{{ deviceDataInfo.time }}</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="equipment-list-data-echart">
|
|
@@ -58,7 +58,10 @@
|
|
|
|
|
|
<script setup>
|
|
|
import { ref, watch } from 'vue'
|
|
|
-import { getObjValue } from 'js-fast-way'
|
|
|
+import { getArrValue, getObjValue, isNullES } from 'js-fast-way'
|
|
|
+import { useClick } from 'hc-vue3-ui'
|
|
|
+import dayjs from 'dayjs'
|
|
|
+import mainApi from '~api/tentative/acquisition/humidity'
|
|
|
|
|
|
const props = defineProps({
|
|
|
data: {
|
|
@@ -84,10 +87,62 @@ watch(isShow, (val) => {
|
|
|
})
|
|
|
|
|
|
//获取数据详情
|
|
|
-const getInfoData = () => {
|
|
|
+const getInfoData = async () => {
|
|
|
+ await getDeviceList()
|
|
|
setChartsData()
|
|
|
}
|
|
|
|
|
|
+//获取设备列表
|
|
|
+const deviceDataInfo = ref({})
|
|
|
+const getDeviceList = async () => {
|
|
|
+ const { token, deviceAddr } = getObjValue(dataInfo.value)
|
|
|
+ if (isNullES(token) || isNullES(deviceAddr)) {
|
|
|
+ deviceDataInfo.value = {}
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let temperature = '0℃', humidity = '0%'
|
|
|
+ const { data } = await mainApi.getRealTimeDataByDeviceAddr(token, deviceAddr)
|
|
|
+ //数据是否存在
|
|
|
+ const arr = getArrValue(data)
|
|
|
+ if (arr.length <= 0) {
|
|
|
+ setDeviceData({ temperature, humidity })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //子级数据是否存在
|
|
|
+ const dataItem = getArrValue(arr[0].dataItem)
|
|
|
+ if (dataItem.length <= 0) {
|
|
|
+ setDeviceData({ temperature, humidity })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //最子级数据判断
|
|
|
+ const registerItem = getArrValue(dataItem[0].registerItem)
|
|
|
+ if (registerItem.length <= 0) {
|
|
|
+ setDeviceData({ temperature, humidity })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //最子级数据
|
|
|
+ for (let i = 0; i < registerItem.length; i++) {
|
|
|
+ if (registerItem[i].registerName === '温度') {
|
|
|
+ temperature = registerItem[i].data + registerItem[i].unit
|
|
|
+ }
|
|
|
+ if (registerItem[i].registerName === '湿度') {
|
|
|
+ humidity = registerItem[i].data + registerItem[i].unit
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //设置数据
|
|
|
+ setDeviceData({ temperature, humidity })
|
|
|
+}
|
|
|
+
|
|
|
+//设置空数据
|
|
|
+const setDeviceData = ({ temperature, humidity }) => {
|
|
|
+ const currentDateTime = new dayjs().format('YYYY年MM月DD日 HH:mm:ss')
|
|
|
+ deviceDataInfo.value = {
|
|
|
+ temperature: temperature,
|
|
|
+ humidity: humidity,
|
|
|
+ time: currentDateTime,
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
//搜索表单
|
|
|
const searchForm = ref({ nodeId: -1, startTime: '', endTime: '', deviceAddr: null, current: 1, size: 20, total: 0 })
|
|
|
const searchClick = () => {
|