// stores/ui.js
|
import { defineStore } from 'pinia'
|
import { ref } from 'vue'
|
|
export const useSimStore = defineStore('simulation', () => {
|
// 隐患点列表
|
const DeviceShowSwitch = ref(true)
|
const DangerShowSwitch = ref(true)
|
const DangerPoint = ref([])
|
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 showLayerTree = ref(true)
|
const schemCard = ref([])
|
const backToHome = ref(false)
|
const selectedScheme = ref(null)
|
// 模拟仿真图例
|
const isShowEarth = ref(false)
|
// 降雨数据列表
|
const rainFalls = ref()
|
// 降雨单位
|
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')
|
}
|
const clearSelectedScheme = () => {
|
selectedScheme.value = null
|
}
|
|
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
|
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 flyToHomeView = () => {
|
const view = {
|
destination: {
|
x: -2355432.569004413,
|
y: 4687573.191838412,
|
z: 4098726.315265574,
|
},
|
orientation: {
|
pitch: -0.9541030830183503,
|
roll: 0.00031421159527500464,
|
heading: 6.140424766644804,
|
},
|
};
|
viewer.scene.camera.flyTo(view);
|
}
|
|
const startYHGL = () => {
|
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
|
isShowEarth.value = false
|
|
}
|
|
const startMNPG = () => {
|
init()
|
isShowEarth.value = false
|
|
}
|
|
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 {
|
// UI 状态
|
navigationShow,
|
leftShow,
|
rightShow,
|
plottingShow,
|
messageShow,
|
announcementShow,
|
functionShow,
|
locationShow,
|
tableShow,
|
flowShow,
|
debuffShow,
|
rightRiverShow,
|
showPreview,
|
weatherShow,
|
barShow,
|
deviceShow,
|
showLayerTree,
|
schemCard,
|
backToHome,
|
rainFalls,
|
intensityUnit,
|
DangerPoint,
|
DeviceShowSwitch,
|
DangerShowSwitch,
|
isShowEarth,
|
|
// 方案相关方法
|
setSchemCard,
|
addSchemCard,
|
removeSchemCardItem,
|
updateSchemCardItem,
|
setBackToHome,
|
|
// ✅ 暴露 selectedScheme 及其方法
|
selectedScheme, // 响应式引用
|
setSelectedScheme, // 方法
|
clearSelectedScheme, // 方法
|
|
// 控制逻辑
|
init,
|
startYHGL,
|
startZHJC,
|
startMNFZ,
|
startMNPG,
|
handleNavClick,
|
}
|
})
|