1
0
Эх сурвалжийг харах

[Feat 0000]数据中心设备监测模块修改

bobo04052021@163.com 4 сар өмнө
parent
commit
da6c18d3f1

+ 18 - 10
src/views/vent/dataCenter/deviceCenter/index.vue

@@ -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);
 }
 
 // 外层表格列配置

+ 7 - 0
src/views/vent/dataCenter/stationCenter/index.vue

@@ -29,6 +29,7 @@
               :expand-row-by-click="true"
               :expandedRowKeys="expandedRowKeys"
               @expand="handleExpand"
+              :loading="loading"
             >
               <!-- 自定义展开图标 -->
               <template #expandIcon="{ expanded, onExpand, record }">
@@ -109,6 +110,7 @@ const clsoeNum = ref(0);
 const monitorList = ref<Record<string, any[]>>({}); // 监测数据列表
 const expandedRowKeys = ref([]);
 const selectedIndex = ref(0);
+const loading = ref(false);
 // // 分页参数
 // const paginationState = ref({
 //   current: 1,
@@ -187,6 +189,8 @@ async function getSubStationList() {
 }
 //菜单选项切换
 function cardClick(item, ind) {
+  loading.value = true;
+
   selectedIndex.value = selectedIndex.value === ind ? -1 : ind;
   if (timer) {
     clearInterval(timer);
@@ -202,8 +206,11 @@ const loadingMap = reactive({});
 async function getDeviceList(ID?) {
   const params: any = {
     subId: ID.toString(),
+    pageNo: 1,
+    pageSize: 2000,
   };
   const result = await getDeviceListByType(params);
+  loading.value = false;
   deviceList.value = result.records;
 }
 // 外层表格列配置