Commit 028cc35988c99be32631ae0816ebdf1ffe07228c

Authored by ww
1 parent 0db2dbdf

perf: 优化修改产品时变更子设备绑定的网关产品时默认选择第一项

@@ -348,7 +348,7 @@ export const step1Schemas: FormSchema[] = [ @@ -348,7 +348,7 @@ export const step1Schemas: FormSchema[] = [
348 popconfirmTitle: () => 348 popconfirmTitle: () =>
349 updateOrgHelpMessage.map((text) => h('div', { style: { maxWidth: '240px' } }, text)), 349 updateOrgHelpMessage.map((text) => h('div', { style: { maxWidth: '240px' } }, text)),
350 }), 350 }),
351 - componentProps: ({ formModel }) => { 351 + componentProps: ({ formModel, formActionType }) => {
352 return { 352 return {
353 component: 'OrgTreeSelect', 353 component: 'OrgTreeSelect',
354 defaultLockStatus: !!formModel?.isUpdate, 354 defaultLockStatus: !!formModel?.isUpdate,
@@ -358,6 +358,17 @@ export const step1Schemas: FormSchema[] = [ @@ -358,6 +358,17 @@ export const step1Schemas: FormSchema[] = [
358 organizationId: formModel?.sensorOrganizationId, 358 organizationId: formModel?.sensorOrganizationId,
359 }, 359 },
360 }, 360 },
  361 + onOptionsChange: (options: Recordable[]) => {
  362 + if (!formModel?.organizationId && formModel?.deviceType === DeviceTypeEnum.SENSOR) {
  363 + const firstItem = options?.[0];
  364 +
  365 + if (firstItem && firstItem?.id) {
  366 + const { setFieldsValue, clearValidate } = formActionType;
  367 + setFieldsValue({ organizationId: firstItem.id });
  368 + clearValidate('organizationId');
  369 + }
  370 + }
  371 + },
361 }, 372 },
362 }; 373 };
363 }, 374 },