guonan
2025-07-03 f37845dd0a787dd42bf6c72e923433f30fcd8cc3
src/store/simulation.js
@@ -2,11 +2,20 @@
import { defineStore } from 'pinia'
import { ref } from 'vue'
export const useSimStore = defineStore('simulation', () => {
    // 历史回放列表
    const rePlayList = ref([])
    // 北京市所有村的code
    const townCodeAll = ref([])
    // 实时模拟最新的layer
    const layerDate = ref("")
    // 帧数
    const frameNum = ref(0)
    // 目录树选中
    const userSelectedLayers = ref([])
    // 隐患点列表
    const DangerPoint = ref([])
    const DeviceShowSwitch = ref(false)
    const DangerShowSwitch = ref(false)
    const DangerPoint = ref([])
    // 监测设备列表
    const devices = ref([])
    const navigationShow = ref(true)
@@ -40,11 +49,22 @@
    // 降雨单位
    const intensityUnit = ref()
    const setSelectedScheme = (scheme) => {
        selectedScheme.value = scheme
        rainFalls.value = JSON.parse(scheme.data).rainfalls
        intensityUnit.value = JSON.parse(scheme.data).intensityUnit
        console.log(intensityUnit.value, 'shceme')
    }
        selectedScheme.value = scheme;
        try {
            const parsedData = JSON.parse(scheme.data);
            // 只有当 rainfalls 和 intensityUnit 存在且非空时才赋值
            if (parsedData.rainfalls && parsedData.intensityUnit) {
                rainFalls.value = parsedData.rainfalls;
                intensityUnit.value = parsedData.intensityUnit;
            } else {
                console.warn("缺少必要的 rainfalls 或 intensityUnit 字段");
            }
        } catch (error) {
            console.error("解析 scheme.data 出错", error);
        }
    };
    const clearSelectedScheme = () => {
        selectedScheme.value = null
    }
@@ -155,7 +175,9 @@
        }
    }
    const updateSelectedLayers = (keys) => {
        userSelectedLayers.value = keys;
    }
@@ -188,7 +210,11 @@
        waterLegendData,
        currentInfo,
        isShowEarth,
        userSelectedLayers,
        devices,
        frameNum,
        layerDate,
        rePlayList,
        // 方案相关方法
        setSchemCard,
@@ -209,5 +235,6 @@
        startMNFZ,
        startMNPG,
        handleNavClick,
        updateSelectedLayers
    }
})