From f0a0f01ca70e852caf0300fd47d1840799c4d65d Mon Sep 17 00:00:00 2001 From: guonan <guonan201020@163.com> Date: 星期二, 10 六月 2025 11:08:34 +0800 Subject: [PATCH] 撒点 --- src/views/GisView.vue | 50 ++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/views/GisView.vue b/src/views/GisView.vue index 4d59796..bbb0786 100644 --- a/src/views/GisView.vue +++ b/src/views/GisView.vue @@ -47,7 +47,12 @@ import { useSimStore } from "@/store/simulation"; const simStore = useSimStore(); -import { getDangerPoint, getDeviceInfo } from "@/api/hpApi"; +import { + getDangerPoint, + getDeviceInfo, + getAeraCode, + getAeraTownCode, +} from "@/api/hpApi"; /////////////////////////鍦板浘褰卞儚閫夋嫨///////////////////////// const views = [ { label: "鍦板浘", value: "map", icon: "鍦板浘.png" }, @@ -419,22 +424,39 @@ }; // 鍒濆鍖栧尯鍩熺粺璁� -function initDistrictCount(level = "secondary") { - const getPoint = - level === "secondary" ? getDistrictCount : getDistrictCountByCity; - const config = LEVEL_CONFIG[level]; - - getPoint() - .then((res) => { +async function initDistrictCount(level = "secondary") { + try { + if (level === "primary") { + // 涓�绾у尯鍩燂細鐩存帴璋冪敤 getAeraCode() + const res = await getAeraCode(); res.data.forEach((item) => { - processDistrictItem(item, config, level); // 娣诲姞level鍙傛暟 + processDistrictItem(item, LEVEL_CONFIG[level], level); }); - }) - .catch((error) => { - console.error(`鍒濆鍖�${level}绾у尯鍩熺粺璁″け璐�:`, error); - }); -} + } else if (level === "secondary") { + // 浜岀骇鍖哄煙锛氬厛鑾峰彇涓�绾у尯鍩燂紝鍐嶉亶鍘嗘瘡涓竴绾у尯鍩熺殑 code 鏌ヨ浜岀骇鍖哄煙 + const primaryRes = await getAeraCode(); + // 閬嶅巻鎵�鏈変竴绾у尯鍩熺殑 districtCode锛屽苟鍙戣姹備簩绾у尯鍩熸暟鎹� + const townPromises = primaryRes.data.map((item) => + getAeraTownCode(item.districtCode) + ); + + // 绛夊緟鎵�鏈変簩绾у尯鍩熻姹傚畬鎴� + const townResults = await Promise.all(townPromises); + + // 澶勭悊鎵�鏈変簩绾у尯鍩熸暟鎹� + townResults.forEach((townRes) => { + townRes.data.forEach((townItem) => { + processDistrictItem(townItem, LEVEL_CONFIG[level], level); + }); + }); + } else { + console.error("鏈煡鐨� level 绫诲瀷:", level); + } + } catch (error) { + console.error(`鍒濆鍖� ${level} 绾у尯鍩熺粺璁″け璐�:`, error); + } +} // 澶勭悊鍗曚釜鍖哄煙椤� function processDistrictItem(item, config, level = "secondary") { // 娣诲姞榛樿鍊� -- Gitblit v1.9.3