From 687d15815ed738173c5a82495f0056fb2c9d7f25 Mon Sep 17 00:00:00 2001
From: guonan <guonan201020@163.com>
Date: 星期二, 08 七月 2025 15:56:20 +0800
Subject: [PATCH] 优化

---
 src/views/Home.vue |   94 ++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 72 insertions(+), 22 deletions(-)

diff --git a/src/views/Home.vue b/src/views/Home.vue
index 95b8455..243e35a 100644
--- a/src/views/Home.vue
+++ b/src/views/Home.vue
@@ -8,10 +8,14 @@
   <!-- <Left v-if="leftShow" />
 		<Right v-if="rightShow" /> -->
 
-  <Tools :style="rightRiverShow || showDangerAssess
-    ? { right: '400px' }
-    : { right: '12px' }
-    " class="tools" />
+  <Tools
+    :style="
+      rightRiverShow || showDangerAssess
+        ? { right: '400px' }
+        : { right: '12px' }
+    "
+    class="tools"
+  />
   <!-- <Message v-if="messageShow" class="messageTool" /> -->
   <Announcement v-show="$route.fullPath != '/'" class="announcementTool" />
   <!-- <Location v-if="locationShow" class="locationTool" /> -->
@@ -22,7 +26,6 @@
   <ImagePreview v-if="showPreview" />
   <!-- <Weather v-if="weatherShow" @close="weatherShow = false" /> -->
   <Bar v-if="barShow" @close="barShow = false" />
-
   <Detail v-if="showDetail" />
 </template>
 
@@ -52,17 +55,20 @@
 import GisView from "./GisView.vue";
 // import Device from "@/components/menu/Device.vue";
 import Detail from "@/components/tools/Detail.vue";
-// 涓嶅彲浠ュ垹闄わ紝鍚﹀垯鍏ㄥ眬鏍峰紡浼氫涪鎺夛紝涓嶇煡閬撳師鍥�
-import ResultAssess from "@/components/monifangzhen/ResultAssess.vue";
+// import ResultAssess from "@/components/monifangzhen/ResultAssess.vue";
 // import DangerAssess from "@/components/monifangzhen/DangerAssess.vue";
 import { showDeviceDetail } from "@/store";
-import { setupTokenRefresh } from "@/api/hpApi.js"
-import { getData } from "@/api/trApi.js"
-import { convertToWKT } from '@/utils/wktUtils';
+import { setupTokenRefresh, getDangerPoint, getAllCode } from "@/api/hpApi.js";
+import { convertToWKT } from "@/utils/wktUtils";
+import { getDeviceInfoSHG, getSafePoint } from "@/api/hpApi";
 
 const route = useRoute();
 const simStore = useSimStore();
 
+// 鎺ユ敹鏉ヨ嚜 ComponentA 鐨勪簨浠讹紝骞舵洿鏂� isFlying
+function handleBackToHome() {
+  backHome.value = false;
+}
 // 浠� store 涓В鏋勯渶瑕佺殑鐘舵��
 const {
   flowShow,
@@ -76,26 +82,70 @@
 } = storeToRefs(simStore);
 const { init, startYHGL, startZHJC, startMNFZ, startMNPG } = simStore;
 // 妯℃嫙鐨勭粡绾害鏁扮粍
-const coordinates = [
-  [120.123456, 30.654321],
-  [120.234567, 30.765432],
-  [120.345678, 30.876543],
-  [120.123456, 30.654321]
+const multiPolygonCoordinates = [
+  [
+    [120.123456, 30.654321],
+    [120.234567, 30.765432],
+    [120.345678, 30.876543],
+    [120.123456, 30.654321], // 闂悎鐐�
+  ],
+  [
+    [121.111111, 31.222222],
+    [121.333333, 31.444444],
+    [121.555555, 31.666666],
+    [121.111111, 31.222222], // 闂悎鐐�
+  ],
 ];
-
 
 // 璁$畻灞炴��
 const showDetail = computed(() => showDeviceDetail.value);
-onMounted(() => {
-  setupTokenRefresh()// 鑾峰彇瀹忓浘token
-  getData() //娴嬭瘯tr鍚庣
+
+function extractAllChildrenInfoUnique(dataArray) {
+  const map = new Map();
+
+  function traverse(nodes) {
+    if (!Array.isArray(nodes)) return;
+
+    for (const node of nodes) {
+      const key = node.code;
+
+      // 妫�鏌ユ槸鍚︽槸鏈�鍚庝竴灞傦紙娌℃湁瀛愯妭鐐规垨瀛愯妭鐐逛负绌烘暟缁勶級
+      if (!node.children || node.children.length === 0) {
+        if (key && !map.has(key)) {
+          map.set(key, { name: node.nameChn, code: key });
+        }
+      } else {
+        // 濡傛灉鏈夊瓙鑺傜偣锛岀户缁�掑綊閬嶅巻
+        traverse(node.children);
+      }
+    }
+  }
+
+  traverse(dataArray);
+  return Array.from(map.values());
+}
+
+onMounted(async () => {
+  getAllCode().then((res) => {
+    // 鍖椾含甯傛墍鏈夋潙浠ュ強琛楅亾code
+    simStore.townCodeAll = extractAllChildrenInfoUnique(res.data[0].children);
+  });
+  setupTokenRefresh(); // 鑾峰彇瀹忓浘token
+  // getSimData(); //娴嬭瘯tr鍚庣
+  // 鑾峰彇闅愭偅鐐瑰垪琛紙鍥犱负涓杞悗绔帴鍙h幏鍙栧姞杞芥椂闂磋緝闀匡級
+  getDangerPoint("110116110000").then((res) => {
+    simStore.DangerPoint = res.data.pageData;
+  });
+
+  getDeviceInfoSHG(null).then((res) => {
+    simStore.devices = res.data.pageData;
+  });
   try {
-    const wktResult = convertToWKT(coordinates);
-    console.log(wktResult);
+    const wktResult = convertToWKT(multiPolygonCoordinates);
+    // console.log(wktResult,'a');
     // 杈撳嚭: MULTIPOLYGON(((120.123456 30.654321,120.234567 30.765432,120.345678 30.876543,120.123456 30.654321)))
   } catch (error) {
     console.error(error.message);
-
   }
 });
 // 鍒濆鍖�

--
Gitblit v1.9.3