Commit 1a7682726afe0ee5e15f8aa39e67a43ef3a338c7
1 parent
efb2ef3e
fix: DEFECT-994 gateway device options incomplete on select sensor device
Showing
2 changed files
with
13 additions
and
5 deletions
... | ... | @@ -80,10 +80,9 @@ export const deleteDevice = (ids: string[]) => { |
80 | 80 | * 查询设备配置 |
81 | 81 | * @param params pageSize page name |
82 | 82 | */ |
83 | -export const deviceProfile = (params) => { | |
84 | - return defHttp.get({ | |
83 | +export const deviceProfile = () => { | |
84 | + return defHttp.get<DeviceRecord[]>({ | |
85 | 85 | url: DeviceManagerApi.DEVICE_PROFILE_URL_ME, |
86 | - params, | |
87 | 86 | }); |
88 | 87 | }; |
89 | 88 | ... | ... |
... | ... | @@ -62,10 +62,18 @@ export const step1Schemas: FormSchema[] = [ |
62 | 62 | label: '所属产品', |
63 | 63 | required: true, |
64 | 64 | component: 'ApiSelect', |
65 | - componentProps: ({ formActionType }) => { | |
65 | + componentProps: ({ formActionType, formModel }) => { | |
66 | 66 | const { setFieldsValue } = formActionType; |
67 | 67 | return { |
68 | - api: deviceProfile, | |
68 | + api: async () => { | |
69 | + const options = await deviceProfile(); | |
70 | + const { profileId } = formModel; | |
71 | + if (profileId) { | |
72 | + const selectRecord = options.find((item) => item.tbProfileId === profileId); | |
73 | + selectRecord && setFieldsValue({ transportType: selectRecord!.transportType }); | |
74 | + } | |
75 | + return options; | |
76 | + }, | |
69 | 77 | labelField: 'name', |
70 | 78 | valueField: 'tbProfileId', |
71 | 79 | onChange( |
... | ... | @@ -148,6 +156,7 @@ export const step1Schemas: FormSchema[] = [ |
148 | 156 | ifShow: ({ values }) => values.deviceType === 'SENSOR' && values.organizationId, |
149 | 157 | componentProps: ({ formModel }) => { |
150 | 158 | const { organizationId, transportType } = formModel; |
159 | + if (![organizationId, transportType].every(Boolean)) return {}; | |
151 | 160 | return { |
152 | 161 | api: getGatewayDevice, |
153 | 162 | showSearch: true, | ... | ... |