From 1119a7837323e052d3e6256cddd3283d919bd959 Mon Sep 17 00:00:00 2001 From: guonan <guonan201020@163.com> Date: 星期四, 26 六月 2025 15:44:02 +0800 Subject: [PATCH] 提交 --- src/views/Home.vue | 32 +++++++++++++++++++++++++++++++- 1 files changed, 31 insertions(+), 1 deletions(-) diff --git a/src/views/Home.vue b/src/views/Home.vue index 0c1b6e9..efd0a70 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -58,7 +58,7 @@ // import ResultAssess from "@/components/monifangzhen/ResultAssess.vue"; // import DangerAssess from "@/components/monifangzhen/DangerAssess.vue"; import { showDeviceDetail } from "@/store"; -import { setupTokenRefresh, getDangerPoint } from "@/api/hpApi.js"; +import { setupTokenRefresh, getDangerPoint, getAllCode } from "@/api/hpApi.js"; import { convertToWKT } from "@/utils/wktUtils"; import { getDeviceInfoSHG, getSafePoint } from "@/api/hpApi"; @@ -100,7 +100,37 @@ // 璁$畻灞炴�� const showDetail = computed(() => showDeviceDetail.value); +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); + console.log(simStore.townCodeAll,'aaaaaaaaa') + }); setupTokenRefresh(); // 鑾峰彇瀹忓浘token // getSimData(); //娴嬭瘯tr鍚庣 // 鑾峰彇闅愭偅鐐瑰垪琛紙鍥犱负涓杞悗绔帴鍙h幏鍙栧姞杞芥椂闂磋緝闀匡級 -- Gitblit v1.9.3