Commit 4733b03841eb1ea8d2f39f3fb2514591c299111d

Authored by fengtao
1 parent 2749fa40

fix:修改设备属性下拉选择里面不能有null值

... ... @@ -29,7 +29,6 @@
29 29 <script lang="ts" setup>
30 30 import { reactive, UnwrapRef, watchEffect, ref } from 'vue';
31 31 import { propTypes } from '/@/utils/propTypes';
32   - import { SelectTypes } from 'ant-design-vue/es/select';
33 32 import { Select } from 'ant-design-vue';
34 33 import { getAttribute } from '/@/api/ruleengine/ruleengineApi';
35 34
... ... @@ -42,16 +41,23 @@
42 41 value: propTypes.object.def({}),
43 42 orgId: propTypes.string.def(''),
44 43 });
45   - const selectOptions = ref<SelectTypes['options']>([]);
46   - //获取属性
  44 + const selectOptions: any = ref([]);
  45 + //获取对应设备属性
47 46 const getAttr = async (orgId, deviceId) => {
48 47 const res = await getAttribute(orgId, deviceId);
49 48 selectOptions.value = res.map((o) => {
50   - return {
51   - label: o,
52   - value: o,
53   - };
  49 + let obj: any = {};
  50 + if (o !== null) {
  51 + obj = {
  52 + label: o,
  53 + value: o,
  54 + };
  55 + return obj;
  56 + }
54 57 });
  58 + //如果服务端返回的数组里含有null 过滤null值
  59 + const excludeNull = selectOptions.value.filter(Boolean);
  60 + selectOptions.value = excludeNull;
55 61 };
56 62 //动态数据
57 63 const dynamicInput: UnwrapRef<{ params: Params[] }> = reactive({ params: [] });
... ...