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/Location.vue |   22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/src/components/menu/Location.vue b/src/components/menu/Location.vue
index de29198..d37b435 100644
--- a/src/components/menu/Location.vue
+++ b/src/components/menu/Location.vue
@@ -66,7 +66,7 @@
 
 <script setup>
 import { ref, onMounted, watch, onBeforeUnmount } from "vue";
-import { createPoint, removeEntities } from "@/utils/map";
+import { createPoint,clearAllPoints } from "@/utils/map";
 import { useSimStore } from "@/store/simulation";
 import { initeWaterPrimitiveView } from "@/utils/water"; //鐩告満flyTo鍑芥暟锛屽悗缁璷ptions鍒楄〃涓湁瀵瑰簲缁忕含搴﹀悗寮冪敤
 import { useRoute, onBeforeRouteUpdate } from "vue-router";
@@ -91,7 +91,7 @@
 const simStore = useSimStore();
 // onBeforeRouteUpdate((to, from, next) => {
 //   if (to.path !== "/yhgl") {
-//     handleCleanup();
+//     clearAllPoints();
 //   }
 //   next();
 // });
@@ -99,7 +99,7 @@
 
 onBeforeUnmount(() => {
   if (route.path !== "/yhgl") {
-    handleCleanup();
+    clearAllPoints();
   }
 });
 const selectValue = ref("瀛欒儭娌�");
@@ -134,6 +134,8 @@
 const loading = ref(true); // 鎺у埗鍔犺浇鐘舵��
 
 function handleClick(district) {
+  // 姝ゅ璋冪敤鏄洜涓篏isView椤甸潰浼氬湪鐐瑰嚮涓嬩竴涔¢晣涔嬪墠鎶婁笂涓�涓�夋嫨鐨勫尯鍩熺殑闅愭偅鐐规竻闄ゆ帀锛堝鏋滃垰濂介�夋嫨浜嗗瓩鑳℃矡锛岄偅涔堜笅涓�涓偣鍑诲皢浼氭竻绌哄瓩鑳℃矡鐨勯殣鎮g偣锛�
+  initializeDevicePoints();
   const entity = viewer.entities.getById(district.hdId);
   if (entity) {
     viewer.flyTo(entity, {
@@ -145,11 +147,7 @@
     });
   }
 }
-const handleCleanup = async () => {
-  await Promise.all(
-    districtList.value.map((item) => removeEntities(item.hdId))
-  );
-};
+
 const initializeDevicePoints = async () => {
   await Promise.all(
     districtList.value.map(async (item, index) => {
@@ -169,7 +167,7 @@
 };
 
 const filterDataByArea = async (areaName) => {
-  handleCleanup();
+  clearAllPoints();
   if (!areaName || !simStore.DangerPoint || simStore.DangerPoint.length === 0) {
     districtList.value = [];
     return;
@@ -207,7 +205,7 @@
         isInitialized = true;
       }
     } else {
-      handleCleanup();
+      clearAllPoints();
       isInitialized = false;
     }
   }
@@ -220,7 +218,7 @@
       filterDataByArea(selectValue.value);
       loading.value = false; // 鏁版嵁鍔犺浇瀹屾垚
     } else {
-      handleCleanup();
+      clearAllPoints();
       districtList.value = [];
       loading.value = true; // 鏁版嵁鏈噯澶囧氨缁�
     }
@@ -228,7 +226,7 @@
 );
 
 onMounted(() => {
-  handleCleanup();
+  clearAllPoints();
   // initeWaterPrimitiveView();
   // 榛樿鍏堟鏌ヤ竴閬嶆暟鎹�
   if (simStore.DangerPoint && simStore.DangerPoint.length > 0) {

--
Gitblit v1.9.3