|
|
@@ -12,14 +12,14 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<div class="hc-tentative-acquisition-humidity-equipment">
|
|
|
- <hc-card-item v-for="item in 2" :key="item" class="equipment-list">
|
|
|
+ <hc-card-item v-for="item in deviceDataList" :key="item.deviceAddr" class="equipment-list">
|
|
|
<template #header>
|
|
|
- <div class="status-dot" :class="item === 1 ? 'run' : ''" />
|
|
|
- <div class="name ml-10px">300900317</div>
|
|
|
+ <div class="status-dot" :class="item.deviceStatus === 'normal' ? 'run' : ''" />
|
|
|
+ <div class="name ml-10px">{{ item.deviceName }}</div>
|
|
|
</template>
|
|
|
<template #extra>
|
|
|
- <div class="icon-btn text-#2bb781">
|
|
|
- <el-tooltip content="重启">
|
|
|
+ <div class="icon-btn text-#2bb781" @click="getDeviceList">
|
|
|
+ <el-tooltip content="刷新">
|
|
|
<hc-icon name="restart" />
|
|
|
</el-tooltip>
|
|
|
</div>
|
|
|
@@ -30,27 +30,20 @@
|
|
|
</div>
|
|
|
<el-button size="small" class="ml-10px" @click="viewDetailsClick">查看详情</el-button>
|
|
|
</template>
|
|
|
- <div class="equipment-list-data hc-flex">
|
|
|
- <div class="item temperature hc-flex">
|
|
|
- <div class="icon-box">
|
|
|
- <hc-icon name="temp-hot" />
|
|
|
+ <div v-if="item.dataItem.length > 0" class="equipment-list-data hc-flex">
|
|
|
+ <template v-for="(items, indexs) in item.dataItem[0].registerItem" :key="indexs">
|
|
|
+ <div class="item hc-flex" :class="items.registerName === '温度' ? 'temperature' : 'humidity' ">
|
|
|
+ <div class="icon-box">
|
|
|
+ <hc-icon v-if="items.registerName === '温度'" name="temp-hot" />
|
|
|
+ <hc-icon v-if="items.registerName === '湿度'" name="water-percent" />
|
|
|
+ </div>
|
|
|
+ <div class="content">
|
|
|
+ <div class="name">{{ items.registerName }}</div>
|
|
|
+ <div class="num">{{ items.data }}{{ items.unit }}</div>
|
|
|
+ <div class="time">记录时间:{{ currentDateTime }}</div>
|
|
|
+ </div>
|
|
|
</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>
|
|
|
- </div>
|
|
|
- <div class="item humidity hc-flex">
|
|
|
- <div class="icon-box">
|
|
|
- <hc-icon name="water-percent" />
|
|
|
- </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>
|
|
|
- </div>
|
|
|
+ </template>
|
|
|
</div>
|
|
|
</hc-card-item>
|
|
|
</div>
|
|
|
@@ -60,8 +53,39 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { onMounted, ref } from 'vue'
|
|
|
+import { getArrValue, getObjValue, isNullES } from 'js-fast-way'
|
|
|
+import { onActivated, onMounted, ref } from 'vue'
|
|
|
+import { useClick } from 'hc-vue3-ui'
|
|
|
+import dayjs from 'dayjs'
|
|
|
import HcEquipmentData from './model/equipment-data.vue'
|
|
|
+import mainApi from '~api/tentative/acquisition/humidity'
|
|
|
+
|
|
|
+//页面被激活
|
|
|
+onActivated(() => {
|
|
|
+ useDataApi()
|
|
|
+})
|
|
|
+
|
|
|
+//获取数据
|
|
|
+const useDataApi = async () => {
|
|
|
+ await useClick()
|
|
|
+ getToken().then()
|
|
|
+}
|
|
|
+
|
|
|
+//获取token
|
|
|
+const yunToken = ref('')
|
|
|
+const getToken = async () => {
|
|
|
+ const { code, msg, data } = await mainApi.getToken({
|
|
|
+ loginName: 'h240816wjbm',
|
|
|
+ password: 'h240816wjbm',
|
|
|
+ })
|
|
|
+ const { token } = getObjValue(data)
|
|
|
+ if (code === 1000 && !isNullES(token)) {
|
|
|
+ yunToken.value = token
|
|
|
+ await getDeviceList()
|
|
|
+ } else {
|
|
|
+ window.$message.error(msg ?? '获取数据失败,请联系管理员')
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
//搜索表单
|
|
|
const searchForm = ref({ status: null, ip: null })
|
|
|
@@ -69,6 +93,21 @@ const searchClick = () => {
|
|
|
window.$message.warning('暂不支持此操作')
|
|
|
}
|
|
|
|
|
|
+//获取设备列表
|
|
|
+const deviceDataList = ref([])
|
|
|
+const currentDateTime = ref('')
|
|
|
+const getDeviceList = async () => {
|
|
|
+ await useClick()
|
|
|
+ if (isNullES(yunToken.value)) {
|
|
|
+ deviceDataList.value = []
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const { data } = await mainApi.getRealTimeData(yunToken.value)
|
|
|
+ deviceDataList.value = getArrValue(data)
|
|
|
+ //获取当前时间
|
|
|
+ currentDateTime.value = new dayjs().format('YYYY年MM月DD日 HH:mm:ss')
|
|
|
+}
|
|
|
+
|
|
|
//查看详情
|
|
|
const isEquipmentDataShow = ref(false)
|
|
|
const viewDetailsClick = () => {
|