From bf0eb543e2deab8a1629dd2a46f8e1cd191531e1 Mon Sep 17 00:00:00 2001
From: wangjuncheng <1>
Date: 星期四, 17 七月 2025 15:22:01 +0800
Subject: [PATCH] Merge branch 'master' of http://103.135.160.14:9034/r/NslWeb

---
 src/components/tools/LayerTree.vue         |    3 
 src/components/tools/Detail.vue            |   63 +++++++++------
 src/api/hpApi.js                           |   19 ++++
 src/store/simulation.js                    |    3 
 src/views/Home.vue                         |   49 ++++++++----
 src/components/menu/TimeLine.vue           |   25 +++---
 src/components/tools/DebuffDetail.vue      |    2 
 src/views/mnfz.vue                         |   38 ++++++++-
 src/components/monifangzhen/schemeCard.vue |    2 
 9 files changed, 138 insertions(+), 66 deletions(-)

diff --git a/src/api/hpApi.js b/src/api/hpApi.js
index b18a094..9c220ff 100644
--- a/src/api/hpApi.js
+++ b/src/api/hpApi.js
@@ -247,15 +247,18 @@
   return response.data;
 }
 
-// 鏌ヨ瀛欒儭娌熼伩闄╁満鎵�
-export async function getSafePoint() {
+// 鏌ヨ鍖椾含甯傞伩闄╁満鎵�
+export async function getSafePoint(data) {
   const response = await axios.get("/hp/safeHavenLocation/getDataSelect", {
     params: {
-      divisionId: 110116110218
+      divisionId: data
     }
   });
   return response.data;
 }
+// 110116110218
+
+
 
 // 鏌ヨ鍖椾含甯�
 export async function getAllCode() {
@@ -283,4 +286,14 @@
     }
   });
   return response.data;
+}
+
+// 鐩戞祴璁惧涓叧鑱旂殑闅愭偅鐐圭殑鍏蜂綋淇℃伅
+export async function hdByDevice(data) {
+  const response = await axios.get("/hp/sinoDzHiddenDangerPoint/getDetail", {
+    params: {
+      unifiedCode: data
+    }
+  });
+  return response.data;
 }
\ No newline at end of file
diff --git a/src/components/menu/TimeLine.vue b/src/components/menu/TimeLine.vue
index b341eb1..6951358 100644
--- a/src/components/menu/TimeLine.vue
+++ b/src/components/menu/TimeLine.vue
@@ -1135,23 +1135,24 @@
   if (selectedScheme.value.type === 2) {
     try {
       await ElMessageBox.confirm("鏂规鏈仠姝㈡椂缁撴潫妯℃嫙鍚庯紝鍚庡彴灏嗗仠姝㈣绠�", {
-        confirmButtonText: "杩斿洖鍒楄〃",
-        cancelButtonText: "缁撴潫妯℃嫙",
+        confirmButtonText: "缁撴潫妯℃嫙",
+        cancelButtonText: "杩斿洖鍒楄〃",
         type: "warning",
       });
-      // 鐢ㄦ埛鐐瑰嚮浜嗙‘璁わ紝杩欓噷涓嶆墽琛屼换浣曟搷浣滐紝浠呭叧闂璇濇
+
+      const res = await stopSim(selectedScheme.value.id);
+      if (res.code == 404) {
+        ElMessage.warning("璇ユ湇鍔″凡鍋滄");
+      } else {
+        ElMessage.success("鏈嶅姟姝e湪鍋滄涓�");
+      }
     } catch (error) {
-      stopSim(selectedScheme.value.id).then((res) => {
-        if (res.code == 404) {
-          ElMessage.warning("璇ユ湇鍔″凡鍋滄");
-        } else {
-          ElMessage.success("鏈嶅姟姝e湪鍋滄涓�");
-        }
-      });
-      // return;
+      // 鐢ㄦ埛鐐瑰嚮浜嗐�愯繑鍥炲垪琛ㄣ�戞垨鑰呭嚭鐜伴敊璇�
+      return;
     }
   }
-  // 涓嶇type鏄笉鏄�2锛屾渶缁堥兘鎵ц缁撴潫妯℃嫙鐨勬搷浣�
+
+  // 涓嶇 type 鏄笉鏄� 2锛屾渶缁堥兘鎵ц缁撴潫妯℃嫙鎿嶄綔
   endSimulation();
 }
 
