| | |
| | | // stores/ui.js |
| | | import { defineStore } from 'pinia' |
| | | import { ref } from 'vue' |
| | | import { createSimData } from '@/api/trApi' |
| | | |
| | | 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 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) |
| | |
| | | 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 |
| | | console.log(rainFalls.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 |
| | | } |
| | |
| | | rightRiverShow.value = false |
| | | showPreview.value = false |
| | | deviceShow.value = false |
| | | showResultAssess.value = false |
| | | showDangerAssess.value = false |
| | | schemCard.value = [] |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | 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 |
| | | // rightRiverShow.value = true |
| | | isShowEarth.value = false |
| | | |
| | | } |
| | | |
| | | const startMNPG = () => { |
| | | init() |
| | | // showResultAssess.value = true |
| | | // showDangerAssess.value = true |
| | | isShowEarth.value = false |
| | | } |
| | | |
| | | const setBackToHome = (value) => { |
| | |
| | | |
| | | // 导航点击 |
| | | const handleNavClick = (index) => { |
| | | showDeviceDetail.value = false; |
| | | switch (index) { |
| | | case 1: |
| | | startYHGL() |
| | |
| | | break |
| | | } |
| | | } |
| | | |
| | | const updateSelectedLayers = (keys) => { |
| | | userSelectedLayers.value = keys; |
| | | } |
| | | |
| | | |
| | | |
| | | return { |
| | | // UI 状态 |
| | |
| | | weatherShow, |
| | | barShow, |
| | | deviceShow, |
| | | showResultAssess, |
| | | showLayerTree, |
| | | showDangerAssess, |
| | | schemCard, |
| | | backToHome, |
| | | rainFalls, |
| | | intensityUnit, |
| | | DangerPoint, |
| | | DeviceShowSwitch, |
| | | DangerShowSwitch, |
| | | waterLegendData, |
| | | currentInfo, |
| | | isShowEarth, |
| | | userSelectedLayers, |
| | | devices, |
| | | frameNum, |
| | | schemWaterInfo, |
| | | layerDate, |
| | | rePlayList, |
| | | selectNWJ, |
| | | openDia, |
| | | crossSection, |
| | | |
| | | // 方案相关方法 |
| | | setSchemCard, |
| | |
| | | startMNFZ, |
| | | startMNPG, |
| | | handleNavClick, |
| | | updateSelectedLayers |
| | | } |
| | | }) |