Commit e81094f8460e95cfb1a4652a78266845fabfb65f

Authored by loveumiko
1 parent a50efc3d

fix: 修复导入设备,切换选择的组织没有清空上个组织下的网关设备

... ... @@ -109,7 +109,8 @@ export const basicInfoForm: FormSchema[] = [
109 109 label: '所属组织',
110 110 component: 'ApiTreeSelect',
111 111 rules: [{ required: true, message: '所属组织为必填项' }],
112   - componentProps: () => {
  112 + componentProps: ({ formModel, formActionType }) => {
  113 + const { setFieldsValue } = formActionType;
113 114 return {
114 115 maxLength: 250,
115 116 placeholder: '请选择所属组织',
... ... @@ -119,6 +120,11 @@ export const basicInfoForm: FormSchema[] = [
119 120 return data;
120 121 },
121 122 getPopupContainer: () => document.body,
  123 + onChange(e) {
  124 + if (e != formModel?.[FieldsEnum.ORGANIZATION_ID]) {
  125 + setFieldsValue({ [FieldsEnum.GATEWAY_TB_DEVICE_ID]: null });
  126 + }
  127 + },
122 128 };
123 129 },
124 130 },
... ... @@ -193,7 +199,12 @@ export const basicInfoForm: FormSchema[] = [
193 199 deviceType: DeviceTypeEnum.GATEWAY,
194 200 organizationId,
195 201 });
196   - return result;
  202 + return result.map((item) => {
  203 + return {
  204 + ...item,
  205 + name: item.alias || item.name,
  206 + };
  207 + });
197 208 } catch (error) {
198 209 return [];
199 210 }
... ...