From 0719dc09c2d9b297f836c4e0832c9db622adfcd0 Mon Sep 17 00:00:00 2001
From: guonan <guonan201020@163.com>
Date: 星期六, 07 六月 2025 18:25:58 +0800
Subject: [PATCH] 增加隐患点及监测设备以及解决ID报错问题

---
 src/components/menu/Device.vue |   35 ++++++++++++++++-------------------
 1 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/src/components/menu/Device.vue b/src/components/menu/Device.vue
index 5edadbe..99d409b 100644
--- a/src/components/menu/Device.vue
+++ b/src/components/menu/Device.vue
@@ -72,7 +72,7 @@
 <script setup>
 import { ref, computed, onMounted, watch, onBeforeUnmount } from "vue";
 import { useRoute, onBeforeRouteUpdate } from "vue-router";
-import { createPoint, removeEntities } from "@/utils/map";
+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鍒楄〃涓湁瀵瑰簲缁忕含搴﹀悗寮冪敤
@@ -93,17 +93,17 @@
   }
 });
 
-onBeforeRouteUpdate((to, from, next) => {
-  if (to.path !== "/zhjc") {
-    handleCleanup();
-  }
-  next();
-});
+// onBeforeRouteUpdate((to, from, next) => {
+//   if (to.path !== "/zhjc") {
+//     handleCleanup();
+//   }
+//   next();
+// });
 const route = useRoute();
 
 onBeforeUnmount(() => {
   if (route.path !== "/zhjc") {
-    handleCleanup();
+    clearAllPoints();
   }
 });
 watch(
@@ -112,18 +112,14 @@
     if (newValue) {
       initializeDevicePoints();
     } else {
-      handleCleanup();
+      clearAllPoints();
     }
   }
 );
 
 const deviceListAll = ref([]);
 const deviceEntities = ref([]);
-const handleCleanup = () => {
-  deviceListAll.value.forEach((item) => {
-    removeEntities(item.deviceId);
-  });
-};
+
 // const initializeDevicePoints = (val) => {
 const initializeDevicePoints = () => {
   const list = [];
@@ -149,14 +145,15 @@
 // 鏍规嵁鍖哄煙鍚嶇О鍔犺浇璁惧鍒楄〃
 const loadDeviceList = async (areaName) => {
   try {
+    clearAllPoints();
     isLoading.value = true;
-    handleCleanup();
     // const res = await getDeviceInfoShg();
     // const allDevices = res.data.pageData;
-    const devicesInArea = allDevices.value.filter((item) =>
+    deviceListAll.value = allDevices.value.filter((item) =>
       item.deviceName?.includes(areaName)
     );
-    deviceListAll.value = devicesInArea;
+
+    initializeDevicePoints();
     // getDeviceInfo().then((res) => {
     //   const list = res.data.pageData;
     //   deviceListAll.value = [];
@@ -292,8 +289,8 @@
 
 .tree-container {
   position: relative;
-  height: calc(100% - 80px);
-  margin-top: 10px;
+  height: calc(100% - 22px);
+  // margin-top: 10px;
   overflow-y: auto;
 }
 

--
Gitblit v1.9.3