| | |
| | | import { defineStore } from 'pinia' |
| | | import { ref } from 'vue' |
| | | export const useSimStore = defineStore('simulation', () => { |
| | | // 历史回放列表 |
| | | const rePlayList = ref([]) |
| | | // 北京市所有村的code |
| | | const townCodeAll = ref([]) |
| | | // 实时模拟最新的layer |
| | |
| | | // 降雨单位 |
| | | const intensityUnit = ref() |
| | | const setSelectedScheme = (scheme) => { |
| | | selectedScheme.value = scheme |
| | | rainFalls.value = JSON.parse(scheme.data).rainfalls |
| | | intensityUnit.value = JSON.parse(scheme.data).intensityUnit |
| | | } |
| | | 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 |
| | | } |
| | |
| | | devices, |
| | | frameNum, |
| | | layerDate, |
| | | rePlayList, |
| | | |
| | | // 方案相关方法 |
| | | setSchemCard, |