diff --git a/apps/web-antd/src/views/dataManger/deviceData/index.vue b/apps/web-antd/src/views/dataManger/deviceData/index.vue index 507f822..25d8d64 100644 --- a/apps/web-antd/src/views/dataManger/deviceData/index.vue +++ b/apps/web-antd/src/views/dataManger/deviceData/index.vue @@ -219,20 +219,22 @@ const gridOptions: VxeGridProps = { if (!page) { return { items: [], totalCount: 0 }; } + // 获取当前表单值,如果formValues为空则从表单API获取 + const currentFormValues = formValues || (gridApi?.formApi ? await gridApi.formApi.getValues() : {}) || {}; // 处理DeviceType和IoTDataType,确保传递数字类型 - const deviceTypeValue = formValues.DeviceType || DeviceType; + const deviceTypeValue = currentFormValues.DeviceType || DeviceType; const deviceTypeNumber = deviceTypeValue ? Number(deviceTypeValue) : undefined; - const ioTDataTypeValue = formValues.IoTDataType; + const ioTDataTypeValue = currentFormValues.IoTDataType; // 处理DeviceId,当设备类型为集中器(10)时,使用focusId - let finalDeviceId = formValues.DeviceId || DeviceId || ''; - let finalFocusAddress = formValues.FocusAddress || ''; + let finalDeviceId = currentFormValues.DeviceId || DeviceId || ''; + let finalFocusAddress = currentFormValues.FocusAddress || ''; // 优先使用选中的设备信息 - const deviceInfo = selectedDeviceInfo.value || (formValues.DeviceId && deviceOptions.value.length > 0 ? getDeviceInfoById(formValues.DeviceId) : null); + const deviceInfo = selectedDeviceInfo.value || (currentFormValues.DeviceId && deviceOptions.value.length > 0 ? getDeviceInfoById(currentFormValues.DeviceId) : null); if (deviceInfo) { finalFocusAddress = deviceInfo.focusAddress || ''; @@ -259,7 +261,7 @@ const gridOptions: VxeGridProps = { DeviceId: finalDeviceId ? finalDeviceId.toString() : '', FocusAddress: finalFocusAddress || FocusAddress || '', // 添加其他表单参数 - SystemName: formValues.SystemName || SystemName || '', + SystemName: currentFormValues.SystemName || SystemName || '', IoTDataType: ioTDataTypeValue || undefined, }, });