From a5ff6d6ec90207453f52686a57df0c0135d1c5b2 Mon Sep 17 00:00:00 2001
From: guonan <guonan201020@163.com>
Date: 星期二, 20 五月 2025 15:08:43 +0800
Subject: [PATCH] Merge branch 'master' of http://103.135.160.14:9034/r/NslWeb

---
 src/components/menu/Location.vue |   71 ++++++++++++++++++++---------------
 1 files changed, 41 insertions(+), 30 deletions(-)

diff --git a/src/components/menu/Location.vue b/src/components/menu/Location.vue
index 7749e80..312a474 100644
--- a/src/components/menu/Location.vue
+++ b/src/components/menu/Location.vue
@@ -1,31 +1,32 @@
-<template>
-  <div class="district">
-    <div class="left-top">
-      <span>鐩戞祴浣嶇疆</span>
-    </div>
-
-    <div class="left-content district-content">
-      <div style="margin-left: 5px">
-        <span style="color: white">閲嶇偣娌燂細</span>
-        <el-select @change="handleChange" v-model="selectValue" placeholder="Select" size="large" style="width: 240px">
-          <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
-        </el-select>
+  <template>
+    <div class="district">
+      <div class="left-top">
+        <span>鐩戞祴浣嶇疆</span>
       </div>
 
-      <!-- 婊氬姩鍖哄煙 -->
-      <div style="overflow-y: auto; height: 95%">
-        <!-- 鍔犺浇閬僵灞� -->
-        <div v-if="loading" class="loading-overlay">
-          <div class="spinner"></div>
+      <div class="left-content district-content">
+        <div style="margin-left: 5px">
+          <span style="color: white">閲嶇偣娌燂細</span>
+          <el-select @change="handleChange" v-model="selectValue" placeholder="Select" size="large"
+            style="width: 240px">
+            <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
+          </el-select>
         </div>
-        <div v-else v-for="(item, key) in districtList" :key="key" class="district-item" @click="handleClick(item)">
-          <div class="district-item-icon"></div>
-          <div class="district-item-text">{{ item.hdName }}</div>
+
+        <!-- 婊氬姩鍖哄煙 -->
+        <div style="overflow-y: auto; height: 95%">
+          <!-- 鍔犺浇閬僵灞� -->
+          <div v-if="loading" class="loading-overlay">
+            <div class="spinner"></div>
+          </div>
+          <div v-else v-for="(item, key) in districtList" :key="key" class="district-item" @click="handleClick(item)">
+            <div class="district-item-icon"></div>
+            <div class="district-item-text">{{ item.hdName }}</div>
+          </div>
         </div>
       </div>
     </div>
-  </div>
-</template>
+  </template>
 
 <script setup>
 import { ref, onMounted, watch, onBeforeUnmount } from "vue";
@@ -112,11 +113,14 @@
     districtList.value = [];
     return;
   }
-
-  districtList.value = simStore.DangerPoint.filter((item) =>
+  const filteredData = simStore.DangerPoint.filter((item) =>
     item.position?.includes(areaName)
   );
-  await initializeDevicePoints();
+
+  if (JSON.stringify(districtList.value) !== JSON.stringify(filteredData)) {
+    districtList.value = filteredData;
+    await initializeDevicePoints();
+  }
 };
 
 // 澶勭悊鍖哄煙鍙樺寲浜嬩欢
@@ -128,11 +132,19 @@
   }
   filterDataByArea(areaName);
 };
-watch(() => simStore.DangerShowSwitch, (newValue, oldValue) => {
+let isInitialized = false;
+
+watch(() => simStore.DangerShowSwitch, async (newValue, oldValue) => {
+  console.log('褰撳墠鐘舵�侊細', newValue);
+
   if (newValue) {
-    initializeDevicePoints();
+    if (!isInitialized) {
+      await initializeDevicePoints();
+      isInitialized = true;
+    }
   } else {
-    handleCleanup()
+    handleCleanup();
+    isInitialized = false;
   }
 });
 // 鐩戝惉 simStore.DangerPoint 鍙樺寲
@@ -147,8 +159,7 @@
       districtList.value = [];
       loading.value = true; // 鏁版嵁鏈噯澶囧氨缁�
     }
-  },
-  { immediate: true }
+  }
 );
 
 onMounted(() => {

--
Gitblit v1.9.3