...
|
...
|
@@ -167,7 +167,7 @@ |
167
|
167
|
import AddTriggerForm from './addForm/trigger.vue';
|
168
|
168
|
import AddConditiForm from './addForm/condition.vue';
|
169
|
169
|
import AddActionForm from './addForm/doaction.vue';
|
170
|
|
- import { IAddTrigger, IAddCondition, IAddAction } from './index';
|
|
170
|
+ import { IAddTrigger } from './index';
|
171
|
171
|
import { Button } from '/@/components/Button';
|
172
|
172
|
|
173
|
173
|
export default defineComponent({
|
...
|
...
|
@@ -184,8 +184,6 @@ |
184
|
184
|
setup(_, { emit }) {
|
185
|
185
|
const { proxy } = getCurrentInstance();
|
186
|
186
|
const lastEditRefTriggerChildDataArray = ref<[]>([]);
|
187
|
|
- const lastEditRefConditionChildDataArray = ref<[]>([]);
|
188
|
|
- const lastEditRefActionChildDataArray = ref<[]>([]);
|
189
|
187
|
const lastRefTriggerChildDataArray = ref<[]>([]);
|
190
|
188
|
const lastRefConditionChildDataArray = ref<[]>([]);
|
191
|
189
|
const lastRefActionChildDataArray = ref<[]>([]);
|
...
|
...
|
@@ -200,42 +198,6 @@ |
200
|
198
|
compare: '',
|
201
|
199
|
value: '',
|
202
|
200
|
});
|
203
|
|
- const editTriggerData = reactive<IAddTrigger>({
|
204
|
|
- triggerType: '',
|
205
|
|
- entityId: '请选择设备',
|
206
|
|
- touchWay: '请选择触发方式',
|
207
|
|
- attributeChoose: '请选择属性',
|
208
|
|
- compare: '',
|
209
|
|
- value: '',
|
210
|
|
- });
|
211
|
|
- const addConditionData = reactive<IAddCondition>({
|
212
|
|
- triggerType: '',
|
213
|
|
- entityId: '',
|
214
|
|
- createTime: '',
|
215
|
|
- updateTime: '',
|
216
|
|
- compare: '',
|
217
|
|
- value: '',
|
218
|
|
- });
|
219
|
|
- const editConditionData = reactive<IAddCondition>({
|
220
|
|
- entityId: '请选择设备',
|
221
|
|
- createTime: '',
|
222
|
|
- updateTime: '',
|
223
|
|
- triggerType: '',
|
224
|
|
- compare: '',
|
225
|
|
- value: '',
|
226
|
|
- });
|
227
|
|
- const addActionData = reactive<IAddAction>({
|
228
|
|
- outTarget: '',
|
229
|
|
- entityId: '',
|
230
|
|
- command: '',
|
231
|
|
- sceneLinkageId: '',
|
232
|
|
- });
|
233
|
|
- const editActionData = reactive<IAddAction>({
|
234
|
|
- outTarget: '',
|
235
|
|
- entityId: '请选择设备',
|
236
|
|
- command: '请输入执行命令',
|
237
|
|
- sceneLinkageId: '',
|
238
|
|
- });
|
239
|
201
|
const addTriggerPushData = ref<[]>([]);
|
240
|
202
|
const addConditionPushData = ref<[]>([]);
|
241
|
203
|
const addActionPushData = ref<[]>([]);
|
...
|
...
|
@@ -261,10 +223,9 @@ |
261
|
223
|
const newConditionFilterMap = ref<[]>([]);
|
262
|
224
|
const newActionFilterMap = ref<[]>([]);
|
263
|
225
|
let filterNewConditionArr = [];
|
264
|
|
- let filterNewActionArr = [];
|
265
|
|
- const pushEditArray = [];
|
266
|
|
- const pushEditConditionArray = [];
|
267
|
|
- const pushEditActionArray = [];
|
|
226
|
+ const pushEditArray = ref<any>([{}]);
|
|
227
|
+ const pushEditConditionArray = ref<any>([{}]);
|
|
228
|
+ const pushEditActionArray = ref<any>([{}]);
|
268
|
229
|
let filterArrayTrigger = [];
|
269
|
230
|
const filterArrayCondition = ref<[]>([]);
|
270
|
231
|
const filterArrayAction = ref<[]>([]);
|
...
|
...
|
@@ -279,6 +240,7 @@ |
279
|
240
|
doActions: [],
|
280
|
241
|
};
|
281
|
242
|
let optionsItemArray = ref<[]>([]);
|
|
243
|
+ const isNoChange = ref(false);
|
282
|
244
|
|
283
|
245
|
const [registerForm, { resetFields, setFieldsValue, validateFields }] = useForm({
|
284
|
246
|
labelWidth: 120,
|
...
|
...
|
@@ -291,8 +253,6 @@ |
291
|
253
|
isUpdate.value = !!data?.isUpdate;
|
292
|
254
|
if (!unref(isUpdate)) {
|
293
|
255
|
try {
|
294
|
|
- filterNewActionArr = [];
|
295
|
|
- filterNewActionArr.length = 0;
|
296
|
256
|
refTriggerChildData = {};
|
297
|
257
|
refConditionChildData = {};
|
298
|
258
|
refActionChildData = {};
|
...
|
...
|
@@ -337,45 +297,51 @@ |
337
|
297
|
return e;
|
338
|
298
|
}
|
339
|
299
|
} else {
|
340
|
|
- newFilterMap.value = [];
|
341
|
|
- newConditionFilterMap.value = [];
|
342
|
|
- newActionFilterMap.value = [];
|
343
|
|
- clearAllArrayFunc();
|
344
|
|
- editTriggerPushData.value = [];
|
345
|
|
- editTriggerPushData.value.length = 0;
|
346
|
|
- editConditionPushData.value = [];
|
347
|
|
- editConditionPushData.value.length = 0;
|
348
|
|
- editActionPushData.value = [];
|
349
|
|
- editActionPushData.value.length = 0;
|
350
|
|
- lastEditRefTriggerChildDataArray.value = [];
|
351
|
|
- getId.value = data.record.id;
|
352
|
|
- getTenantId.value = data.record.tenantId;
|
353
|
|
- await setFieldsValue({
|
354
|
|
- ...data.record,
|
355
|
|
- });
|
356
|
|
- editTriggerPushData.value = data.record.triggers;
|
357
|
|
- editConditionPushData.value = data.record.doConditions;
|
358
|
|
- editActionPushData.value = data.record.doActions;
|
359
|
|
- const options = await screenLinkPageByDeptIdGetDevice({
|
360
|
|
- organizationId: data.record.organizationId,
|
361
|
|
- });
|
362
|
300
|
try {
|
|
301
|
+ pushEditArray.value = [];
|
|
302
|
+ pushEditArray.value.length = 0;
|
|
303
|
+ pushEditConditionArray.value.length = 0;
|
|
304
|
+ pushEditConditionArray.value = [];
|
|
305
|
+ pushEditActionArray.value = [];
|
|
306
|
+ pushEditActionArray.value.length = 0;
|
|
307
|
+ newFilterMap.value = [];
|
|
308
|
+ newConditionFilterMap.value = [];
|
|
309
|
+ newActionFilterMap.value = [];
|
|
310
|
+ clearAllArrayFunc();
|
|
311
|
+ editTriggerPushData.value = [];
|
|
312
|
+ editTriggerPushData.value.length = 0;
|
|
313
|
+ editConditionPushData.value = [];
|
|
314
|
+ editConditionPushData.value.length = 0;
|
|
315
|
+ editActionPushData.value = [];
|
|
316
|
+ editActionPushData.value.length = 0;
|
|
317
|
+ lastEditRefTriggerChildDataArray.value = [];
|
|
318
|
+ getId.value = data.record.id;
|
|
319
|
+ getTenantId.value = data.record.tenantId;
|
|
320
|
+ await setFieldsValue({
|
|
321
|
+ ...data.record,
|
|
322
|
+ });
|
|
323
|
+ editTriggerPushData.value = data.record.triggers;
|
|
324
|
+ isNoChange.value = true;
|
|
325
|
+ editConditionPushData.value = data.record.doConditions;
|
|
326
|
+ editActionPushData.value = data.record.doActions;
|
|
327
|
+ const options = await screenLinkPageByDeptIdGetDevice({
|
|
328
|
+ organizationId: data.record.organizationId,
|
|
329
|
+ });
|
363
|
330
|
data.record.triggers.forEach((f1) => {
|
364
|
331
|
options.items?.forEach((f2) => {
|
365
|
|
- if (f2.id == f1.entityId) {
|
|
332
|
+ if (f2.tbDeviceId == f1.entityId) {
|
366
|
333
|
newFilterMap.value.push({
|
367
|
|
- value: f2.id,
|
|
334
|
+ value: f2.tbDeviceId,
|
368
|
335
|
label: f2.name,
|
369
|
336
|
});
|
370
|
337
|
}
|
371
|
338
|
});
|
372
|
339
|
});
|
373
|
|
-
|
374
|
340
|
data.record.doConditions.forEach((f1) => {
|
375
|
341
|
options.items?.forEach((f2) => {
|
376
|
|
- if (f2.id == f1.entityId) {
|
|
342
|
+ if (f2.tbDeviceId == f1.entityId) {
|
377
|
343
|
newConditionFilterMap.value.push({
|
378
|
|
- value: f2.id,
|
|
344
|
+ value: f2.tbDeviceId,
|
379
|
345
|
label: f2.name,
|
380
|
346
|
});
|
381
|
347
|
}
|
...
|
...
|
@@ -383,20 +349,24 @@ |
383
|
349
|
});
|
384
|
350
|
data.record.doActions.forEach((f1) => {
|
385
|
351
|
options.items?.forEach((f2) => {
|
386
|
|
- if (f2.id == f1.entityId) {
|
|
352
|
+ if (f2.tbDeviceId == f1.deviceId) {
|
387
|
353
|
newActionFilterMap.value.push({
|
388
|
|
- value: f2.id,
|
|
354
|
+ value: f2.tbDeviceId,
|
389
|
355
|
label: f2.name,
|
390
|
356
|
});
|
391
|
357
|
}
|
392
|
358
|
});
|
393
|
359
|
});
|
394
|
|
- } catch (e) {}
|
|
360
|
+ } catch (e) {
|
|
361
|
+ return e;
|
|
362
|
+ }
|
395
|
363
|
}
|
396
|
364
|
});
|
397
|
365
|
const getTitle = computed(() => (!unref(isUpdate) ? '新增场景联动' : '编辑场景联动'));
|
398
|
366
|
const handleClose = () => {
|
399
|
|
- pushEditArray.length = 0;
|
|
367
|
+ pushEditArray.value.length = 0;
|
|
368
|
+ pushEditConditionArray.value.length = 0;
|
|
369
|
+ pushEditActionArray.value.length = 0;
|
400
|
370
|
lastRefTriggerChildDataArray.value.length = 0;
|
401
|
371
|
lastRefTriggerChildDataArray.value = [];
|
402
|
372
|
lastRefConditionChildDataArray.value.length = 0;
|
...
|
...
|
@@ -431,12 +401,9 @@ |
431
|
401
|
}
|
432
|
402
|
};
|
433
|
403
|
watch(getData, async (newV) => {
|
434
|
|
- // getDeviceInfo.value = newV;
|
435
|
|
- // getDeviceInfo1.value = newV;
|
436
|
|
- // getDeviceInfo2.value = newV;
|
437
|
404
|
const options = await screenLinkPageByDeptIdGetDevice({ organizationId: newV });
|
438
|
405
|
options.items.forEach((v) => {
|
439
|
|
- return (v.value = v.id), (v.label = v.name);
|
|
406
|
+ return (v.value = v.tbDeviceId), (v.label = v.name);
|
440
|
407
|
});
|
441
|
408
|
optionsItemArray.value = options.items;
|
442
|
409
|
updateDeviceIdFunc(optionsItemArray.value);
|
...
|
...
|
@@ -457,7 +424,7 @@ |
457
|
424
|
}
|
458
|
425
|
};
|
459
|
426
|
|
460
|
|
- //触发器方法
|
|
427
|
+ //获取触发器方法
|
461
|
428
|
const refTriggerChildDataFunc = () => {
|
462
|
429
|
try {
|
463
|
430
|
refTriggerChildData = proxy.$refs.refTriggerChild.getFieldsValueFunc();
|
...
|
...
|
@@ -465,7 +432,7 @@ |
465
|
432
|
return e;
|
466
|
433
|
}
|
467
|
434
|
};
|
468
|
|
- //执行条件方法
|
|
435
|
+ //获取执行条件方法
|
469
|
436
|
const refConditionChildDataFunc = () => {
|
470
|
437
|
try {
|
471
|
438
|
refConditionChildData = proxy.$refs.refConditionChild.getFieldsValueFunc();
|
...
|
...
|
@@ -473,7 +440,7 @@ |
473
|
440
|
return e;
|
474
|
441
|
}
|
475
|
442
|
};
|
476
|
|
- //执行动作方法
|
|
443
|
+ //获取执行动作方法
|
477
|
444
|
const refActionChildDataFunc = () => {
|
478
|
445
|
try {
|
479
|
446
|
refActionChildData = proxy.$refs.refActionChild.getFieldsValueFunc();
|
...
|
...
|
@@ -484,101 +451,75 @@ |
484
|
451
|
|
485
|
452
|
const getDefaultValue = () => {
|
486
|
453
|
if (!unref(isUpdate)) {
|
|
454
|
+ refTriggerChildDataFunc();
|
|
455
|
+ refConditionChildDataFunc();
|
|
456
|
+ refActionChildDataFunc();
|
|
457
|
+ const newTriggerArray = addTriggerPushData.value.concat(refTriggerChildData);
|
|
458
|
+ const newConditionArray = addConditionPushData.value.concat(refConditionChildData);
|
|
459
|
+ const newActionArray = addActionPushData.value.concat(refActionChildData);
|
|
460
|
+ newTriggerArray.shift();
|
|
461
|
+ newConditionArray.shift();
|
|
462
|
+ newActionArray.shift();
|
487
|
463
|
delete getAllFormData.id;
|
488
|
464
|
delete getAllFormData.getTenantId;
|
489
|
465
|
triggersObj = {
|
490
|
|
- triggers: lastRefTriggerChildDataArray.value,
|
|
466
|
+ triggers: newTriggerArray,
|
491
|
467
|
};
|
492
|
468
|
conditionsObj = {
|
493
|
|
- doConditions: lastRefConditionChildDataArray.value,
|
|
469
|
+ doConditions: newConditionArray,
|
494
|
470
|
};
|
495
|
471
|
actionsObj = {
|
496
|
|
- doActions: lastRefActionChildDataArray.value,
|
|
472
|
+ doActions: newActionArray,
|
497
|
473
|
};
|
498
|
474
|
Object.assign(getAllFormData, triggersObj, conditionsObj, actionsObj);
|
499
|
475
|
} else {
|
500
|
|
- refTriggerChildDataFunc();
|
501
|
|
- refConditionChildDataFunc();
|
502
|
|
- refActionChildDataFunc();
|
503
|
|
- pushEditArray.push(refTriggerChildData as never);
|
504
|
|
- pushEditConditionArray.push(refConditionChildData as never);
|
505
|
|
- pushEditActionArray.push(refActionChildData as never);
|
506
|
|
- pushEditArray.forEach((f) => {
|
507
|
|
- editTriggerPushData.value.push(f as never);
|
508
|
|
- });
|
509
|
|
- pushEditConditionArray.forEach((f) => {
|
510
|
|
- editConditionPushData.value.push(f as never);
|
511
|
|
- });
|
512
|
|
- pushEditActionArray.forEach((f) => {
|
513
|
|
- editActionPushData.value.push(f as never);
|
514
|
|
- });
|
515
|
|
- const filterTwoArrayTrigger = editTriggerPushData.value.filter((f) =>
|
516
|
|
- f?.hasOwnProperty('id')
|
517
|
|
- );
|
518
|
|
-
|
519
|
|
- const filterTwoArrayCondition = editConditionPushData.value.filter((f) =>
|
520
|
|
- f?.hasOwnProperty('id')
|
521
|
|
- );
|
522
|
|
-
|
523
|
|
- const filterTwoArrayAction = editActionPushData.value.filter((f) =>
|
524
|
|
- f?.hasOwnProperty('id')
|
525
|
|
- );
|
526
|
|
-
|
527
|
|
- const filterThreeArrayTrigger = editTriggerPushData.value.filter(
|
528
|
|
- (f) => f?.entityId == ''
|
529
|
|
- );
|
530
|
|
- const filterThreeArrayCondition = editConditionPushData.value.filter(
|
531
|
|
- (f) => f?.entityId == ''
|
532
|
|
- );
|
533
|
|
- const filterThreeArrayAction = editActionPushData.value.filter((f) => f?.entityId == '');
|
534
|
|
- const filterFourArrayTrigger = filterThreeArrayTrigger.filter(
|
535
|
|
- (f) => f?.triggerType !== ''
|
536
|
|
- );
|
537
|
|
- const filterFourArrayCondition = filterThreeArrayCondition.filter(
|
538
|
|
- (f) => f?.triggerType !== ''
|
539
|
|
- );
|
540
|
|
-
|
541
|
|
- const filterFourArrayAction = filterThreeArrayAction.filter((f) => f?.outTarget !== '');
|
542
|
|
-
|
543
|
|
- filterFourArrayTrigger.forEach((f) => {
|
544
|
|
- filterTwoArrayTrigger.push(f);
|
|
476
|
+ let kongTriggerObj = {};
|
|
477
|
+ let kongConditionObj = {};
|
|
478
|
+ let kongActionObj = {};
|
|
479
|
+ editTriggerPushData.value.forEach((f) => {
|
|
480
|
+ kongTriggerObj = f;
|
|
481
|
+ pushEditArray.value.push(kongTriggerObj);
|
545
|
482
|
});
|
546
|
|
- filterFourArrayCondition.forEach((f) => {
|
547
|
|
- filterTwoArrayCondition.push(f);
|
|
483
|
+ editConditionPushData.value.forEach((f) => {
|
|
484
|
+ kongConditionObj = f;
|
|
485
|
+ pushEditConditionArray.value.push(kongConditionObj);
|
548
|
486
|
});
|
549
|
|
- filterFourArrayAction.forEach((f) => {
|
550
|
|
- filterTwoArrayAction.push(f);
|
|
487
|
+ editActionPushData.value.forEach((f) => {
|
|
488
|
+ kongActionObj = f;
|
|
489
|
+ pushEditActionArray.value.push(kongActionObj);
|
551
|
490
|
});
|
552
|
|
-
|
553
|
|
- let editTriggersObj = {
|
554
|
|
- triggers: filterTwoArrayTrigger,
|
|
491
|
+ refTriggerChildDataFunc();
|
|
492
|
+ let newTriggerArray = pushEditArray.value.concat(refTriggerChildData);
|
|
493
|
+ newTriggerArray = newTriggerArray.filter((f) => Object.keys(f).length !== 0);
|
|
494
|
+ newTriggerArray.shift();
|
|
495
|
+ triggersObj = {
|
|
496
|
+ triggers: isNoChange.value ? editTriggerPushData.value : newTriggerArray,
|
555
|
497
|
};
|
556
|
|
- let editConditionsObj = {
|
557
|
|
- doConditions: filterTwoArrayCondition,
|
|
498
|
+ refConditionChildDataFunc();
|
|
499
|
+ let newConditionArray = pushEditConditionArray.value.concat(refConditionChildData);
|
|
500
|
+ newConditionArray = newConditionArray.filter((f) => Object.keys(f).length !== 0);
|
|
501
|
+ newConditionArray.shift();
|
|
502
|
+ conditionsObj = {
|
|
503
|
+ doConditions: newConditionArray,
|
558
|
504
|
};
|
559
|
|
- let editActionsObj = {
|
560
|
|
- doActions: filterTwoArrayAction,
|
|
505
|
+ refActionChildDataFunc();
|
|
506
|
+ let newActionArray = pushEditActionArray.value.concat(refActionChildData);
|
|
507
|
+ newActionArray = newActionArray.filter((f) => Object.keys(f).length !== 0);
|
|
508
|
+ newActionArray.shift();
|
|
509
|
+ actionsObj = {
|
|
510
|
+ doActions: newActionArray,
|
561
|
511
|
};
|
562
|
|
- Object.assign(getAllFormData, editTriggersObj, editConditionsObj, editActionsObj);
|
|
512
|
+ Object.assign(getAllFormData, triggersObj, conditionsObj, actionsObj);
|
563
|
513
|
}
|
564
|
514
|
};
|
565
|
515
|
|
566
|
516
|
const handleSubmit = async () => {
|
567
|
517
|
if (!unref(isUpdate)) {
|
568
|
|
- addTrigger();
|
569
|
|
- addCondition();
|
570
|
|
- addAction();
|
571
|
518
|
getDefaultValue();
|
572
|
519
|
getValuesFormData = await validateFields();
|
573
|
520
|
if (!getValuesFormData) return;
|
|
521
|
+ if (getAllFormData.doActions.length == 0) return createMessage.error('请填写执行动作');
|
574
|
522
|
Object.assign(getAllFormData, getValuesFormData);
|
575
|
|
- let kongObj = true;
|
576
|
|
- lastRefActionChildDataArray.value.forEach((f) => {
|
577
|
|
- if (Object.keys(f).length == 0) {
|
578
|
|
- kongObj = false;
|
579
|
|
- }
|
580
|
|
- });
|
581
|
|
- if (!kongObj) return createMessage.error('请填写执行动作');
|
582
|
523
|
await screenLinkPageAddApi(getAllFormData);
|
583
|
524
|
createMessage.success('场景联动新增成功');
|
584
|
525
|
closeDrawer();
|
...
|
...
|
@@ -589,49 +530,41 @@ |
589
|
530
|
Object.assign(getAllFormData, getValuesFormData);
|
590
|
531
|
getAllFormData.id = getId.value;
|
591
|
532
|
getAllFormData.tenantId = getTenantId.value;
|
|
533
|
+ refTriggerChildData = {};
|
|
534
|
+ pushEditArray.value.length = 0;
|
|
535
|
+ pushEditConditionArray.value.length = 0;
|
|
536
|
+ pushEditActionArray.value.length = 0;
|
|
537
|
+ console.log('edit data', getAllFormData);
|
592
|
538
|
await screenLinkPageUpdateApi(getAllFormData);
|
593
|
539
|
createMessage.success('场景联动编辑成功');
|
594
|
540
|
closeDrawer();
|
595
|
541
|
emit('success');
|
596
|
542
|
}
|
597
|
543
|
};
|
598
|
|
-
|
599
|
|
- //默认添加触发器
|
600
|
|
- const defaultAddTrigger = () => {
|
601
|
|
- if (unref(addTriggerPushData).length == 0) {
|
602
|
|
- setTimeout(() => {
|
603
|
|
- addTrigger();
|
604
|
|
- }, 10);
|
605
|
|
- }
|
606
|
|
- };
|
607
|
544
|
//新增触发器
|
608
|
545
|
const addTrigger = () => {
|
609
|
546
|
if (!unref(isUpdate)) {
|
610
|
|
- unref(addTriggerPushData).push(addTriggerData as never);
|
611
|
547
|
refTriggerChildDataFunc();
|
612
|
|
- filterNewTriggerArr.push(refTriggerChildData as never);
|
613
|
|
- (lastRefTriggerChildDataArray.value as never[]) = filterNewTriggerArr.filter(
|
614
|
|
- (v) => Object.keys(v).length !== 0
|
615
|
|
- );
|
616
|
|
- const newGetTriggerData = lastRefTriggerChildDataArray.value.map((m) => {
|
|
548
|
+ unref(addTriggerPushData).push(refTriggerChildData as never);
|
|
549
|
+ addTriggerPushData.value = addTriggerPushData.value.map((m) => {
|
617
|
550
|
return {
|
618
|
551
|
triggerType: m?.triggerType,
|
619
|
|
- entityId: m?.entityId,
|
|
552
|
+ entityId: m?.entityId || m?.entityId1 || m?.entityId2,
|
620
|
553
|
triggerCondition: {
|
621
|
554
|
condition: [
|
622
|
555
|
{
|
623
|
556
|
key: {
|
624
|
|
- key: 'CO2',
|
625
|
|
- type: 'TIME_SERIES',
|
|
557
|
+ key: m.key1 == null ? 'CO2' : m.key1,
|
|
558
|
+ type: m.type1 == null ? 'TIME_SERIES' : m.type1,
|
626
|
559
|
},
|
627
|
|
- valueType: 'NUMERIC',
|
|
560
|
+ valueType: m.type2 == null ? 'NUMERIC' : m.type2,
|
628
|
561
|
value: {},
|
629
|
562
|
predicate: {
|
630
|
|
- type: 'NUMERIC',
|
|
563
|
+ type: m.type2 == null ? 'NUMERIC' : m.type2,
|
631
|
564
|
value: {
|
632
|
|
- defaultValue: Number(m.value),
|
|
565
|
+ defaultValue: Number(m.value) == null ? 0 : Number(m.value),
|
633
|
566
|
},
|
634
|
|
- operation: m.operation,
|
|
567
|
+ operation: m.operation == null ? 'GREATER_OR_EQUAL' : m.operation,
|
635
|
568
|
},
|
636
|
569
|
},
|
637
|
570
|
],
|
...
|
...
|
@@ -641,7 +574,6 @@ |
641
|
574
|
},
|
642
|
575
|
};
|
643
|
576
|
});
|
644
|
|
- lastRefTriggerChildDataArray.value = newGetTriggerData;
|
645
|
577
|
try {
|
646
|
578
|
setTimeout(() => {
|
647
|
579
|
proxy.$refs.refTriggerChild.updateFieldDeviceId(optionsItemArray.value);
|
...
|
...
|
@@ -650,45 +582,70 @@ |
650
|
582
|
return e;
|
651
|
583
|
}
|
652
|
584
|
} else {
|
|
585
|
+ isNoChange.value = false;
|
|
586
|
+ unref(editTriggerPushData).push(refTriggerChildData as never);
|
653
|
587
|
refTriggerChildDataFunc();
|
654
|
|
- pushEditArray.push(refTriggerChildData as never);
|
655
|
|
- unref(editTriggerPushData).push(addTriggerData as never);
|
|
588
|
+ pushEditArray.value.push(refTriggerChildData);
|
|
589
|
+ pushEditArray.value = pushEditArray.value.map((m) => {
|
|
590
|
+ return {
|
|
591
|
+ triggerType: m?.triggerType,
|
|
592
|
+ entityId: m?.entityId || m?.entityId1 || m?.entityId2,
|
|
593
|
+ triggerCondition: {
|
|
594
|
+ condition: [
|
|
595
|
+ {
|
|
596
|
+ key: {
|
|
597
|
+ key: m.key1 == null ? 'CO2' : m.key1,
|
|
598
|
+ type: m.type1 == null ? 'TIME_SERIES' : m.type1,
|
|
599
|
+ },
|
|
600
|
+ valueType: m.type2 == null ? 'NUMERIC' : m.type2,
|
|
601
|
+ value: {},
|
|
602
|
+ predicate: {
|
|
603
|
+ type: m.type2 == null ? 'NUMERIC' : m.type2,
|
|
604
|
+ value: {
|
|
605
|
+ defaultValue: Number(m.value) == null ? 0 : Number(m.value),
|
|
606
|
+ },
|
|
607
|
+ operation: m.operation == null ? 'GREATER_OR_EQUAL' : m.operation,
|
|
608
|
+ },
|
|
609
|
+ },
|
|
610
|
+ ],
|
|
611
|
+ spec: {
|
|
612
|
+ type: 'SIMPLE',
|
|
613
|
+ },
|
|
614
|
+ },
|
|
615
|
+ };
|
|
616
|
+ });
|
|
617
|
+ try {
|
|
618
|
+ setTimeout(() => {
|
|
619
|
+ proxy.$refs.refTriggerChild.updateFieldDeviceId(optionsItemArray.value);
|
|
620
|
+ }, 150);
|
|
621
|
+ } catch (e) {
|
|
622
|
+ return e;
|
|
623
|
+ }
|
|
624
|
+ refTriggerChildData = {};
|
656
|
625
|
}
|
657
|
626
|
};
|
658
|
627
|
const removeTrigger = () => {
|
659
|
628
|
if (!unref(isUpdate)) {
|
660
|
629
|
try {
|
661
|
|
- unref(addTriggerPushData).splice(0, 1);
|
662
|
|
- lastRefTriggerChildDataArray.value.splice(0, 1);
|
|
630
|
+ unref(addTriggerPushData).pop();
|
663
|
631
|
} catch (e) {
|
664
|
632
|
return e;
|
665
|
633
|
}
|
666
|
634
|
} else {
|
667
|
635
|
try {
|
668
|
|
- unref(editTriggerPushData).splice(0, 1);
|
669
|
|
- lastEditRefTriggerChildDataArray.value.pop();
|
|
636
|
+ unref(editTriggerPushData).pop();
|
670
|
637
|
} catch (e) {
|
671
|
638
|
return e;
|
672
|
639
|
}
|
673
|
640
|
}
|
674
|
641
|
};
|
675
|
642
|
|
676
|
|
- //默认添加执行条件
|
677
|
|
- const defaultAddCondition = () => {
|
678
|
|
- if (unref(addConditionPushData).length == 0) {
|
679
|
|
- addCondition();
|
680
|
|
- }
|
681
|
|
- };
|
682
|
643
|
//新增执行条件
|
683
|
644
|
const addCondition = () => {
|
684
|
645
|
if (!unref(isUpdate)) {
|
685
|
|
- unref(addConditionPushData).push(addConditionData as never);
|
686
|
646
|
refConditionChildDataFunc();
|
687
|
|
- filterNewConditionArr.push(refConditionChildData as never);
|
688
|
|
- (lastRefConditionChildDataArray.value as never[]) = filterNewConditionArr.filter(
|
689
|
|
- (v) => Object.keys(v).length !== 0
|
690
|
|
- );
|
691
|
|
- const newGetConditionData = lastRefConditionChildDataArray.value.map((m) => {
|
|
647
|
+ unref(addConditionPushData).push(refConditionChildData as never);
|
|
648
|
+ addConditionPushData.value = addConditionPushData.value.map((m) => {
|
692
|
649
|
return {
|
693
|
650
|
triggerType: m?.triggerType,
|
694
|
651
|
entityId: m?.entityId,
|
...
|
...
|
@@ -699,14 +656,29 @@ |
699
|
656
|
type: 'TIME_SERIES',
|
700
|
657
|
key: 'CO2',
|
701
|
658
|
},
|
702
|
|
- valueType: 'NUMERIC',
|
|
659
|
+ valueType:
|
|
660
|
+ m.type == 'NUMERIC1'
|
|
661
|
+ ? 'NUMERIC'
|
|
662
|
+ : m.type == 'NUMERIC2'
|
|
663
|
+ ? 'NUMERIC'
|
|
664
|
+ : 'NUMERIC',
|
703
|
665
|
value: {},
|
704
|
666
|
predicate: {
|
705
|
|
- type: 'NUMERIC',
|
|
667
|
+ type:
|
|
668
|
+ m.type == 'NUMERIC1'
|
|
669
|
+ ? 'NUMERIC'
|
|
670
|
+ : m.type == 'NUMERIC2'
|
|
671
|
+ ? 'NUMERIC'
|
|
672
|
+ : 'NUMERIC',
|
706
|
673
|
value: {
|
707
|
|
- defaultValue: Number(m.value),
|
|
674
|
+ defaultValue:
|
|
675
|
+ Number(m.value1) == null
|
|
676
|
+ ? 0
|
|
677
|
+ : Number(m.value1) || Number(m.value2) == null
|
|
678
|
+ ? 0
|
|
679
|
+ : Number(m.value2),
|
708
|
680
|
},
|
709
|
|
- operation: m.operation,
|
|
681
|
+ operation: m.operation1 || m.operatio2,
|
710
|
682
|
},
|
711
|
683
|
},
|
712
|
684
|
],
|
...
|
...
|
@@ -716,7 +688,6 @@ |
716
|
688
|
},
|
717
|
689
|
};
|
718
|
690
|
});
|
719
|
|
- lastRefConditionChildDataArray.value = newGetConditionData;
|
720
|
691
|
try {
|
721
|
692
|
setTimeout(() => {
|
722
|
693
|
proxy.$refs.refConditionChild.updateFieldDeviceId(optionsItemArray.value);
|
...
|
...
|
@@ -725,23 +696,73 @@ |
725
|
696
|
return e;
|
726
|
697
|
}
|
727
|
698
|
} else {
|
|
699
|
+ isNoChange.value = false;
|
|
700
|
+ unref(editConditionPushData).push(refConditionChildData as never);
|
728
|
701
|
refConditionChildDataFunc();
|
729
|
|
- pushEditConditionArray.push(refConditionChildData as never);
|
730
|
|
- unref(editConditionPushData).push(addConditionData as never);
|
|
702
|
+ pushEditConditionArray.value.push(refConditionChildData);
|
|
703
|
+ pushEditConditionArray.value = pushEditConditionArray.value.map((m) => {
|
|
704
|
+ return {
|
|
705
|
+ triggerType: m?.triggerType,
|
|
706
|
+ entityId: m?.entityId,
|
|
707
|
+ triggerCondition: {
|
|
708
|
+ condition: [
|
|
709
|
+ {
|
|
710
|
+ key: {
|
|
711
|
+ type: 'TIME_SERIES',
|
|
712
|
+ key: 'CO2',
|
|
713
|
+ },
|
|
714
|
+ valueType:
|
|
715
|
+ m.type == 'NUMERIC1'
|
|
716
|
+ ? 'NUMERIC'
|
|
717
|
+ : m.type == 'NUMERIC2'
|
|
718
|
+ ? 'NUMERIC'
|
|
719
|
+ : 'NUMERIC',
|
|
720
|
+ value: {},
|
|
721
|
+ predicate: {
|
|
722
|
+ type:
|
|
723
|
+ m.type == 'NUMERIC1'
|
|
724
|
+ ? 'NUMERIC'
|
|
725
|
+ : m.type == 'NUMERIC2'
|
|
726
|
+ ? 'NUMERIC'
|
|
727
|
+ : 'NUMERIC',
|
|
728
|
+ value: {
|
|
729
|
+ defaultValue:
|
|
730
|
+ Number(m.value1) == null
|
|
731
|
+ ? 0
|
|
732
|
+ : Number(m.value1) || Number(m.value2) == null
|
|
733
|
+ ? 0
|
|
734
|
+ : Number(m.value2),
|
|
735
|
+ },
|
|
736
|
+ operation: m.operation1 || m.operatio2,
|
|
737
|
+ },
|
|
738
|
+ },
|
|
739
|
+ ],
|
|
740
|
+ spec: {
|
|
741
|
+ type: 'SIMPLE',
|
|
742
|
+ },
|
|
743
|
+ },
|
|
744
|
+ };
|
|
745
|
+ });
|
|
746
|
+ try {
|
|
747
|
+ setTimeout(() => {
|
|
748
|
+ proxy.$refs.refConditionChild.updateFieldDeviceId(optionsItemArray.value);
|
|
749
|
+ }, 150);
|
|
750
|
+ } catch (e) {
|
|
751
|
+ return e;
|
|
752
|
+ }
|
|
753
|
+ refConditionChildData = {};
|
731
|
754
|
}
|
732
|
755
|
};
|
733
|
756
|
const removeCondition = () => {
|
734
|
757
|
if (!unref(isUpdate)) {
|
735
|
758
|
try {
|
736
|
|
- unref(addConditionPushData).splice(0, 1);
|
737
|
|
- lastRefConditionChildDataArray.value.pop();
|
|
759
|
+ unref(addConditionPushData).pop();
|
738
|
760
|
} catch (e) {
|
739
|
761
|
return e;
|
740
|
762
|
}
|
741
|
763
|
} else {
|
742
|
764
|
try {
|
743
|
765
|
unref(editConditionPushData).splice(0, 1);
|
744
|
|
- lastEditRefConditionChildDataArray.value.pop();
|
745
|
766
|
} catch (e) {
|
746
|
767
|
return e;
|
747
|
768
|
}
|
...
|
...
|
@@ -757,12 +778,8 @@ |
757
|
778
|
//新增执行动作
|
758
|
779
|
const addAction = () => {
|
759
|
780
|
if (!unref(isUpdate)) {
|
760
|
|
- unref(addActionPushData).push(addActionData as never);
|
761
|
781
|
refActionChildDataFunc();
|
762
|
|
- filterNewActionArr.push(refActionChildData as never);
|
763
|
|
- (lastRefActionChildDataArray.value as never[]) = filterNewActionArr.filter(
|
764
|
|
- (v) => Object.keys(v).length !== 0
|
765
|
|
- );
|
|
782
|
+ unref(addActionPushData).push(refActionChildData as never);
|
766
|
783
|
try {
|
767
|
784
|
setTimeout(() => {
|
768
|
785
|
proxy.$refs.refActionChild.updateFieldDeviceId(optionsItemArray.value);
|
...
|
...
|
@@ -771,23 +788,30 @@ |
771
|
788
|
return e;
|
772
|
789
|
}
|
773
|
790
|
} else {
|
|
791
|
+ isNoChange.value = false;
|
|
792
|
+ unref(editActionPushData).push(refActionChildData as never);
|
774
|
793
|
refActionChildDataFunc();
|
775
|
|
- pushEditActionArray.push(refActionChildData as never);
|
776
|
|
- unref(editActionPushData).push(addActionData as never);
|
|
794
|
+ pushEditActionArray.value.push(refActionChildData);
|
|
795
|
+ try {
|
|
796
|
+ setTimeout(() => {
|
|
797
|
+ proxy.$refs.refActionChild.updateFieldDeviceId(optionsItemArray.value);
|
|
798
|
+ }, 150);
|
|
799
|
+ } catch (e) {
|
|
800
|
+ return e;
|
|
801
|
+ }
|
|
802
|
+ refActionChildData = {};
|
777
|
803
|
}
|
778
|
804
|
};
|
779
|
805
|
const removeAction = () => {
|
780
|
806
|
if (!unref(isUpdate)) {
|
781
|
807
|
try {
|
782
|
|
- unref(addActionPushData).splice(0, 1);
|
783
|
|
- lastRefActionChildDataArray.value.pop();
|
|
808
|
+ unref(addActionPushData).pop();
|
784
|
809
|
} catch (e) {
|
785
|
810
|
return e;
|
786
|
811
|
}
|
787
|
812
|
} else {
|
788
|
813
|
try {
|
789
|
814
|
unref(editActionPushData).splice(0, 1);
|
790
|
|
- lastEditRefActionChildDataArray.value.pop();
|
791
|
815
|
} catch (e) {
|
792
|
816
|
return e;
|
793
|
817
|
}
|
...
|
...
|
@@ -797,8 +821,6 @@ |
797
|
821
|
return {
|
798
|
822
|
updateDeviceIdFunc,
|
799
|
823
|
handleClose,
|
800
|
|
- defaultAddTrigger,
|
801
|
|
- defaultAddCondition,
|
802
|
824
|
newFilterMap,
|
803
|
825
|
newConditionFilterMap,
|
804
|
826
|
newActionFilterMap,
|
...
|
...
|
|