From f373e0c0797e1800bf066fdfbb748bb9242230f6 Mon Sep 17 00:00:00 2001 From: wangjuncheng <1> Date: 星期二, 08 七月 2025 17:46:02 +0800 Subject: [PATCH] 泥位计 --- public/json/rainfall.js | 98 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 98 insertions(+), 0 deletions(-) diff --git a/public/json/rainfall.js b/public/json/rainfall.js new file mode 100644 index 0000000..2c9d523 --- /dev/null +++ b/public/json/rainfall.js @@ -0,0 +1,98 @@ +const jsonFetch = ref(null); +const currentReplayIndex = ref(0); +const isReplaySequencePlaying = ref(false); // 鏂板锛氭爣璁版槸鍚︽鍦ㄩ『搴忔挱鏀� + +async function initializeSimulationData(force = false, replayItem = null) { + try { + const schemeInfo = selectedScheme.value; + serviceInfo = schemeInfo.serviceName; + + if (schemeInfo.type == 2) { + if (replayItem || (simStore.rePlayList && simStore.rePlayList.length != 0)) { + jsonFetch.value = replayItem || simStore.rePlayList[currentReplayIndex.value]; + speedShow.value = true; + } else { + jsonFetch.value = layerDate.value; + speedShow.value = false; + } + } else { + getRainfallData(); + speedShow.value = true; + jsonFetch.value = null; + } + + const { + waterTimestamps: timestamps, + watersMaxHeight, + watersMinHeight, + } = await fetchWaterSimulationData(serviceInfo, jsonFetch.value); + + if (timestamps) { + frameNum.value = timestamps.length; + waterTimestamps.value = timestamps; + updateTimelineRange(); + timeMarkers.value = generateTimeMarkers(timestamps); + sendCurrentPlayingTime.value = timestamps[0]; + currentPlayingTime.value = dayjs(timestamps[0]).format( + "YYYY-MM-DD HH:mm:ss" + ); + } + minFlowRate = watersMinHeight; + maxFlowRate = watersMaxHeight; + + // 濡傛灉鏄洖鏀炬ā寮忎笖涓嶆槸寮哄埗鍒锋柊锛屽垯寮�濮嬫挱鏀� + if (schemeInfo.type == 2 && !force && isReplaySequencePlaying.value) { + togglePlay(); + } + } catch (error) { + console.error("Error loading water simulation data:", error); + ElMessage({ + message: "闄嶉洦鏁版嵁鍑洪敊锛岃閲嶆柊鏂板缓妯℃嫙鏂规锛�", + type: "warning", + }); + } +} + +function handlePlayFinished() { + if (selectedScheme.value.type !== 2 || !isReplaySequencePlaying.value) return; + + // 纭繚鎾斁鐘舵�佸凡鍋滄 + isPlaying.value = false; + + // 鎾斁涓嬩竴涓垨缁撴潫搴忓垪 + currentReplayIndex.value++; + + if (currentReplayIndex.value < simStore.rePlayList.length) { + // 鐭殏寤惰繜纭繚鐘舵�佸畬鍏ㄩ噸缃� + setTimeout(() => { + initializeSimulationData(false, simStore.rePlayList[currentReplayIndex.value]); + }, 100); + } else { + // 搴忓垪鎾斁缁撴潫 + isReplaySequencePlaying.value = false; + currentReplayIndex.value = 0; + } +} + +// 寮�濮嬮『搴忔挱鏀炬墍鏈夐」鐩� +function startReplaySequence() { + if (simStore.rePlayList?.length > 0) { + currentReplayIndex.value = 0; + isReplaySequencePlaying.value = true; + initializeSimulationData(false, simStore.rePlayList[0]); + } +} + +// 鎸傝浇鏃惰皟鐢� +onMounted(async () => { + await initializeSimulationData(); +}); + +// 鐩戝惉鎾斁瀹屾垚浜嬩欢 +watch(() => finishPlay.value, (newVal) => { + if (newVal && selectedScheme.value.type === 2 && isReplaySequencePlaying.value) { + handlePlayFinished(); + } +}); + +// 鍏朵粬鍘熸湁浠g爜淇濇寔涓嶅彉... \ No newline at end of file -- Gitblit v1.9.3