Commit 31440c851290ac2ba056d3d27571ec9d51e23b1f

Authored by fengtao
1 parent 03b52f86

pref:场景联动设备属性接口更换为设备接口里的获取属性

@@ -108,10 +108,10 @@ export const getOrganizationAlarmConfig = (params: { organizationId }) => { @@ -108,10 +108,10 @@ export const getOrganizationAlarmConfig = (params: { organizationId }) => {
108 // url: ScreenManagerApi.GET_ATTRBUTELIST + '/' + orgId + joinText, 108 // url: ScreenManagerApi.GET_ATTRBUTELIST + '/' + orgId + joinText,
109 // }); 109 // });
110 // }; 110 // };
111 -export const getAttribute = (orgId, deviceIds) => { 111 +export const getAttribute = (orgId) => {
112 // const joinText = deviceIds == null ? [] : '?deviceIds=' + deviceIds; 112 // const joinText = deviceIds == null ? [] : '?deviceIds=' + deviceIds;
113 return defHttp.get({ 113 return defHttp.get({
114 - url: `${ScreenManagerApi.GET_ATTRBUTELIST}${orgId}/${deviceIds}`, 114 + url: `${ScreenManagerApi.GET_ATTRBUTELIST}${orgId}`,
115 }); 115 });
116 }; 116 };
117 117
@@ -228,7 +228,7 @@ @@ -228,7 +228,7 @@
228 // 回显触发器数据---此处是个闭包! 228 // 回显触发器数据---此处是个闭包!
229 triggers.forEach((trigger, index) => { 229 triggers.forEach((trigger, index) => {
230 nextTick(async () => { 230 nextTick(async () => {
231 - const selectDeviceId = ref(''); 231 + const selectProductId = ref('');
232 // 回显启用规则 232 // 回显启用规则
233 unref(skipUnwrap.triggerItemRefs)[index].currentIndex = 233 unref(skipUnwrap.triggerItemRefs)[index].currentIndex =
234 map[trigger.triggerCondition.schedule.type]; 234 map[trigger.triggerCondition.schedule.type];
@@ -245,18 +245,16 @@ @@ -245,18 +245,16 @@
245 operationType: trigger?.triggerCondition?.condition?.condition[0]?.valueType, 245 operationType: trigger?.triggerCondition?.condition?.condition[0]?.valueType,
246 detail: trigger?.triggerCondition?.alarmDetails, 246 detail: trigger?.triggerCondition?.alarmDetails,
247 entityId: trigger?.entityId, 247 entityId: trigger?.entityId,
  248 + deviceProfileId: trigger?.deviceProfileId,
248 replaceValue: trigger?.triggerCondition?.condition?.spec?.predicate?.defaultValue, 249 replaceValue: trigger?.triggerCondition?.condition?.spec?.predicate?.defaultValue,
249 time: trigger?.triggerCondition?.condition?.spec?.predicate?.defaultValue, 250 time: trigger?.triggerCondition?.condition?.spec?.predicate?.defaultValue,
250 timeUnit: trigger?.triggerCondition?.condition?.spec?.unit, 251 timeUnit: trigger?.triggerCondition?.condition?.spec?.unit,
251 }); 252 });
252 - if (trigger.entityId != undefined) {  
253 - selectDeviceId.value = trigger?.entityId; 253 + if (trigger.deviceProfileId != undefined) {
  254 + selectProductId.value = trigger?.deviceProfileId;
254 } 255 }
255 //fengtao-把设备id回传给子组件 256 //fengtao-把设备id回传给子组件
256 - unref(skipUnwrap.triggerItemRefs)[index].updateFieldAttributeFunc(  
257 - selectDeviceId.value,  
258 - provideOrgid.value  
259 - ); 257 + unref(skipUnwrap.triggerItemRefs)[index].updateFieldAttributeFunc(selectProductId.value);
260 //fengtao 258 //fengtao
261 // 设置值operationType 259 // 设置值operationType
262 unref(skipUnwrap.triggerItemRefs)[index].operationType = 260 unref(skipUnwrap.triggerItemRefs)[index].operationType =
@@ -309,7 +307,7 @@ @@ -309,7 +307,7 @@
309 307
310 doConditions.forEach((condition, index) => { 308 doConditions.forEach((condition, index) => {
311 nextTick(async () => { 309 nextTick(async () => {
312 - const selectDeviceId = ref(''); 310 + const selectProductId = ref('');
313 // 回显启用规则 311 // 回显启用规则
314 unref(skipUnwrap.conditionItemRefs)[index].currentIndex = 312 unref(skipUnwrap.conditionItemRefs)[index].currentIndex =
315 map[condition.triggerCondition.schedule.type]; 313 map[condition.triggerCondition.schedule.type];
@@ -327,17 +325,17 @@ @@ -327,17 +325,17 @@
327 operationType: condition?.triggerCondition?.condition?.condition[0]?.valueType, 325 operationType: condition?.triggerCondition?.condition?.condition[0]?.valueType,
328 detail: condition?.triggerCondition?.alarmDetails, 326 detail: condition?.triggerCondition?.alarmDetails,
329 entityId: condition?.entityId, 327 entityId: condition?.entityId,
  328 + deviceProfileId: condition?.deviceProfileId,
330 replaceValue: condition?.triggerCondition?.condition?.spec?.predicate?.defaultValue, 329 replaceValue: condition?.triggerCondition?.condition?.spec?.predicate?.defaultValue,
331 time: condition?.triggerCondition?.condition?.spec?.predicate?.defaultValue, 330 time: condition?.triggerCondition?.condition?.spec?.predicate?.defaultValue,
332 timeUnit: condition?.triggerCondition?.condition?.spec?.unit, 331 timeUnit: condition?.triggerCondition?.condition?.spec?.unit,
333 }); 332 });
334 - if (condition?.entityId != undefined) {  
335 - selectDeviceId.value = condition?.entityId; 333 + if (condition?.deviceProfileId != undefined) {
  334 + selectProductId.value = condition?.deviceProfileId;
336 } 335 }
337 //fengtao-把设备id回传给子组件 336 //fengtao-把设备id回传给子组件
338 unref(skipUnwrap.conditionItemRefs)[index].updateFieldAttributeFunc( 337 unref(skipUnwrap.conditionItemRefs)[index].updateFieldAttributeFunc(
339 - selectDeviceId.value,  
340 - provideOrgid.value 338 + selectProductId.value
341 ); 339 );
342 //fengtao 340 //fengtao
343 // 设置值operationType 341 // 设置值operationType
@@ -391,7 +389,7 @@ @@ -391,7 +389,7 @@
391 389
392 doActions.forEach((action, index) => { 390 doActions.forEach((action, index) => {
393 nextTick(() => { 391 nextTick(() => {
394 - const selectDeviceId = ref(''); 392 + const selectProductId = ref('');
395 // 设置执行动作外层值 393 // 设置执行动作外层值
396 unref(skipUnwrap.actionItemRefs)[index].setFieldsFormValueFun({ 394 unref(skipUnwrap.actionItemRefs)[index].setFieldsFormValueFun({
397 ...action, 395 ...action,
@@ -439,6 +437,7 @@ @@ -439,6 +437,7 @@
439 .valueType, 437 .valueType,
440 detail: action.doContext.clearRule[index].triggerCondition.alarmDetails, 438 detail: action.doContext.clearRule[index].triggerCondition.alarmDetails,
441 entityId: action.doContext.clearRule[index].entityId, 439 entityId: action.doContext.clearRule[index].entityId,
  440 + deviceProfileId: action.doContext.clearRule[index]?.deviceProfileId,
442 replaceValue: 441 replaceValue:
443 action.doContext.clearRule[index].triggerCondition.condition.spec.predicate 442 action.doContext.clearRule[index].triggerCondition.condition.spec.predicate
444 .defaultValue, 443 .defaultValue,
@@ -447,17 +446,12 @@ @@ -447,17 +446,12 @@
447 timeUnit: 446 timeUnit:
448 action.doContext.clearRule[index].triggerCondition.condition.spec.unit, 447 action.doContext.clearRule[index].triggerCondition.condition.spec.unit,
449 }); 448 });
450 - if (action.doContext.clearRule[index].entityId != undefined) {  
451 - selectDeviceId.value = action.doContext.clearRule[index].entityId; 449 + if (action.doContext.clearRule[index]?.deviceProfileId != undefined) {
  450 + selectProductId.value = action.doContext.clearRule[index]?.deviceProfileId;
452 } 451 }
453 //fengtao-把设备id回传给子组件 452 //fengtao-把设备id回传给子组件
454 - item.updateFieldAttributeFunc(selectDeviceId.value, provideOrgid.value);  
455 - // item.updateFieldDeviceId(  
456 - // deviceList.value,  
457 - // provideOrgid.value,  
458 - // isUpdate.value,  
459 - // getMasterDeviceList.value  
460 - // ); 453 + item.updateFieldAttributeFunc(selectProductId.value);
  454 + item.updateFieldDeviceId(deviceList.value, provideOrgid.value, isUpdate.value);
461 //fengtao 455 //fengtao
462 // 单独设置operationType值 操作符类型 NUMERIC|String|Boolean|DATE_TIME 456 // 单独设置operationType值 操作符类型 NUMERIC|String|Boolean|DATE_TIME
463 item.operationType = 457 item.operationType =
@@ -534,12 +528,12 @@ @@ -534,12 +528,12 @@
534 }); 528 });
535 529
536 // 设置设备的options 530 // 设置设备的options
537 - const setEditFields = (_linkAge, _deviceList) => {  
538 - // unref(linkAge).map((item) => {  
539 - //TODO-fengtao  
540 - // item.updateFieldDeviceId(deviceList, orgId, isUpdate, getMasterDeviceList);  
541 - //TODO-fengtao  
542 - // }); 531 + const setEditFields = (linkAge, deviceList) => {
  532 + unref(linkAge).map((item) => {
  533 + // TODO-fengtao
  534 + item.updateFieldDeviceId(deviceList, orgId, isUpdate);
  535 + // TODO-fengtao
  536 + });
543 }; 537 };
544 // 设置告警配置options 538 // 设置告警配置options
545 const setEditAlarmConfig = (linkAge, alarmConfigList) => { 539 const setEditAlarmConfig = (linkAge, alarmConfigList) => {
@@ -600,7 +594,7 @@ @@ -600,7 +594,7 @@
600 unref(linkAge).map((item) => { 594 unref(linkAge).map((item) => {
601 isOrganizationChange && item.resetFieldsValueFunc(); 595 isOrganizationChange && item.resetFieldsValueFunc();
602 //TODO fengtao 596 //TODO fengtao
603 - // item.updateFieldDeviceId(deviceList, orgId, isUpdate, getMasterDeviceList); 597 + item.updateFieldDeviceId(deviceList, orgId, isUpdate);
604 if (isUpdate.value) { 598 if (isUpdate.value) {
605 item.updateEditFieldAlarmConfig(editAlarmConfigData); 599 item.updateEditFieldAlarmConfig(editAlarmConfigData);
606 } else { 600 } else {
@@ -3,6 +3,7 @@ import { BasicColumn, FormSchema } from '/@/components/Table'; @@ -3,6 +3,7 @@ import { BasicColumn, FormSchema } from '/@/components/Table';
3 import { 3 import {
4 byOrganizationIdGetMasterDevice, 4 byOrganizationIdGetMasterDevice,
5 screenLinkOrganizationGetApi, 5 screenLinkOrganizationGetApi,
  6 + getAttribute,
6 } from '/@/api/ruleengine/ruleengineApi'; 7 } from '/@/api/ruleengine/ruleengineApi';
7 import { scheduleOptions } from './formatData'; 8 import { scheduleOptions } from './formatData';
8 import { copyTransFun } from '/@/utils/fnUtils'; 9 import { copyTransFun } from '/@/utils/fnUtils';
@@ -196,6 +197,52 @@ export const trigger_condition_schema: FormSchema[] = [ @@ -196,6 +197,52 @@ export const trigger_condition_schema: FormSchema[] = [
196 colProps: { span: 6 }, 197 colProps: { span: 6 },
197 }, 198 },
198 { 199 {
  200 + field: 'deviceProfileId',
  201 + label: '',
  202 + component: 'ApiSelect',
  203 + colProps: { span: 6 },
  204 + componentProps: ({ formActionType }) => {
  205 + const { updateSchema, setFieldsValue } = formActionType;
  206 + return {
  207 + api: deviceProfile,
  208 + placeholder: '请选择产品',
  209 + labelField: 'name',
  210 + valueField: 'id',
  211 + getPopupContainer: () => document.body,
  212 + onChange: async (e) => {
  213 + if (e) {
  214 + setFieldsValue({ type2: '' });
  215 + 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 + });
  224 + updateSchema({
  225 + field: 'type2',
  226 + componentProps: {
  227 + placeholder: '请选择属性',
  228 + options,
  229 + },
  230 + });
  231 + } else {
  232 + updateSchema({
  233 + field: 'type2',
  234 + componentProps: {
  235 + placeholder: '请选择属性',
  236 + options,
  237 + },
  238 + });
  239 + }
  240 + }
  241 + },
  242 + };
  243 + },
  244 + },
  245 + {
199 field: 'device', 246 field: 'device',
200 label: '', 247 label: '',
201 component: 'Select', 248 component: 'Select',
@@ -208,6 +255,7 @@ export const trigger_condition_schema: FormSchema[] = [ @@ -208,6 +255,7 @@ export const trigger_condition_schema: FormSchema[] = [
208 }, 255 },
209 colProps: { span: 6 }, 256 colProps: { span: 6 },
210 }, 257 },
  258 +
211 { 259 {
212 field: 'entityId', 260 field: 'entityId',
213 label: '', 261 label: '',
@@ -219,6 +267,7 @@ export const trigger_condition_schema: FormSchema[] = [ @@ -219,6 +267,7 @@ export const trigger_condition_schema: FormSchema[] = [
219 ifShow: ({ values }) => isPart(values.device), 267 ifShow: ({ values }) => isPart(values.device),
220 colProps: { span: 6 }, 268 colProps: { span: 6 },
221 }, 269 },
  270 +
222 { 271 {
223 field: 'time', 272 field: 'time',
224 label: '', 273 label: '',
@@ -370,17 +419,19 @@ export const actionSchema: FormSchema[] = [ @@ -370,17 +419,19 @@ export const actionSchema: FormSchema[] = [
370 component: 'ApiSelect', 419 component: 'ApiSelect',
371 componentProps: ({ formModel }) => { 420 componentProps: ({ formModel }) => {
372 const deviceProfileId = formModel['deviceProfileId']; 421 const deviceProfileId = formModel['deviceProfileId'];
373 - return {  
374 - placeholder: '请选择设备',  
375 - mode: 'multiple',  
376 - api: byOrganizationIdGetMasterDevice,  
377 - params: {  
378 - organizationId: unref(organizationId),  
379 - deviceProfileId,  
380 - },  
381 - labelField: 'name',  
382 - valueField: 'id',  
383 - }; 422 + if (unref(organizationId)) {
  423 + return {
  424 + placeholder: '请选择设备',
  425 + mode: 'multiple',
  426 + api: byOrganizationIdGetMasterDevice,
  427 + params: {
  428 + organizationId: unref(organizationId),
  429 + deviceProfileId,
  430 + },
  431 + labelField: 'name',
  432 + valueField: 'id',
  433 + };
  434 + }
384 }, 435 },
385 ifShow: ({ values }) => isPart(values.device) && isDeviceOut(values.outTarget), 436 ifShow: ({ values }) => isPart(values.device) && isDeviceOut(values.outTarget),
386 colProps: { span: 6 }, 437 colProps: { span: 6 },
@@ -394,7 +445,7 @@ export const actionSchema: FormSchema[] = [ @@ -394,7 +445,7 @@ export const actionSchema: FormSchema[] = [
394 colProps: { 445 colProps: {
395 span: 6, 446 span: 6,
396 }, 447 },
397 - defaultValue: '0', 448 + defaultValue: 0,
398 componentProps: ({ formActionType }) => { 449 componentProps: ({ formActionType }) => {
399 const { setFieldsValue } = formActionType; 450 const { setFieldsValue } = formActionType;
400 return { 451 return {
@@ -17,6 +17,7 @@ export const genTriggerOrConditionData = (triggerData) => { @@ -17,6 +17,7 @@ export const genTriggerOrConditionData = (triggerData) => {
17 time, 17 time,
18 timeUnit, 18 timeUnit,
19 replaceValue, 19 replaceValue,
  20 + deviceProfileId,
20 } = triggerData; 21 } = triggerData;
21 const mapPredicate = predicate?.map((item) => { 22 const mapPredicate = predicate?.map((item) => {
22 return { 23 return {
@@ -40,6 +41,7 @@ export const genTriggerOrConditionData = (triggerData) => { @@ -40,6 +41,7 @@ export const genTriggerOrConditionData = (triggerData) => {
40 }; 41 };
41 }); 42 });
42 return { 43 return {
  44 + deviceProfileId,
43 triggerType, 45 triggerType,
44 entityType: device, 46 entityType: device,
45 entityId: entityId?.length ? entityId : null, 47 entityId: entityId?.length ? entityId : null,
@@ -115,6 +117,7 @@ export const genActionData = (actionData) => { @@ -115,6 +117,7 @@ export const genActionData = (actionData) => {
115 triggerType: item.triggerType, 117 triggerType: item.triggerType,
116 entityType: item.device, 118 entityType: item.device,
117 entityId: item.device === 'PART' ? item.entityId : null, 119 entityId: item.device === 'PART' ? item.entityId : null,
  120 + deviceProfileId: item.deviceProfileId,
118 triggerCondition: { 121 triggerCondition: {
119 alarmDetails: item.detail, 122 alarmDetails: item.detail,
120 condition: { 123 condition: {
@@ -62,10 +62,10 @@ @@ -62,10 +62,10 @@
62 import { CollapseContainer } from '/@/components/Container/index'; 62 import { CollapseContainer } from '/@/components/Container/index';
63 import { BasicForm, useForm } from '/@/components/Form/index'; 63 import { BasicForm, useForm } from '/@/components/Form/index';
64 import { Card, Select, Input, Tooltip } from 'ant-design-vue'; 64 import { Card, Select, Input, Tooltip } from 'ant-design-vue';
65 - import { trigger_condition_schema } from '../config/config.data.ts'; 65 + import { trigger_condition_schema } from '../config/config.data';
66 import { getAttribute } from '/@/api/ruleengine/ruleengineApi'; 66 import { getAttribute } from '/@/api/ruleengine/ruleengineApi';
67 import ConditionScreening from './ConditionScreening.vue'; 67 import ConditionScreening from './ConditionScreening.vue';
68 - import { scheduleOptions, timeUnitOptions, options } from '../config/formatData.ts'; 68 + import { scheduleOptions, timeUnitOptions, options } from '../config/formatData';
69 import { Icon } from '/@/components/Icon'; 69 import { Icon } from '/@/components/Icon';
70 import AlarmSchedule from './AlarmSchedule.vue'; 70 import AlarmSchedule from './AlarmSchedule.vue';
71 import { useModal } from '/@/components/Modal'; 71 import { useModal } from '/@/components/Modal';
@@ -99,22 +99,12 @@ @@ -99,22 +99,12 @@
99 return { ...getFieldsValue(), predicate, schedule: alarmScheduleRef.value.scheduleData }; 99 return { ...getFieldsValue(), predicate, schedule: alarmScheduleRef.value.scheduleData };
100 }; 100 };
101 101
102 - const updateFieldDeviceId = (deviceList: any[], orgId, isUpdate) => { 102 + const updateFieldDeviceId = (deviceList: any[], _, isUpdate) => {
103 if (isUpdate) { 103 if (isUpdate) {
104 updateSchema({ 104 updateSchema({
105 field: 'entityId', 105 field: 'entityId',
106 componentProps: { 106 componentProps: {
107 options: deviceList, 107 options: deviceList,
108 - onChange(e) {  
109 - if (e) {  
110 - if (isUpdate) {  
111 - setFieldsValue({ type2: '' });  
112 - }  
113 - //fengtao  
114 - updateFieldAttributeFunc(e, orgId);  
115 - //fengtao  
116 - }  
117 - },  
118 }, 108 },
119 }); 109 });
120 } 110 }
@@ -127,53 +117,15 @@ @@ -127,53 +117,15 @@
127 { label: '部分', value: 'PART' }, 117 { label: '部分', value: 'PART' },
128 ], 118 ],
129 async onChange(e) { 119 async onChange(e) {
130 - setFieldsValue({ type2: '' });  
131 setFieldsValue({ entityId: [] }); 120 setFieldsValue({ entityId: [] });
132 - //部分切换-清空或者重置为初始值  
133 - updateSchema({  
134 - field: 'type2',  
135 - componentProps: {  
136 - options: [],  
137 - },  
138 - });  
139 if (e) { 121 if (e) {
140 //fengtao 122 //fengtao
141 if (e == 'ALL') { 123 if (e == 'ALL') {
142 - if (orgId) {  
143 - const data = await getAttribute(orgId, null);  
144 - //fengtao  
145 - const options = data.map((m) => {  
146 - return {  
147 - label: m,  
148 - value: m,  
149 - };  
150 - });  
151 - updateSchema({  
152 - field: 'type2',  
153 - componentProps: {  
154 - placeholder: '请选择属性',  
155 - options,  
156 - },  
157 - });  
158 - }  
159 } else { 124 } else {
160 - const getT = getFieldsValue();  
161 - const entityId = getT.entityId;  
162 - if (entityId !== undefined && entityId.length > 0) {  
163 - updateFieldAttributeFunc(entityId, orgId);  
164 - }  
165 updateSchema({ 125 updateSchema({
166 field: 'entityId', 126 field: 'entityId',
167 componentProps: { 127 componentProps: {
168 options: deviceList, 128 options: deviceList,
169 - onChange(e) {  
170 - if (e) {  
171 - setFieldsValue({ type2: '' });  
172 - //fengtao  
173 - updateFieldAttributeFunc(e, orgId);  
174 - //fengtao  
175 - }  
176 - },  
177 }, 129 },
178 }); 130 });
179 } 131 }
@@ -189,30 +141,32 @@ @@ -189,30 +141,32 @@
189 const setFieldsFormValueFun = (fieldsValue) => { 141 const setFieldsFormValueFun = (fieldsValue) => {
190 setFieldsValue(fieldsValue); 142 setFieldsValue(fieldsValue);
191 }; 143 };
192 - //TODO-fengtao  
193 - const updateFieldAttributeFunc = async (deviceId, orgId) => {  
194 - //TODO-fengtao  
195 - let data;  
196 - if (deviceId !== undefined && deviceId.length > 0) {  
197 - const joinDeviceIds = deviceId.join(',');  
198 - data = await getAttribute(orgId, joinDeviceIds); 144 + const updateFieldAttributeFunc = async (e) => {
  145 + const res = await getAttribute(e);
  146 + let options: any = [];
  147 + if (Array.isArray(res)) {
  148 + options = res.map((m) => {
  149 + return {
  150 + label: m?.identifier,
  151 + value: m?.identifier,
  152 + };
  153 + });
  154 + updateSchema({
  155 + field: 'type2',
  156 + componentProps: {
  157 + placeholder: '请选择属性',
  158 + options,
  159 + },
  160 + });
199 } else { 161 } else {
200 - data = await getAttribute(orgId, null); 162 + updateSchema({
  163 + field: 'type2',
  164 + componentProps: {
  165 + placeholder: '请选择属性',
  166 + options,
  167 + },
  168 + });
201 } 169 }
202 - //TODO-fengtao  
203 - const options = data.map((m) => {  
204 - return {  
205 - label: m,  
206 - value: m,  
207 - };  
208 - });  
209 - updateSchema({  
210 - field: 'type2',  
211 - componentProps: {  
212 - placeholder: '请选择属性',  
213 - options: options,  
214 - },  
215 - });  
216 }; 170 };
217 //TODO-fengtao 171 //TODO-fengtao
218 const schedule = ref('ANY_TIME'); 172 const schedule = ref('ANY_TIME');
@@ -62,16 +62,16 @@ @@ -62,16 +62,16 @@
62 import { BasicForm, useForm } from '/@/components/Form/index'; 62 import { BasicForm, useForm } from '/@/components/Form/index';
63 import { Icon } from '/@/components/Icon'; 63 import { Icon } from '/@/components/Icon';
64 import { Tooltip, Card, Select, Input } from 'ant-design-vue'; 64 import { Tooltip, Card, Select, Input } from 'ant-design-vue';
65 - import { trigger_condition_schema } from '../config/config.data.ts'; 65 + import { trigger_condition_schema } from '../config/config.data';
66 import { getAttribute } from '/@/api/ruleengine/ruleengineApi'; 66 import { getAttribute } from '/@/api/ruleengine/ruleengineApi';
67 import ConditionScreening from './ConditionScreening.vue'; 67 import ConditionScreening from './ConditionScreening.vue';
68 - import { scheduleOptions, timeUnitOptions, options } from '../config/formatData.ts'; 68 + import { scheduleOptions, timeUnitOptions, options } from '../config/formatData';
69 import AlarmSchedule from './AlarmSchedule.vue'; 69 import AlarmSchedule from './AlarmSchedule.vue';
70 import { useModal } from '/@/components/Modal'; 70 import { useModal } from '/@/components/Modal';
71 import { cloneDeep } from 'lodash-es'; 71 import { cloneDeep } from 'lodash-es';
72 import { useMessage } from '/@/hooks/web/useMessage'; 72 import { useMessage } from '/@/hooks/web/useMessage';
73 73
74 - const props = defineProps({ 74 + defineProps({
75 title: { 75 title: {
76 type: String, 76 type: String,
77 required: true, 77 required: true,
@@ -139,23 +139,13 @@ @@ -139,23 +139,13 @@
139 }; 139 };
140 140
141 //TODO-fengtao 141 //TODO-fengtao
142 - const updateFieldDeviceId = (deviceList: any[], orgId, isUpdate) => { 142 + const updateFieldDeviceId = (deviceList: any[], _, isUpdate) => {
143 //用于编辑回显 143 //用于编辑回显
144 if (isUpdate.value) { 144 if (isUpdate.value) {
145 updateSchema({ 145 updateSchema({
146 field: 'entityId', 146 field: 'entityId',
147 componentProps: { 147 componentProps: {
148 options: deviceList, 148 options: deviceList,
149 - onChange(e) {  
150 - if (e) {  
151 - if (isUpdate.value) {  
152 - setFieldsValue({ type2: '' });  
153 - }  
154 - //fengtao  
155 - updateFieldAttributeFunc(e, orgId.value);  
156 - //fengtao  
157 - }  
158 - },  
159 }, 149 },
160 }); 150 });
161 } 151 }
@@ -168,52 +158,15 @@ @@ -168,52 +158,15 @@
168 { label: '部分', value: 'PART' }, 158 { label: '部分', value: 'PART' },
169 ], 159 ],
170 async onChange(e) { 160 async onChange(e) {
171 - setFieldsValue({ type2: '' });  
172 setFieldsValue({ entityId: [] }); 161 setFieldsValue({ entityId: [] });
173 - updateSchema({  
174 - field: 'type2',  
175 - componentProps: {  
176 - options: [],  
177 - },  
178 - });  
179 if (e) { 162 if (e) {
180 //fengtao 163 //fengtao
181 if (e == 'ALL') { 164 if (e == 'ALL') {
182 - if (props.provideOrgid || orgId.value) {  
183 - const data = await getAttribute(props.provideOrgid || orgId.value, null);  
184 - //fengtao  
185 - const options = data.map((m) => {  
186 - return {  
187 - label: m,  
188 - value: m,  
189 - };  
190 - });  
191 - updateSchema({  
192 - field: 'type2',  
193 - componentProps: {  
194 - placeholder: '请选择属性',  
195 - options,  
196 - },  
197 - });  
198 - }  
199 } else { 165 } else {
200 - const getT = getFieldsValue();  
201 - const entityId = getT.entityId;  
202 - if (entityId !== undefined && entityId.length > 0) {  
203 - updateFieldAttributeFunc(entityId, orgId.value);  
204 - }  
205 updateSchema({ 166 updateSchema({
206 field: 'entityId', 167 field: 'entityId',
207 componentProps: { 168 componentProps: {
208 options: deviceList, 169 options: deviceList,
209 - onChange(e) {  
210 - if (e) {  
211 - setFieldsValue({ type2: '' });  
212 - //fengtao  
213 - updateFieldAttributeFunc(e, orgId.value);  
214 - //fengtao  
215 - }  
216 - },  
217 }, 170 },
218 }); 171 });
219 } 172 }
@@ -233,29 +186,32 @@ @@ -233,29 +186,32 @@
233 setFieldsValue(fieldsValue); 186 setFieldsValue(fieldsValue);
234 }; 187 };
235 //TODO-fengtao 188 //TODO-fengtao
236 - const updateFieldAttributeFunc = async (deviceId, orgId) => {  
237 - //TODO-fengtao  
238 - let data;  
239 - if (deviceId !== undefined && deviceId.length > 0) {  
240 - const joinDeviceIds = deviceId.join(',');  
241 - data = await getAttribute(orgId || props.provideOrgid, joinDeviceIds); 189 + const updateFieldAttributeFunc = async (e) => {
  190 + const res = await getAttribute(e);
  191 + let options: any = [];
  192 + if (Array.isArray(res)) {
  193 + options = res.map((m) => {
  194 + return {
  195 + label: m?.identifier,
  196 + value: m?.identifier,
  197 + };
  198 + });
  199 + updateSchema({
  200 + field: 'type2',
  201 + componentProps: {
  202 + placeholder: '请选择属性',
  203 + options,
  204 + },
  205 + });
242 } else { 206 } else {
243 - data = await getAttribute(orgId || props.provideOrgid, null); 207 + updateSchema({
  208 + field: 'type2',
  209 + componentProps: {
  210 + placeholder: '请选择属性',
  211 + options,
  212 + },
  213 + });
244 } 214 }
245 - //TODO-fengtao  
246 - const options = data.map((m) => {  
247 - return {  
248 - label: m,  
249 - value: m,  
250 - };  
251 - });  
252 - updateSchema({  
253 - field: 'type2',  
254 - componentProps: {  
255 - placeholder: '请选择属性',  
256 - options: options,  
257 - },  
258 - });  
259 }; 215 };
260 //TODO-fengtao 216 //TODO-fengtao
261 const handleDelete = (params: { index: number; title: string }) => { 217 const handleDelete = (params: { index: number; title: string }) => {
@@ -170,11 +170,10 @@ @@ -170,11 +170,10 @@
170 const changeOutTarget = () => { 170 const changeOutTarget = () => {
171 emit('getActionFormArr'); 171 emit('getActionFormArr');
172 }; 172 };
173 - const [registerAction, { getFieldsValue, resetFields, updateSchema, setFieldsValue, validate }] =  
174 - useForm({  
175 - schemas: actionSchema,  
176 - showActionButtonGroup: false,  
177 - }); 173 + const [registerAction, { getFieldsValue, resetFields, setFieldsValue, validate }] = useForm({
  174 + schemas: actionSchema,
  175 + showActionButtonGroup: false,
  176 + });
178 177
179 // 获取整个执行动作表单值 178 // 获取整个执行动作表单值
180 const getFieldsValueFunc = () => { 179 const getFieldsValueFunc = () => {
@@ -274,26 +273,14 @@ @@ -274,26 +273,14 @@
274 const isUpdateItem = ref(''); 273 const isUpdateItem = ref('');
275 const deviceListItem = ref([]); 274 const deviceListItem = ref([]);
276 275
277 - //TODO-fengtao  
278 - const updateFieldDeviceId = (deviceList, orgId, isUpdate, getMasterDeviceList) => { 276 + //update 2022-11-28
  277 + const updateFieldDeviceId = (deviceList, orgId, isUpdate) => {
279 if (isUpdate.value) { 278 if (isUpdate.value) {
280 orgIdItem.value = orgId.value; 279 orgIdItem.value = orgId.value;
281 } 280 }
282 orgIdItem.value = orgId.value; 281 orgIdItem.value = orgId.value;
283 isUpdateItem.value = isUpdate.value; 282 isUpdateItem.value = isUpdate.value;
284 - const options = getMasterDeviceList.value.map((m) => {  
285 - return {  
286 - value: m.id,  
287 - label: m.name,  
288 - };  
289 - });  
290 deviceListItem.value = deviceList.value; 283 deviceListItem.value = deviceList.value;
291 - updateSchema({  
292 - field: 'deviceId',  
293 - componentProps: {  
294 - options,  
295 - },  
296 - });  
297 }; 284 };
298 //FT add 2022-10-27 285 //FT add 2022-10-27
299 const updateEditFieldAlarmConfig = (alarmConfigList) => { 286 const updateEditFieldAlarmConfig = (alarmConfigList) => {