Showing
1 changed file
with
17 additions
and
15 deletions
... | ... | @@ -44,21 +44,23 @@ |
44 | 44 | const selectOptions: any = ref([]); |
45 | 45 | //获取对应设备属性 |
46 | 46 | const getAttr = async (orgId, _) => { |
47 | - const res = await getAttribute(orgId); | |
48 | - if (Array.isArray(res)) { | |
49 | - selectOptions.value = res.map((o) => { | |
50 | - let obj: any = {}; | |
51 | - if (o?.identifier !== null) { | |
52 | - obj = { | |
53 | - label: o?.identifier, | |
54 | - value: o?.identifier, | |
55 | - }; | |
56 | - return obj; | |
57 | - } | |
58 | - }); | |
59 | - //如果服务端返回的数组里含有null 过滤null值 | |
60 | - const excludeNull = selectOptions.value.filter(Boolean); | |
61 | - selectOptions.value = excludeNull; | |
47 | + if (orgId) { | |
48 | + const res = await getAttribute(orgId); | |
49 | + if (Array.isArray(res)) { | |
50 | + selectOptions.value = res.map((o) => { | |
51 | + let obj: any = {}; | |
52 | + if (o?.identifier !== null) { | |
53 | + obj = { | |
54 | + label: o?.identifier, | |
55 | + value: o?.identifier, | |
56 | + }; | |
57 | + return obj; | |
58 | + } | |
59 | + }); | |
60 | + //如果服务端返回的数组里含有null 过滤null值 | |
61 | + const excludeNull = selectOptions.value.filter(Boolean); | |
62 | + selectOptions.value = excludeNull; | |
63 | + } | |
62 | 64 | } |
63 | 65 | }; |
64 | 66 | //动态数据 | ... | ... |