From f373e0c0797e1800bf066fdfbb748bb9242230f6 Mon Sep 17 00:00:00 2001 From: wangjuncheng <1> Date: 星期二, 08 七月 2025 17:46:02 +0800 Subject: [PATCH] 泥位计 --- src/components/monifangzhen/WaterDepthContent.vue | 10 +++- src/components/monifangzhen/WaterVelocityContent.vue | 9 +++- src/components/menu/flowRate_waterLevel.vue | 48 ++++++++++++++++++++---- 3 files changed, 54 insertions(+), 13 deletions(-) diff --git a/src/components/menu/flowRate_waterLevel.vue b/src/components/menu/flowRate_waterLevel.vue index 89996ff..e980b38 100644 --- a/src/components/menu/flowRate_waterLevel.vue +++ b/src/components/menu/flowRate_waterLevel.vue @@ -53,7 +53,7 @@ import { useSimStore } from "@/store/simulation"; import { storeToRefs } from "pinia"; const simStore = useSimStore(); -const { selectedScheme, currentInfo } = storeToRefs(simStore); +const { selectedScheme, currentInfo, selectNWJ } = storeToRefs(simStore); // 鏂板鐩戝惉 selectNWJ import { EventBus } from "@/eventBus"; const pickedPoints = ref([]); @@ -61,7 +61,7 @@ const isPickingActive = ref(false); const currentTime = ref(0); let serviceInfo = ref(null); - +const isCurrentInfoFromSelectNWJ = ref(false); const props = defineProps({ playingTime: { type: String, @@ -70,6 +70,7 @@ }); const viewer = window.viewer; +serviceInfo = selectedScheme.value.serviceName; function getPickPosition(windowPosition) { if (!viewer) return null; @@ -85,10 +86,9 @@ height: cartographic.height }; } + function addPointToViewer(point, index) { const displayTime = currentTime.value || "鏈缃椂闂�"; - const schemeInfo = selectedScheme.value; - serviceInfo = schemeInfo.serviceName; // 濡傛灉宸叉湁閫変腑鐐癸紝鍒欏厛娓呴櫎 if (pickedPoints.value.length >= 1) { @@ -139,7 +139,8 @@ currentInfo.value = { longitude: point.longitude, latitude: point.latitude, - serviceInfo: serviceInfo + serviceInfo: serviceInfo, + deviceName: null }; // 璇锋眰鏁版嵁骞舵洿鏂� label getFlowRateInfo(point.longitude, point.latitude, displayTime).then(result => { @@ -169,7 +170,6 @@ if (position) { const index = pickedPoints.value.length; addPointToViewer(position, index); - } }, Cesium.ScreenSpaceEventType.LEFT_CLICK); } @@ -181,6 +181,7 @@ isPickingActive.value = true; ElMessage.success(`寮�濮�--娴侀噺娴侀��--鎷惧彇鍧愭爣鍔熻兘锛岃鐐瑰嚮鍦板浘閫夋嫨鐐逛綅锛侀�夊彇瀹岃鍙婃椂鍏抽棴锛岄伩鍏嶅奖鍝嶅叾浠栧姛鑳斤紒`); } + function stopPicking() { if (handler.value) { handler.value.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK); @@ -189,6 +190,7 @@ } isPickingActive.value = false; } + function togglePick() { if (isPickingActive.value) { stopPicking(); @@ -199,6 +201,7 @@ isPickingActive.value = true; } } + watch( () => props.playingTime, async (newVal, oldVal) => { @@ -229,6 +232,7 @@ `.trim(); } } + function endCalculation() { pickedPoints.value.forEach(pointInfo => { if (pointInfo.labelEntity) viewer.entities.remove(pointInfo.labelEntity); @@ -237,13 +241,13 @@ pickedPoints.value = []; EventBus.emit("clear-water-depth"); EventBus.emit("clear-water-velocity"); - } defineExpose({ endCalculation, stopPicking }); + function getFlowRateInfo(lon, lat, time) { const params = { lon: lon, @@ -252,7 +256,6 @@ serviceName: serviceInfo }; return getFlowRate(params).then(data => { - // console.log('鑾峰彇鍒扮殑鏁版嵁:', data); if (data && data.code === 200) { return { depth: data.data.depth.toFixed(2), @@ -266,5 +269,34 @@ return { depth: 'N/A', velocity: 'N/A' }; }); } + +// 馃憞 鐩戝惉 simStore.selectNWJ锛屽綋鍏舵湁鍊兼椂鎵ц娓呴櫎鎿嶄綔 +watch(() => selectNWJ.value, (newVal) => { + if (newVal != null && newVal !== '') { + // 馃憞 鏈夊�兼椂鑷姩鍋滄鎷惧彇骞舵竻闄ゅ疄浣� + if (isPickingActive.value) stopPicking(); + if (pickedPoints.value.length > 0) endCalculation(); + console.log(newVal,'asdasdasdads'); + const { longitude, latitude ,deviceName} = newVal; + currentInfo.value = { + longitude, + latitude, + serviceInfo: serviceInfo, + deviceName + }; + console.log(currentInfo.value, '杩欓噷杩涜鏁版嵁鐨勬墦鍗�'); + + isCurrentInfoFromSelectNWJ.value = true; + + // 馃憞 鍙�夛細璋冪敤涓�娆″垎鏋愬嚱鏁版潵鍔犺浇鏁版嵁锛堟牴鎹綘鐨勪笟鍔¢渶瑕佸喅瀹氭槸鍚﹀惎鐢級 + // getFlowRateInfo(longitude, latitude, currentTime.value).then(...) + + } else { + // 馃憞 濡傛灉 selectNWJ 琚竻绌猴紝鎭㈠鎵嬪姩閫夋嫨鑳藉姏 + isCurrentInfoFromSelectNWJ.value = false; + } +}, + { immediate: true }); + </script> <style lang="less" scoped></style> \ No newline at end of file diff --git a/src/components/monifangzhen/WaterDepthContent.vue b/src/components/monifangzhen/WaterDepthContent.vue index c7cfe2f..1f6ea95 100644 --- a/src/components/monifangzhen/WaterDepthContent.vue +++ b/src/components/monifangzhen/WaterDepthContent.vue @@ -7,7 +7,10 @@ <div v-else> <div class="location-info"> <h3>浣嶇疆淇℃伅</h3> - <p class="coordinates"> + <p v-if="deviceName" class="coordinates"> + {{ deviceName }} + </p> + <p v-if="!deviceName" class="coordinates"> 缁忓害锛� <strong>{{ safeCurrentInfo.longitude.toFixed(3) }} </strong> 绾害锛�<strong>{{ safeCurrentInfo.latitude.toFixed(3) }}</strong> </p> @@ -38,7 +41,9 @@ const simStore = useSimStore(); const { currentInfo } = storeToRefs(simStore); - +const deviceName = computed(() => { + return currentInfo.value?.deviceName; +}); // 鍥捐〃 DOM 寮曠敤 const chartDom = ref(null); let myChart = null; @@ -96,7 +101,6 @@ async function fetchDataAndUpdateChart(chart) { const info = currentInfo.value; if (!info || showSelectPrompt.value || !chartDom.value) return; - const { longitude, latitude, serviceInfo } = info; const result = await getFlowRateInfo(longitude, latitude, serviceInfo); diff --git a/src/components/monifangzhen/WaterVelocityContent.vue b/src/components/monifangzhen/WaterVelocityContent.vue index 49f030a..2801bea 100644 --- a/src/components/monifangzhen/WaterVelocityContent.vue +++ b/src/components/monifangzhen/WaterVelocityContent.vue @@ -7,7 +7,10 @@ <div v-else> <div class="location-info"> <h3>浣嶇疆淇℃伅</h3> - <p class="coordinates"> + <p v-if="deviceName" class="coordinates"> + {{ deviceName }} + </p> + <p v-if="!deviceName" class="coordinates"> 缁忓害锛� <strong>{{ safeCurrentInfo.longitude.toFixed(3) }} </strong> 绾害锛�<strong>{{ safeCurrentInfo.latitude.toFixed(3) }}</strong> </p> @@ -38,7 +41,9 @@ const simStore = useSimStore(); const { currentInfo } = storeToRefs(simStore); - +const deviceName = computed(() => { + return currentInfo.value?.deviceName; +}); // 鍥捐〃 DOM 寮曠敤 const chartDom = ref(null); let myChart = null; -- Gitblit v1.9.3