...
|
...
|
@@ -99,7 +99,6 @@ |
99
|
99
|
screenLinkPageByDeptIdGetDevice,
|
100
|
100
|
getOrganizationAlarmConfig,
|
101
|
101
|
byOganizationIdGetMasterDevice,
|
102
|
|
- getAttribute,
|
103
|
102
|
} from '/@/api/ruleengine/ruleengineApi';
|
104
|
103
|
import TriggerOrCondition from './cpns/Trigger-Condition.vue';
|
105
|
104
|
import Action from './cpns/Action.vue';
|
...
|
...
|
@@ -107,8 +106,8 @@ |
107
|
106
|
import { formatToDateTime } from '/@/utils/dateUtil';
|
108
|
107
|
|
109
|
108
|
const emit = defineEmits(['register', 'success']);
|
110
|
|
-
|
111
|
109
|
const provideOrgid = ref('');
|
|
110
|
+
|
112
|
111
|
const { createMessage } = useMessage();
|
113
|
112
|
const triggerData = ref([]);
|
114
|
113
|
const conditionData = ref([]);
|
...
|
...
|
@@ -125,8 +124,6 @@ |
125
|
124
|
let getConditionFormValue = ref([]);
|
126
|
125
|
let getActionFormValue = ref([]);
|
127
|
126
|
const editEntryIdData = ref([]);
|
128
|
|
- const editEntryIdExcludeDoActionData = ref([]);
|
129
|
|
- let editAttrIdData = [];
|
130
|
127
|
const editAlarmConfigData = ref([]);
|
131
|
128
|
const isUpdate = ref(false);
|
132
|
129
|
const id = ref(undefined);
|
...
|
...
|
@@ -158,31 +155,24 @@ |
158
|
155
|
await setFieldsValue(data.record);
|
159
|
156
|
id.value = recordId;
|
160
|
157
|
tenantId.value = recordTenantId;
|
|
158
|
+ //TODO-fengtao-把组织id传给子组件
|
161
|
159
|
provideOrgid.value = organizationId;
|
|
160
|
+ //TODO-fengtao获取当前执行动作下的设备(master那个接口)
|
|
161
|
+ getMasterDeviceList.value = await byOganizationIdGetMasterDevice(organizationId);
|
|
162
|
+ //TODO-fengtao
|
162
|
163
|
// 获取当前组织下的设备列表
|
163
|
|
- const options = await byOganizationIdGetMasterDevice(organizationId);
|
164
|
|
- const optionsExcludeDoAction = await screenLinkPageByDeptIdGetDevice({ organizationId });
|
|
164
|
+ const options = await screenLinkPageByDeptIdGetDevice({
|
|
165
|
+ organizationId,
|
|
166
|
+ });
|
165
|
167
|
// 获取当前组织下的告警配置
|
166
|
168
|
const alarmConfig = await getOrganizationAlarmConfig({ organizationId });
|
167
|
|
- // 获取当前组织下的属性列表
|
168
|
|
- const attrList = await getAttribute(
|
169
|
|
- organizationId,
|
170
|
|
- triggers.map((m) => m.entityId).join(',')
|
171
|
|
- );
|
172
|
|
- watchAttrList.value = await getAttribute(organizationId, null);
|
173
|
169
|
|
174
|
170
|
// 生成回显时对应得组件数量
|
175
|
171
|
triggerData.value = [...new Array(triggers.length).keys()];
|
176
|
172
|
conditionData.value = [...new Array(doConditions.length).keys()];
|
177
|
173
|
actionData.value = [...new Array(doActions.length).keys()];
|
178
|
174
|
// 回显设备列表
|
179
|
|
- editEntryIdData.value = options.map((item) => {
|
180
|
|
- return {
|
181
|
|
- value: item.id,
|
182
|
|
- label: item.name,
|
183
|
|
- };
|
184
|
|
- });
|
185
|
|
- editEntryIdExcludeDoActionData.value = optionsExcludeDoAction.items.map((item) => {
|
|
175
|
+ editEntryIdData.value = options.items.map((item) => {
|
186
|
176
|
return {
|
187
|
177
|
value: item.tbDeviceId,
|
188
|
178
|
label: item.name,
|
...
|
...
|
@@ -195,17 +185,11 @@ |
195
|
185
|
};
|
196
|
186
|
});
|
197
|
187
|
deviceList.value = editEntryIdData.value;
|
198
|
|
- deviceExcludeDoAction.value = editEntryIdExcludeDoActionData.value;
|
199
|
|
-
|
200
|
|
- //回显属性列表
|
201
|
|
- editAttrIdData = attrList;
|
202
|
188
|
nextTick(() => {
|
203
|
|
- setEditFields(skipUnwrap.triggerItemRefs, editEntryIdExcludeDoActionData);
|
204
|
|
- setEditFields(skipUnwrap.conditionItemRefs, editEntryIdExcludeDoActionData);
|
|
189
|
+ setEditFields(skipUnwrap.triggerItemRefs, editEntryIdData);
|
|
190
|
+ setEditFields(skipUnwrap.conditionItemRefs, editEntryIdData);
|
205
|
191
|
setEditFields(skipUnwrap.actionItemRefs, editEntryIdData);
|
206
|
192
|
setEditAlarmConfig(skipUnwrap.actionItemRefs, editAlarmConfigData);
|
207
|
|
- setEditAttr(skipUnwrap.triggerItemRefs, editAttrIdData);
|
208
|
|
- setEditAttr(skipUnwrap.conditionItemRefs, editAttrIdData);
|
209
|
193
|
});
|
210
|
194
|
|
211
|
195
|
const map = {
|
...
|
...
|
@@ -216,6 +200,7 @@ |
216
|
200
|
// 回显触发器数据---此处是个闭包!
|
217
|
201
|
triggers.forEach((trigger, index) => {
|
218
|
202
|
nextTick(async () => {
|
|
203
|
+ const selectDeviceId = ref('');
|
219
|
204
|
// 回显启用规则
|
220
|
205
|
unref(skipUnwrap.triggerItemRefs)[index].currentIndex =
|
221
|
206
|
map[trigger.triggerCondition.schedule.type];
|
...
|
...
|
@@ -223,15 +208,12 @@ |
223
|
208
|
unref(skipUnwrap.triggerItemRefs)[index].isUpdate = true;
|
224
|
209
|
unref(skipUnwrap.triggerItemRefs)[index].alarmScheduleRef.scheduleData =
|
225
|
210
|
trigger.triggerCondition.schedule;
|
226
|
|
- const getAttrKeyOption = trigger?.triggerCondition?.condition?.condition?.map(
|
227
|
|
- (m) => m.key.key
|
228
|
|
- );
|
229
|
211
|
unref(skipUnwrap.triggerItemRefs)[index].setFieldsFormValueFun({
|
230
|
212
|
triggered: trigger?.triggerCondition?.condition?.spec?.type,
|
231
|
213
|
device: trigger?.entityType,
|
232
|
214
|
triggerType: trigger?.triggerType,
|
233
|
215
|
type1: trigger?.triggerCondition?.condition?.condition[0]?.key?.type,
|
234
|
|
- type2: getAttrKeyOption,
|
|
216
|
+ type2: trigger?.triggerCondition?.condition?.condition[0]?.key?.key,
|
235
|
217
|
operationType: trigger?.triggerCondition?.condition?.condition[0]?.valueType,
|
236
|
218
|
detail: trigger?.triggerCondition?.alarmDetails,
|
237
|
219
|
entityId: trigger?.entityId,
|
...
|
...
|
@@ -239,6 +221,15 @@ |
239
|
221
|
time: trigger?.triggerCondition?.condition?.spec?.predicate?.defaultValue,
|
240
|
222
|
timeUnit: trigger?.triggerCondition?.condition?.spec?.unit,
|
241
|
223
|
});
|
|
224
|
+ if (trigger.entityId != undefined) {
|
|
225
|
+ selectDeviceId.value = trigger?.entityId;
|
|
226
|
+ }
|
|
227
|
+ //fengtao-把设备id回传给子组件
|
|
228
|
+ unref(skipUnwrap.triggerItemRefs)[index].updateFieldAttributeFunc(
|
|
229
|
+ selectDeviceId.value,
|
|
230
|
+ provideOrgid.value
|
|
231
|
+ );
|
|
232
|
+ //fengtao
|
242
|
233
|
// 设置值operationType
|
243
|
234
|
unref(skipUnwrap.triggerItemRefs)[index].operationType =
|
244
|
235
|
trigger.triggerCondition?.condition.condition[0].valueType;
|
...
|
...
|
@@ -298,15 +289,12 @@ |
298
|
289
|
unref(skipUnwrap.conditionItemRefs)[index].isUpdate = true;
|
299
|
290
|
unref(skipUnwrap.conditionItemRefs)[index].alarmScheduleRef.scheduleData =
|
300
|
291
|
condition.triggerCondition.schedule;
|
301
|
|
- const getAttrKeyOption = condition?.triggerCondition?.condition?.condition?.map(
|
302
|
|
- (m) => m.key.key
|
303
|
|
- );
|
304
|
292
|
unref(skipUnwrap.conditionItemRefs)[index].setFieldsFormValueFun({
|
305
|
293
|
triggered: condition?.triggerCondition?.condition?.spec?.type,
|
306
|
294
|
device: condition?.entityType,
|
307
|
295
|
triggerType: condition?.triggerType,
|
308
|
296
|
type1: condition?.triggerCondition?.condition?.condition[0]?.key?.type,
|
309
|
|
- type2: getAttrKeyOption,
|
|
297
|
+ type2: condition?.triggerCondition?.condition?.condition[0]?.key?.key,
|
310
|
298
|
operationType: condition?.triggerCondition?.condition?.condition[0]?.valueType,
|
311
|
299
|
detail: condition?.triggerCondition?.alarmDetails,
|
312
|
300
|
entityId: condition?.entityId,
|
...
|
...
|
@@ -493,11 +481,9 @@ |
493
|
481
|
// 设置设备的options
|
494
|
482
|
const setEditFields = (linkAge, deviceList) => {
|
495
|
483
|
unref(linkAge).map((item) => {
|
496
|
|
- if (item.isTriggerAndConditionFlag == 'isTriggerAndConditionFlag') {
|
497
|
|
- item.updateExcludeActionFieldDeviceId(deviceList);
|
498
|
|
- } else {
|
499
|
|
- item.updateFieldDeviceId(deviceList);
|
500
|
|
- }
|
|
484
|
+ //TODO-fengtao
|
|
485
|
+ item.updateFieldDeviceId(deviceList, orgId, isUpdate, getMasterDeviceList);
|
|
486
|
+ //TODO-fengtao
|
501
|
487
|
});
|
502
|
488
|
};
|
503
|
489
|
// 设置告警配置options
|
...
|
...
|
@@ -506,29 +492,21 @@ |
506
|
492
|
item.updateEditFieldAlarmConfig(alarmConfigList);
|
507
|
493
|
});
|
508
|
494
|
};
|
509
|
|
- //设置设备属性的options
|
510
|
|
- const setEditAttr = (linkAge, attrList) => {
|
511
|
|
- unref(linkAge).map((item) => {
|
512
|
|
- item.updateFieldAttr(attrList);
|
513
|
|
- });
|
514
|
|
- };
|
515
|
|
-
|
516
|
495
|
// 监听组织变化更新设备列表
|
517
|
496
|
const deviceList = ref([]);
|
|
497
|
+ const getMasterDeviceList = ref([]);
|
|
498
|
+ const orgId = ref('');
|
518
|
499
|
const alarmConfigList = ref([]);
|
519
|
|
- const watchAttrList = ref([]);
|
520
|
|
- const deviceExcludeDoAction = ref([]);
|
521
|
500
|
watch(organizationId, async (newValue: string) => {
|
522
|
501
|
if (!newValue) return;
|
523
|
|
- provideOrgid.value = newValue;
|
524
|
|
- const items = await byOganizationIdGetMasterDevice(newValue);
|
525
|
|
- const itemExcludeDoAction = await screenLinkPageByDeptIdGetDevice({ organizationId: newValue });
|
526
|
|
- deviceExcludeDoAction.value = itemExcludeDoAction.items.map((item) => ({
|
527
|
|
- label: item.name,
|
528
|
|
- value: item.tbDeviceId,
|
529
|
|
- }));
|
530
|
|
- deviceList.value = items.map((item) => ({ label: item.name, value: item.id }));
|
531
|
|
- watchAttrList.value = await getAttribute(newValue, null);
|
|
502
|
+ const { items } = await screenLinkPageByDeptIdGetDevice({ organizationId: newValue });
|
|
503
|
+ //TODO fengtao
|
|
504
|
+ getMasterDeviceList.value = await byOganizationIdGetMasterDevice(newValue);
|
|
505
|
+ //TODO fengtao
|
|
506
|
+ deviceList.value = items.map((item) => ({ label: item.name, value: item.tbDeviceId }));
|
|
507
|
+ //TODO fengtao
|
|
508
|
+ orgId.value = newValue;
|
|
509
|
+ //TODO fengtao
|
532
|
510
|
setFields(skipUnwrap.triggerItemRefs, true);
|
533
|
511
|
setFields(skipUnwrap.conditionItemRefs, true);
|
534
|
512
|
setFields(skipUnwrap.actionItemRefs, true);
|
...
|
...
|
@@ -541,12 +519,9 @@ |
541
|
519
|
function setFields(linkAge, isOrganizationChange = false) {
|
542
|
520
|
unref(linkAge).map((item) => {
|
543
|
521
|
isOrganizationChange && item.resetFieldsValueFunc();
|
544
|
|
- if (item.isTriggerAndConditionFlag == 'isTriggerAndConditionFlag') {
|
545
|
|
- item.updateExcludeActionFieldDeviceId(deviceExcludeDoAction);
|
546
|
|
- item.updateFieldAttr(watchAttrList);
|
547
|
|
- } else {
|
548
|
|
- item.updateFieldDeviceId(deviceList);
|
549
|
|
- }
|
|
522
|
+ //TODO fengtao
|
|
523
|
+ item.updateFieldDeviceId(deviceList, orgId, isUpdate, getMasterDeviceList);
|
|
524
|
+ //TODO fengtao
|
550
|
525
|
});
|
551
|
526
|
}
|
552
|
527
|
function setAlarmConfig(linkAge, isOrganizationChange = false) {
|
...
|
...
|
@@ -609,7 +584,20 @@ |
609
|
584
|
id: unref(id),
|
610
|
585
|
tenantId: unref(tenantId),
|
611
|
586
|
};
|
612
|
|
-
|
|
587
|
+ //TODO fengtao---修改之前如果是新增,如果条件筛选页面打开,但没填值,还是可以新增成功
|
|
588
|
+ const typeBoolean = postAddOrEditData?.triggers?.some((f) => {
|
|
589
|
+ let type = false;
|
|
590
|
+ f?.triggerCondition?.condition?.condition?.some((s) => {
|
|
591
|
+ if (s?.predicate?.value?.defaultValue == undefined) {
|
|
592
|
+ type = true;
|
|
593
|
+ } else {
|
|
594
|
+ type = false;
|
|
595
|
+ }
|
|
596
|
+ });
|
|
597
|
+ return type;
|
|
598
|
+ });
|
|
599
|
+ if (typeBoolean) return createMessage.error('请填写条件筛选');
|
|
600
|
+ //TODO fengtao
|
613
|
601
|
await screenLinkPageAddApi(postAddOrEditData, unref(isUpdate));
|
614
|
602
|
createMessage.success(`${unref(isUpdate) ? '编辑' : '新增'}成功`);
|
615
|
603
|
closeDrawer();
|
...
|
...
|
@@ -659,8 +647,14 @@ |
659
|
647
|
</script>
|
660
|
648
|
|
661
|
649
|
<style lang="less" scoped>
|
662
|
|
- ///统一下拉选择框宽度,否则超出默认宽度会造成页面样式错乱
|
663
|
|
- :deep(.ant-select-selector) {
|
664
|
|
- max-width: 14.2rem;
|
|
650
|
+ //TODO-fengtao
|
|
651
|
+ ///移除选择框默认样式(24px)否则超出默认宽度会造成页面样式错乱
|
|
652
|
+ ::v-deep(.ant-select-selector) {
|
|
653
|
+ padding-right: 0px !important;
|
|
654
|
+ }
|
|
655
|
+
|
|
656
|
+ ::v-deep(.ant-select-selection-overflow) {
|
|
657
|
+ max-width: 10vw !important;
|
665
|
658
|
}
|
|
659
|
+ //TODO-fengtao
|
666
|
660
|
</style> |
...
|
...
|
|