From b23bc4d88ed6215fdda94dc94a15dd62e9f4a5cc Mon Sep 17 00:00:00 2001
From: guonan <guonan201020@163.com>
Date: 星期四, 12 六月 2025 11:59:10 +0800
Subject: [PATCH] 北京市隐患点和监测设备修改

---
 src/components/menu/Device.vue |  117 +++++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 83 insertions(+), 34 deletions(-)

diff --git a/src/components/menu/Device.vue b/src/components/menu/Device.vue
index e587b5e..22b7f18 100644
--- a/src/components/menu/Device.vue
+++ b/src/components/menu/Device.vue
@@ -9,7 +9,7 @@
         <el-select
           @change="handleChange1"
           v-model="selectValue1"
-          placeholder="Select"
+          placeholder="璇烽�夋嫨琛屾斂鍖�"
           size="mini"
           style="width: 240px"
         >
@@ -26,7 +26,7 @@
         <el-select
           @change="handleChange"
           v-model="selectValue"
-          placeholder="Select"
+          placeholder="璇烽�夋嫨閲嶇偣娌�"
           size="mini"
           style="width: 240px"
         >
@@ -50,6 +50,7 @@
         <el-tree
           v-show="!isLoading"
           :data="deviceTree"
+          default-expand-all
           node-key="deviceId"
           :props="treeProps"
           @node-click="handleTreeNodeClick"
@@ -74,10 +75,10 @@
 import { useRoute, onBeforeRouteUpdate } from "vue-router";
 import { createPoint, removeEntities, clearAllPoints } from "@/utils/map";
 import { deviceDictList, getDictName } from "@/constant/dict.js";
-import { getDeviceInfoShg, getDeviceInfo } from "@/api/hpApi";
 import { initeWaterPrimitiveView } from "@/utils/water"; //鐩告満flyTo鍑芥暟锛屽悗缁璷ptions鍒楄〃涓湁瀵瑰簲缁忕含搴﹀悗寮冪敤
 import { useSimStore } from "@/store/simulation";
 import { Loading } from "@element-plus/icons-vue";
+import { getDeviceInfoByPage } from "@/api/hpApi";
 
 const simStore = useSimStore();
 
@@ -94,12 +95,6 @@
   }
 });
 
-// onBeforeRouteUpdate((to, from, next) => {
-//   if (to.path !== "/zhjc") {
-//     handleCleanup();
-//   }
-//   next();
-// });
 const route = useRoute();
 
 onBeforeUnmount(() => {
@@ -108,22 +103,34 @@
   }
 });
 
-// watch(
-//   () => simStore.DeviceShowSwitch,
-//   (newValue, oldValue) => {
-//     if (newValue) {
-//       initializeDevicePoints();
-//     } else {
-//       clearAllPoints();
-//     }
-//   }
-// );
+const selectValue1 = ref("");
+
+const BJoptions = ref([
+  { label: "瀵嗕簯鍖�", value: "110118000000" },
+  { label: "鎴垮北鍖�", value: "110111000000" },
+  { label: "闂ㄥご娌熷尯", value: "110109000000" },
+  { label: "寤跺簡鍖�", value: "110119000000" },
+  { label: "鎬�鏌斿尯", value: "110116000000" },
+  { label: "鏄屽钩鍖�", value: "110114000000" },
+  { label: "骞宠胺鍖�", value: "110117000000" },
+  { label: "娴锋穩鍖�", value: "110108000000" },
+  { label: "鐭虫櫙灞卞尯", value: "110107000000" },
+  { label: "涓板彴鍖�", value: "110106000000" },
+]);
+
+const selectValue = ref("瀛欒儭娌�");
+
+const options = ref([
+  { value: "瀛欒儭娌�", label: "瀛欒儭娌�" },
+  { value: "楸兼按娲炲悗娌�", label: "楸兼按娲炲悗娌�" },
+  { value: "浜庡瑗挎矡", label: "浜庡瑗挎矡" },
+  { value: "鍖楁渤娌�", label: "鍖楁渤娌�" },
+  { value: "榫欐硥宄潙", label: "榫欐硥宄潙" },
+]);
 
 const deviceListAll = ref([]);
 
 const initializeDevicePoints = () => {
-  const list = [];
-  // val.forEach((item, index) => {
   deviceListAll.value.forEach((item, index) => {
     // 鏍规嵁闇�姹傚彲澧炲垹
     item.type = getDictName(deviceDictList, item.dictDeviceType);
@@ -135,6 +142,19 @@
     // console.log(`璁惧鍚嶇О: ${item.id}, 璁惧绫诲瀷: ${item.name}`);
     createPoint(item);
   });
+};
+
+const DevicePoints = async (item) => {
+  // 鏍规嵁闇�姹傚彲澧炲垹
+  item.type = getDictName(deviceDictList, item.dictDeviceType);
+  item.name = item.deviceName
+  // item.name = item.deviceName.split(selectValue.value)[1] || item.deviceName;
+  item.id = item.deviceId;
+  item.className = "device";
+  item.showLabel = true;
+  // 鎵撳嵃姣忎釜璁惧鐨勫悕绉板拰璁惧绫诲瀷
+  // console.log(`璁惧鍚嶇О: ${item.id}, 璁惧绫诲瀷: ${item.name}`);
+  createPoint(item);
 };
 
 // 鏍规嵁鍖哄煙鍚嶇О鍔犺浇璁惧鍒楄〃
