修复bug
This commit is contained in:
parent
92c14fe460
commit
ba7ebdb348
@ -43,6 +43,9 @@ const fetchDeviceOptions = async () => {
|
|||||||
|
|
||||||
// 根据设备ID获取设备信息对象
|
// 根据设备ID获取设备信息对象
|
||||||
const getDeviceInfoById = (deviceId: string) => {
|
const getDeviceInfoById = (deviceId: string) => {
|
||||||
|
if (!deviceId || !deviceOptions.value || deviceOptions.value.length === 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return deviceOptions.value.find((device) => device.id === deviceId);
|
return deviceOptions.value.find((device) => device.id === deviceId);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -116,7 +119,7 @@ const formOptions: VbenFormProps = {
|
|||||||
|
|
||||||
if (deviceId) {
|
if (deviceId) {
|
||||||
// 先尝试从 deviceOptions 中查找(备用方案)
|
// 先尝试从 deviceOptions 中查找(备用方案)
|
||||||
let device = deviceOptions.value.find(d => d.id === deviceId);
|
let device = deviceOptions.value.length > 0 ? deviceOptions.value.find(d => d.id === deviceId) : null;
|
||||||
|
|
||||||
// 如果没找到,尝试从 DeviceSelect 组件中获取
|
// 如果没找到,尝试从 DeviceSelect 组件中获取
|
||||||
if (!device && gridApi?.formApi) {
|
if (!device && gridApi?.formApi) {
|
||||||
@ -206,14 +209,14 @@ const gridOptions: VxeGridProps<any> = {
|
|||||||
const ioTDataTypeValue = formValues.IoTDataType;
|
const ioTDataTypeValue = formValues.IoTDataType;
|
||||||
|
|
||||||
// 处理DeviceId,当设备类型为集中器(10)时,使用focusId
|
// 处理DeviceId,当设备类型为集中器(10)时,使用focusId
|
||||||
let finalDeviceId = formValues.DeviceId || DeviceId;
|
let finalDeviceId = formValues.DeviceId || DeviceId || '';
|
||||||
let finalFocusAddress = formValues.FocusAddress;
|
let finalFocusAddress = formValues.FocusAddress || '';
|
||||||
|
|
||||||
// 优先使用选中的设备信息
|
// 优先使用选中的设备信息
|
||||||
const deviceInfo = selectedDeviceInfo.value || (formValues.DeviceId ? getDeviceInfoById(formValues.DeviceId) : null);
|
const deviceInfo = selectedDeviceInfo.value || (formValues.DeviceId && deviceOptions.value.length > 0 ? getDeviceInfoById(formValues.DeviceId) : null);
|
||||||
|
|
||||||
if (deviceInfo) {
|
if (deviceInfo) {
|
||||||
finalFocusAddress = deviceInfo.focusAddress;
|
finalFocusAddress = deviceInfo.focusAddress || '';
|
||||||
|
|
||||||
if (deviceTypeNumber === 10) {
|
if (deviceTypeNumber === 10) {
|
||||||
// 集中器类型使用focusId
|
// 集中器类型使用focusId
|
||||||
@ -233,12 +236,12 @@ const gridOptions: VxeGridProps<any> = {
|
|||||||
pageIndex: page.currentPage,
|
pageIndex: page.currentPage,
|
||||||
pageSize: page.pageSize,
|
pageSize: page.pageSize,
|
||||||
// 优先使用表单中的值,如果没有则使用路由参数
|
// 优先使用表单中的值,如果没有则使用路由参数
|
||||||
DeviceType: deviceTypeNumber,
|
DeviceType: deviceTypeNumber || undefined,
|
||||||
DeviceId: finalDeviceId.toString(),
|
DeviceId: finalDeviceId ? finalDeviceId.toString() : '',
|
||||||
FocusAddress: finalFocusAddress || FocusAddress,
|
FocusAddress: finalFocusAddress || FocusAddress || '',
|
||||||
// 添加其他表单参数
|
// 添加其他表单参数
|
||||||
SystemName: formValues.SystemName || SystemName,
|
SystemName: formValues.SystemName || SystemName || '',
|
||||||
IoTDataType: ioTDataTypeValue,
|
IoTDataType: ioTDataTypeValue || undefined,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user