diff --git a/src/components/monifangzhen/schemeCard.vue b/src/components/monifangzhen/schemeCard.vue
index ed91fdf..b3d1b9d 100644
--- a/src/components/monifangzhen/schemeCard.vue
+++ b/src/components/monifangzhen/schemeCard.vue
@@ -321,7 +321,7 @@
         return; // 闃绘鍚庣画鎿嶄綔
       } else {
         simStore.rePlayList = res.data;
-        console.log(simStore.rePlayList, "lisi");
+        console.log(simStore.rePlayList, "瀹炴椂妯℃嫙鍘嗗彶鍥炴斁鍒楄〃");
       }
       // 浣跨敤 nextTick 纭繚 DOM 鏇存柊鍚庡啀鎵ц鍚庣画鎿嶄綔
       nextTick(() => {
diff --git a/src/components/tools/DebuffDetail.vue b/src/components/tools/DebuffDetail.vue
index 7660ab3..5a4ca4f 100644
--- a/src/components/tools/DebuffDetail.vue
+++ b/src/components/tools/DebuffDetail.vue
@@ -152,7 +152,7 @@
 
 // 鐢熷懡鍛ㄦ湡閽╁瓙
 onMounted(() => {
-  console.log(filteredData);
+  // console.log(filteredData);
   updateThreatData();
   getRainfallData();
 });
diff --git a/src/components/tools/Detail.vue b/src/components/tools/Detail.vue
index 245373a..160623b 100644
--- a/src/components/tools/Detail.vue
+++ b/src/components/tools/Detail.vue
@@ -22,6 +22,8 @@
   dialogPositon,
 } from "@/store";
 
+import { hdByDevice } from "@/api/hpApi";
+
 const detailList = ref([]);
 const detailTitle = ref("璁惧璇︽儏");
 const name = ref("");
@@ -29,33 +31,44 @@
   showDeviceDetail.value = false;
   coloseDialog();
 }
+
 // 鐩戞祴璁惧鍏蜂綋淇℃伅
