无人机管理后台前端(已迁走)
张含笑
2025-08-05 c832bf2e80ac465e71b7a1c1f7a59d4252030989
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
<!--
 * @Author       : yuan
 * @Date         : 2025-05-26 17:30:33
 * @LastEditors  : yuan
 * @LastEditTime : 2025-06-10 15:46:18
 * @FilePath     : \src\views\job\components\DeviceJobDetailsMap.vue
 * @Description  : 
 * Copyright 2025 OBKoro1, All Rights Reserved. 
 * 2025-05-26 17:30:33
-->
<template>
    <div id="deviceJobDetailsMap" class="ztzf-cesium">
        <PlanarRouteLineList :curRouteLineData="curRouteLineData" @routeLineListClick="routeLineListClick" />
    </div>
</template>
<script setup>
import PlanarRouteLineList from '@/components/PlanarRouteLineList/PlanarRouteLineList.vue'
 
import { PublicCesium } from '@/utils/cesium/publicCesium'
 
const props = defineProps(['detailsData'])
 
import { useRouteLine } from '@/hooks/useRouteLine/useRouteLine.js'
 
// 加载航线hook
const { curRouteLineData, routeLineListClick, initViewer, renderPreviewLine } = useRouteLine()
 
 
let viewer = null
const initMap = () => {
    viewer = new PublicCesium({ dom: 'deviceJobDetailsMap' }).getViewer()
 
    initViewer(viewer)
}
 
// 绘制线和飞行
const drawLine = async () => {
    Promise.all(
        props.detailsData.way_lines.map(
            async item => await renderPreviewLine(`${item.url}?_t=${new Date().getTime()}`, item.wayline_type)
        )
    )
}
 
const removeMap = () => {
    viewer.entities.removeAll()
    viewer.destroy()
}
 
watch(
    () => props.detailsData,
    (newValue, oldValue) => {
        if (newValue) {
            drawLine()
        }
    }
)
 
onBeforeUnmount(() => {
    removeMap()
})
 
onMounted(() => {
    nextTick(() => {
        initMap()
    })
})
</script>
<style scoped lang="scss">
#deviceJobDetailsMap {
    position: relative;
    height: 100%;
}
</style>