Showing
1 changed file
with
16 additions
and
15 deletions
@@ -13,6 +13,11 @@ import { deviceProfile } from '/@/api/device/deviceManager'; | @@ -13,6 +13,11 @@ import { deviceProfile } from '/@/api/device/deviceManager'; | ||
13 | import { getModelServices } from '/@/api/device/modelOfMatter'; | 13 | import { getModelServices } from '/@/api/device/modelOfMatter'; |
14 | import { ModelOfMatterParams } from '/@/api/device/model/modelOfMatterModel'; | 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,14 +218,8 @@ export const trigger_condition_schema: FormSchema[] = [ | ||
213 | if (e) { | 218 | if (e) { |
214 | setFieldsValue({ type2: '' }); | 219 | setFieldsValue({ type2: '' }); |
215 | const res = await getAttribute(e); | 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 | updateSchema({ | 223 | updateSchema({ |
225 | field: 'type2', | 224 | field: 'type2', |
226 | componentProps: { | 225 | componentProps: { |
@@ -228,14 +227,16 @@ export const trigger_condition_schema: FormSchema[] = [ | @@ -228,14 +227,16 @@ export const trigger_condition_schema: FormSchema[] = [ | ||
228 | options, | 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 | }, |