修复设备数据重复查询的问题

This commit is contained in:
ChenYi 2026-07-09 16:46:16 +08:00
parent fb2f3a1da1
commit 61a3e7e594
2 changed files with 22 additions and 2 deletions

View File

@ -104,6 +104,10 @@ const fetchData = async () => {
} }
}; };
// ioTDataType props.value immediate fetchData
// DevicePatchListAsync query
const scheduleFetch = useDebounceFn(() => fetchData(), 100);
/** /**
* 处理搜索输入 * 处理搜索输入
*/ */
@ -145,7 +149,7 @@ watch(
searchInput.value = ''; searchInput.value = '';
pendingAutoSelectFirst.value = !!props.value; pendingAutoSelectFirst.value = !!props.value;
if (newVal) { if (newVal) {
fetchData(); scheduleFetch();
} else { } else {
options.value = []; options.value = [];
total.value = 0; total.value = 0;
@ -172,7 +176,7 @@ watch(
query.value.pageIndex = 1; query.value.pageIndex = 1;
query.value.deviceAddress = newVal; query.value.deviceAddress = newVal;
pendingAutoSelectFirst.value = true; pendingAutoSelectFirst.value = true;
fetchData(); scheduleFetch();
}, },
{ immediate: true }, { immediate: true },
); );

View File

@ -111,12 +111,25 @@ const isInitializing = ref(false);
// //
// //
// //
//
// DeviceDataInfoPage
const lastReloadSig = ref<string>('');
const debouncedReload = useDebounceFn(async () => { const debouncedReload = useDebounceFn(async () => {
if (!gridApi?.formApi) { if (!gridApi?.formApi) {
return; return;
} }
const values = await gridApi.formApi.getValues(); const values = await gridApi.formApi.getValues();
if (values.DeviceAddress && values.IoTDataType) { if (values.DeviceAddress && values.IoTDataType) {
const sig = [
values.IoTDataType,
values.DeviceAddress,
values.StartCreationTime,
values.EndCreationTime,
].join('|');
if (sig === lastReloadSig.value) {
return;
}
lastReloadSig.value = sig;
gridApi.reload(values); gridApi.reload(values);
} }
}, 200); }, 200);
@ -193,6 +206,9 @@ const gridOptions: VxeGridProps<any> = {
showOverflow: true, showOverflow: true,
showHeaderOverflow: true, showHeaderOverflow: true,
proxyConfig: { proxyConfig: {
//
// DevicePath 204
autoLoad: false,
ajax: { ajax: {
query: async ({ page, sorts, filters }, formValues) => { query: async ({ page, sorts, filters }, formValues) => {
// page // page