| | |
| | | import { fetchWaterSimulationData } from "@/api/trApi.js"; |
| | | import { EventBus } from "@/eventBus"; |
| | | import { ElMessage } from "element-plus"; |
| | | import { useSimStore } from '@/store/simulation' |
| | | import { storeToRefs } from 'pinia' |
| | | const simStore = useSimStore() |
| | | const { selectedScheme } = storeToRefs(simStore) |
| | | |
| | | const emit = defineEmits(["timeUpdate", "isPlaying", "playbackFinished"]); |
| | | |
| | |
| | | startPlayback(); |
| | | if (!isWaterPrimitiveCreated.value) { |
| | | // 第一次播放时创建水体模拟层 |
| | | console.log(selectedScheme.value,'这里是当前方案的全部信息'); |
| | | |
| | | createWaterPrimitive({ interval: intervalMap[playbackRate.value] }); |
| | | |
| | | isWaterPrimitiveCreated.value = true; // 标记为已创建 |
| | | } else { |
| | | // 后续播放时调用恢复接口 |
| | |
| | | } |
| | | |
| | | watch( |
| | | () => selectedScheme.value, |
| | | () => currentTime.value, |
| | | () => { |
| | | if (waterTimestamps.value.length > 0) { |
| | |
| | | // alert("当前方案尚未完成,无法进入模拟!"); |
| | | // return; |
| | | // } |
| | | simStore.setSelectedScheme(item) |
| | | |
| | | currentScheme.value = item; |
| | | schemeInfoShow.value = true; |
| | | emit("closeBtn", false); |
| | |
| | | // stores/ui.js |
| | | import { defineStore } from 'pinia' |
| | | import { ref } from 'vue' |
| | | import { createSimData } from '@/api/trApi'; |
| | | import { createSimData } from '@/api/trApi' |
| | | |
| | | export const useSimStore = defineStore('simulation', () => { |
| | | // 所有UI状态 |
| | | // 所有UI状态... |
| | | const navigationShow = ref(true) |
| | | const leftShow = ref(false) |
| | | const rightShow = ref(false) |
| | |
| | | const showDangerAssess = ref(false) |
| | | const schemCard = ref([]) |
| | | const backToHome = ref(false) |
| | | const selectedScheme = ref(null) |
| | | const setSelectedScheme = (scheme) => { |
| | | selectedScheme.value = scheme |
| | | } |
| | | const clearSelectedScheme = () => { |
| | | selectedScheme.value = null |
| | | } |
| | | |
| | | // 初始化方法 |
| | | const init = () => { |
| | | navigationShow.value = true |
| | | leftShow.value = false |
| | |
| | | schemCard.value = [] |
| | | } |
| | | |
| | | // 方案相关 |
| | | const setSchemCard = (data) => { |
| | | schemCard.value = data |
| | | } |
| | | |
| | | // 添加单个方案数据 |
| | | const addSchemCard = (item) => { |
| | | schemCard.value.unshift(item) |
| | | } |
| | | |
| | | // 删除指定方案数据 |
| | | const removeSchemCardItem = (id) => { |
| | | schemCard.value = schemCard.value.filter(item => item.id !== id) |
| | | } |
| | | |
| | | // 更新指定方案数据 |
| | | const updateSchemCardItem = (id, newData) => { |
| | | const index = schemCard.value.findIndex(item => item.id === id) |
| | | if (index !== -1) { |
| | | schemCard.value[index] = { ...schemCard.value[index], ...newData } |
| | | } |
| | | } |
| | | |
| | | |
| | | const startYHGL = () => { |
| | | init() |
| | |
| | | // showResultAssess.value = true |
| | | // showDangerAssess.value = true |
| | | } |
| | | |
| | | const setBackToHome = (value) => { |
| | | backToHome.value = value; |
| | | }; |
| | | backToHome.value = value |
| | | } |
| | | |
| | | // 导航点击 |
| | | const handleNavClick = (index) => { |
| | | switch (index) { |
| | |
| | | break |
| | | } |
| | | } |
| | | |
| | | return { |
| | | // UI 状态 |
| | | navigationShow, |
| | | leftShow, |
| | | rightShow, |
| | |
| | | showLayerTree, |
| | | showDangerAssess, |
| | | schemCard, |
| | | // selectTab, |
| | | backToHome, |
| | | handleNavClick, |
| | | |
| | | // 方案相关方法 |
| | | setSchemCard, |
| | | addSchemCard, |
| | | removeSchemCardItem, |
| | | updateSchemCardItem, |
| | | setBackToHome, |
| | | |
| | | // ✅ 暴露 selectedScheme 及其方法 |
| | | selectedScheme, // 响应式引用 |
| | | setSelectedScheme, // 方法 |
| | | clearSelectedScheme, // 方法 |
| | | |
| | | // 控制逻辑 |
| | | init, |
| | | startYHGL, |
| | | startZHJC, |
| | | startMNFZ, |
| | | startMNPG, |
| | | setSchemCard, |
| | | addSchemCard, |
| | | removeSchemCardItem, |
| | | updateSchemCardItem, |
| | | // handleClickTab, |
| | | // createSimulation, |
| | | setBackToHome |
| | | handleNavClick, |
| | | } |
| | | }) |