Showing
1 changed file
with
16 additions
and
15 deletions
... | ... | @@ -13,6 +13,11 @@ import { deviceProfile } from '/@/api/device/deviceManager'; |
13 | 13 | import { getModelServices } from '/@/api/device/modelOfMatter'; |
14 | 14 | import { ModelOfMatterParams } from '/@/api/device/model/modelOfMatterModel'; |
15 | 15 | |
16 | +type TOption = { | |
17 | + label: string; | |
18 | + value: string; | |
19 | +}; | |
20 | + | |
16 | 21 | /** |
17 | 22 | * 所使用的枚举值 |
18 | 23 | */ |
... | ... | @@ -213,14 +218,8 @@ export const trigger_condition_schema: FormSchema[] = [ |
213 | 218 | if (e) { |
214 | 219 | setFieldsValue({ type2: '' }); |
215 | 220 | const res = await getAttribute(e); |
216 | - let options: any = []; | |
217 | - if (Array.isArray(res)) { | |
218 | - options = res.map((m) => { | |
219 | - return { | |
220 | - label: m?.identifier, | |
221 | - value: m?.identifier, | |
222 | - }; | |
223 | - }); | |
221 | + const options = ref<TOption[]>([]); | |
222 | + const obj = (options) => | |
224 | 223 | updateSchema({ |
225 | 224 | field: 'type2', |
226 | 225 | componentProps: { |
... | ... | @@ -228,14 +227,16 @@ export const trigger_condition_schema: FormSchema[] = [ |
228 | 227 | options, |
229 | 228 | }, |
230 | 229 | }); |
231 | - } else { | |
232 | - updateSchema({ | |
233 | - field: 'type2', | |
234 | - componentProps: { | |
235 | - placeholder: '请选择属性', | |
236 | - options, | |
237 | - }, | |
230 | + if (Array.isArray(res)) { | |
231 | + options.value = res.map((m) => { | |
232 | + return { | |
233 | + label: m?.identifier, | |
234 | + value: m?.identifier, | |
235 | + }; | |
238 | 236 | }); |
237 | + obj(options.value); | |
238 | + } else { | |
239 | + obj(options.value); | |
239 | 240 | } |
240 | 241 | } |
241 | 242 | }, | ... | ... |