guonan
2025-05-29 cd5080b2e3d84c274f90bee762348be3f89e3c29
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
// 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 showResultAssess = ref(false)
    const showLayerTree = ref(true)
    const showDangerAssess = ref(false)
    const schemCard = ref([])
    const backToHome = ref(false)
    const selectedScheme = ref(null)
    // 降雨数据列表
    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
        showResultAssess.value = false
        showDangerAssess.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
    }
 
    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 {
        // UI 状态
        navigationShow,
        leftShow,
        rightShow,
        plottingShow,
        messageShow,
        announcementShow,
        functionShow,
        locationShow,
        tableShow,
        flowShow,
        debuffShow,
        rightRiverShow,
        showPreview,
        weatherShow,
        barShow,
        deviceShow,
        showResultAssess,
        showLayerTree,
        showDangerAssess,
        schemCard,
        backToHome,
        rainFalls,
        intensityUnit,
        DangerPoint,
        DeviceShowSwitch,
        DangerShowSwitch,
 
        // 方案相关方法
        setSchemCard,
        addSchemCard,
        removeSchemCardItem,
        updateSchemCardItem,
        setBackToHome,
 
        // ✅ 暴露 selectedScheme 及其方法
        selectedScheme,          // 响应式引用
        setSelectedScheme,      // 方法
        clearSelectedScheme,    // 方法
 
        // 控制逻辑
        init,
        startYHGL,
        startZHJC,
        startMNFZ,
        startMNPG,
        handleNavClick,
    }
})