|
@@ -46,7 +46,9 @@
|
|
|
<span>返回</span>
|
|
|
</el-button>
|
|
|
</template>
|
|
|
- <hc-table :column="tableColumn" :datas="tableData" :loading="tableLoading" :is-current-row="false" />
|
|
|
+ <hc-table :column="tableColumn" :datas="tableData" :loading="tableLoading" :is-current-row="false">
|
|
|
+ <template #deviceName>{{ deviceDataInfo.deviceName }}</template>
|
|
|
+ </hc-table>
|
|
|
</hc-card>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -89,14 +91,14 @@ watch(isShow, (val) => {
|
|
|
const isLoading = ref(true)
|
|
|
const getInfoData = async () => {
|
|
|
isLoading.value = true
|
|
|
- getDateTime()
|
|
|
+ await getDateTime()
|
|
|
await getDeviceList()
|
|
|
await getTableData()
|
|
|
isLoading.value = false
|
|
|
}
|
|
|
|
|
|
//处理默认的搜索时间
|
|
|
-const getDateTime = () => {
|
|
|
+const getDateTime = async () => {
|
|
|
const now = dayjs()
|
|
|
const hourAgo = now.subtract(1, 'hour')
|
|
|
const start = hourAgo.format('YYYY-MM-DD HH:mm:ss')
|
|
@@ -115,26 +117,27 @@ const getDeviceList = async () => {
|
|
|
isLoading.value = false
|
|
|
return
|
|
|
}
|
|
|
- let temperature = '0℃', humidity = '0%'
|
|
|
+ let temperature = '0℃', humidity = '0%', deviceName = ''
|
|
|
const { data } = await mainApi.getRealTimeDataByDeviceAddr(token, deviceAddr)
|
|
|
//数据是否存在
|
|
|
const arr = getArrValue(data)
|
|
|
if (arr.length <= 0) {
|
|
|
- setDeviceData({ temperature, humidity })
|
|
|
+ setDeviceData({ temperature, humidity, deviceName })
|
|
|
isLoading.value = false
|
|
|
return
|
|
|
}
|
|
|
+ deviceName = arr[0].deviceName
|
|
|
//子级数据是否存在
|
|
|
const dataItem = getArrValue(arr[0].dataItem)
|
|
|
if (dataItem.length <= 0) {
|
|
|
- setDeviceData({ temperature, humidity })
|
|
|
+ setDeviceData({ temperature, humidity, deviceName })
|
|
|
isLoading.value = false
|
|
|
return
|
|
|
}
|
|
|
//最子级数据判断
|
|
|
const registerItem = getArrValue(dataItem[0].registerItem)
|
|
|
if (registerItem.length <= 0) {
|
|
|
- setDeviceData({ temperature, humidity })
|
|
|
+ setDeviceData({ temperature, humidity, deviceName })
|
|
|
isLoading.value = false
|
|
|
return
|
|
|
}
|
|
@@ -148,14 +151,15 @@ const getDeviceList = async () => {
|
|
|
}
|
|
|
}
|
|
|
//设置数据
|
|
|
- setDeviceData({ temperature, humidity })
|
|
|
+ setDeviceData({ temperature, humidity, deviceName })
|
|
|
isLoading.value = false
|
|
|
}
|
|
|
|
|
|
//设置空数据
|
|
|
-const setDeviceData = ({ temperature, humidity }) => {
|
|
|
+const setDeviceData = ({ temperature, humidity, deviceName }) => {
|
|
|
const currentDateTime = new dayjs().format('YYYY年MM月DD日 HH:mm:ss')
|
|
|
deviceDataInfo.value = {
|
|
|
+ deviceName: deviceName,
|
|
|
temperature: temperature,
|
|
|
humidity: humidity,
|
|
|
time: currentDateTime,
|
|
@@ -164,19 +168,21 @@ const setDeviceData = ({ temperature, humidity }) => {
|
|
|
|
|
|
//搜索表单
|
|
|
const searchForm = ref({ nodeId: -1, startTime: '', endTime: '', deviceAddr: null })
|
|
|
-const searchClick = () => {
|
|
|
- const arr = dateTimeArr.value
|
|
|
+const searchClick = async () => {
|
|
|
+ const arr = getArrValue(dateTimeArr.value)
|
|
|
if (arr.length < 2) {
|
|
|
- getDateTime()
|
|
|
+ await getDateTime()
|
|
|
+ await getTableData()
|
|
|
} else {
|
|
|
searchForm.value.startTime = arr[0]
|
|
|
searchForm.value.endTime = arr[1]
|
|
|
- getTableData()
|
|
|
+ await getTableData()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//历史记录表格
|
|
|
const tableColumn = [
|
|
|
+ { key: 'deviceName', name: '设备名称' },
|
|
|
{ key: 'deviceAddr', name: '设备地址' },
|
|
|
{ key: 'temperature', name: '温度' },
|
|
|
{ key: 'humidity', name: '湿度' },
|