-function handlDeviceDetail() {
-  detailTitle.value = deviceDetail.value.deviceForShort;
-  detailList.value = [
-    {
-      name: "璁惧缂栧彿",
-      value:
-        deviceDetail.value.deviceCode || Math.floor(Math.random() * 100000),
-    },
-    {
-      name: "璁惧绫诲瀷",
-      value: deviceDetail.value.type || deviceDetail.value.deviceTypeName,
-    },
-    {
-      name: "鍏宠仈闅愭偅鐐�",
-      value: deviceDetail.value.hdName,
-    },
-    {
-      name: "缇ら槻鍛�",
-      value: deviceDetail.value.groupTestGroupDefenseUserName,
-    },
-    {
-      name: "缇ら槻鍛樼數璇�",
-      value: deviceDetail.value.groupTestGroupDefenseMobile,
-    },
-  ];
+async function handlDeviceDetail() {
+  const hdInfo = ref();
+
+  try {
+    const res = await hdByDevice(deviceDetail.value.hdUnifiedCode);
+    hdInfo.value = res.data;
+
+    detailList.value = [
+      {
+        name: "璁惧缂栧彿",
+        value: deviceDetail.value.deviceCode || Math.floor(Math.random() * 100000),
+      },
+      {
+        name: "璁惧绫诲瀷",
+        value: deviceDetail.value.type || deviceDetail.value.deviceTypeName,
+      },
+      {
+        name: "鍏宠仈闅愭偅鐐�",
+        value: deviceDetail.value.hdName,
+      },
+      {
+        name: "缇ゆ祴缇ら槻鍛�",
+        value: hdInfo.value?.groupTestGroupDefenseUserName || "鏆傛棤淇℃伅",
+      },
+      {
+        name: "缇ゆ祴缇ら槻鍛樼數璇�",
+        value: hdInfo.value?.groupTestGroupDefenseMobile || "鏆傛棤淇℃伅",
+      },
+    ];
+
+    detailTitle.value = deviceDetail.value.deviceForShort;
+  } catch (err) {
+    console.error("鑾峰彇 hdInfo 澶辫触", err);
+  }
 }
+
 // 闅愭偅鐐瑰叿浣撲俊鎭�
 function handleDistrictDetail() {
   const name = deviceDetail.value.hdName;
diff --git a/src/components/tools/LayerTree.vue b/src/components/tools/LayerTree.vue
index a7338fb..3e607c7 100644
--- a/src/components/tools/LayerTree.vue
+++ b/src/components/tools/LayerTree.vue
@@ -267,7 +267,6 @@
   if (list && Array.isArray(list)) {
     for (const item of list) {
       const entity = await item;
-      console.log(entity,'eeeeeeeee')
 
       let shouldRemove = true; // 榛樿瑕佸垹闄�
 
@@ -375,7 +374,7 @@
  * 娣诲姞閬块櫓鍦烘墍鏁版嵁
  */
 function addTetrahedron() {
-  getSafePoint().then((res) => {
+  getSafePoint(110116110218).then((res) => {
     const geoJsonData = convertToGeoJson(res.data); // 杞崲涓� GeoJSON
     // 鍔犺浇 GeoJSON 鏁版嵁鍒板湴鍥�
     loadAreaPolygon(geoJsonData, true).then((entities) => {
diff --git a/src/store/simulation.js b/src/store/simulation.js
index bb75f7e..e810802 100644
--- a/src/store/simulation.js
+++ b/src/store/simulation.js
@@ -1,6 +1,7 @@
 // stores/ui.js
 import { defineStore } from 'pinia'
 import { ref } from 'vue'
+import { showDeviceDetail } from "@/store";
 export const useSimStore = defineStore('simulation', () => {
     // 鏂潰鏁版嵁
     const crossSection = ref([])
@@ -157,7 +158,6 @@
     const startMNPG = () => {
         init()
         isShowEarth.value = false
-
     }
 
     const setBackToHome = (value) => {
@@ -166,6 +166,7 @@
 
     // 瀵艰埅鐐瑰嚮
     const handleNavClick = (index) => {
+        showDeviceDetail.value = false;
         switch (index) {
             case 1:
                 startYHGL()
diff --git a/src/views/Home.vue b/src/views/Home.vue
index 243e35a..d627921 100644
--- a/src/views/Home.vue
+++ b/src/views/Home.vue
@@ -60,7 +60,7 @@
 import { showDeviceDetail } from "@/store";
 import { setupTokenRefresh, getDangerPoint, getAllCode } from "@/api/hpApi.js";
 import { convertToWKT } from "@/utils/wktUtils";
-import { getDeviceInfoSHG, getSafePoint } from "@/api/hpApi";
+import { getDeviceInfoSHG, getWeather } from "@/api/hpApi";
 
 const route = useRoute();
 const simStore = useSimStore();
@@ -100,35 +100,52 @@
 // 璁$畻灞炴��
 const showDetail = computed(() => showDeviceDetail.value);
 
-function extractAllChildrenInfoUnique(dataArray) {
-  const map = new Map();
+function groupTopWithLeafNodes(dataArray) {
+  const result = {};
 
-  function traverse(nodes) {
+  function traverse(nodes, topLevelName = null) {
     if (!Array.isArray(nodes)) return;
 
     for (const node of nodes) {
-      const key = node.code;
+      const isLeaf = !node.children || node.children.length === 0;
 
-      // 妫�鏌ユ槸鍚︽槸鏈�鍚庝竴灞傦紙娌℃湁瀛愯妭鐐规垨瀛愯妭鐐逛负绌烘暟缁勶級
-      if (!node.children || node.children.length === 0) {
-        if (key && !map.has(key)) {
-          map.set(key, { name: node.nameChn, code: key });
+      // 濡傛灉鏄《灞傝妭鐐癸紝璁板綍瀹冪殑鍚嶅瓧浣滀负 key
+      if (!topLevelName && !isLeaf) {
+        topLevelName = node.nameChn;
+        if (!result[topLevelName]) {
+          result[topLevelName] = [];
         }
-      } else {
-        // 濡傛灉鏈夊瓙鑺傜偣锛岀户缁�掑綊閬嶅巻
-        traverse(node.children);
+      }
+
+      // 濡傛灉鏄彾瀛愯妭鐐癸紝鍔犲叆瀵瑰簲鏁扮粍
+      if (isLeaf && topLevelName) {
+        result[topLevelName].push({
+          name: node.nameChn,
+          code: node.code,
+        });
+      }
+
+      // 缁х画閫掑綊瀛愯妭鐐癸紙淇濇寔褰撳墠椤跺眰鍚嶇О锛�
+      if (node.children && node.children.length > 0) {
+        traverse(node.children, topLevelName);
       }
     }
   }
 
-  traverse(dataArray);
-  return Array.from(map.values());
-}
+  // 閬嶅巻鏁翠釜澶ф暟缁勪腑鐨勬瘡涓�椤癸紙鍗虫瘡涓�涓尯鍩燂級
+  for (const item of dataArray) {
+    if (item && item.children && Array.isArray(item.children)) {
+      traverse([item]); // 鎶婂綋鍓嶉」鍖呰鎴愭暟缁勶紝鏂逛究缁熶竴澶勭悊
+    }
+  }
 
+  return result;
+}
 onMounted(async () => {
   getAllCode().then((res) => {
     // 鍖椾含甯傛墍鏈夋潙浠ュ強琛楅亾code
-    simStore.townCodeAll = extractAllChildrenInfoUnique(res.data[0].children);
+    simStore.townCodeAll = groupTopWithLeafNodes(res.data[0].children);
+    console.log(simStore.townCodeAll, "涓杞帴鍙h幏鍙栦埂闀嘽ode");
   });
   setupTokenRefresh(); // 鑾峰彇瀹忓浘token
   // getSimData(); //娴嬭瘯tr鍚庣
diff --git a/src/views/mnfz.vue b/src/views/mnfz.vue
index b015a4a..6a243ed 100644
--- a/src/views/mnfz.vue
+++ b/src/views/mnfz.vue
@@ -142,28 +142,55 @@
   });
   dataSources.length = 0;
 }
+
 // 閬块櫓鍦烘墍锛岀豢鑹插瘜鏂囨湰
 async function addTetrahedron(visible) {
   const emergencyAreaList = [];
 
   try {
-    const res = await getSafePoint();
+    let codesToFetch = [];
 
-    const geoJsonData = convertToGeoJson(res.data);
+    // 鍒ゆ柇褰撳墠閫夋嫨鍖哄煙鏄惁涓衡�滃尯鈥�
+    if (simStore.selectedScheme.areaName.includes("鍖�")) {
+      // 浠� simStore.townCodeAll 涓嬁鍒拌鍖轰笅鐨勬墍鏈変埂闀� code
+      const townList = simStore.townCodeAll[simStore.selectedScheme.areaName];
+
+      // 鍋囪 townList 鏄竴涓暟缁勶紝閲岄潰姣忎釜鍏冪礌鏈� .code 瀛楁
+      if (Array.isArray(townList)) {
+        codesToFetch = townList.map((item) => item.code);
+      } else {
+        console.warn("鏈壘鍒板搴旂殑涔¢晣鍒楄〃");
+        return;
+      }
+    } else {
+      // 涓嶆槸鈥滃尯鈥濓紝灏变娇鐢ㄩ粯璁� code
+      codesToFetch = ["110116110218"];
+    }
+
+    // 骞跺彂璇锋眰鎵�鏈� code 鐨勯伩闄╃偣鏁版嵁
+    const allRes = await Promise.all(
+      codesToFetch.map((code) => getSafePoint(code))
+    );
+
+    // 鍚堝苟缁撴灉锛堝亣璁炬瘡涓� res.data 鏄竴涓暟缁勶級
+    const allSafePoints = allRes.flatMap((res) => res.data);
+
+    // 杞崲涓� GeoJSON锛堝鏋滄瘡涓� data 閮介渶瑕佸崟鐙鐞嗭級
+    const geoJsonData = convertToGeoJson(allSafePoints);
 
     // 鍔犺浇搴曞眰闈㈢墖锛堝杈瑰舰锛�
     const polygonEntities = await loadAreaPolygon(geoJsonData, true);
     emergencyAreaList.push(...polygonEntities);
 
     // 娣诲姞缁胯壊瀵屾枃鏈爣娉�
-    const textPromises = res.data.map(async (item) => {
+    const textPromises = allSafePoints.map(async (item) => {
       const point = earthCtrl.factory.createRichTextPoint(
         "閬块櫓鍦烘墍",
-        [item.lon , item.lat , 540],
+        [item.lon, item.lat, 540],
         {
           distanceDisplayCondition:
             new SmartEarth.Cesium.DistanceDisplayCondition(0, 2000),
-          fontColor: "#fff", 
+          fontColor: "#fff",
           fontSize: 20,
         },
         "0"
@@ -179,6 +206,7 @@
     console.error("鍔犺浇閬块櫓鍦烘墍澶辫触锛�", error);
   }
 }
+
 // 鍒犻櫎閬块櫓鍦烘墍鐨勫瘜鏂囨湰瀹炰綋
 function removeEmergencyPoints() {
   const emergencyAreaList = treeMap.get("閬块櫓鍦烘墍"); // 鑾峰彇瀛樺偍鐨勯伩闄╁満鎵�瀹炰綋鍒楄〃

--
Gitblit v1.9.3