智慧园区前端大屏
linwe
2024-11-14 6cc2eb5ed9a6bdfe5fa3d9fe2313e04e6d7ebc9d
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
<!--
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2023-03-10 15:27:59
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2024-11-12 18:10:32
 * @FilePath: \bigScreen\src\views\space\components\leftContainer.vue
 * @Description: 
 * 
 * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved. 
-->
<script setup>
import { getList } from "@/api/space/space"
import { onUnmounted, reactive } from 'vue'
const resData = reactive({
    data: [{
        label: '一级防控',
        value: '1',
        type: 1,
        remark: '防火提及配套设置、装置围堰、罐区围堰'
    }, {
        label: '二级防控',
        value: '2',
        type: 1,
        remark: '雨污水排口一体化闸阀、车间收集池、雨污管阀'
    },
    {
        label: '三级防控',
        value: '3',
        type: 1,
        remark: '事故应急池、雨水收集池'
    }
    ]
})
const curSelect = ref('1')
let addTileLayers = {}
const handleCheckChange = (row) => {
    console.log(row)
    resData.data.forEach(item => {
        if (row.value === item.value) {
            if (!addTileLayers[item.label]) {
                addTileLayers[item.label] = new DC.HtmlLayer(item.label)
                window.$viewer.addLayer(addTileLayers[item.label])
                getList({
                    size: 1000,
                    preLevel: item.type,
                }).then(res => {
                    let data = res.data.data.records
                    data.filter(i => i.lng && i.lng != '' && i.lat && i.lat != '').forEach(i => {
                        let iconEl = ''
                        if ('showPanel' in item && item.showPanel == false) {
                            if (item.backgroundIcon) {
                                iconEl = `
                          <div class="map-name">${i[item.showParams] || i.name}</div>
                          <div class="map-icon">
                            <img src="${item.backgroundIcon}">
                          </div>
                          `
                            }
                        } else {
                            iconEl = `<div class="marsBlueGradientPnl">
                                 <div>${item.remark}</div>  </div>`
                        }
                        let divIcon = new DC.DivIcon(
                            new DC.Position(i.lng, i.lat, 0),
                            `<div class="public-map-popup">
                    ${iconEl}
                  </div>`
                        )
 
                        divIcon.attrParams = i
 
                        let incident = () => { }
 
                        if (item.incident) incident = item.incident
 
                        divIcon.on(DC.MouseEventType.CLICK, incident)
 
                        addTileLayers[item.label].addOverlay(divIcon)
                    })
                })
            } else {
                addTileLayers[item.label].show = true
            }
        } else {
            if (addTileLayers[item.label]) {
                addTileLayers[item.label].show = false
            }
        }
    })
}
 
const tabClick = (item) => {
    handleCheckChange(item)
    curSelect.value = item.value
}
 
 
const showOn = computed(() => (item) => {
    if (curSelect.value == item.value) {
        return true
    }
    return false
})
 
onMounted(() => {
    tabClick(resData.data[0])
}),
 
    onUnmounted(() => {
        let arr = Object.keys(addTileLayers)
        arr.forEach(i => {
            addTileLayers[i] && window.$viewer.removeLayer(addTileLayers[i])
        })
    })
</script>
 
<template>
    <div class="left-container cur-container">
        <div class="tablist h100">
            <div class="cursor-p" :class="{ on: showOn(item) }" v-for="item, index in resData.data" :key="index"
                @click="tabClick(item)">
                <div class="nowrap-ellipsis-hidden">
                    {{ item.label }}
                </div>
            </div>
        </div>
    </div>
</template>
 
<style lang="scss" scoped>
.cur-container {
    background: transparent;
    pointer-events: none;
 
    .tablist {
        pointer-events: all;
 
 
        &>div {
            margin-top: 86px;
            padding: 10px;
            width: 64px;
            height: 64px;
            line-height: 64px;
            text-align: center;
            border-radius: 50%;
            box-shadow: inset 0 0 40px #409eff;
            color: #fff;
            box-sizing: content-box;
 
            &.on {
                position: relative;
                color: #75b1ff;
            }
        }
    }
}
</style>