refactor:
- extend NdmDeviceAlarmLogVO - only query alarm counts - separate request and store update in useQuery - refactor station card and alarm modal, data fetching is now inside modal - optimize device tree - optimize query station list - make export size follow page size - fix query sequence and make them follow stations -> devices -> alarms
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import type { NdmDeviceAlarmLogResultVO } from '@/apis/models';
|
||||
import { ndmDeviceAlarmLogDefaultExportByTemplate, postNdmDeviceAlarmLogPage } from '@/apis/requests';
|
||||
import { JAVA_INTEGER_MAX_VALUE } from '@/constants';
|
||||
import { DeviceType, DeviceTypeCode, DeviceTypeName, type DeviceTypeVal } from '@/enums/device-type';
|
||||
import { useCurrentAlarmsStore } from '@/stores/current-alarms';
|
||||
import { useStationStore } from '@/stores/station';
|
||||
@@ -140,18 +139,18 @@ const { mutate: getAlarmList, isPending: isTableLoading } = useMutation({
|
||||
alarmDate_ge: searchFields.alarmDate[0],
|
||||
alarmDate_le: searchFields.alarmDate[1],
|
||||
},
|
||||
size: tablePagination.pageSize!,
|
||||
current: tablePagination.page!,
|
||||
sort: 'id',
|
||||
current: tablePagination.page ?? 1,
|
||||
size: tablePagination.pageSize ?? 10,
|
||||
order: 'descending',
|
||||
sort: 'id',
|
||||
});
|
||||
return res;
|
||||
},
|
||||
onSuccess: (res) => {
|
||||
const { records, pages, size, total } = res;
|
||||
tablePagination.pageSize = parseInt(size);
|
||||
tablePagination.pageCount = parseInt(pages);
|
||||
tablePagination.itemCount = parseInt(total);
|
||||
return records;
|
||||
},
|
||||
onSuccess: (records) => {
|
||||
tableData.value = records;
|
||||
},
|
||||
onError: (error) => {
|
||||
@@ -180,10 +179,10 @@ const { mutate: downloadTableData, isPending: isDownloading } = useMutation({
|
||||
alarmDate_ge: searchFields.alarmDate[0],
|
||||
alarmDate_le: searchFields.alarmDate[1],
|
||||
},
|
||||
current: 1,
|
||||
size: JAVA_INTEGER_MAX_VALUE,
|
||||
sort: 'id',
|
||||
current: tablePagination.page ?? 1,
|
||||
size: tablePagination.pageSize ?? 10,
|
||||
order: 'descending',
|
||||
sort: 'id',
|
||||
});
|
||||
return data;
|
||||
},
|
||||
@@ -255,7 +254,7 @@ onBeforeMount(() => getAlarmList());
|
||||
|
||||
<!-- 表格区域:填满剩余空间 -->
|
||||
<div style="flex: 1 1 auto; min-height: 0; padding: 8px">
|
||||
<NDataTable remote :columns="tableColumns" :data="tableData" :pagination="tablePagination" :loading="isTableLoading" :single-line="false" flex-height style="height: 100%" />
|
||||
<NDataTable :loading="isTableLoading" :columns="tableColumns" :data="tableData" :pagination="tablePagination" :single-line="false" remote flex-height style="height: 100%" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -4,27 +4,27 @@ import DeviceAlarmDetailModal from '@/components/dashboard-page/device-alarm-det
|
||||
import DeviceParamsConfigModal from '@/components/dashboard-page/device-params-config-modal.vue';
|
||||
import OfflineDeviceDetailModal from '@/components/dashboard-page/offline-device-detail-modal.vue';
|
||||
import StationCard from '@/components/dashboard-page/station-card.vue';
|
||||
import { useLineAlarmsQuery, useLineDevicesQuery } from '@/composables/query';
|
||||
import { useLineAlarmCountsQuery, useLineDevicesQuery } from '@/composables/query';
|
||||
import { useStationStore } from '@/stores/station';
|
||||
import { useLineDevicesStore } from '@/stores/line-devices';
|
||||
import { useLineAlarmsStore } from '@/stores/line-alarms';
|
||||
import { NGrid, NGi } from 'naive-ui';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { ref, watch } from 'vue';
|
||||
import { useLineAlarmCountsStore } from '@/stores/line-alarm-counts';
|
||||
|
||||
const stationStore = useStationStore();
|
||||
const { stationList } = storeToRefs(stationStore);
|
||||
const lineDevicesStore = useLineDevicesStore();
|
||||
const { lineDevices } = storeToRefs(lineDevicesStore);
|
||||
const lineAlarmsStore = useLineAlarmsStore();
|
||||
const { lineAlarms } = storeToRefs(lineAlarmsStore);
|
||||
const lineAlarmCountsStore = useLineAlarmCountsStore();
|
||||
const { lineAlarmCounts } = storeToRefs(lineAlarmCountsStore);
|
||||
|
||||
const { isFetching: lineDevicesFetching } = useLineDevicesQuery();
|
||||
const { isFetching: lineAlarmsFetching } = useLineAlarmsQuery();
|
||||
const { isFetching: lineAlarmCountsFetching } = useLineAlarmCountsQuery();
|
||||
|
||||
// 当设备查询或告警查询正在进行时,显示加载条
|
||||
watch(
|
||||
[lineDevicesFetching, lineAlarmsFetching],
|
||||
[lineDevicesFetching, lineAlarmCountsFetching],
|
||||
(fetchingList) => {
|
||||
if (fetchingList.some((pending) => pending)) {
|
||||
window.$loadingBar.start();
|
||||
@@ -61,7 +61,7 @@ const openDeviceParamsConfigModal = (station: Station) => {
|
||||
<StationCard
|
||||
:station="station"
|
||||
:station-devices="lineDevices[station.code]"
|
||||
:station-alarms="lineAlarms[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"
|
||||
@@ -72,7 +72,7 @@ const openDeviceParamsConfigModal = (station: Station) => {
|
||||
<!-- 离线设备详情对话框 -->
|
||||
<OfflineDeviceDetailModal v-model:show="offlineDeviceTreeModalShow" :station="selectedStation" :station-devices="selectedStation?.code ? lineDevices[selectedStation.code] : undefined" />
|
||||
<!-- 设备告警详情对话框 -->
|
||||
<DeviceAlarmDetailModal v-model:show="deviceAlarmTreeModalShow" :station="selectedStation" :station-alarms="selectedStation?.code ? lineAlarms[selectedStation.code] : undefined" />
|
||||
<DeviceAlarmDetailModal v-model:show="deviceAlarmTreeModalShow" :station="selectedStation" :station-alarm-counts="selectedStation?.code ? lineAlarmCounts[selectedStation.code] : undefined" />
|
||||
<!-- 设备配置面板对话框 -->
|
||||
<DeviceParamsConfigModal v-model:show="deviceParamsConfigModalShow" :station="selectedStation" />
|
||||
</template>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
import type { NdmVimpLogResultVO } from '@/apis/models/device';
|
||||
import { ndmVimpLogDefaultExportByTemplate, postNdmVimpLogPage } from '@/apis/requests';
|
||||
import { useStationListQuery } from '@/composables/query';
|
||||
import { JAVA_INTEGER_MAX_VALUE } from '@/constants';
|
||||
import { useStationStore } from '@/stores/station';
|
||||
import { downloadByData } from '@/utils/download';
|
||||
import { useMutation } from '@tanstack/vue-query';
|
||||
@@ -79,25 +78,25 @@ const tablePagination = reactive<PaginationProps>({
|
||||
|
||||
const { mutate: getVimpLogList, isPending: isTableLoading } = useMutation({
|
||||
mutationFn: async () => {
|
||||
if (!searchFields.stationCode) return [];
|
||||
if (!searchFields.stationCode) throw Error('请选择车站');
|
||||
const res = await postNdmVimpLogPage(searchFields.stationCode, {
|
||||
model: {},
|
||||
extra: {
|
||||
createdTime_precisest: searchFields.createdTime[0],
|
||||
createdTime_preciseed: searchFields.createdTime[1],
|
||||
},
|
||||
size: tablePagination.pageSize!,
|
||||
current: tablePagination.page!,
|
||||
sort: 'id',
|
||||
current: tablePagination.page ?? 1,
|
||||
size: tablePagination.pageSize ?? 10,
|
||||
order: 'descending',
|
||||
sort: 'id',
|
||||
});
|
||||
return res;
|
||||
},
|
||||
onSuccess: (res) => {
|
||||
const { records, pages, size, total } = res;
|
||||
tablePagination.pageSize = parseInt(size);
|
||||
tablePagination.pageCount = parseInt(pages);
|
||||
tablePagination.itemCount = parseInt(total);
|
||||
return records;
|
||||
},
|
||||
onSuccess: (records) => {
|
||||
tableData.value = records;
|
||||
},
|
||||
onError: (error) => {
|
||||
@@ -124,10 +123,10 @@ const { mutate: downloadTableData, isPending: isDownloading } = useMutation({
|
||||
createdTime_precisest: searchFields.createdTime[0],
|
||||
createdTime_preciseed: searchFields.createdTime[1],
|
||||
},
|
||||
current: 1,
|
||||
size: JAVA_INTEGER_MAX_VALUE,
|
||||
sort: 'id',
|
||||
current: tablePagination.page ?? 1,
|
||||
size: tablePagination.pageSize ?? 10,
|
||||
order: 'descending',
|
||||
sort: 'id',
|
||||
});
|
||||
return data;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user