保安服务企业管理项目备份
zhongrj
2024-05-24 f2a74b0b28b74dc29be85ec8e6328bdd262f84b9
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
 
<template>
    <div style="width: 100%; height: 100%;">
        <OlMapBox ref="olmapboxelement" @getlivePersonLocationList="getlivePersonLocationList"></OlMapBox>
    </div>
</template>
 
<script>
import OlMapBox from "./components/OlMapBox.vue"
import { getlivePersonLocationList } from "@/api/livePersonLocation/livePersonLocation"
 
// 获取实时保安位置定时器
let liveBATimer
 
export default {
    name: "livePersonLocation",
    components: { OlMapBox },
 
    data () {
        return {
            // publicPath: process.env.BASE_URL,
            livePersonLocationList: []
        }
    },
 
    created () {
        // 首先执行一次,必须等地图渲染完成再去创建图标图层!
        this.$nextTick(() => {
            this.getlivePersonLocationList()
        })
        liveBATimer = setInterval(() => {
            this.getlivePersonLocationList()
        }, 60000)//一分钟执行一次
    },
 
    methods: {
        // 获取保安列表实时位置数据
        getlivePersonLocationList () {
            if (this.$refs.olmapboxelement) {//不清除就不新增
                this.$refs.olmapboxelement.mapRemoveLayer(['livePersonLocationLayer'])
            }
            getlivePersonLocationList().then(res => {
                this.livePersonLocationList = res.data.data
                res.data.data.forEach(item => {
                    item.lng = item.longitude
                    item.lat = item.latitude
                    item.text = item.realName
                })
                this.$refs.olmapboxelement.mapAddClusterLayer('livePersonLocationLayer', 'img/map/security.png', res.data.data, this.livePersonIconClick)
            })
        },
 
        // 保安实时图标点击事件
        livePersonIconClick (e) {
            this.$refs.olmapboxelement.generateMapPopup(e)
        }
    },
 
    destroyed () {
        // 清除保安图标图层
        if (this.$refs.olmapboxelement) {//不清除就不新增
            this.$refs.olmapboxelement.mapRemoveLayer(['livePersonLocationLayer'])
        }
        liveBATimer && clearInterval(liveBATimer)
    }
}
</script>
 
<style scoped></style>