|
|
@@ -37,6 +37,7 @@
|
|
|
:expand-row-by-click="true"
|
|
|
:expanded-row-keys="expandedRowKeys"
|
|
|
@expand="onExpand"
|
|
|
+ :loading="loading"
|
|
|
>
|
|
|
<!-- 自定义展开图标 -->
|
|
|
<template #expandIcon="{ expanded, onExpand, record }">
|
|
|
@@ -146,7 +147,7 @@ const isRefresh = ref(true);
|
|
|
const treeNodeTitle = ref(''); // 选中的树形标题
|
|
|
const deviceList = ref<any[]>([]); // 设备列表
|
|
|
const monitorList = ref<Record<string, any[]>>({}); // 监测数据列表
|
|
|
-
|
|
|
+const loading = ref(false);
|
|
|
// 当前展开的行key数组
|
|
|
const expandedRowKeys = ref([]);
|
|
|
const scroll = reactive({
|
|
|
@@ -168,16 +169,19 @@ const onSelect: TreeProps['onSelect'] = (keys, e) => {
|
|
|
deviceType.value = '';
|
|
|
systemID.value = '';
|
|
|
deviceList.value = [];
|
|
|
- const title = e.node.title;
|
|
|
- if (e.node.parent && e.node.parent.node.type.toString().startsWith('sys')) {
|
|
|
- systemType.value = e.node.parent.node.type;
|
|
|
- if (deviceType.value != e.node.parent.node.type) deviceType.value = e.node.parent.node.type;
|
|
|
- systemID.value = e.node.type;
|
|
|
+ const currentNode = e.node;
|
|
|
+ const parentNode = currentNode.parent?.node;
|
|
|
+ let newDeviceType = '';
|
|
|
+ if (parentNode && parentNode.type.toString().startsWith('sys')) {
|
|
|
+ systemType.value = parentNode.type;
|
|
|
+ newDeviceType = parentNode.type;
|
|
|
+ systemID.value = currentNode.type;
|
|
|
} else {
|
|
|
- systemType.value = e.node.type;
|
|
|
- if (deviceType.value != e.node.type) deviceType.value = e.node.type;
|
|
|
+ systemType.value = currentNode.type;
|
|
|
+ newDeviceType = currentNode.type;
|
|
|
}
|
|
|
- getDeviceList(deviceType.value);
|
|
|
+ deviceType.value = newDeviceType;
|
|
|
+ getDeviceList(newDeviceType);
|
|
|
};
|
|
|
// 获取所有节点key的函数
|
|
|
const getAllNodeKeys = (nodes, type) => {
|
|
|
@@ -238,19 +242,23 @@ async function getDeviceList(deviceTypeVal?: any) {
|
|
|
clearInterval(timer);
|
|
|
timer = undefined;
|
|
|
}
|
|
|
+ loading.value = true;
|
|
|
const fetchDeviceData = async () => {
|
|
|
const params: any = {
|
|
|
devKind: deviceTypeVal,
|
|
|
+ pageNo: 1,
|
|
|
+ pageSize: 2000,
|
|
|
};
|
|
|
try {
|
|
|
const result = await getDeviceListByType(params);
|
|
|
+ loading.value = false;
|
|
|
deviceList.value = result.records; // 更新设备列表
|
|
|
} catch (error) {
|
|
|
console.error('定时请求设备列表失败:', error);
|
|
|
}
|
|
|
};
|
|
|
await fetchDeviceData();
|
|
|
- timer = setInterval(fetchDeviceData, 2000); // 2000ms = 2秒
|
|
|
+ timer = setInterval(fetchDeviceData, 3000);
|
|
|
}
|
|
|
|
|
|
// 外层表格列配置
|