applications/drone-command/src/views/basicManage/deviceStock/deviceStock.vue
@@ -33,6 +33,21 @@ </el-form-item> </el-col> <el-col :span="4"> <el-form-item label="时间" prop="belongDept"> <el-date-picker popper-class="ztzf-date-picker-popper" class="ztzf-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-col> <el-col :span="4"> <el-form-item> <el-button @click="resetForm">重置</el-button> <el-button type="primary" @click="handleSearch">查询</el-button> @@ -42,6 +57,7 @@ </el-form> <div> <el-button type="primary" @click="handleAdd">新增</el-button> <el-button type="primary" @click="exportFile" :loading="exportLoading">导出</el-button> <el-button type="danger" :disabled="!selectedIds.length" @click="handleDelete()">删除</el-button> </div> <el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange"> @@ -79,11 +95,11 @@ <script setup> import { onMounted, ref } from 'vue' import { ElMessage, ElMessageBox } from 'element-plus' import { fwDevicePageApi, fwDeviceRemoveApi } from '@/views/basicManage/deviceStock/fwDevice' import { exportFwDeviceApi, fwDevicePageApi, fwDeviceRemoveApi } from '@/views/basicManage/deviceStock/fwDevice' import FormDiaLog from './FormDiaLog.vue' import { getDictionaryByCode } from '@/api/system/dictbiz' import { getDeptTree } from '@/api/system/dept' import { getDictLabel } from '@ztzf/utils' import { blobDownload, dateRangeFormat, getDictLabel } from '@ztzf/utils' const initSearchParams = () => ({ deviceName: '', // 设备名称 @@ -103,19 +119,22 @@ deviceType: [], //设备类型 deviceAtt: [], //设备属性 }) const dateRange = ref([]) const deptTree = ref([]) const treeProps = { label: 'name', children: 'children', } const exportLoading = ref(false) provide('dictObj', dictObj) provide('deptTree', deptTree) // 获取列表 async function getList() { const range = dateRangeFormat(dateRange.value) loading.value = true try { const res = await fwDevicePageApi(searchParams.value) const res = await fwDevicePageApi({ ...searchParams.value, start_time: range[0], end_time: range[1] }) list.value = res?.data?.data?.records ?? [] total.value = res?.data?.data?.total ?? 0 } finally { @@ -131,6 +150,7 @@ // 重置查询 function resetForm() { dateRange.value = [] queryParamsRef.value?.resetFields() searchParams.value.current = 1 getList() @@ -162,6 +182,17 @@ selectedIds.value = rows.map(item => item.id) } function exportFile() { exportLoading.value = true exportFwDeviceApi() .then(res => { blobDownload(res) }) .finally(() => { exportLoading.value = false }) } // 获取字典 function getDictList() { getDictionaryByCode('deviceType,deviceAtt').then(res => { applications/drone-command/src/views/basicManage/deviceStock/fwDevice.js
@@ -35,3 +35,12 @@ params, }) } //导出 export const exportFwDeviceApi = () => { return request({ url: `/drone-fw/record/fwDroneAlarmRecord/export-fwDroneAlarmRecord`, method: 'get', responseType: 'blob', }) } applications/drone-command/src/views/recordManage/alarmRecords/alarmRecords.vue
@@ -32,6 +32,9 @@ </el-col> </el-row> </el-form> <div> <el-button type="primary" @click="exportFile" :loading="exportLoading">导出</el-button> </div> <el-table v-loading="loading" :data="list"> <el-table-column type="index" width="60" label="序号" /> @@ -46,7 +49,7 @@ {{ getDeviceTypeName(row.droneType) }} </template> </el-table-column> <el-table-column prop="deviceCode" label="设备编码"/> <el-table-column prop="deviceCode" label="设备编码" /> <el-table-column label="设备状态"> <template v-slot="{ row }"> {{ getDeviceStatus(row) }} @@ -75,8 +78,9 @@ <script setup> import { computed, onMounted, ref } from 'vue' import { getDictionaryByCode } from '@/api/system/dictbiz' import { fwDroneAlarmRecordPageApi } from './fwDroneAlarmRecord' import { exportFwDroneAlarmRecordApi, fwDroneAlarmRecordPageApi } from './fwDroneAlarmRecord' import FormDiaLog from './FormDiaLog.vue' import { blobDownload } from '@ztzf/utils' const initSearchParams = () => ({ droneName: '', // 无人机名称 @@ -94,6 +98,7 @@ const dictObj = ref({ deviceType: [], }) const exportLoading = ref(false) const deviceTypeMap = computed(() => { const map = new Map() dictObj.value.deviceType.forEach(item => { @@ -132,6 +137,17 @@ dialogRef.value?.open({ mode: 'view', row: { ...row } }) } function exportFile() { exportLoading.value = true exportFwDroneAlarmRecordApi() .then(res => { blobDownload(res) }) .finally(() => { exportLoading.value = false }) } function getDeviceStatus(row) { return row.deviceStatus ?? row.status ?? '-' } applications/drone-command/src/views/recordManage/alarmRecords/fwDroneAlarmRecord.js
@@ -35,3 +35,12 @@ params, }) } //导出 export const exportFwDroneAlarmRecordApi = () => { return request({ url: `/drone-fw/record/fwDroneAlarmRecord/export-fwDroneAlarmRecord`, method: 'get', responseType: 'blob', }) } packages/utils/common/index.js
@@ -9,3 +9,17 @@ export function getDictLabel(value, dictList) { return dictList.find(item => item.dictKey === value)?.dictValue || value || '-' } export function blobDownload(res) { const disposition = res.headers?.['content-disposition'] || res.headers?.['Content-Disposition'] const encodedName = disposition.split('filename=')[1] const filename = decodeURIComponent(encodedName) const elink = document.createElement('a') elink.download = filename elink.style.display = 'none' const blob = new Blob([res.data]) elink.href = URL.createObjectURL(blob) document.body.appendChild(elink) elink.click() document.body.removeChild(elink) }