guonan
8 天以前 d06f7ad0231d5fb029ab8520bf442590d3bab20b
src/store/simulation.js
@@ -1,12 +1,29 @@
// stores/ui.js
import { defineStore } from 'pinia'
import { ref } from 'vue'
import { showDeviceDetail } from "@/store";
export const useSimStore = defineStore('simulation', () => {
    // 断面数据
    const crossSection = ref([])
    const openDia = ref(true)
    // 历史回放列表
    const rePlayList = ref([])
    // 北京市所有村的code
    const townCodeAll = ref([])
    // 实时模拟最新的layer
    const layerDate = ref("")
    // 帧数
    const frameNum = ref(0)
    // 目录树选中
    const userSelectedLayers = ref([])
    // 隐患点列表
    const DeviceShowSwitch = ref(true)
    const DangerShowSwitch = ref(true)
    const DeviceShowSwitch = ref(false)
    const DangerShowSwitch = ref(false)
    const DangerPoint = ref([])
    // 泥位计
    const selectNWJ = ref()
    // 监测设备列表
    const devices = ref([])
    const navigationShow = ref(true)
    const leftShow = ref(false)
    const rightShow = ref(false)
@@ -23,22 +40,39 @@
    const weatherShow = ref(false)
    const barShow = ref(false)
    const deviceShow = ref(false)
    const showResultAssess = ref(false)
    const showLayerTree = ref(true)
    const showDangerAssess = ref(false)
    const schemCard = ref([])
    const backToHome = ref(false)
    const selectedScheme = ref(null)
    // 当前模拟经纬度
    const currentInfo = ref({})
    // 图例
    const waterLegendData = ref([])
    // 模拟仿真图例
    const isShowEarth = ref(false)
    // 降雨数据列表
    const rainFalls = ref()
    // 降雨单位
    const intensityUnit = ref()
    // 方案下水深流速等数据
    let schemWaterInfo = 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
    }
@@ -58,8 +92,6 @@
        rightRiverShow.value = false
        showPreview.value = false
        deviceShow.value = false
        showResultAssess.value = false
        showDangerAssess.value = false
        schemCard.value = []
    }
@@ -102,24 +134,30 @@
        init()
        flyToHomeView()
        locationShow.value = true
        isShowEarth.value = true
    }
    const startZHJC = () => {
        init()
        flyToHomeView()
        functionShow.value = true
        deviceShow.value = true
        isShowEarth.value = true
    }
    const startMNFZ = () => {
        init()
        flyToHomeView()
        leftShow.value = true
        // rightRiverShow.value = true
        isShowEarth.value = false
    }
    const startMNPG = () => {
        init()
        // showResultAssess.value = true
        // showDangerAssess.value = true
        isShowEarth.value = false
    }
    const setBackToHome = (value) => {
@@ -128,6 +166,7 @@
    // 导航点击
    const handleNavClick = (index) => {
        showDeviceDetail.value = false;
        switch (index) {
            case 1:
                startYHGL()
@@ -143,6 +182,12 @@
                break
        }
    }
    const updateSelectedLayers = (keys) => {
        userSelectedLayers.value = keys;
    }
    return {
        // UI 状态
@@ -162,9 +207,7 @@
        weatherShow,
        barShow,
        deviceShow,
        showResultAssess,
        showLayerTree,
        showDangerAssess,
        schemCard,
        backToHome,
        rainFalls,
@@ -172,6 +215,18 @@
        DangerPoint,
        DeviceShowSwitch,
        DangerShowSwitch,
        waterLegendData,
        currentInfo,
        isShowEarth,
        userSelectedLayers,
        devices,
        frameNum,
        schemWaterInfo,
        layerDate,
        rePlayList,
        selectNWJ,
        openDia,
        crossSection,
        // 方案相关方法
        setSchemCard,
@@ -192,5 +247,6 @@
        startMNFZ,
        startMNPG,
        handleNavClick,
        updateSelectedLayers
    }
})