| | |
| | | import { useSimStore } from "@/store/simulation"; |
| | | import { storeToRefs } from "pinia"; |
| | | const simStore = useSimStore(); |
| | | const { selectedScheme, frameNum, layerDate } = storeToRefs(simStore); |
| | | const { selectedScheme, frameNum, layerDate, schemWaterInfo } = |
| | | storeToRefs(simStore); |
| | | import { clearAllPoints } from "@/utils/map"; |
| | | |
| | | const emit = defineEmits([ |
| | | "timeUpdate", |
| | |
| | | } |
| | | |
| | | // 触发进度更新 |
| | | const progress = currentTime.value / totalDuration; |
| | | emit("timeUpdate", progress * 100); |
| | | // const progress = currentTime.value / totalDuration; |
| | | // 实时模拟应该不用显示弹窗吧 |
| | | // emit("timeUpdate", progress * 100); |
| | | |
| | | // 如果需要触发某些更新函数,也可以保留 |
| | | updateWaterColorByTime(); |
| | |
| | | // 降雨数据相关变量 |
| | | let rainFallValues = ref([]); // 存储原始降雨量数据 |
| | | let minRainValue = ref(Infinity); |
| | | let averageRainIntensity = ref(); |
| | | let maxRainValue = ref(-Infinity); |
| | | // 获取降雨数据 |
| | | function getRainfallData() { |
| | |
| | | |
| | | // 提取 intensity 值 |
| | | rainFallValues.value = hourlyRainfallList.map((r) => r.intensity); |
| | | // 计算平均雨强 |
| | | if (rainFallValues.value.length > 0) { |
| | | const sumIntensity = rainFallValues.value.reduce( |
| | | (sum, val) => sum + val, |
| | | 0 |
| | | ); |
| | | averageRainIntensity.value = sumIntensity / rainFallValues.value.length; |
| | | } else { |
| | | averageRainIntensity.value = 0; // 或者 null 表示无数据 |
| | | } |
| | | |
| | | console.log("平均雨强为:", averageRainIntensity.value); |
| | | |
| | | minRainValue.value = Math.min(...rainFallValues.value); |
| | | maxRainValue.value = Math.max(...rainFallValues.value); |
| | | |
| | |
| | | watersMaxHeight, |
| | | watersMinHeight |
| | | ); |
| | | |
| | | const waterInfoArr = [ |
| | | watersMaxHeight, |
| | | maxRainValue.value, |
| | | averageRainIntensity.value, |
| | | ]; |
| | | schemWaterInfo.value = waterInfoArr; |
| | | // 更新时间轴相关数据 |
| | | if (timestamps) { |
| | | frameNum.value = timestamps.length; |
| | |
| | | watch( |
| | | () => finishPlay.value, |
| | | (newVal) => { |
| | | if (newVal && selectedScheme.value.type === 2) { |
| | | if ( |
| | | newVal && |
| | | selectedScheme.value.type === 2 && |
| | | simStore.rePlayList.length > 0 |
| | | ) { |
| | | handlePlayFinished(); |
| | | } |
| | | } |
| | |
| | | if (selectedScheme.value.type === 2) { |
| | | try { |
| | | await ElMessageBox.confirm("方案未停止时结束模拟后,后台将停止计算", { |
| | | confirmButtonText: "返回列表", |
| | | cancelButtonText: "结束模拟", |
| | | confirmButtonText: "结束模拟", |
| | | cancelButtonText: "返回列表", |
| | | type: "warning", |
| | | }); |
| | | // 用户点击了确认,这里不执行任何操作,仅关闭对话框 |
| | | |
| | | const res = await stopSim(selectedScheme.value.id); |
| | | if (res.code == 404) { |
| | | ElMessage.warning("该服务已停止"); |
| | | } else { |
| | | ElMessage.success("服务正在停止中"); |
| | | } |
| | | } catch (error) { |
| | | stopSim(selectedScheme.value.id).then((res) => { |
| | | if (res.code == 404) { |
| | | ElMessage.warning("该服务已停止"); |
| | | } else { |
| | | ElMessage.success("服务正在停止中"); |
| | | } |
| | | }); |
| | | // 用户点击了【返回列表】或者出现错误 |
| | | // return; |
| | | } |
| | | } |
| | | // 不管type是不是2,最终都执行结束模拟的操作 |
| | | |
| | | // 不管 type 是不是 2,最终都执行结束模拟操作 |
| | | endSimulation(); |
| | | } |
| | | |
| | | async function endSimulation() { |
| | | clearAllPoints(); |
| | | simStore.openDia = true; |
| | | simStore.crossSection = []; |
| | | // 结束模拟之后清除layer列表 |
| | | simStore.rePlayList = []; |
| | | console.log(simStore.rePlayList, "结束模拟清除rePlayListrePlayList列表"); |
| | | EventBus.emit("close-time"); |
| | | endSimulate(); |
| | | isWaterPrimitiveCreated.value = false; |