refactor: remove /dashboard, migrate icmp-export
This commit is contained in:
@@ -1,63 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { exportIcmpApi } from '@/apis';
|
||||
import { DeviceStatisticCard } from '@/components';
|
||||
import { useLineAlarmsQuery, useLineDevicesQuery } from '@/composables';
|
||||
import { useDeviceStore, useStationStore } from '@/stores';
|
||||
import { downloadByData } from '@/utils';
|
||||
import { useMutation } from '@tanstack/vue-query';
|
||||
import dayjs from 'dayjs';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { watch } from 'vue';
|
||||
|
||||
const stationStore = useStationStore();
|
||||
const { stationList } = storeToRefs(stationStore);
|
||||
const lineDevicesStore = useDeviceStore();
|
||||
const { lineDevices } = storeToRefs(lineDevicesStore);
|
||||
|
||||
const { error: lineDevicesQueryError } = useLineDevicesQuery();
|
||||
const { error: lineAlarmsQueryError } = useLineAlarmsQuery();
|
||||
|
||||
watch([lineDevicesQueryError, lineAlarmsQueryError], ([newLineDevicesQueryError, newLineAlarmsQueryError]) => {
|
||||
if (newLineDevicesQueryError) {
|
||||
window.$message.error(newLineDevicesQueryError.message);
|
||||
}
|
||||
if (newLineAlarmsQueryError) {
|
||||
window.$message.error(newLineAlarmsQueryError.message);
|
||||
}
|
||||
});
|
||||
|
||||
const { mutate: exportDevices, isPending: exporting } = useMutation({
|
||||
mutationFn: async (params: { status: string }) => {
|
||||
const data = await exportIcmpApi(params.status);
|
||||
return data;
|
||||
},
|
||||
onSuccess: (data, variables) => {
|
||||
const { status } = variables;
|
||||
let fileName = '全部设备列表';
|
||||
if (status === '10') {
|
||||
fileName = '在线设备列表';
|
||||
} else if (status === '20') {
|
||||
fileName = '离线设备列表';
|
||||
}
|
||||
const time = dayjs().format('YYYY-MM-DD_HH-mm-ss');
|
||||
downloadByData(data, `${fileName}_${time}.xlsx`);
|
||||
},
|
||||
onError: (error) => {
|
||||
console.error(error);
|
||||
window.$message.error(error.message);
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DeviceStatisticCard
|
||||
:station-list="stationList"
|
||||
:line-devices="lineDevices"
|
||||
:button-loading="exporting"
|
||||
@export-all="() => exportDevices({ status: '' })"
|
||||
@export-online="() => exportDevices({ status: '10' })"
|
||||
@export-offline="() => exportDevices({ status: '20' })"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
@@ -1,9 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import type { Station } from '@/apis';
|
||||
import { DeviceAlarmDetailModal, DeviceParamsConfigModal, OfflineDeviceDetailModal, StationCard } from '@/components';
|
||||
import { DeviceAlarmDetailModal, DeviceExportModal, DeviceParamsConfigModal, OfflineDeviceDetailModal, StationCard } from '@/components';
|
||||
import { useLineAlarmsQuery, useLineDevicesQuery } from '@/composables';
|
||||
import { useAlarmStore, useDeviceStore, useSettingStore, useStationStore } from '@/stores';
|
||||
import { NGrid, NGi } from 'naive-ui';
|
||||
import { NGrid, NGi, NScrollbar, NFlex, NButtonGroup, NButton } from 'naive-ui';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { ref, watch } from 'vue';
|
||||
|
||||
@@ -28,6 +28,14 @@ watch([lineDevicesQueryError, lineAlarmsQueryError], ([newLineDevicesQueryError,
|
||||
}
|
||||
});
|
||||
|
||||
const stationSelectable = ref(false);
|
||||
const selectedStations = ref<Record<Station['code'], boolean>>({});
|
||||
const showActionConfirm = ref(false);
|
||||
const showDeviceExportModal = ref(false);
|
||||
const openDeviceExportModal = () => {
|
||||
showDeviceExportModal.value = true;
|
||||
};
|
||||
|
||||
const selectedStation = ref<Station>();
|
||||
const offlineDeviceTreeModalShow = ref(false);
|
||||
const deviceAlarmTreeModalShow = ref(false);
|
||||
@@ -47,18 +55,31 @@ const openDeviceParamsConfigModal = (station: Station) => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NGrid :cols="stationGridColumns" :x-gap="6" :y-gap="6" style="padding: 8px">
|
||||
<NGi v-for="station in stationList" :key="station.code">
|
||||
<StationCard
|
||||
:station="station"
|
||||
:station-devices="lineDevices[station.code]"
|
||||
:station-alarm-counts="lineAlarmCounts[station.code]"
|
||||
@open-offline-device-detail-modal="openOfflineDeviceDetailModal"
|
||||
@open-device-alarm-detail-modal="openDeviceAlarmDetailModal"
|
||||
@open-device-params-config-modal="openDeviceParamsConfigModal"
|
||||
/>
|
||||
</NGi>
|
||||
</NGrid>
|
||||
<NScrollbar content-style="padding-right: 8px" style="width: 100%; height: 100%">
|
||||
<NFlex justify="space-between" align="center" style="padding: 8px 8px 0 8px">
|
||||
<NButtonGroup>
|
||||
<NButton secondary :focusable="false" @click="openDeviceExportModal">导出设备状态</NButton>
|
||||
<NButton v-if="false">导出录像诊断</NButton>
|
||||
<NButton v-if="false">同步摄像机</NButton>
|
||||
</NButtonGroup>
|
||||
<NFlex v-if="showActionConfirm" size="small">
|
||||
<NButton quaternary size="small" type="primary" :focusable="false">确定</NButton>
|
||||
<NButton quaternary size="small" type="tertiary" :focusable="false">取消</NButton>
|
||||
</NFlex>
|
||||
</NFlex>
|
||||
<NGrid :cols="stationGridColumns" :x-gap="6" :y-gap="6" style="padding: 8px">
|
||||
<NGi v-for="station in stationList" :key="station.code">
|
||||
<StationCard
|
||||
:station="station"
|
||||
:station-devices="lineDevices[station.code]"
|
||||
:station-alarm-counts="lineAlarmCounts[station.code]"
|
||||
@open-offline-device-detail-modal="openOfflineDeviceDetailModal"
|
||||
@open-device-alarm-detail-modal="openDeviceAlarmDetailModal"
|
||||
@open-device-params-config-modal="openDeviceParamsConfigModal"
|
||||
/>
|
||||
</NGi>
|
||||
</NGrid>
|
||||
</NScrollbar>
|
||||
|
||||
<!-- 离线设备详情对话框 -->
|
||||
<OfflineDeviceDetailModal v-model:show="offlineDeviceTreeModalShow" :station="selectedStation" :station-devices="selectedStation?.code ? lineDevices[selectedStation.code] : undefined" />
|
||||
@@ -66,6 +87,8 @@ const openDeviceParamsConfigModal = (station: Station) => {
|
||||
<DeviceAlarmDetailModal v-model:show="deviceAlarmTreeModalShow" :station="selectedStation" :station-alarm-counts="selectedStation?.code ? lineAlarmCounts[selectedStation.code] : undefined" />
|
||||
<!-- 设备配置面板对话框 -->
|
||||
<DeviceParamsConfigModal v-model:show="deviceParamsConfigModalShow" :station="selectedStation" />
|
||||
<!-- 设备状态导出对话框 -->
|
||||
<DeviceExportModal v-model:show="showDeviceExportModal" />
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
|
||||
Reference in New Issue
Block a user