<template>
|
<basic-container>
|
<el-form ref="queryParamsRef" :model="searchParams" class="command-page-history-search">
|
<el-form-item label="无人机名称" prop="droneName">
|
<el-input
|
class="command-input"
|
v-model="searchParams.droneName"
|
placeholder="请输入"
|
clearable
|
@clear="handleSearch"
|
/>
|
</el-form-item>
|
<el-form-item label="区域" prop="areaName">
|
<el-input
|
class="command-input"
|
v-model="searchParams.areaName"
|
placeholder="请输入"
|
clearable
|
@clear="handleSearch"
|
/>
|
</el-form-item>
|
<el-form-item label="告警时间">
|
<el-date-picker
|
popper-class="command-date-picker-popper"
|
class="command-date-picker"
|
v-model="dateRange"
|
type="daterange"
|
range-separator="至"
|
start-placeholder="开始日期"
|
end-placeholder="结束日期"
|
value-format="YYYY-MM-DD HH:mm:ss"
|
@change="handleSearch"
|
/>
|
</el-form-item>
|
<el-form-item class="history-search-actions">
|
<el-button :icon="RefreshRight" @click="resetForm"></el-button>
|
<el-button class="search-btn" :icon="Search" @click="handleSearch"></el-button>
|
</el-form-item>
|
</el-form>
|
|
<div class="command-table-toolbar">
|
<el-button
|
:icon="Download"
|
color="#1A2652"
|
type="primary"
|
@click="exportFile"
|
:loading="exportLoading"
|
:disabled="!selectionList.length"
|
>
|
导出
|
</el-button>
|
</div>
|
|
<div class="command-table-container" v-loading="loading" element-loading-background="rgba(5, 5, 15, 0.6)">
|
<div class="command-table-content command-table-content-bg">
|
<el-table class="command-table" :data="list" ref="tableRef" @selection-change="handleSelectionChange">
|
<el-table-column type="selection" width="48" />
|
<el-table-column type="index" show-overflow-tooltip width="64" label="序号" />
|
<el-table-column prop="droneName" show-overflow-tooltip width="140" label="无人机名称" />
|
<el-table-column prop="serialNo" show-overflow-tooltip label="无人机序列号" />
|
<el-table-column prop="alarmTime" show-overflow-tooltip label="告警时间" />
|
<el-table-column prop="areaName" show-overflow-tooltip label="区域" />
|
<el-table-column prop="triggerType" show-overflow-tooltip label="触发原因" />
|
<el-table-column show-overflow-tooltip label="停留时长">
|
<template v-slot="{ row }">
|
{{ formatStayDuration(row.stayDuration) }}
|
</template>
|
</el-table-column>
|
<el-table-column label="操作" class-name="operation-btns">
|
<template v-slot="{ row }">
|
<el-link @click="handleView(row)">历史轨迹</el-link>
|
</template>
|
</el-table-column>
|
</el-table>
|
</div>
|
|
<div class="command-table-pagination">
|
<el-pagination
|
popper-class="command-select-popper"
|
v-model:current-page="searchParams.current"
|
v-model:page-size="searchParams.size"
|
layout="total, prev, pager, next, sizes"
|
:total="total"
|
@change="getList"
|
/>
|
</div>
|
</div>
|
|
<TrajectoryDiaLog ref="dialogRef" />
|
</basic-container>
|
</template>
|
|
<script setup>
|
import { Search, RefreshRight, Download } from '@element-plus/icons-vue'
|
import { onMounted, ref, nextTick } from 'vue'
|
import { exportFwDroneFlightRecordApi, fwDroneFlightRecordPageApi } from './fwDroneFlightRecord'
|
import { blobDownload, dateRangeFormat } from '@ztzf/utils'
|
import { saveOperationLog } from '@ztzf/apis'
|
import { useRoute } from 'vue-router'
|
import TrajectoryDiaLog from '@/views/recordManage/historyTracks/TrajectoryDiaLog.vue'
|
|
const initSearchParams = () => ({
|
droneName: '', // 无人机名称
|
areaName: '', // 区域
|
current: 1, // 当前页
|
size: 10, // 每页大小
|
})
|
const searchParams = ref(initSearchParams()) // 查询参数
|
const total = ref(0) // 总条数
|
const loading = ref(true) // 列表加载中
|
const list = ref([]) // 列表数据
|
const tableRef = ref(null)
|
const selectionList = ref([])
|
const queryParamsRef = ref(null) // 查询表单实例
|
const dateRange = ref([])
|
const exportLoading = ref(false)
|
const dialogRef = ref(null) // 弹框实例
|
const route = useRoute()
|
|
// 获取列表
|
async function getList() {
|
const range = dateRangeFormat(dateRange.value)
|
loading.value = true
|
try {
|
const params = { ...searchParams.value, startTime: range?.[0], endTime: range?.[1] }
|
const res = await fwDroneFlightRecordPageApi(params)
|
list.value = res?.data?.data?.records ?? []
|
total.value = res?.data?.data?.total ?? 0
|
selectionList.value = []
|
await nextTick()
|
tableRef.value?.clearSelection()
|
} finally {
|
loading.value = false
|
}
|
}
|
|
// 查询
|
function handleSearch() {
|
searchParams.value.current = 1
|
getList()
|
}
|
|
// 重置查询
|
function resetForm() {
|
dateRange.value = []
|
queryParamsRef.value?.resetFields()
|
searchParams.value.current = 1
|
getList()
|
}
|
|
function formatStayDuration(value) {
|
if (!value) return '-'
|
if (typeof value == 'string') return value
|
const hour = String(value.hour ?? 0).padStart(2, '0')
|
const minute = String(value.minute ?? 0).padStart(2, '0')
|
const second = String(value.second ?? 0).padStart(2, '0')
|
return `${hour}:${minute}:${second}`
|
}
|
|
function exportFile() {
|
const range = dateRangeFormat(dateRange.value)
|
const ids = selectionList.value.map(item => item.id).filter(Boolean)
|
exportLoading.value = true
|
exportFwDroneFlightRecordApi({
|
...searchParams.value,
|
start_time: range?.[0],
|
end_time: range?.[1],
|
ids: ids.join(','),
|
})
|
.then(res => {
|
saveOperationLog({
|
requestUri: route.path,
|
title: `${route.name || '历史轨迹'}-导出`,
|
type: 1,
|
})
|
blobDownload(res)
|
})
|
.finally(() => {
|
exportLoading.value = false
|
})
|
}
|
|
function handleSelectionChange(selection) {
|
selectionList.value = selection || []
|
}
|
|
function handleView(row) {
|
dialogRef.value?.open({ mode: 'view', row: { ...row } })
|
}
|
|
onMounted(() => {
|
getList()
|
})
|
</script>
|
<style scoped lang="scss"></style>
|