perf: set default date range to 1 week in HistoryDiagCard
This commit is contained in:
@@ -9,13 +9,13 @@ function getValueByFieldPath(record: Record<string, any>, fieldPath?: string) {
|
||||
import type { NdmDeviceResultVO, NdmSnmpLogResultVO } from '@/apis/models';
|
||||
import { useDeviceSnmpLogsQuery } from '@/composables/query';
|
||||
import { destr } from 'destr';
|
||||
import { NCard, NDataTable, type DataTableColumns, type DataTableRowData, type PaginationProps } from 'naive-ui';
|
||||
import { NCard, NDataTable, type DataTableColumns, type DataTableRowData, type DatePickerProps, type PaginationProps } from 'naive-ui';
|
||||
import { computed, h, reactive, toRefs, watch } from 'vue';
|
||||
|
||||
const props = defineProps<{
|
||||
stationCode: string;
|
||||
ndmDevice: NdmDeviceResultVO;
|
||||
dateTimeRange: [number, number];
|
||||
dateTimeRange: DatePickerProps['value'];
|
||||
cpuUsageField?: string;
|
||||
memUsageField?: string;
|
||||
diskUsageField?: string;
|
||||
@@ -59,7 +59,7 @@ const pagination = reactive<PaginationProps>({
|
||||
const page = computed(() => pagination.page ?? 1);
|
||||
const pageSize = computed(() => pagination.pageSize ?? DEFAULT_PAGE_SIZE);
|
||||
|
||||
const { snmpLogRespData, isPending, refresh } = useDeviceSnmpLogsQuery(stationCode, ndmDevice, dateTimeRange, page, pageSize);
|
||||
const { snmpLogRespData, isPending, refetch } = useDeviceSnmpLogsQuery(stationCode, ndmDevice, dateTimeRange, page, pageSize);
|
||||
|
||||
watch(snmpLogRespData, (data) => {
|
||||
if (data) {
|
||||
@@ -86,7 +86,14 @@ const tableData = computed<DataTableRowData[]>(() => {
|
||||
|
||||
defineExpose({
|
||||
isPending,
|
||||
refresh,
|
||||
refresh: () => {
|
||||
if (pagination.page !== 1 || pagination.pageSize !== DEFAULT_PAGE_SIZE) {
|
||||
pagination.page = 1;
|
||||
pagination.pageSize = DEFAULT_PAGE_SIZE;
|
||||
} else {
|
||||
refetch();
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user