forked from drone/command-center-dashboard

罗广辉
2025-04-21 2800fa4f32f3900509cb4d6eefaf2bfaf54efdd7
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
<template>
    <div class="footer" v-show="isHideBottomIcon">
        <img
            v-for="(item,index) in list.filter(i => !i.show)"
            :class="item.className"
            :src="item.active ? item.activeImg : item.img"
            alt=""
            @click="footAction(item,index)"
        />
    </div>
    <div class="intelligent-introduction-flying">
        <img
            class="orthophoto"
            src="@/assets/images/intelligent-introduction-flying.png"
            alt=""
            @click="footAction(list[5],5)"
        />
    </div>
</template>
 
<script setup>
import img1 from '@/assets/images/home/footer/machine-nest.png'
import activeImg1 from '@/assets/images/home/footer/machine-nest1.png'
import img2 from '@/assets/images/home/footer/event.png'
import activeImg2 from '@/assets/images/home/footer/event1.png'
import img3 from '@/assets/images/home/footer/panorama.png'
import activeImg3 from '@/assets/images/home/footer/panorama1.png'
import img4 from '@/assets/images/home/footer/3D.png'
import activeImg4 from '@/assets/images/home/footer/3D1.png'
import img5 from '@/assets/images/home/footer/orthophoto.png'
import activeImg5 from '@/assets/images/home/footer/orthophoto1.png'
 
import { useMapAggregation } from '@/hooks/useMapAggregation/useMapAggregation'
import { useStore } from 'vuex'
import func from '@/utils/func'
import { ElMessage } from 'element-plus'
 
const store = useStore()
const footActiveIndex = computed(() => store.state.home.footActiveIndex)
const isHideBottomIcon = computed(() => store.state.common.isHideBottomIcon)
 
// 机巢聚合
const { init, removeAll } = useMapAggregation('device')
// 事件聚合
const { init: eventInit, removeAll: eventRemove } = useMapAggregation('event')
 
const list = ref([
    {
        name: 'jc',
        img: img1,
        activeImg: activeImg1,
        active: true,
        className: 'machine-nest',
        init: init,
        removeAll: removeAll,
    },
    {
        name: 'sj',
        img: img2,
        activeImg: activeImg2,
        active: false,
        className: 'event',
        init: eventInit,
        removeAll: eventRemove,
    },
    { name: 'qj', img: img3, activeImg: activeImg3, active: false, className: 'panorama',undeveloped:true },
    { name: 'sw', img: img4, activeImg: activeImg4, active: false, className: 'threeD',undeveloped:true },
    { name: 'zs', img: img5, activeImg: activeImg5, active: false, className: 'orthophoto',undeveloped:true },
    { name: 'zyjf', active: false, show: true },
])
 
const footAction = (toItem, index) => {
    if (toItem.undeveloped) return ElMessage.warning('正在加急开发中...')
    const fromItem = list.value.find(item => item.active)  //上一个激活item
    if (fromItem.name === toItem?.name) return  //是重复点击
    index !== undefined && store.commit('setFootActiveIndex', index) //是按钮点击得动作
    fromItem?.removeAll?.()
    nextTick(() => toItem?.init?.())
    list.value = list.value.map(item => ({ ...item, active: item.name === toItem?.name }))
    if (index === 5) {
        // 相关图标不显示
        store.commit('setHideBottomIcon', false)
    }
}
 
watch(
    footActiveIndex,
    val => {
        footAction(list.value[val])
    },
    { deep: true }
)
 
// 销毁前钩子
onBeforeUnmount(() => {
    removeAll()
    eventRemove()
})
onMounted(() => {
    nextTick(() => {
        init()
    })
})
</script>
 
<style scoped lang="scss">
.footer {
    position: absolute;
    bottom: 84px;
    left: 624px;
 
    img {
        width: 103px;
        height: 119px;
        cursor: pointer;
    }
 
    .event {
        position: relative;
        left: 40px;
        bottom: 15px;
    }
 
    .panorama {
        position: relative;
        left: 80px;
        bottom: 34px;
    }
 
    .threeD {
        position: relative;
        left: 120px;
        bottom: 15px;
    }
 
    .orthophoto {
        position: relative;
        left: 160px;
    }
}
 
.intelligent-introduction-flying {
    position: absolute;
    left: 888px;
    bottom: 23px;
 
    img {
        cursor: pointer;
        width: 146px;
        height: 54px;
    }
}
</style>