@@ -174,26 +194,49 @@
     ElMessage("璇烽�夋嫨涓�涓尯鍩�");
     return;
   }
+  selectValue1.value = "";
+  selectValue.value = item;
   // 鏍规嵁鏂板尯鍩熷悕閲嶆柊鍔犺浇璁惧鍒楄〃
   loadDeviceList(item);
   initializeDevicePoints();
-
-  // console.log(deviceListAll.value);
 };
 
-const selectValue1 = ref("鍖椾含甯�");
+// 澶勭悊鍖哄煙鍙樺寲浜嬩欢
+const handleChange1 = async (item) => {
+  if (!item) {
+    ElMessage("璇烽�夋嫨涓�涓尯鍩�");
+    return;
+  }
+  selectValue1.value = item;
+  selectValue.value = "";
+  deviceListAll.value = [];
+  let pageNum = 1;
+  let hasMore = true;
 
-const BJoptions = ref([]);
+  try {
+    while (hasMore) {
+      const res = await getDeviceInfoByPage(item, pageNum);
 
-const selectValue = ref("瀛欒儭娌�");
+      // 灏嗘柊鏁版嵁杩藉姞鍒板垪琛ㄤ腑
+      deviceListAll.value = [...deviceListAll.value, ...res.data.pageData];
 
-const options = ref([
-  { value: "瀛欒儭娌�", label: "瀛欒儭娌�" },
-  { value: "楸兼按娲炲悗娌�", label: "楸兼按娲炲悗娌�" },
-  { value: "浜庡瑗挎矡", label: "浜庡瑗挎矡" },
-  { value: "鍖楁渤娌�", label: "鍖楁渤娌�" },
-  { value: "榫欐硥宄潙", label: "榫欐硥宄潙" },
-]);
+      // 鍒ゆ柇鏄惁杩樻湁涓嬩竴椤�
+      if (pageNum < res.data.pageCount) {
+        pageNum++;
+        await new Promise((resolve) => setTimeout(resolve, 300));
+      } else {
+        hasMore = false;
+      }
+    }
+  } catch (err) {
+    console.error("鑾峰彇鐩戞祴璁惧澶辫触", err);
+    deviceListAll.value = []; // 鍙�夛細娓呯┖鎴栦繚鐣欏凡鍔犺浇閮ㄥ垎
+  } finally {
+    // 鏆傛椂鍏堝叧闂姞杞界姸鎬侊紝鍥犱负姝ゅ涓哄垎椤佃姹傛暟鎹紝鐒跺悗涓�鐐逛竴鐐圭殑娓叉煋锛屾渶缁堜細鍔犺浇瀹屾垚
+    // 濡傛灉寮�鍚姞杞界姸鎬侊紝鏈�鍚庤繕鏄細绛夋墍鏈夋暟鎹兘璇锋眰鍥炴潵鎵嶄細娓叉煋
+    // loading.value = false; // 鍏抽棴鍔犺浇鐘舵��
+  }
+};
 
 const treeProps = {
   label: "deviceName",
@@ -229,7 +272,13 @@
 });
 
 function handleTreeNodeClick(data) {
-  initializeDevicePoints();
+  if (selectValue.value) {
+    // 姝ゅ璋冪敤鏄洜涓篏isView椤甸潰浼氬湪鐐瑰嚮涓嬩竴涔¢晣涔嬪墠鎶婁笂涓�涓�夋嫨鐨勫尯鍩熺殑闅愭偅鐐规竻闄ゆ帀锛堝鏋滃垰濂介�夋嫨浜嗗瓩鑳℃矡锛岄偅涔堜笅涓�涓偣鍑诲皢浼氭竻绌哄瓩鑳℃矡鐨勯殣鎮g偣锛�
+    initializeDevicePoints();
+  } else {
+    // 琛屾斂鍖哄垝鐨勭偣浣嶅お澶氫簡锛屽彧鑳介�変腑鍝釜娓叉煋鍝釜
+    DevicePoints(data);
+  }
   // 鍙湁璁惧鑺傜偣鎵嶅鐞嗙偣鍑讳簨浠�
   if (!data.children) {
     const entity = viewer.entities.getById(data.deviceId);

--
Gitblit v1.9.3