Commit c1efd1f6da4e16a682d36a8502e4b909a4988a92

Authored by fengtao
1 parent 4888f7a6

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

@@ -18,7 +18,8 @@ enum ScreenManagerApi { @@ -18,7 +18,8 @@ enum ScreenManagerApi {
18 SCREEN_ORGANIZATION_URL = '/organization/me/list', 18 SCREEN_ORGANIZATION_URL = '/organization/me/list',
19 SCREEN_CHANGE_STATUS = '/convert/update/scene', 19 SCREEN_CHANGE_STATUS = '/convert/update/scene',
20 SCREEN_GET_BY_DEPTID = '/scene_linkage/device/', 20 SCREEN_GET_BY_DEPTID = '/scene_linkage/device/',
21 - GET_ATTRBUTELIST = '/device/keys', 21 + // GET_ATTRBUTELIST = '/device/keys',
  22 + GET_ATTRBUTELIST = '/device/attributes/',
22 ALARM_PROFILE = '/alarm/profile/', 23 ALARM_PROFILE = '/alarm/profile/',
23 MASTER_GET_DEVICE = '/device/list/master', 24 MASTER_GET_DEVICE = '/device/list/master',
24 } 25 }
@@ -101,10 +102,16 @@ export const getOrganizationAlarmConfig = (params: { organizationId }) => { @@ -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 export const getAttribute = (orgId, deviceIds) => { 111 export const getAttribute = (orgId, deviceIds) => {
105 - const joinText = deviceIds == null ? [] : '?deviceIds=' + deviceIds; 112 + // const joinText = deviceIds == null ? [] : '?deviceIds=' + deviceIds;
106 return defHttp.get({ 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,7 +55,6 @@
55 import { screenLinkPageByDeptIdGetDevice } from '/@/api/ruleengine/ruleengineApi'; 55 import { screenLinkPageByDeptIdGetDevice } from '/@/api/ruleengine/ruleengineApi';
56 import { Select } from 'ant-design-vue'; 56 import { Select } from 'ant-design-vue';
57 import DeviceAttrCpns from './cpns/DeviceAttrCpns.vue'; 57 import DeviceAttrCpns from './cpns/DeviceAttrCpns.vue';
58 - import { SelectTypes } from 'ant-design-vue/es/select';  
59 import { SchemaFiled } from './config.data'; 58 import { SchemaFiled } from './config.data';
60 import { QueryWay } from '../../device/localtion/cpns/TimePeriodForm/config'; 59 import { QueryWay } from '../../device/localtion/cpns/TimePeriodForm/config';
61 import { AggregateDataEnum } from '../../device/localtion/cpns/TimePeriodForm/config'; 60 import { AggregateDataEnum } from '../../device/localtion/cpns/TimePeriodForm/config';
@@ -68,6 +67,14 @@ @@ -68,6 +67,14 @@
68 device?: string; 67 device?: string;
69 name?: string; 68 name?: string;
70 attributes?: string | undefined; 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 const emit = defineEmits(['success', 'register']); 79 const emit = defineEmits(['success', 'register']);
73 const bindDeviceRefObj = { 80 const bindDeviceRefObj = {
@@ -76,7 +83,7 @@ @@ -76,7 +83,7 @@
76 const isUpdate = ref(true); 83 const isUpdate = ref(true);
77 const editId = ref(''); 84 const editId = ref('');
78 const orgId = ref(''); 85 const orgId = ref('');
79 - const selectOptions: Ref<SelectTypes['options']> = ref([]); 86 + const selectOptions: Ref<TSelectOption[]> = ref([]);
80 const selectDevice = ref([]); 87 const selectDevice = ref([]);
81 const deviceList: Ref<TDeviceList[]> = ref([]); 88 const deviceList: Ref<TDeviceList[]> = ref([]);
82 const editDeviceList: Ref<TDeviceList[]> = ref([]); 89 const editDeviceList: Ref<TDeviceList[]> = ref([]);
@@ -126,18 +133,20 @@ @@ -126,18 +133,20 @@
126 return { 133 return {
127 label: item.name, 134 label: item.name,
128 value: item.tbDeviceId, 135 value: item.tbDeviceId,
  136 + id: item.id,
  137 + deviceProfileId: item.deviceProfileId,
129 }; 138 };
130 }); 139 });
131 } 140 }
132 } 141 }
133 ); 142 );
134 //设备Select选中 143 //设备Select选中
135 - const handleDeviceChange = (e) => { 144 + const handleDeviceChange = (_, o) => {
136 if (unref(isUpdate)) { 145 if (unref(isUpdate)) {
137 //编辑 146 //编辑
138 let temp: any = []; 147 let temp: any = [];
139 editDeviceAttr.value.forEach((f) => { 148 editDeviceAttr.value.forEach((f) => {
140 - temp = [f, ...e]; 149 + temp = [f, ...o];
141 }); 150 });
142 let deWeightThree = () => { 151 let deWeightThree = () => {
143 let map = new Map(); 152 let map = new Map();
@@ -150,11 +159,11 @@ @@ -150,11 +159,11 @@
150 }; 159 };
151 temp = deWeightThree(); 160 temp = deWeightThree();
152 deviceList.value = temp; 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 } else { 165 } else {
157 - deviceList.value = e; 166 + deviceList.value = o;
158 } 167 }
159 }; 168 };
160 //设备取消删除 169 //设备取消删除
@@ -284,6 +293,8 @@ @@ -284,6 +293,8 @@
284 return { 293 return {
285 label: item.name, 294 label: item.name,
286 value: item.tbDeviceId, 295 value: item.tbDeviceId,
  296 + id: item.id,
  297 + deviceProfileId: item.deviceProfileId,
287 }; 298 };
288 }); 299 });
289 const deviceIds = editResData.data.executeAttributes.map((m) => { 300 const deviceIds = editResData.data.executeAttributes.map((m) => {
@@ -295,7 +306,16 @@ @@ -295,7 +306,16 @@
295 selectDevice.value = deviceIds; 306 selectDevice.value = deviceIds;
296 //回显设备属性 307 //回显设备属性
297 editDeviceAttr.value = editResData.data.executeAttributes?.map((item) => { 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 return { 317 return {
  318 + ...T,
299 label: item.name, 319 label: item.name,
300 value: item.device, 320 value: item.device,
301 attributes: item.attributes, 321 attributes: item.attributes,
@@ -45,19 +45,21 @@ @@ -45,19 +45,21 @@
45 //获取对应设备属性 45 //获取对应设备属性
46 const getAttr = async (orgId, deviceId) => { 46 const getAttr = async (orgId, deviceId) => {
47 const res = await getAttribute(orgId, deviceId); 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 const dynamicInput: UnwrapRef<{ params: Params[] }> = reactive({ params: [] }); 65 const dynamicInput: UnwrapRef<{ params: Params[] }> = reactive({ params: [] });
@@ -69,12 +71,12 @@ @@ -69,12 +71,12 @@
69 * 初始化数值 71 * 初始化数值
70 */ 72 */
71 async function initVal() { 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 dynamicInput.params.push({ 76 dynamicInput.params.push({
75 name: props.value.label, 77 name: props.value.label,
76 device: props.value.value, 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 }