| | |
| | | // 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, |
| | | } |
| | | }) |