wangjuncheng
2025-04-29 342e93ab9e770f58f783cc40847ec6acf3750235
change
已修改3个文件
59 ■■■■■ 文件已修改
src/components/menu/TimeLine.vue 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/monifangzhen/schemeCard.vue 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/store/simulation.js 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/menu/TimeLine.vue
@@ -92,6 +92,10 @@
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"]);
@@ -147,7 +151,10 @@
    startPlayback();
    if (!isWaterPrimitiveCreated.value) {
      // 第一次播放时创建水体模拟层
      console.log(selectedScheme.value,'这里是当前方案的全部信息');
      createWaterPrimitive({ interval: intervalMap[playbackRate.value] });
      isWaterPrimitiveCreated.value = true; // 标记为已创建
    } else {
      // 后续播放时调用恢复接口
@@ -270,6 +277,7 @@
}
watch(
  () => selectedScheme.value,
  () => currentTime.value,
  () => {
    if (waterTimestamps.value.length > 0) {
src/components/monifangzhen/schemeCard.vue
@@ -73,6 +73,8 @@
  //   alert("当前方案尚未完成,无法进入模拟!");
  //   return;
  // }
  simStore.setSelectedScheme(item)
  currentScheme.value = item;
  schemeInfoShow.value = true;
  emit("closeBtn", false);
src/store/simulation.js
@@ -1,10 +1,10 @@
// 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)
@@ -26,8 +26,14 @@
    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
@@ -48,29 +54,24 @@
        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()
@@ -94,9 +95,11 @@
        // showResultAssess.value = true
        // showDangerAssess.value = true
    }
    const setBackToHome = (value) => {
        backToHome.value = value;
    };
        backToHome.value = value
    }
    // 导航点击
    const handleNavClick = (index) => {
        switch (index) {
@@ -114,7 +117,9 @@
                break
        }
    }
    return {
        // UI 状态
        navigationShow,
        leftShow,
        rightShow,
@@ -135,20 +140,26 @@
        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,
    }
})