修复设备管理界面数据查看跳转数据获取失败的问题

This commit is contained in:
ChenYi 2026-07-09 11:51:51 +08:00
parent 474f4347ee
commit fb2f3a1da1

View File

@ -7,6 +7,8 @@ import { useRoute } from 'vue-router';
import { Page } from '@vben/common-ui';
import { useDebounceFn } from '@vueuse/core';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import {
postTreeModelDeviceDataInfoPage,
@ -106,6 +108,19 @@ const isGridInitialized = ref(false);
//
const isInitializing = ref(false);
//
//
//
const debouncedReload = useDebounceFn(async () => {
if (!gridApi?.formApi) {
return;
}
const values = await gridApi.formApi.getValues();
if (values.DeviceAddress && values.IoTDataType) {
gridApi.reload(values);
}
}, 200);
const formOptions: VbenFormProps = {
schema: querySchema.value,
initialValues: {
@ -116,14 +131,12 @@ const formOptions: VbenFormProps = {
submitOnChange: false,
//
handleValuesChange: async (values, changedFields) => {
//
if (isInitializing.value) {
console.log('初始化中,跳过表单值变化处理');
return;
}
// IoTDataType DeviceAddress
// IoTDataType DeviceAddress
//
if (changedFields.includes('IoTDataType')) {
if (isInitializing.value) {
return;
}
const currentValues = await gridApi.formApi.getValues();
if (currentValues.DeviceAddress) {
await gridApi.formApi.setFieldValue('DeviceAddress', undefined);
@ -131,18 +144,17 @@ const formOptions: VbenFormProps = {
return;
}
// DeviceAddress IoTDataType
// DeviceAddress IoTDataType
// DeviceDataInfoPage
if (changedFields.includes('DeviceAddress')) {
const currentValues = await gridApi.formApi.getValues();
if (currentValues.DeviceAddress && currentValues.IoTDataType) {
setTimeout(() => {
gridApi.reload(currentValues);
}, 0);
}
debouncedReload();
return;
}
//
//
if (isInitializing.value) {
return;
}
const relevantFields = new Set([
'EndCreationTime',
'StartCreationTime',
@ -152,12 +164,7 @@ const formOptions: VbenFormProps = {
);
if (hasRelevantChange) {
const currentValues = await gridApi.formApi.getValues();
if (currentValues.DeviceAddress && currentValues.IoTDataType) {
setTimeout(() => {
gridApi.reload(currentValues);
}, 0);
}
debouncedReload();
}
},
};
@ -383,12 +390,9 @@ const initializeGrid = async () => {
isInitializing.value = false;
// handleValuesChange
// reload
// handleValuesChange
if (updatedValues.IoTDataType && updatedValues.DeviceAddress) {
await gridApi.reload();
}
//
//
debouncedReload();
} else {
isInitializing.value = false;
}