// stores/ui.js
|
import { defineStore } from 'pinia'
|
import { ref } from 'vue'
|
import { createSimData } from '@/api/trApi';
|
|
export const useSimStore = defineStore('ui', () => {
|
// 所有UI状态
|
const navigationShow = ref(true)
|
const leftShow = ref(false)
|
const rightShow = ref(false)
|
const plottingShow = ref(false)
|
const messageShow = ref(false)
|
const announcementShow = ref(false)
|
const functionShow = ref(false)
|
const locationShow = ref(false)
|
const tableShow = ref(false)
|
const flowShow = ref(false)
|
const debuffShow = ref(false)
|
const rightRiverShow = ref(false)
|
const showPreview = ref(false)
|
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 selectTab = ref("行政区划仿真")
|
const backToHome = ref(false)
|
|
// 初始化方法
|
const init = () => {
|
navigationShow.value = true
|
leftShow.value = false
|
rightShow.value = false
|
plottingShow.value = false
|
messageShow.value = false
|
announcementShow.value = false
|
functionShow.value = false
|
locationShow.value = false
|
tableShow.value = false
|
flowShow.value = false
|
backToHome.value = false
|
rightRiverShow.value = false
|
showPreview.value = false
|
deviceShow.value = false
|
showResultAssess.value = false
|
showDangerAssess.value = false
|
schemCard.value = []
|
selectTab.value = "行政区划仿真"
|
|
}
|
|
const handleClickTab = (data) => {
|
selectTab.value = data
|
}
|
|
// 新建方案
|
const createSimulation = async (forms) => {
|
const getAreaType = (tabName) => {
|
switch (tabName) {
|
case '行政区划仿真':
|
return 1
|
case '重点区域仿真':
|
return 2
|
case '重点沟仿真':
|
return 3
|
default:
|
return 0 // 自定义
|
}
|
}
|
const params = {
|
areaType: getAreaType(selectTab),
|
createTime: Date.now(),
|
name: forms.name,
|
// 1为预测模拟,2为实时模拟,3为历史模拟
|
type: 1,
|
// 0为创建仿真,1为预处理,2为分析中,10为完成,20为出错
|
status: 0,
|
}
|
try {
|
await createSimData(params)
|
} catch (error) {
|
console.error('创建仿真失败:', error)
|
}
|
}
|
|
// 方案相关
|
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()
|
locationShow.value = true
|
}
|
|
const startZHJC = () => {
|
init()
|
functionShow.value = true
|
deviceShow.value = true
|
}
|
|
const startMNFZ = () => {
|
init()
|
leftShow.value = true
|
rightRiverShow.value = true
|
}
|
|
const startMNPG = () => {
|
init()
|
// showResultAssess.value = true
|
// showDangerAssess.value = true
|
}
|
const setBackToHome = (value) => {
|
backToHome.value = value;
|
};
|
// 导航点击
|
const handleNavClick = (index) => {
|
switch (index) {
|
case 1:
|
startYHGL()
|
break
|
case 2:
|
startZHJC()
|
break
|
case 3:
|
startMNFZ()
|
break
|
case 4:
|
startMNPG()
|
break
|
}
|
}
|
return {
|
navigationShow,
|
leftShow,
|
rightShow,
|
plottingShow,
|
messageShow,
|
announcementShow,
|
functionShow,
|
locationShow,
|
tableShow,
|
flowShow,
|
debuffShow,
|
rightRiverShow,
|
showPreview,
|
weatherShow,
|
barShow,
|
deviceShow,
|
showResultAssess,
|
showLayerTree,
|
showDangerAssess,
|
schemCard,
|
selectTab,
|
handleNavClick,
|
init,
|
startYHGL,
|
startZHJC,
|
startMNFZ,
|
startMNPG,
|
setSchemCard,
|
addSchemCard,
|
removeSchemCardItem,
|
updateSchemCardItem,
|
handleClickTab,
|
createSimulation,
|
backToHome,
|
setBackToHome
|
}
|
})
|