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/views/mnfz.vue | 136 ++++++++++++++++++++++++++------------------- 1 files changed, 79 insertions(+), 57 deletions(-) diff --git a/src/views/mnfz.vue b/src/views/mnfz.vue index 141a4de..6a243ed 100644 --- a/src/views/mnfz.vue +++ b/src/views/mnfz.vue @@ -34,7 +34,11 @@ import DebuffTable from "@/components/tools/DebuffTable.vue"; import { getMaxInfluenceArea } from "@/api/index"; import { createPoint, geomToGeoJSON } from "@/utils/map.js"; -import { loadAreaPolygon, clearAreaPolygon } from "@/utils/area"; +import { + loadAreaPolygon, + clearAreaPolygon, + convertToGeoJson, +} from "@/utils/area"; import colors from "@/assets/img/left/colors3.png"; @@ -43,6 +47,7 @@ import { useSimStore } from "@/store/simulation"; import { storeToRefs } from "pinia"; +import { getSafePoint } from "@/api/hpApi"; const simStore = useSimStore(); const { rightRiverShow } = storeToRefs(simStore); @@ -63,7 +68,6 @@ }); function startSimulate(form) { - // console.log("form", form); showWaterSimulate.value = true; rightRiverShow.value = true; waterSimulateParams.value = form; @@ -74,8 +78,8 @@ clearTrailLine(); removeEmergencyPoints(); removeDataSources(); + showWaterSimulate.value = false; setTimeout(() => { - showWaterSimulate.value = false; isDynamicMode.value = false; // 娓呴櫎濞佽儊瀵硅薄琛ㄦ牸鍐呭 EventBus.emit("reset-table"); @@ -138,53 +142,71 @@ }); dataSources.length = 0; } -// 閬块櫓鍦烘墍锛岀豢鑹插瘜鏂囨湰 -function addTetrahedron(visible) { - const emergencyAreaList = []; - // 杩欓噷鏄坊鍔犻伩闄╁満鎵�搴曞眰闈㈢墖 - loadAreaPolygon("/json/emergency_area.geojson", true).then((entities) => { - emergencyAreaList.push(...entities); - }); - // console.log('polygon', polygon); - let list = [ - { - name: "灏瑰缓鍗庡", - longitude: 116.593517, - latitude: 40.568391, - altitude: 528.45, - }, - // { - // name: "鑼冩尟姹熷", - // longitude: 116.591059, - // latitude: 40.574068, - // altitude: 528, - // }, - // { - // name: "鍚庡潯", - // longitude: 116.597975, - // latitude: 40.558199, - // altitude: 528, - // }, - ]; - // 杩欓噷鏄坊鍔犻伩闄╁満鎵�瀵屾枃鏈珮浜樉绀� - list.forEach((item) => { - let point = earthCtrl.factory.createRichTextPoint( - "閬块櫓鍦烘墍", - [item.longitude, item.latitude, item.altitude - 10], - { - distanceDisplayCondition: - new SmartEarth.Cesium.DistanceDisplayCondition(0, 2000), - fontColor: "#ffffff", - fontSize: 20, - }, - "0" +// 閬块櫓鍦烘墍锛岀豢鑹插瘜鏂囨湰 +async function addTetrahedron(visible) { + const emergencyAreaList = []; + + try { + let codesToFetch = []; + + // 鍒ゆ柇褰撳墠閫夋嫨鍖哄煙鏄惁涓衡�滃尯鈥� + 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)) ); - console.log("point", point); - emergencyAreaList.push(point); - }); - treeMap.set("閬块櫓鍦烘墍", emergencyAreaList); + + // 鍚堝苟缁撴灉锛堝亣璁炬瘡涓� 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 = allSafePoints.map(async (item) => { + const point = earthCtrl.factory.createRichTextPoint( + "閬块櫓鍦烘墍", + [item.lon, item.lat, 540], + { + distanceDisplayCondition: + new SmartEarth.Cesium.DistanceDisplayCondition(0, 2000), + fontColor: "#fff", + fontSize: 20, + }, + "0" + ); + emergencyAreaList.push(point); + }); + + await Promise.all(textPromises); + + // 灏嗙粨鏋滀繚瀛樺埌 treeMap + treeMap.set("閬块櫓鍦烘墍", emergencyAreaList); + } catch (error) { + console.error("鍔犺浇閬块櫓鍦烘墍澶辫触锛�", error); + } } + // 鍒犻櫎閬块櫓鍦烘墍鐨勫瘜鏂囨湰瀹炰綋 function removeEmergencyPoints() { const emergencyAreaList = treeMap.get("閬块櫓鍦烘墍"); // 鑾峰彇瀛樺偍鐨勯伩闄╁満鎵�瀹炰綋鍒楄〃 @@ -299,7 +321,7 @@ url: "/json/line.json", color: "#00FF00", width: 12.0, - pointColor: "#73FFA7", + pointColor: "#FFFF73", speed: 2, far: 50000, }); @@ -542,9 +564,9 @@ function playbackFinished(val) { isFinish.value = val; } -function isColorRender(val){ - console.log('杩欓噷鎵撳嵃鏄惁鏄剧ず姘翠綅鍥句緥鐨勫�硷細',val); - isShowLegend.value = val +function isColorRender(val) { + // console.log('杩欓噷鎵撳嵃鏄惁鏄剧ず姘翠綅鍥句緥鐨勫�硷細',val); + isShowLegend.value = val; } // 瀹氫箟鍏ㄥ眬鍙橀噺瀛樺偍褰撳墠姝e湪闂姩鐨勯潰鐗� let flashingPolygon = null; @@ -654,11 +676,11 @@ <style lang="less" scoped> @import url("../assets/css/home.css"); .legend { - // background: url("@/assets/img/right/rightbg.png"); - color: white; - position: fixed; - bottom: 6%; - right: 20%; - z-index: 3333; + // background: url("@/assets/img/right/rightbg.png"); + color: white; + position: fixed; + bottom: 6%; + right: 20%; + z-index: 3333; } </style> -- Gitblit v1.9.3