Showing
1 changed file
with
12 additions
and
1 deletions
... | ... | @@ -348,7 +348,7 @@ export const step1Schemas: FormSchema[] = [ |
348 | 348 | popconfirmTitle: () => |
349 | 349 | updateOrgHelpMessage.map((text) => h('div', { style: { maxWidth: '240px' } }, text)), |
350 | 350 | }), |
351 | - componentProps: ({ formModel }) => { | |
351 | + componentProps: ({ formModel, formActionType }) => { | |
352 | 352 | return { |
353 | 353 | component: 'OrgTreeSelect', |
354 | 354 | defaultLockStatus: !!formModel?.isUpdate, |
... | ... | @@ -358,6 +358,17 @@ export const step1Schemas: FormSchema[] = [ |
358 | 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 | }, | ... | ... |