吉安感知网项目-前端
张含笑
2026-01-09 3dbe7bb7d7101cf0f2e4c68bc577323784967199
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
<template>
    <el-dialog v-model="visible" :title="dialogTitle" @closed="handleClosed" destroy-on-close>
        <div>
            <div>无人机名称:{{ formData.droneName }}</div>
            <div>序列号: {{ formData.serialNo }}</div>
            <div>告警时间: {{ formData.alarmTime }}</div>
            <div>触发原因: {{ formData.triggerType }}</div>
            <div>停留时长: {{ formData.stayDuration }}</div>
        </div>
        <el-table :data="list">
            <el-table-column type="index" width="60" label="序号" />
            <el-table-column prop="areaCode" label="areaCode" />
            <el-table-column prop="createTime" label="createTime" />
            <el-table-column prop="latitude" label="latitude" />
            <el-table-column prop="longitude" label="longitude" />
        </el-table>
        <template #footer>
            <el-button @click="handleCancel">{{ dialogReadonly ? '关闭' : '取消' }}</el-button>
        </template>
    </el-dialog>
</template>
 
<script setup>
import { computed, ref } from 'vue'
import { fwDroneFlightRecordDetailApi } from '@/views/recordManage/historyTracks/fwDroneFlightRecord'
import { fwDroneFlightRecordDetailPageApi } from '@/views/recordManage/historyTracks/flyTrajectory'
 
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 ?? []
    formData.value = res?.data?.data ?? {}
}
 
// 关闭后重置
function handleClosed() {
    formData.value = initForm()
}
 
// 打开弹框
async function open({ mode, row } = {}) {
    dialogMode.value = mode || 'add'
    formData.value = row
    visible.value = true
    if (dialogMode.value === 'add') {
        formData.value = initForm()
    } else {
        await loadDetail()
    }
}
 
defineExpose({ open })
</script>