From a9c4f7775e82d93638e607fa6c5fafe22f5310b4 Mon Sep 17 00:00:00 2001
From: guonan <guonan201020@163.com>
Date: 星期五, 16 五月 2025 15:06:27 +0800
Subject: [PATCH] 完善接口部分

---
 src/components/tools/LayerTree.vue |   92 ++++++++++++++++++++++++---------------------
 1 files changed, 49 insertions(+), 43 deletions(-)

diff --git a/src/components/tools/LayerTree.vue b/src/components/tools/LayerTree.vue
index 214ca3e..7a44b05 100644
--- a/src/components/tools/LayerTree.vue
+++ b/src/components/tools/LayerTree.vue
@@ -13,18 +13,26 @@
 </template>
 
 <script setup>
-import { ref, onMounted, watch, nextTick, onUnmounted } from "vue";
+import {
+  ref,
+  onMounted,
+  watch,
+  nextTick,
+  onUnmounted,
+  computed,
+  watchEffect,
+} from "vue";
 import { createPoint, removeEntities, addTileset } from "@/utils/map";
 import { deviceDictList, getDictName } from "@/constant/dict.js";
 import { useRoute } from "vue-router";
 import { loadAreaPolygon, clearAreaPolygon } from "@/utils/area";
 import { checkedKeys } from "@/store/index";
-import {
-  getDuanMainData,
-  getDevicetListData,
-  getDistrictListData,
-} from "@/api/index.js";
-import { init } from "echarts";
+import { getDuanMainData, getDistrictListData } from "@/api/index.js";
+import { getDeviceInfo, getDangerPoint } from "@/api/hpApi";
+
+import { useSimStore } from "@/store/simulation";
+
+const simStore = useSimStore();
 
 const route = useRoute();
 
@@ -34,7 +42,7 @@
     label: "涓夌淮鏈嶅姟",
     children: [
       { label: "妯″瀷鏁版嵁" },
-      { label: "鍦板舰鏁版嵁" }, 
+      { label: "鍦板舰鏁版嵁" },
       { label: "褰卞儚鏁版嵁" },
     ],
   },
@@ -85,7 +93,6 @@
 //   // });
 //   // treeMap.set("褰卞儚鏁版嵁", ImageryLayer);
 // }
-
 
 // 鍦板舰鏁版嵁
 let TerrainLayer = null;
@@ -216,16 +223,15 @@
   }
 }
 
-// 璁惧鍒楄〃
+// 鐩戞祴璁惧鍒楄〃
 const devicetList = ref([]);
 
-/**
- * 鑾峰彇璁惧鍒楄〃骞跺垵濮嬪寲璁惧鐐�
- */
+// 鐩戞祴璁惧鍒楄〃
 const getDevicetList = async () => {
-  await getDevicetListData().then((res) => {
-    devicetList.value = res.data;
-  });
+  const res = await getDeviceInfo(); // 璋冩暣getDeviceInfo浠ユ帴鍙楀姩鎬佸弬鏁帮紝濡傛灉闇�瑕佺殑璇�
+  devicetList.value = res.data.pageData.filter((item) =>
+    item.deviceName?.includes("瀛欒儭娌�")
+  );
 };
 
 async function initDevicePoint() {
@@ -233,7 +239,7 @@
   await getDevicetList();
   devicetList.value.forEach((item) => {
     item.type = getDictName(deviceDictList, item.dictDeviceType);
-    item.name = item.type;
+    item.name = item.deviceName.split("瀛欒儭娌�")[1];
     item.id = item.deviceId;
     item.className = "device";
     item.showLabel = true;
@@ -245,34 +251,34 @@
   treeMap.set("缁煎悎鐩戞祴璁惧淇℃伅", list);
 }
 
-// 鍖哄煙鍒楄〃
-const districtList = ref([]);
+// 闅愭偅鐐瑰垪琛�
+watchEffect(() => {
+  const dangerPoints = simStore.DangerPoint.filter((item) =>
+    item.position?.includes("瀛欒儭娌�")
+  );
 
-/**
- * 鑾峰彇鍖哄煙鍒楄〃骞跺垵濮嬪寲鍖哄煙鐐�
- */
-const getDistrictList = async () => {
-  await getDistrictListData().then((res) => {
-    districtList.value = res.data;
-  });
-};
+  if (dangerPoints && dangerPoints.length > 0) {
+    const list = [];
 
-async function initDistrictPoint() {
-  let list = [];
-  await getDistrictList();
-  districtList.value.forEach((item) => {
-    item.showBillboard = true;
-    item.className = "district";
-    // item.type = "娉ョ煶娴�";        //鏁版嵁icon璁剧疆
-    const entity = createPoint(item);
-    entity.show = false;
-    list.push(entity);
-  });
-  treeMap.set("瀛欒儭娌熼殣鎮g偣", list);
-}
+    dangerPoints.forEach((item) => {
+      // console.log(item, "item");
+      item.id = item.hdId;
+      item.name = item.hdName;
+      item.latitude = item.lat;
+      item.longitude = item.lon;
+      item.showBillboard = true;
+      item.type = item.disasterType;
+      item.className = "district";
+      const entity = createPoint(item);
+      entity.show = false;
+      list.push(entity);
+    });
+
+    treeMap.set("瀛欒儭娌熼殣鎮g偣", list);
+  }
+});
 
 let divPointList = [];
-
 /**
  * 鍒濆鍖栨柇闈㈢偣
  */
@@ -320,7 +326,7 @@
  */
 function getData() {
   initDevicePoint();
-  initDistrictPoint();
+  // initDistrictPoint();
   initDuanmianPoint();
   addTetrahedron();
 }
@@ -393,6 +399,6 @@
   overflow: hidden;
 }
 /deep/ .el-tree {
-    overflow: hidden !important;
+  overflow: hidden !important;
 }
 </style>

--
Gitblit v1.9.3