Commit c1efd1f6da4e16a682d36a8502e4b909a4988a92

Authored by fengtao
1 parent 4888f7a6

pref:报表配置设备属性接口更换为设备接口里的获取属性

... ... @@ -18,7 +18,8 @@ enum ScreenManagerApi {
18 18 SCREEN_ORGANIZATION_URL = '/organization/me/list',
19 19 SCREEN_CHANGE_STATUS = '/convert/update/scene',
20 20 SCREEN_GET_BY_DEPTID = '/scene_linkage/device/',
21   - GET_ATTRBUTELIST = '/device/keys',
  21 + // GET_ATTRBUTELIST = '/device/keys',
  22 + GET_ATTRBUTELIST = '/device/attributes/',
22 23 ALARM_PROFILE = '/alarm/profile/',
23 24 MASTER_GET_DEVICE = '/device/list/master',
24 25 }
... ... @@ -101,10 +102,16 @@ export const getOrganizationAlarmConfig = (params: { organizationId }) => {
101 102 /**
102 103 * 获取设备属性列表
103 104 */
  105 +// export const getAttribute = (orgId, deviceIds) => {
  106 +// const joinText = deviceIds == null ? [] : '?deviceIds=' + deviceIds;
  107 +// return defHttp.get({
  108 +// url: ScreenManagerApi.GET_ATTRBUTELIST + '/' + orgId + joinText,
  109 +// });
  110 +// };
104 111 export const getAttribute = (orgId, deviceIds) => {
105   - const joinText = deviceIds == null ? [] : '?deviceIds=' + deviceIds;
  112 + // const joinText = deviceIds == null ? [] : '?deviceIds=' + deviceIds;
106 113 return defHttp.get({
107   - url: ScreenManagerApi.GET_ATTRBUTELIST + '/' + orgId + joinText,
  114 + url: `${ScreenManagerApi.GET_ATTRBUTELIST}${orgId}/${deviceIds}`,
108 115 });
109 116 };
110 117
... ...
... ... @@ -55,7 +55,6 @@
55 55 import { screenLinkPageByDeptIdGetDevice } from '/@/api/ruleengine/ruleengineApi';
56 56 import { Select } from 'ant-design-vue';
57 57 import DeviceAttrCpns from './cpns/DeviceAttrCpns.vue';
58   - import { SelectTypes } from 'ant-design-vue/es/select';
59 58 import { SchemaFiled } from './config.data';
60 59 import { QueryWay } from '../../device/localtion/cpns/TimePeriodForm/config';
61 60 import { AggregateDataEnum } from '../../device/localtion/cpns/TimePeriodForm/config';
... ... @@ -68,6 +67,14 @@
68 67 device?: string;
69 68 name?: string;
70 69 attributes?: string | undefined;
  70 + deviceProfileId?: string;
  71 + id?: string;
  72 + };
  73 + type TSelectOption = {
  74 + value?: string;
  75 + label?: string;
  76 + deviceProfileId?: string;
  77 + id?: string;
71 78 };
72 79 const emit = defineEmits(['success', 'register']);
73 80 const bindDeviceRefObj = {
... ... @@ -76,7 +83,7 @@
76 83 const isUpdate = ref(true);
77 84 const editId = ref('');
78 85 const orgId = ref('');
79   - const selectOptions: Ref<SelectTypes['options']> = ref([]);
  86 + const selectOptions: Ref<TSelectOption[]> = ref([]);
80 87 const selectDevice = ref([]);
81 88 const deviceList: Ref<TDeviceList[]> = ref([]);
82 89 const editDeviceList: Ref<TDeviceList[]> = ref([]);
... ... @@ -126,18 +133,20 @@
126 133 return {
127 134 label: item.name,
128 135 value: item.tbDeviceId,
  136 + id: item.id,
  137 + deviceProfileId: item.deviceProfileId,
129 138 };
130 139 });
131 140 }
132 141 }
133 142 );
134 143 //设备Select选中
135   - const handleDeviceChange = (e) => {
  144 + const handleDeviceChange = (_, o) => {
136 145 if (unref(isUpdate)) {
137 146 //编辑
138 147 let temp: any = [];
139 148 editDeviceAttr.value.forEach((f) => {
140   - temp = [f, ...e];
  149 + temp = [f, ...o];
141 150 });
142 151 let deWeightThree = () => {
143 152 let map = new Map();
... ... @@ -150,11 +159,11 @@
150 159 };
151 160 temp = deWeightThree();
152 161 deviceList.value = temp;
153   - if (e.length !== 0) {
154   - deviceList.value = e;
  162 + if (o.length !== 0) {
  163 + deviceList.value = o;
155 164 }
156 165 } else {
157   - deviceList.value = e;
  166 + deviceList.value = o;
158 167 }
159 168 };
160 169 //设备取消删除
... ... @@ -284,6 +293,8 @@
284 293 return {
285 294 label: item.name,
286 295 value: item.tbDeviceId,
  296 + id: item.id,
  297 + deviceProfileId: item.deviceProfileId,
287 298 };
288 299 });
289 300 const deviceIds = editResData.data.executeAttributes.map((m) => {
... ... @@ -295,7 +306,16 @@
295 306 selectDevice.value = deviceIds;
296 307 //回显设备属性
297 308 editDeviceAttr.value = editResData.data.executeAttributes?.map((item) => {
  309 + const T = selectOptions.value.find((o) => {
  310 + if (item.device === o.value) {
  311 + return {
  312 + id: o.id,
  313 + deviceProfileId: o.deviceProfileId,
  314 + };
  315 + }
  316 + });
298 317 return {
  318 + ...T,
299 319 label: item.name,
300 320 value: item.device,
301 321 attributes: item.attributes,
... ...
... ... @@ -45,19 +45,21 @@
45 45 //获取对应设备属性
46 46 const getAttr = async (orgId, deviceId) => {
47 47 const res = await getAttribute(orgId, deviceId);
48   - selectOptions.value = res.map((o) => {
49   - let obj: any = {};
50   - if (o !== null) {
51   - obj = {
52   - label: o,
53   - value: o,
54   - };
55   - return obj;
56   - }
57   - });
58   - //如果服务端返回的数组里含有null 过滤null值
59   - const excludeNull = selectOptions.value.filter(Boolean);
60   - selectOptions.value = excludeNull;
  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;
  62 + }
61 63 };
62 64 //动态数据
63 65 const dynamicInput: UnwrapRef<{ params: Params[] }> = reactive({ params: [] });
... ... @@ -69,12 +71,12 @@
69 71 * 初始化数值
70 72 */
71 73 async function initVal() {
72   - if (props.orgId && props.value.value) {
73   - await getAttr(props.orgId, props.value.value);
  74 + if (props.value) {
  75 + await getAttr(props.value?.deviceProfileId, props.value?.id);
74 76 dynamicInput.params.push({
75 77 name: props.value.label,
76 78 device: props.value.value,
77   - attributes: props.value.attributes == [] ? [] : props.value.attributes,
  79 + attributes: props.value?.attributes == [] ? [] : props.value.attributes,
78 80 });
79 81 }
80 82 }
... ...