智慧园区前端大屏
shuishen
2024-12-18 9a37c5e1b2190c3f6ec71483923922189091dd52
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
<!--
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2023-03-10 15:27:59
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2024-11-28 19:29:15
 * @FilePath: \bigScreen\src\views\companyInfo\components\box\unitContent.vue
 * @Description:
 *
 * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved.
-->
<script setup>
import EventBus from 'utils/bus'
import { nextTick } from 'vue'
 
import { getDictionary } from "@/api/dict/dict"
import { onUnmounted, reactive } from 'vue'
import { getList } from "@/api/space/space"
const { VITE_APP_BASE } = import.meta.env
let image = ref(
  [{ label: '阀', value: VITE_APP_BASE + 'img/mapicon/ysf.png' }
    , { label: '池', value: VITE_APP_BASE + 'img/mapicon/yjc.png' }
    , { label: '泵', value: VITE_APP_BASE + 'img/mapicon/yjb.png' }]
)
 
const resData = reactive({
  data: []
})
const curSelect = ref('')
 
let addTileLayers = {}
let addPupoLayers = {}
onMounted(() => {
  handleCheckChange()
})
const handleCheckChange = () => {
  let companyInfo = JSON.parse(localStorage.getItem('companyInfo'))
  // resData.data.forEach(item => {
  // if (row.value == item.value) {
  if (!addTileLayers[companyInfo.name]) {
    addTileLayers[companyInfo.name] = new DC.HtmlLayer(companyInfo.name)
    window.$viewer.addLayer(addTileLayers[companyInfo.name])
    getList({
      firmId: companyInfo.id,
      size: 1000,
      // type: item.type,
    }).then(res => {
      let data = res.data.data.records
      data.filter(i => i.lng && i.lng != '' && i.lat && i.lat != '').forEach(i => {
        let img = image.value.filter(l => i.name.includes(l.label))
        img = img.length > 0 ? img : image.value
        let iconEl = `<div class="map-name">${i.name}</div>
                            <div class="map-icon"> <img src="${img[0].value}"> </div>`
        let divIcon = new DC.DivIcon(
          new DC.Position(i.lng, i.lat, i.ele || 64),
          `<div class="public-map-popup  ${'yjc-box'}"> ${iconEl}  </div>`
        )
        divIcon.attrParams = i
        let incident = (e) => {
          const { attrParams } = e.overlay
          // 删除
          destroy()
          if (!attrParams.imageUrl) {
            return
          }
          addPupoLayers[attrParams.name] = new DC.HtmlLayer(attrParams.name)
          window.$viewer.addLayer(addPupoLayers[attrParams.name])
          let iconEl = `<div class="marsBlueGradientPnl">
            <img src="${attrParams.imageUrl}" />
                </div>`
          let divIcon = new DC.DivIcon(
            new DC.Position(attrParams.lng, attrParams.lat, attrParams.ele || 64),
            `<div class="public-map-popup-qy">
                    ${iconEl}
                  </div>`
          )
          let incident = () => {
            destroy()
          }
          divIcon.on(DC.MouseEventType.CLICK, incident)
          addPupoLayers[attrParams.name].addOverlay(divIcon)
        }
 
        // if (item.incident) incident = item.incident
 
        divIcon.on(DC.MouseEventType.CLICK, incident)
 
        addTileLayers[companyInfo.name] && addTileLayers[companyInfo.name].addOverlay(divIcon)
      })
    })
  } else {
    addTileLayers[companyInfo.name].show = true
  }
  // } else {
  //     if (addTileLayers[item.label]) {
  //         addTileLayers[item.label].show = false
  //     }
  // }
  // })
}
// 销毁
function destroy () {
  let arr = Object.keys(addPupoLayers)
  arr.filter(i => i != 'hgyq').forEach(i => {
    addPupoLayers[i] && window.$viewer && window.$viewer.removeLayer(addPupoLayers[i])
    addPupoLayers[i] = null
    delete addPupoLayers[i]
  })
  addPupoLayers = {}
}
nextTick(() => {
  EventBus.emit('restHandleCheckChange', `3-3-2`)
  EventBus.emit('restHandleCheckChange', `3-3-4`)
})
onUnmounted(() => {
  let arr = Object.keys(addTileLayers)
  arr.forEach(i => {
    addTileLayers[i] && window.$viewer && window.$viewer.removeLayer(addTileLayers[i])
    addTileLayers[i] = null
    delete addTileLayers[i]
  })
  destroy()
  addTileLayers = null
  addPupoLayers = null
  EventBus.emit('restHandleDelChange', `3-3-2`)
  EventBus.emit('restHandleDelChange', `3-3-4`)
})
</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: 16px;
      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>