吉安感知网项目-前端
shuishen
2026-02-03 89380e6260a75d1d3b94de687ebcc2f50d50659d
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<template>
    <el-dialog
        class="command-page-map-view-dialog"
        v-model="visible"
        :show-close="false"
        :close-on-click-modal="false"
        @closed="handleClosed"
        destroy-on-close
    >
        <div class="dialog-container">
            <div class="left-container">
                <div class="leftMap command-cesium" id="leftMapContainer"></div>
            </div>
            <div class="right-container">
                <div class="header">
                    <span>{{ dialogTitle }}</span>
 
                    <el-icon class="close-btn" @click.stop="visible = false"><Close /></el-icon>
                </div>
 
                <div class="content">
                    <div class="detail-title">轨迹信息</div>
                    <el-row>
                        <el-col :span="24">
                            <div class="label">无人机名称</div>
                            <div class="val">{{ formData.droneName }}</div>
                        </el-col>
                        <el-col :span="24">
                            <div class="label">无人机序列号</div>
                            <div class="val">{{ formData.serialNo }}</div>
                        </el-col>
                        <el-col :span="24">
                            <div class="label">告警时间</div>
                            <div class="val">{{ formData.alarmTime }}</div>
                        </el-col>
                        <el-col :span="24">
                            <div class="label">触发原因</div>
                            <div class="val">{{ formData.triggerType }}</div>
                        </el-col>
                        <el-col :span="24">
                            <div class="label">停留时长</div>
                            <div class="val">{{ formData.stayDuration }}</div>
                        </el-col>
                    </el-row>
                    <div class="detail-title">轨迹点</div>
                    <div class="command-table-container">
                        <div class="command-table-content">
                            <el-table class="command-table" :data="list" :row-class-name="getRowClassName">
                                <el-table-column type="index" width="60" label="序号" />
                                <el-table-column label="经纬度">
                                    <template #default="{ row }">{{ row.longitude }},{{ row.latitude }}</template>
                                </el-table-column>
                                <el-table-column prop="createTime" label="时间" />
                            </el-table>
                        </div>
                    </div>
                </div>
                <div class="footer">
                    <el-button v-if="dialogMode != 'view'" color="#2B2B4C" @click="handleCancel">{{ dialogReadonly ? '关闭' : '取消' }}</el-button>
                </div>
            </div>
        </div>
    </el-dialog>
</template>
 
<script setup>
import { Close } from '@element-plus/icons-vue'
 
import { computed, nextTick, ref } from 'vue'
import { fwDroneFlightRecordDetailApi } from '@/views/recordManage/historyTracks/fwDroneFlightRecord'
import { fwDroneFlightRecordDetailPageApi } from '@/views/recordManage/historyTracks/flyTrajectory'
import { PublicCesium } from '@/utils/cesium/publicCesium'
import * as Cesium from 'cesium'
import { flyVisual } from '@ztzf/utils'
import { ArrowLineMaterialProperty } from '@/utils/cesium/Material'
import droneIcon from '@/assets/images/dataCockpit/map/drone.png'
 
const initForm = () => ({
    droneName: '',
    serialNo: '',
    alarmTime: '',
    triggerType: '',
    stayDuration: '',
})
let list = ref([])
const emit = defineEmits(['success'])
const formData = ref(initForm()) // 表单数据
const visible = ref(false) // 弹框显隐
const dialogMode = ref('add') // 弹框模式
const dialogReadonly = computed(() => dialogMode.value === 'view')
const dialogTitle = computed(() => {
    if (dialogMode.value === 'edit') {
        return '编辑'
    } else if (dialogMode.value === 'view') {
        return '查看'
    } else {
        return '新增'
    }
})
 
// 关闭弹框
function handleCancel() {
    visible.value = false
}
 
// 加载详情
async function loadDetail() {
    if (!formData.value.id) return
    const res = await fwDroneFlightRecordDetailApi({ id: formData.value.id })
    const res1 = await fwDroneFlightRecordDetailPageApi({ flightRecordId: formData.value.id })
    list.value = res1.data.data.records ?? []
    drawFlightPath()
    formData.value = res?.data?.data ?? {}
}
 
let arrowLineMaterialProperty = new ArrowLineMaterialProperty({
    color: new Cesium.Color(128 / 255, 215 / 255, 255 / 255, 1),
    directionColor: new Cesium.Color(1, 1, 1, 1),
    outlineColor: new Cesium.Color(1, 1, 1, 1),
    outlineWidth: 0,
    speed: 5,
})
 
// 角度转c3
function degreesToC3({ longitude, latitude, height = 0 }) {
    return Cesium.Cartesian3.fromDegrees(longitude, latitude, height)
}
// 渲染航线
function drawFlightPath() {
    const positions = list.value.map(p => degreesToC3(p))
    if (!positions.length) return
    droneLineEntity && geometricSource.entities.remove(droneLineEntity)
    droneLineEntity = geometricSource.entities.add({
        polyline: {
            width: 4,
            positions: positions,
            material: arrowLineMaterialProperty,
            clampToGround: false,
        },
    })
    startDroneEntity && geometricSource.entities.remove(startDroneEntity)
    startDroneEntity = geometricSource.entities.add({
        position: positions[0],
        billboard: {
            image: droneIcon,
            width: 40,
            height: 40,
            verticalOrigin: Cesium.VerticalOrigin.CENTER,
        },
    })
    viewer.flyTo(droneLineEntity, { duration: 0 })
}
 
// 关闭后重置
function handleClosed() {
    formData.value = initForm()
    list.value = []
    viewer = null
    geometricSource = null
    droneLineEntity = null
    startDroneEntity = null
}
 
function getRowClassName({ row }) {
    console.log(row.isAlarm, 11111111111)
 
    return row?.isAlarm === 1 ? 'alarm-row' : ''
}
 
let viewer, geometricSource, droneLineEntity, startDroneEntity
function initMap() {
    if (viewer) return
    const publicCesiumInstance = new PublicCesium({
        dom: 'leftMapContainer',
        flatMode: false,
        terrain: true,
        layerMode: 4,
        boundary: false,
    })
    viewer = publicCesiumInstance.getViewer()
    geometricSource = new Cesium.CustomDataSource('geometricSource')
    viewer.dataSources.add(geometricSource)
}
 
// 打开弹框
async function open({ mode, row } = {}) {
    dialogMode.value = mode || 'add'
    visible.value = true
    await nextTick()
    initMap()
    if (dialogMode.value === 'add') {
        formData.value = initForm()
    } else {
        formData.value = row
        await loadDetail()
    }
}
 
defineExpose({ open })
</script>
 
<style scoped lang="scss">
:deep(.alarm-row) {
    background: #2B2B4C !important;
 
    td {
        background-color: transparent !important;
    }
}
</style>