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:
yangsy
2025-09-02 14:21:13 +08:00
parent 54a150ec07
commit 7afb79f826
21 changed files with 475 additions and 439 deletions

View File

@@ -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;
},