From 4b7b8185bdce4272cd5f256fcc777056f54add6d Mon Sep 17 00:00:00 2001
From: wangjuncheng <1>
Date: 星期一, 16 六月 2025 17:03:09 +0800
Subject: [PATCH] 123

---
 src/components/menu/flowRate_waterLevel.vue |   40 ++++++++++++++++++++++++++++------------
 1 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/src/components/menu/flowRate_waterLevel.vue b/src/components/menu/flowRate_waterLevel.vue
index 21082db..dbb557f 100644
--- a/src/components/menu/flowRate_waterLevel.vue
+++ b/src/components/menu/flowRate_waterLevel.vue
@@ -53,7 +53,8 @@
 import { useSimStore } from "@/store/simulation";
 import { storeToRefs } from "pinia";
 const simStore = useSimStore();
-const { selectedScheme } = storeToRefs(simStore);
+const { selectedScheme, currentInfo } = storeToRefs(simStore);
+import { EventBus } from "@/eventBus";
 
 const pickedPoints = ref([]);
 const handler = ref(null);
@@ -89,11 +90,16 @@
 	const schemeInfo = selectedScheme.value;
 	serviceInfo = schemeInfo.serviceName;
 
+	// 濡傛灉宸叉湁閫変腑鐐癸紝鍒欏厛娓呴櫎
+	if (pickedPoints.value.length >= 1) {
+		endCalculation(); // 娓呴櫎鎵�鏈夊凡鏈夌偣
+	}
+
 	// 鍒涘缓 label 瀹炰綋
 	const labelEntity = viewer.entities.add({
 		position: point.cartesian,
 		label: {
-			text: `娴嬮噺鐐� ${pickedPoints.value.length + 1}\n姘存繁: 绛夊緟鍚姩...\n娴侀��: 绛夊緟鍚姩...`,
+			text: `娴嬮噺鐐筡n姘存繁: 绛夊緟鍚姩...\n娴侀��: 绛夊緟鍚姩...`,
 			font: 'bold 14pt monospace',
 			style: Cesium.LabelStyle.FILL_AND_OUTLINE,
 			fillColor: Cesium.Color.YELLOW,
@@ -109,6 +115,7 @@
 			pixelOffsetScaleByDistance: new Cesium.NearFarScalar(100, 1.0, 5000, 0.3),
 		}
 	});
+
 	const groundPosition = Cesium.Cartesian3.fromRadians(
 		point.longitude * Math.PI / 180,
 		point.latitude * Math.PI / 180,
@@ -128,16 +135,21 @@
 			distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 5000)
 		}
 	});
-
+	// 瀛樺偍瀹炰綋寮曠敤涔嬪墠灏辨洿鏂� currentInfo
+	currentInfo.value = {
+		longitude: point.longitude,
+		latitude: point.latitude,
+		serviceInfo: serviceInfo
+	};
 	// 璇锋眰鏁版嵁骞舵洿鏂� label
 	getFlowRateInfo(point.longitude, point.latitude, displayTime).then(result => {
-		updateLabel(pickedPoints.value.length - 1, result.depth, result.velocity);
+		updateLabel(pickedPoints.value.length, result.depth, result.velocity);
 	});
 
 	// 瀛樺偍瀹炰綋寮曠敤
 	pickedPoints.value.push({
 		labelEntity,
-		cylinderEntity, // 浣跨敤鍦嗘煴浠f浛 line 鍜� circle
+		cylinderEntity,
 		longitude: point.longitude,
 		latitude: point.latitude
 	});
@@ -199,18 +211,19 @@
 );
 
 async function updateAllLabels() {
-	for (const pointInfo of pickedPoints.value) {
+	for (let i = 0; i < pickedPoints.value.length; i++) {
+		const pointInfo = pickedPoints.value[i];
 		if (!pointInfo || !pointInfo.labelEntity) continue;
-
 		const result = await getFlowRateInfo(pointInfo.longitude, pointInfo.latitude, currentTime.value);
-		updateLabel(pointInfo, result.depth, result.velocity);
+		updateLabel(i, result.depth, result.velocity);
 	}
 }
 
-function updateLabel(pointInfo, depth, velocity) {
-	if (pointInfo.labelEntity && pointInfo.labelEntity.label) {
+function updateLabel(index, depth, velocity) {
+	const pointInfo = pickedPoints.value[index];
+	if (pointInfo && pointInfo.labelEntity && pointInfo.labelEntity.label) {
 		pointInfo.labelEntity.label.text = `
-娴嬮噺鐐� ${pickedPoints.value.findIndex(p => p === pointInfo) + 1}
+娴嬮噺鐐�
 姘存繁: ${depth} m
 娴侀��: ${velocity} m/s
 `.trim();
@@ -222,6 +235,9 @@
 		if (pointInfo.cylinderEntity) viewer.entities.remove(pointInfo.cylinderEntity);
 	});
 	pickedPoints.value = [];
+	EventBus.emit("clear-water-depth");
+	EventBus.emit("clear-water-velocity");
+
 }
 
 defineExpose({
@@ -236,7 +252,7 @@
 		serviceName: serviceInfo
 	};
 	return getFlowRate(params).then(data => {
-		// console.log('鑾峰彇鍒扮殑鏁版嵁:', data);
+		console.log('鑾峰彇鍒扮殑鏁版嵁:', data);
 		if (data && data.code === 200) {
 			return {
 				depth: data.data.depth.toFixed(2),

--
Gitblit v1.9.3