1
|
<template>
|
1
|
<template>
|
2
|
<div>
|
2
|
<div>
|
3
|
- <BasicDrawer v-bind="$attrs" @register="registerDrawer" @ok="handleSubmit" width="50%" showFooter
|
|
|
4
|
- @close="handleClose" :title="title">
|
3
|
+ <BasicDrawer
|
|
|
4
|
+ v-bind="$attrs"
|
|
|
5
|
+ @register="registerDrawer"
|
|
|
6
|
+ @ok="handleSubmit"
|
|
|
7
|
+ width="50%"
|
|
|
8
|
+ showFooter
|
|
|
9
|
+ @close="handleClose"
|
|
|
10
|
+ :title="title"
|
|
|
11
|
+ >
|
5
|
<div>
|
12
|
<div>
|
6
|
<!-- 基础表单 -->
|
13
|
<!-- 基础表单 -->
|
7
|
<BasicForm @register="registerForm" />
|
14
|
<BasicForm @register="registerForm" />
|
8
|
<!-- 基础表单 -->
|
15
|
<!-- 基础表单 -->
|
9
|
<!-- 触发器-begin -->
|
16
|
<!-- 触发器-begin -->
|
10
|
- <Divider orientation="left">触发器</Divider>
|
17
|
+ <!-- <Divider orientation="left">触发器</Divider> -->
|
|
|
18
|
+ <Divider orientation="left"
|
|
|
19
|
+ ><a-tooltip>
|
|
|
20
|
+ <template #title>场景联动触发的首要条件,"触发器"之间的关系为或,“执行条件”与“触发器”之间的关系为且。</template>
|
|
|
21
|
+ 触发器<QuestionCircleOutlined :style="{fontSize: '14px',marginLeft:'5px'}"/>
|
|
|
22
|
+ </a-tooltip></Divider
|
|
|
23
|
+ >
|
11
|
<div>
|
24
|
<div>
|
12
|
<template v-for="(item, index) in triggerData" :key="item">
|
25
|
<template v-for="(item, index) in triggerData" :key="item">
|
13
|
- <TriggerOrCondition class="mt-4" title="触发器" :index="index" :provideOrgid="provideOrgid"
|
|
|
14
|
- :ref="skipUnwrap.triggerItemRefs" @delete="deleteTriggerOrCondition" />
|
26
|
+ <TriggerOrCondition
|
|
|
27
|
+ class="mt-4"
|
|
|
28
|
+ title="触发器"
|
|
|
29
|
+ :index="index"
|
|
|
30
|
+ :provideOrgid="provideOrgid"
|
|
|
31
|
+ :ref="skipUnwrap.triggerItemRefs"
|
|
|
32
|
+ @delete="deleteTriggerOrCondition"
|
|
|
33
|
+ />
|
15
|
</template>
|
34
|
</template>
|
16
|
<!-- 按钮 -->
|
35
|
<!-- 按钮 -->
|
17
|
<a-button type="primary" class="mt-4" @click="addTrigger" v-if="isView">
|
36
|
<a-button type="primary" class="mt-4" @click="addTrigger" v-if="isView">
|
|
@@ -23,11 +42,23 @@ |
|
@@ -23,11 +42,23 @@ |
23
|
<!-- 触发器-end -->
|
42
|
<!-- 触发器-end -->
|
24
|
|
43
|
|
25
|
<!-- 执行条件-begin -->
|
44
|
<!-- 执行条件-begin -->
|
26
|
- <Divider orientation="left">执行条件</Divider>
|
45
|
+ <Divider orientation="left"
|
|
|
46
|
+ ><a-tooltip>
|
|
|
47
|
+ <template #title>场景联动触发的次要条件,"执行条件"之间的关系为或,
|
|
|
48
|
+“执行条件”与“触发器”之间的关系为且。</template>
|
|
|
49
|
+ 执行条件<QuestionCircleOutlined :style="{fontSize: '14px',marginLeft:'5px'}"/>
|
|
|
50
|
+ </a-tooltip></Divider
|
|
|
51
|
+ >
|
27
|
<div>
|
52
|
<div>
|
28
|
<template v-for="(item, index) in conditionData" :key="item">
|
53
|
<template v-for="(item, index) in conditionData" :key="item">
|
29
|
- <TriggerOrCondition class="mt-4" title="执行条件" :index="index" :provideOrgid="provideOrgid"
|
|
|
30
|
- :ref="skipUnwrap.conditionItemRefs" @delete="deleteTriggerOrCondition" />
|
54
|
+ <TriggerOrCondition
|
|
|
55
|
+ class="mt-4"
|
|
|
56
|
+ title="执行条件"
|
|
|
57
|
+ :index="index"
|
|
|
58
|
+ :provideOrgid="provideOrgid"
|
|
|
59
|
+ :ref="skipUnwrap.conditionItemRefs"
|
|
|
60
|
+ @delete="deleteTriggerOrCondition"
|
|
|
61
|
+ />
|
31
|
</template>
|
62
|
</template>
|
32
|
<!-- 按钮 -->
|
63
|
<!-- 按钮 -->
|
33
|
<a-button type="primary" class="mt-4" @click="addCondition" v-if="isView">
|
64
|
<a-button type="primary" class="mt-4" @click="addCondition" v-if="isView">
|
|
@@ -39,12 +70,26 @@ |
|
@@ -39,12 +70,26 @@ |
39
|
<!-- 执行条件-end -->
|
70
|
<!-- 执行条件-end -->
|
40
|
|
71
|
|
41
|
<!-- 执行动作-begin -->
|
72
|
<!-- 执行动作-begin -->
|
42
|
- <Divider orientation="left">执行动作</Divider>
|
73
|
+ <Divider orientation="left"
|
|
|
74
|
+ ><a-tooltip>
|
|
|
75
|
+ <template #title>触发器和执行条件都满足时,场景联动会做什么,例如:设备联动、告警通知等。</template>
|
|
|
76
|
+ 执行动作<QuestionCircleOutlined :style="{fontSize: '14px',marginLeft:'5px'}"/>
|
|
|
77
|
+ </a-tooltip></Divider
|
|
|
78
|
+ >
|
43
|
<div>
|
79
|
<div>
|
44
|
<template v-for="(item, index) in actionData" :key="item">
|
80
|
<template v-for="(item, index) in actionData" :key="item">
|
45
|
- <Action class="mt-4" :actionIndex="index" :actionData="actionData" :triggerData="triggerData"
|
|
|
46
|
- :ref="skipUnwrap.actionItemRefs" :provideOrgid="provideOrgid" :deviceList="getMasterDeviceList" :arr="arr"
|
|
|
47
|
- @deleteAction="deleteAction" @getActionFormArr="getActionFormArr" />
|
81
|
+ <Action
|
|
|
82
|
+ class="mt-4"
|
|
|
83
|
+ :actionIndex="index"
|
|
|
84
|
+ :actionData="actionData"
|
|
|
85
|
+ :triggerData="triggerData"
|
|
|
86
|
+ :ref="skipUnwrap.actionItemRefs"
|
|
|
87
|
+ :provideOrgid="provideOrgid"
|
|
|
88
|
+ :deviceList="getMasterDeviceList"
|
|
|
89
|
+ :arr="arr"
|
|
|
90
|
+ @deleteAction="deleteAction"
|
|
|
91
|
+ @getActionFormArr="getActionFormArr"
|
|
|
92
|
+ />
|
48
|
</template>
|
93
|
</template>
|
49
|
<!-- 按钮 -->
|
94
|
<!-- 按钮 -->
|
50
|
<a-button type="primary" class="mt-4" @click="addAction" v-if="isView">
|
95
|
<a-button type="primary" class="mt-4" @click="addAction" v-if="isView">
|
|
@@ -59,591 +104,590 @@ |
|
@@ -59,591 +104,590 @@ |
59
|
</div>
|
104
|
</div>
|
60
|
</template>
|
105
|
</template>
|
61
|
<script lang="ts" setup>
|
106
|
<script lang="ts" setup>
|
62
|
-import { ref, watch, unref, computed, nextTick } from 'vue';
|
|
|
63
|
-import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
|
|
|
64
|
-import { formSchema, organizationId } from './config/config.data.ts';
|
|
|
65
|
-import { BasicForm, useForm } from '/@/components/Form';
|
|
|
66
|
-import { genTriggerOrConditionData, genActionData } from './config/formatData.ts';
|
|
|
67
|
-import { Divider } from 'ant-design-vue';
|
|
|
68
|
-import { PlusOutlined } from '@ant-design/icons-vue';
|
|
|
69
|
-import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
70
|
-import {
|
|
|
71
|
- screenLinkPageAddApi,
|
|
|
72
|
- screenLinkPageByDeptIdGetDevice,
|
|
|
73
|
- getOrganizationAlarmConfig,
|
|
|
74
|
- byOganizationIdGetMasterDevice,
|
|
|
75
|
-} from '/@/api/ruleengine/ruleengineApi';
|
|
|
76
|
-import TriggerOrCondition from './cpns/Trigger-Condition.vue';
|
|
|
77
|
-import Action from './cpns/Action.vue';
|
|
|
78
|
-import { findOperation } from './config/formatData.ts';
|
|
|
79
|
-import { formatToDateTime } from '/@/utils/dateUtil';
|
107
|
+ import { ref, watch, unref, computed, nextTick } from 'vue';
|
|
|
108
|
+ import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
|
|
|
109
|
+ import { formSchema, organizationId } from './config/config.data.ts';
|
|
|
110
|
+ import { BasicForm, useForm } from '/@/components/Form';
|
|
|
111
|
+ import { genTriggerOrConditionData, genActionData } from './config/formatData.ts';
|
|
|
112
|
+ import { Divider } from 'ant-design-vue';
|
|
|
113
|
+ import { PlusOutlined,QuestionCircleOutlined } from '@ant-design/icons-vue';
|
|
|
114
|
+ import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
115
|
+ import {
|
|
|
116
|
+ screenLinkPageAddApi,
|
|
|
117
|
+ screenLinkPageByDeptIdGetDevice,
|
|
|
118
|
+ getOrganizationAlarmConfig,
|
|
|
119
|
+ byOganizationIdGetMasterDevice,
|
|
|
120
|
+ } from '/@/api/ruleengine/ruleengineApi';
|
|
|
121
|
+ import TriggerOrCondition from './cpns/Trigger-Condition.vue';
|
|
|
122
|
+ import Action from './cpns/Action.vue';
|
|
|
123
|
+ import { findOperation } from './config/formatData.ts';
|
|
|
124
|
+ import { formatToDateTime } from '/@/utils/dateUtil';
|
80
|
|
125
|
|
81
|
-const emit = defineEmits(['register', 'success']);
|
|
|
82
|
-const provideOrgid = ref('');
|
126
|
+ const emit = defineEmits(['register', 'success']);
|
|
|
127
|
+ const provideOrgid = ref('');
|
83
|
|
128
|
|
84
|
-const { createMessage } = useMessage();
|
|
|
85
|
-const triggerData = ref([]);
|
|
|
86
|
-const conditionData = ref([]);
|
|
|
87
|
-const actionData = ref([]);
|
|
|
88
|
-const skipUnwrap = {
|
|
|
89
|
- triggerItemRefs: ref([]),
|
|
|
90
|
- conditionItemRefs: ref([]),
|
|
|
91
|
- actionItemRefs: ref([]),
|
|
|
92
|
-};
|
|
|
93
|
-const title = computed(
|
|
|
94
|
- () => `${isUpdate.value === 3 ? '查看' : isUpdate.value ? '编辑' : '新增'}场景联动`
|
|
|
95
|
-);
|
|
|
96
|
-let getTriggerFormValue = ref([]);
|
|
|
97
|
-let getConditionFormValue = ref([]);
|
|
|
98
|
-let getActionFormValue = ref([]);
|
|
|
99
|
-const editEntryIdData = ref([]);
|
|
|
100
|
-const editAlarmConfigData = ref([]);
|
|
|
101
|
-const isUpdate = ref(false);
|
|
|
102
|
-const id = ref(undefined);
|
|
|
103
|
-const tenantId = ref(undefined);
|
|
|
104
|
-const isView = ref(true);
|
|
|
105
|
-const [registerForm, { resetFields, validate, setFieldsValue }] = useForm({
|
|
|
106
|
- labelWidth: 120,
|
|
|
107
|
- schemas: formSchema,
|
|
|
108
|
- showActionButtonGroup: false,
|
|
|
109
|
-});
|
|
|
110
|
-const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
|
|
|
111
|
- setDrawerProps({ confirmLoading: false, loading: true });
|
|
|
112
|
- isUpdate.value = data.isUpdate;
|
|
|
113
|
- if (!unref(isUpdate)) {
|
|
|
114
|
- resetFields();
|
|
|
115
|
- //初始化执行动作
|
|
|
116
|
- actionData.value = [Date.now()];
|
|
|
117
|
- } else {
|
|
|
118
|
- // 取值
|
|
|
119
|
- const {
|
|
|
120
|
- id: recordId,
|
|
|
121
|
- tenantId: recordTenantId,
|
|
|
122
|
- organizationId,
|
|
|
123
|
- triggers,
|
|
|
124
|
- doConditions,
|
|
|
125
|
- doActions,
|
|
|
126
|
- } = data.record;
|
|
|
127
|
- // 赋值
|
|
|
128
|
- await setFieldsValue(data.record);
|
|
|
129
|
- id.value = recordId;
|
|
|
130
|
- tenantId.value = recordTenantId;
|
|
|
131
|
- //TODO-fengtao-把组织id传给子组件
|
|
|
132
|
- provideOrgid.value = organizationId;
|
|
|
133
|
- //TODO-fengtao获取当前执行动作下的设备(master那个接口)
|
|
|
134
|
- getMasterDeviceList.value = await byOganizationIdGetMasterDevice(organizationId);
|
|
|
135
|
- //TODO-fengtao
|
|
|
136
|
- // 获取当前组织下的设备列表
|
|
|
137
|
- const options = await screenLinkPageByDeptIdGetDevice({
|
|
|
138
|
- organizationId,
|
|
|
139
|
- });
|
|
|
140
|
- // 获取当前组织下的告警配置
|
|
|
141
|
- const alarmConfig = await getOrganizationAlarmConfig({ organizationId });
|
129
|
+ const { createMessage } = useMessage();
|
|
|
130
|
+ const triggerData = ref([]);
|
|
|
131
|
+ const conditionData = ref([]);
|
|
|
132
|
+ const actionData = ref([]);
|
|
|
133
|
+ const skipUnwrap = {
|
|
|
134
|
+ triggerItemRefs: ref([]),
|
|
|
135
|
+ conditionItemRefs: ref([]),
|
|
|
136
|
+ actionItemRefs: ref([]),
|
|
|
137
|
+ };
|
|
|
138
|
+ const title = computed(
|
|
|
139
|
+ () => `${isUpdate.value === 3 ? '查看' : isUpdate.value ? '编辑' : '新增'}场景联动`
|
|
|
140
|
+ );
|
|
|
141
|
+ let getTriggerFormValue = ref([]);
|
|
|
142
|
+ let getConditionFormValue = ref([]);
|
|
|
143
|
+ let getActionFormValue = ref([]);
|
|
|
144
|
+ const editEntryIdData = ref([]);
|
|
|
145
|
+ const editAlarmConfigData = ref([]);
|
|
|
146
|
+ const isUpdate = ref(false);
|
|
|
147
|
+ const id = ref(undefined);
|
|
|
148
|
+ const tenantId = ref(undefined);
|
|
|
149
|
+ const isView = ref(true);
|
|
|
150
|
+ const [registerForm, { resetFields, validate, setFieldsValue }] = useForm({
|
|
|
151
|
+ labelWidth: 120,
|
|
|
152
|
+ schemas: formSchema,
|
|
|
153
|
+ showActionButtonGroup: false,
|
|
|
154
|
+ });
|
|
|
155
|
+ const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
|
|
|
156
|
+ setDrawerProps({ confirmLoading: false, loading: true });
|
|
|
157
|
+ isUpdate.value = data.isUpdate;
|
|
|
158
|
+ if (!unref(isUpdate)) {
|
|
|
159
|
+ resetFields();
|
|
|
160
|
+ //初始化执行动作
|
|
|
161
|
+ actionData.value = [Date.now()];
|
|
|
162
|
+ } else {
|
|
|
163
|
+ // 取值
|
|
|
164
|
+ const {
|
|
|
165
|
+ id: recordId,
|
|
|
166
|
+ tenantId: recordTenantId,
|
|
|
167
|
+ organizationId,
|
|
|
168
|
+ triggers,
|
|
|
169
|
+ doConditions,
|
|
|
170
|
+ doActions,
|
|
|
171
|
+ } = data.record;
|
|
|
172
|
+ // 赋值
|
|
|
173
|
+ await setFieldsValue(data.record);
|
|
|
174
|
+ id.value = recordId;
|
|
|
175
|
+ tenantId.value = recordTenantId;
|
|
|
176
|
+ //TODO-fengtao-把组织id传给子组件
|
|
|
177
|
+ provideOrgid.value = organizationId;
|
|
|
178
|
+ //TODO-fengtao获取当前执行动作下的设备(master那个接口)
|
|
|
179
|
+ getMasterDeviceList.value = await byOganizationIdGetMasterDevice(organizationId);
|
|
|
180
|
+ //TODO-fengtao
|
|
|
181
|
+ // 获取当前组织下的设备列表
|
|
|
182
|
+ const options = await screenLinkPageByDeptIdGetDevice({
|
|
|
183
|
+ organizationId,
|
|
|
184
|
+ });
|
|
|
185
|
+ // 获取当前组织下的告警配置
|
|
|
186
|
+ const alarmConfig = await getOrganizationAlarmConfig({ organizationId });
|
142
|
|
187
|
|
143
|
- // 生成回显时对应得组件数量
|
|
|
144
|
- triggerData.value = [...new Array(triggers.length).keys()];
|
|
|
145
|
- conditionData.value = [...new Array(doConditions.length).keys()];
|
|
|
146
|
- actionData.value = [...new Array(doActions.length).keys()];
|
|
|
147
|
- // 回显设备列表
|
|
|
148
|
- editEntryIdData.value = options.items.map((item) => {
|
|
|
149
|
- return {
|
|
|
150
|
- value: item.tbDeviceId,
|
|
|
151
|
- label: item.name,
|
|
|
152
|
- };
|
|
|
153
|
- });
|
|
|
154
|
- editAlarmConfigData.value = alarmConfig.map((item) => {
|
|
|
155
|
- return {
|
|
|
156
|
- value: item.id,
|
|
|
157
|
- label: item.name,
|
|
|
158
|
- };
|
|
|
159
|
- });
|
|
|
160
|
- deviceList.value = editEntryIdData.value;
|
|
|
161
|
- nextTick(() => {
|
|
|
162
|
- setEditFields(skipUnwrap.triggerItemRefs, editEntryIdData);
|
|
|
163
|
- setEditFields(skipUnwrap.conditionItemRefs, editEntryIdData);
|
|
|
164
|
- setEditFields(skipUnwrap.actionItemRefs, getMasterDeviceList);
|
|
|
165
|
- setEditAlarmConfig(skipUnwrap.actionItemRefs, editAlarmConfigData);
|
|
|
166
|
- });
|
188
|
+ // 生成回显时对应得组件数量
|
|
|
189
|
+ triggerData.value = [...new Array(triggers.length).keys()];
|
|
|
190
|
+ conditionData.value = [...new Array(doConditions.length).keys()];
|
|
|
191
|
+ actionData.value = [...new Array(doActions.length).keys()];
|
|
|
192
|
+ // 回显设备列表
|
|
|
193
|
+ editEntryIdData.value = options.items.map((item) => {
|
|
|
194
|
+ return {
|
|
|
195
|
+ value: item.tbDeviceId,
|
|
|
196
|
+ label: item.name,
|
|
|
197
|
+ };
|
|
|
198
|
+ });
|
|
|
199
|
+ editAlarmConfigData.value = alarmConfig.map((item) => {
|
|
|
200
|
+ return {
|
|
|
201
|
+ value: item.id,
|
|
|
202
|
+ label: item.name,
|
|
|
203
|
+ };
|
|
|
204
|
+ });
|
|
|
205
|
+ deviceList.value = editEntryIdData.value;
|
|
|
206
|
+ nextTick(() => {
|
|
|
207
|
+ setEditFields(skipUnwrap.triggerItemRefs, editEntryIdData);
|
|
|
208
|
+ setEditFields(skipUnwrap.conditionItemRefs, editEntryIdData);
|
|
|
209
|
+ setEditFields(skipUnwrap.actionItemRefs, getMasterDeviceList);
|
|
|
210
|
+ setEditAlarmConfig(skipUnwrap.actionItemRefs, editAlarmConfigData);
|
|
|
211
|
+ });
|
167
|
|
212
|
|
168
|
- const map = {
|
|
|
169
|
- ANY_TIME: 0,
|
|
|
170
|
- SPECIFIC_TIME: 1,
|
|
|
171
|
- CUSTOM: 2,
|
|
|
172
|
- };
|
|
|
173
|
- // 回显触发器数据---此处是个闭包!
|
|
|
174
|
- triggers.forEach((trigger, index) => {
|
|
|
175
|
- nextTick(async () => {
|
|
|
176
|
- const selectDeviceId = ref('');
|
|
|
177
|
- // 回显启用规则
|
|
|
178
|
- unref(skipUnwrap.triggerItemRefs)[index].currentIndex =
|
|
|
179
|
- map[trigger.triggerCondition.schedule.type];
|
|
|
180
|
- unref(skipUnwrap.triggerItemRefs)[index].scheduleData = trigger.triggerCondition.schedule;
|
|
|
181
|
- unref(skipUnwrap.triggerItemRefs)[index].isUpdate = true;
|
|
|
182
|
- unref(skipUnwrap.triggerItemRefs)[index].alarmScheduleRef.scheduleData =
|
|
|
183
|
- trigger.triggerCondition.schedule;
|
|
|
184
|
- unref(skipUnwrap.triggerItemRefs)[index].setFieldsFormValueFun({
|
|
|
185
|
- triggered: trigger?.triggerCondition?.condition?.spec?.type,
|
|
|
186
|
- device: trigger?.entityType,
|
|
|
187
|
- triggerType: trigger?.triggerType,
|
|
|
188
|
- type1: trigger?.triggerCondition?.condition?.condition[0]?.key?.type,
|
|
|
189
|
- type2: trigger?.triggerCondition?.condition?.condition[0]?.key?.key,
|
|
|
190
|
- operationType: trigger?.triggerCondition?.condition?.condition[0]?.valueType,
|
|
|
191
|
- detail: trigger?.triggerCondition?.alarmDetails,
|
|
|
192
|
- entityId: trigger?.entityId,
|
|
|
193
|
- replaceValue: trigger?.triggerCondition?.condition?.spec?.predicate?.defaultValue,
|
|
|
194
|
- time: trigger?.triggerCondition?.condition?.spec?.predicate?.defaultValue,
|
|
|
195
|
- timeUnit: trigger?.triggerCondition?.condition?.spec?.unit,
|
|
|
196
|
- });
|
|
|
197
|
- if (trigger.entityId != undefined) {
|
|
|
198
|
- selectDeviceId.value = trigger?.entityId;
|
|
|
199
|
- }
|
|
|
200
|
- //fengtao-把设备id回传给子组件
|
|
|
201
|
- unref(skipUnwrap.triggerItemRefs)[index].updateFieldAttributeFunc(
|
|
|
202
|
- selectDeviceId.value,
|
|
|
203
|
- provideOrgid.value
|
|
|
204
|
- );
|
|
|
205
|
- //fengtao
|
|
|
206
|
- // 设置值operationType
|
|
|
207
|
- unref(skipUnwrap.triggerItemRefs)[index].operationType =
|
|
|
208
|
- trigger.triggerCondition?.condition.condition[0].valueType;
|
213
|
+ const map = {
|
|
|
214
|
+ ANY_TIME: 0,
|
|
|
215
|
+ SPECIFIC_TIME: 1,
|
|
|
216
|
+ CUSTOM: 2,
|
|
|
217
|
+ };
|
|
|
218
|
+ // 回显触发器数据---此处是个闭包!
|
|
|
219
|
+ triggers.forEach((trigger, index) => {
|
|
|
220
|
+ nextTick(async () => {
|
|
|
221
|
+ const selectDeviceId = ref('');
|
|
|
222
|
+ // 回显启用规则
|
|
|
223
|
+ unref(skipUnwrap.triggerItemRefs)[index].currentIndex =
|
|
|
224
|
+ map[trigger.triggerCondition.schedule.type];
|
|
|
225
|
+ unref(skipUnwrap.triggerItemRefs)[index].scheduleData = trigger.triggerCondition.schedule;
|
|
|
226
|
+ unref(skipUnwrap.triggerItemRefs)[index].isUpdate = true;
|
|
|
227
|
+ unref(skipUnwrap.triggerItemRefs)[index].alarmScheduleRef.scheduleData =
|
|
|
228
|
+ trigger.triggerCondition.schedule;
|
|
|
229
|
+ unref(skipUnwrap.triggerItemRefs)[index].setFieldsFormValueFun({
|
|
|
230
|
+ triggered: trigger?.triggerCondition?.condition?.spec?.type,
|
|
|
231
|
+ device: trigger?.entityType,
|
|
|
232
|
+ triggerType: trigger?.triggerType,
|
|
|
233
|
+ type1: trigger?.triggerCondition?.condition?.condition[0]?.key?.type,
|
|
|
234
|
+ type2: trigger?.triggerCondition?.condition?.condition[0]?.key?.key,
|
|
|
235
|
+ operationType: trigger?.triggerCondition?.condition?.condition[0]?.valueType,
|
|
|
236
|
+ detail: trigger?.triggerCondition?.alarmDetails,
|
|
|
237
|
+ entityId: trigger?.entityId,
|
|
|
238
|
+ replaceValue: trigger?.triggerCondition?.condition?.spec?.predicate?.defaultValue,
|
|
|
239
|
+ time: trigger?.triggerCondition?.condition?.spec?.predicate?.defaultValue,
|
|
|
240
|
+ timeUnit: trigger?.triggerCondition?.condition?.spec?.unit,
|
|
|
241
|
+ });
|
|
|
242
|
+ if (trigger.entityId != undefined) {
|
|
|
243
|
+ selectDeviceId.value = trigger?.entityId;
|
|
|
244
|
+ }
|
|
|
245
|
+ //fengtao-把设备id回传给子组件
|
|
|
246
|
+ unref(skipUnwrap.triggerItemRefs)[index].updateFieldAttributeFunc(
|
|
|
247
|
+ selectDeviceId.value,
|
|
|
248
|
+ provideOrgid.value
|
|
|
249
|
+ );
|
|
|
250
|
+ //fengtao
|
|
|
251
|
+ // 设置值operationType
|
|
|
252
|
+ unref(skipUnwrap.triggerItemRefs)[index].operationType =
|
|
|
253
|
+ trigger.triggerCondition?.condition.condition[0].valueType;
|
209
|
|
254
|
|
210
|
- const ConditionScreeningForm = await unref(skipUnwrap.triggerItemRefs)[
|
|
|
211
|
- index
|
|
|
212
|
- ].getRefItemConditionScreeningRefs();
|
255
|
+ const ConditionScreeningForm = await unref(skipUnwrap.triggerItemRefs)[
|
|
|
256
|
+ index
|
|
|
257
|
+ ].getRefItemConditionScreeningRefs();
|
213
|
|
258
|
|
214
|
- // 设置对应条件筛选的个数
|
|
|
215
|
- unref(skipUnwrap.triggerItemRefs)[index].setConditionScreeningList([
|
|
|
216
|
- ...new Array(trigger.triggerCondition.condition.condition.length).keys(),
|
|
|
217
|
- ]);
|
|
|
218
|
- // 操作符类型 NUMERIC|String|Boolean|DATE_TIME
|
|
|
219
|
- const valueType = trigger.triggerCondition?.condition.condition[0].valueType;
|
259
|
+ // 设置对应条件筛选的个数
|
|
|
260
|
+ unref(skipUnwrap.triggerItemRefs)[index].setConditionScreeningList([
|
|
|
261
|
+ ...new Array(trigger.triggerCondition.condition.condition.length).keys(),
|
|
|
262
|
+ ]);
|
|
|
263
|
+ // 操作符类型 NUMERIC|String|Boolean|DATE_TIME
|
|
|
264
|
+ const valueType = trigger.triggerCondition?.condition.condition[0].valueType;
|
220
|
|
265
|
|
221
|
- // 循环设置条件筛选值。TODO:此处设置顺序有问题
|
|
|
222
|
- nextTick(() => {
|
|
|
223
|
- const richTextList = [];
|
|
|
224
|
- trigger.triggerCondition.condition.condition.forEach((item, index) => {
|
|
|
225
|
- const formItem = {
|
|
|
226
|
- operation: item.predicate.operation,
|
|
|
227
|
- value:
|
|
|
228
|
- valueType === 'DATE_TIME'
|
|
|
229
|
- ? formatToDateTime(
|
|
|
230
|
- Number(item.predicate.value.defaultValue),
|
|
|
231
|
- 'YYYY-MM-DD HH:mm:ss'
|
|
|
232
|
- )
|
|
|
233
|
- : String(item.predicate.value.defaultValue),
|
|
|
234
|
- ignoreCase: item.valueType === 'STRING' ? item.predicate.ignoreCase : undefined,
|
|
|
235
|
- };
|
|
|
236
|
- richTextList.push({
|
|
|
237
|
- // 查询中文操作符
|
|
|
238
|
- operation: findOperation(valueType, item.predicate.operation).label,
|
|
|
239
|
- value:
|
|
|
240
|
- valueType === 'DATE_TIME'
|
|
|
241
|
- ? formatToDateTime(
|
|
|
242
|
- Number(item.predicate.value.defaultValue),
|
|
|
243
|
- 'YYYY-MM-DD HH:mm:ss'
|
|
|
244
|
- )
|
|
|
245
|
- : String(item.predicate.value.defaultValue),
|
|
|
246
|
- attribute: trigger.triggerCondition?.condition.condition[0]?.key?.key,
|
266
|
+ // 循环设置条件筛选值。TODO:此处设置顺序有问题
|
|
|
267
|
+ nextTick(() => {
|
|
|
268
|
+ const richTextList = [];
|
|
|
269
|
+ trigger.triggerCondition.condition.condition.forEach((item, index) => {
|
|
|
270
|
+ const formItem = {
|
|
|
271
|
+ operation: item.predicate.operation,
|
|
|
272
|
+ value:
|
|
|
273
|
+ valueType === 'DATE_TIME'
|
|
|
274
|
+ ? formatToDateTime(
|
|
|
275
|
+ Number(item.predicate.value.defaultValue),
|
|
|
276
|
+ 'YYYY-MM-DD HH:mm:ss'
|
|
|
277
|
+ )
|
|
|
278
|
+ : String(item.predicate.value.defaultValue),
|
|
|
279
|
+ ignoreCase: item.valueType === 'STRING' ? item.predicate.ignoreCase : undefined,
|
|
|
280
|
+ };
|
|
|
281
|
+ richTextList.push({
|
|
|
282
|
+ // 查询中文操作符
|
|
|
283
|
+ operation: findOperation(valueType, item.predicate.operation).label,
|
|
|
284
|
+ value:
|
|
|
285
|
+ valueType === 'DATE_TIME'
|
|
|
286
|
+ ? formatToDateTime(
|
|
|
287
|
+ Number(item.predicate.value.defaultValue),
|
|
|
288
|
+ 'YYYY-MM-DD HH:mm:ss'
|
|
|
289
|
+ )
|
|
|
290
|
+ : String(item.predicate.value.defaultValue),
|
|
|
291
|
+ attribute: trigger.triggerCondition?.condition.condition[0]?.key?.key,
|
|
|
292
|
+ });
|
|
|
293
|
+ ConditionScreeningForm.value[index].setFieldsValue(formItem);
|
247
|
});
|
294
|
});
|
248
|
- ConditionScreeningForm.value[index].setFieldsValue(formItem);
|
295
|
+ unref(skipUnwrap.triggerItemRefs)[index].setRichText(richTextList);
|
249
|
});
|
296
|
});
|
250
|
- unref(skipUnwrap.triggerItemRefs)[index].setRichText(richTextList);
|
|
|
251
|
});
|
297
|
});
|
252
|
});
|
298
|
});
|
253
|
- });
|
|
|
254
|
|
299
|
|
255
|
- doConditions.forEach((condition, index) => {
|
|
|
256
|
- nextTick(async () => {
|
|
|
257
|
- const selectDeviceId = ref('');
|
|
|
258
|
- // 回显启用规则
|
|
|
259
|
- unref(skipUnwrap.conditionItemRefs)[index].currentIndex =
|
|
|
260
|
- map[condition.triggerCondition.schedule.type];
|
|
|
261
|
- unref(skipUnwrap.conditionItemRefs)[index].scheduleData =
|
|
|
262
|
- condition.triggerCondition.schedule;
|
|
|
263
|
- unref(skipUnwrap.conditionItemRefs)[index].isUpdate = true;
|
|
|
264
|
- unref(skipUnwrap.conditionItemRefs)[index].alarmScheduleRef.scheduleData =
|
|
|
265
|
- condition.triggerCondition.schedule;
|
|
|
266
|
- unref(skipUnwrap.conditionItemRefs)[index].setFieldsFormValueFun({
|
|
|
267
|
- triggered: condition?.triggerCondition?.condition?.spec?.type,
|
|
|
268
|
- device: condition?.entityType,
|
|
|
269
|
- triggerType: condition?.triggerType,
|
|
|
270
|
- type1: condition?.triggerCondition?.condition?.condition[0]?.key?.type,
|
|
|
271
|
- type2: condition?.triggerCondition?.condition?.condition[0]?.key?.key,
|
|
|
272
|
- operationType: condition?.triggerCondition?.condition?.condition[0]?.valueType,
|
|
|
273
|
- detail: condition?.triggerCondition?.alarmDetails,
|
|
|
274
|
- entityId: condition?.entityId,
|
|
|
275
|
- replaceValue: condition?.triggerCondition?.condition?.spec?.predicate?.defaultValue,
|
|
|
276
|
- time: condition?.triggerCondition?.condition?.spec?.predicate?.defaultValue,
|
|
|
277
|
- timeUnit: condition?.triggerCondition?.condition?.spec?.unit,
|
|
|
278
|
- });
|
|
|
279
|
- if (condition?.entityId != undefined) {
|
|
|
280
|
- selectDeviceId.value = condition?.entityId;
|
|
|
281
|
- }
|
|
|
282
|
- //fengtao-把设备id回传给子组件
|
|
|
283
|
- unref(skipUnwrap.conditionItemRefs)[index].updateFieldAttributeFunc(
|
|
|
284
|
- selectDeviceId.value,
|
|
|
285
|
- provideOrgid.value
|
|
|
286
|
- );
|
|
|
287
|
- //fengtao
|
|
|
288
|
- // 设置值operationType
|
|
|
289
|
- unref(skipUnwrap.conditionItemRefs)[index].operationType =
|
|
|
290
|
- condition.triggerCondition?.condition.condition[0].valueType;
|
300
|
+ doConditions.forEach((condition, index) => {
|
|
|
301
|
+ nextTick(async () => {
|
|
|
302
|
+ const selectDeviceId = ref('');
|
|
|
303
|
+ // 回显启用规则
|
|
|
304
|
+ unref(skipUnwrap.conditionItemRefs)[index].currentIndex =
|
|
|
305
|
+ map[condition.triggerCondition.schedule.type];
|
|
|
306
|
+ unref(skipUnwrap.conditionItemRefs)[index].scheduleData =
|
|
|
307
|
+ condition.triggerCondition.schedule;
|
|
|
308
|
+ unref(skipUnwrap.conditionItemRefs)[index].isUpdate = true;
|
|
|
309
|
+ unref(skipUnwrap.conditionItemRefs)[index].alarmScheduleRef.scheduleData =
|
|
|
310
|
+ condition.triggerCondition.schedule;
|
|
|
311
|
+ unref(skipUnwrap.conditionItemRefs)[index].setFieldsFormValueFun({
|
|
|
312
|
+ triggered: condition?.triggerCondition?.condition?.spec?.type,
|
|
|
313
|
+ device: condition?.entityType,
|
|
|
314
|
+ triggerType: condition?.triggerType,
|
|
|
315
|
+ type1: condition?.triggerCondition?.condition?.condition[0]?.key?.type,
|
|
|
316
|
+ type2: condition?.triggerCondition?.condition?.condition[0]?.key?.key,
|
|
|
317
|
+ operationType: condition?.triggerCondition?.condition?.condition[0]?.valueType,
|
|
|
318
|
+ detail: condition?.triggerCondition?.alarmDetails,
|
|
|
319
|
+ entityId: condition?.entityId,
|
|
|
320
|
+ replaceValue: condition?.triggerCondition?.condition?.spec?.predicate?.defaultValue,
|
|
|
321
|
+ time: condition?.triggerCondition?.condition?.spec?.predicate?.defaultValue,
|
|
|
322
|
+ timeUnit: condition?.triggerCondition?.condition?.spec?.unit,
|
|
|
323
|
+ });
|
|
|
324
|
+ if (condition?.entityId != undefined) {
|
|
|
325
|
+ selectDeviceId.value = condition?.entityId;
|
|
|
326
|
+ }
|
|
|
327
|
+ //fengtao-把设备id回传给子组件
|
|
|
328
|
+ unref(skipUnwrap.conditionItemRefs)[index].updateFieldAttributeFunc(
|
|
|
329
|
+ selectDeviceId.value,
|
|
|
330
|
+ provideOrgid.value
|
|
|
331
|
+ );
|
|
|
332
|
+ //fengtao
|
|
|
333
|
+ // 设置值operationType
|
|
|
334
|
+ unref(skipUnwrap.conditionItemRefs)[index].operationType =
|
|
|
335
|
+ condition.triggerCondition?.condition.condition[0].valueType;
|
291
|
|
336
|
|
292
|
- const ConditionScreeningForm = await unref(skipUnwrap.conditionItemRefs)[
|
|
|
293
|
- index
|
|
|
294
|
- ].getRefItemConditionScreeningRefs();
|
337
|
+ const ConditionScreeningForm = await unref(skipUnwrap.conditionItemRefs)[
|
|
|
338
|
+ index
|
|
|
339
|
+ ].getRefItemConditionScreeningRefs();
|
295
|
|
340
|
|
296
|
- // 设置对应条件筛选的个数
|
|
|
297
|
- unref(skipUnwrap.conditionItemRefs)[index].setConditionScreeningList([
|
|
|
298
|
- ...new Array(condition.triggerCondition.condition.condition.length).keys(),
|
|
|
299
|
- ]);
|
|
|
300
|
- // 操作符类型 NUMERIC|String|Boolean|DATE_TIME
|
|
|
301
|
- const valueType = condition.triggerCondition?.condition.condition[0].valueType;
|
341
|
+ // 设置对应条件筛选的个数
|
|
|
342
|
+ unref(skipUnwrap.conditionItemRefs)[index].setConditionScreeningList([
|
|
|
343
|
+ ...new Array(condition.triggerCondition.condition.condition.length).keys(),
|
|
|
344
|
+ ]);
|
|
|
345
|
+ // 操作符类型 NUMERIC|String|Boolean|DATE_TIME
|
|
|
346
|
+ const valueType = condition.triggerCondition?.condition.condition[0].valueType;
|
302
|
|
347
|
|
303
|
- // 循环设置条件筛选值。TODO:此处设置顺序有问题
|
|
|
304
|
- nextTick(() => {
|
|
|
305
|
- const richTextList = [];
|
|
|
306
|
- condition.triggerCondition.condition.condition.forEach((item, index) => {
|
|
|
307
|
- const formItem = {
|
|
|
308
|
- operation: item.predicate.operation,
|
|
|
309
|
- value:
|
|
|
310
|
- valueType === 'DATE_TIME'
|
|
|
311
|
- ? formatToDateTime(
|
|
|
312
|
- Number(item.predicate.value.defaultValue),
|
|
|
313
|
- 'YYYY-MM-DD HH:mm:ss'
|
|
|
314
|
- )
|
|
|
315
|
- : String(item.predicate.value.defaultValue),
|
|
|
316
|
- ignoreCase: item.valueType === 'STRING' ? item.predicate.ignoreCase : undefined,
|
|
|
317
|
- };
|
|
|
318
|
- richTextList.push({
|
|
|
319
|
- // 查询中文操作符
|
|
|
320
|
- operation: findOperation(valueType, item.predicate.operation).label,
|
|
|
321
|
- value:
|
|
|
322
|
- valueType === 'DATE_TIME'
|
|
|
323
|
- ? formatToDateTime(
|
|
|
324
|
- Number(item.predicate.value.defaultValue),
|
|
|
325
|
- 'YYYY-MM-DD HH:mm:ss'
|
|
|
326
|
- )
|
|
|
327
|
- : String(item.predicate.value.defaultValue),
|
|
|
328
|
- attribute: condition.triggerCondition?.condition.condition[0]?.key?.key,
|
348
|
+ // 循环设置条件筛选值。TODO:此处设置顺序有问题
|
|
|
349
|
+ nextTick(() => {
|
|
|
350
|
+ const richTextList = [];
|
|
|
351
|
+ condition.triggerCondition.condition.condition.forEach((item, index) => {
|
|
|
352
|
+ const formItem = {
|
|
|
353
|
+ operation: item.predicate.operation,
|
|
|
354
|
+ value:
|
|
|
355
|
+ valueType === 'DATE_TIME'
|
|
|
356
|
+ ? formatToDateTime(
|
|
|
357
|
+ Number(item.predicate.value.defaultValue),
|
|
|
358
|
+ 'YYYY-MM-DD HH:mm:ss'
|
|
|
359
|
+ )
|
|
|
360
|
+ : String(item.predicate.value.defaultValue),
|
|
|
361
|
+ ignoreCase: item.valueType === 'STRING' ? item.predicate.ignoreCase : undefined,
|
|
|
362
|
+ };
|
|
|
363
|
+ richTextList.push({
|
|
|
364
|
+ // 查询中文操作符
|
|
|
365
|
+ operation: findOperation(valueType, item.predicate.operation).label,
|
|
|
366
|
+ value:
|
|
|
367
|
+ valueType === 'DATE_TIME'
|
|
|
368
|
+ ? formatToDateTime(
|
|
|
369
|
+ Number(item.predicate.value.defaultValue),
|
|
|
370
|
+ 'YYYY-MM-DD HH:mm:ss'
|
|
|
371
|
+ )
|
|
|
372
|
+ : String(item.predicate.value.defaultValue),
|
|
|
373
|
+ attribute: condition.triggerCondition?.condition.condition[0]?.key?.key,
|
|
|
374
|
+ });
|
|
|
375
|
+ ConditionScreeningForm.value[index].setFieldsValue(formItem);
|
329
|
});
|
376
|
});
|
330
|
- ConditionScreeningForm.value[index].setFieldsValue(formItem);
|
377
|
+ unref(skipUnwrap.conditionItemRefs)[index].setRichText(richTextList);
|
331
|
});
|
378
|
});
|
332
|
- unref(skipUnwrap.conditionItemRefs)[index].setRichText(richTextList);
|
|
|
333
|
});
|
379
|
});
|
334
|
});
|
380
|
});
|
335
|
- });
|
|
|
336
|
|
381
|
|
337
|
- doActions.forEach((action, index) => {
|
|
|
338
|
- nextTick(() => {
|
|
|
339
|
- const selectDeviceId = ref('');
|
|
|
340
|
- // 设置执行动作外层值
|
|
|
341
|
- unref(skipUnwrap.actionItemRefs)[index].setFieldsFormValueFun({
|
|
|
342
|
- outTarget: action.outTarget,
|
|
|
343
|
- device: action.entityType,
|
|
|
344
|
- deviceId: action.deviceId,
|
|
|
345
|
- alarm_config: action.alarmProfileId,
|
|
|
346
|
- alarm_level: action.doContext.alarmLevel,
|
|
|
347
|
- });
|
|
|
348
|
- // 如果是设备输出设置脚本值
|
|
|
349
|
- if (action.outTarget === 'DEVICE_OUT') {
|
|
|
350
|
- unref(skipUnwrap.actionItemRefs)[index].setJsonValue(action.doContext.params);
|
|
|
351
|
- }
|
|
|
352
|
- // 清除告警有值?{数组}
|
|
|
353
|
- if (action?.doContext?.clearRule?.length) {
|
|
|
354
|
- unref(skipUnwrap.actionItemRefs)[index].checked = true;
|
|
|
355
|
- // 生成对应清除告警的数组长度
|
|
|
356
|
- unref(skipUnwrap.actionItemRefs)[index].clearRuleList = [
|
|
|
357
|
- ...new Array(action?.doContext?.clearRule?.length).keys(),
|
|
|
358
|
- ];
|
|
|
359
|
- // 推迟执行时机-DOM渲染完毕在执行
|
|
|
360
|
- nextTick(async () => {
|
|
|
361
|
- unref(skipUnwrap.actionItemRefs)[index].refItem.clearRuleRefs.value.map(
|
|
|
362
|
- (item, index) => {
|
|
|
363
|
- // 回显启用规则
|
|
|
364
|
- item.currentIndex =
|
|
|
365
|
- map[action.doContext.clearRule[index].triggerCondition.schedule.type];
|
|
|
366
|
- item.scheduleData = action.doContext.clearRule[index].triggerCondition.schedule;
|
|
|
367
|
- item.isUpdate = true;
|
|
|
368
|
- item.alarmScheduleRef.scheduleData =
|
|
|
369
|
- action.doContext.clearRule[index].triggerCondition.schedule;
|
|
|
370
|
- item.setFieldsFormValueFun({
|
|
|
371
|
- triggered:
|
|
|
372
|
- action.doContext.clearRule[index].triggerCondition.condition.spec.type,
|
|
|
373
|
- device: action.doContext.clearRule[index].entityType,
|
|
|
374
|
- triggerType: action.doContext.clearRule[index].triggerType,
|
|
|
375
|
- type1:
|
|
|
376
|
- action.doContext.clearRule[index].triggerCondition.condition.condition[0].key
|
|
|
377
|
- .type,
|
|
|
378
|
- type2:
|
|
|
379
|
- action.doContext.clearRule[index].triggerCondition.condition.condition[0].key
|
|
|
380
|
- .key,
|
|
|
381
|
- operationType:
|
|
|
382
|
- action.doContext.clearRule[index].triggerCondition.condition.condition[0]
|
|
|
383
|
- .valueType,
|
|
|
384
|
- detail: action.doContext.clearRule[index].triggerCondition.alarmDetails,
|
|
|
385
|
- entityId: action.doContext.clearRule[index].entityId,
|
|
|
386
|
- replaceValue:
|
|
|
387
|
- action.doContext.clearRule[index].triggerCondition.condition.spec.predicate
|
|
|
388
|
- .defaultValue,
|
|
|
389
|
- time: action.doContext.clearRule[index].triggerCondition.condition.spec
|
|
|
390
|
- .predicate.defaultValue,
|
|
|
391
|
- timeUnit:
|
|
|
392
|
- action.doContext.clearRule[index].triggerCondition.condition.spec.unit,
|
|
|
393
|
- });
|
|
|
394
|
- if (action.doContext.clearRule[index].entityId != undefined) {
|
|
|
395
|
- selectDeviceId.value = action.doContext.clearRule[index].entityId;
|
382
|
+ doActions.forEach((action, index) => {
|
|
|
383
|
+ nextTick(() => {
|
|
|
384
|
+ const selectDeviceId = ref('');
|
|
|
385
|
+ // 设置执行动作外层值
|
|
|
386
|
+ unref(skipUnwrap.actionItemRefs)[index].setFieldsFormValueFun({
|
|
|
387
|
+ outTarget: action.outTarget,
|
|
|
388
|
+ device: action.entityType,
|
|
|
389
|
+ deviceId: action.deviceId,
|
|
|
390
|
+ alarm_config: action.alarmProfileId,
|
|
|
391
|
+ alarm_level: action.doContext.alarmLevel,
|
|
|
392
|
+ });
|
|
|
393
|
+ // 如果是设备输出设置脚本值
|
|
|
394
|
+ if (action.outTarget === 'DEVICE_OUT') {
|
|
|
395
|
+ unref(skipUnwrap.actionItemRefs)[index].setJsonValue(action.doContext.params);
|
|
|
396
|
+ }
|
|
|
397
|
+ // 清除告警有值?{数组}
|
|
|
398
|
+ if (action?.doContext?.clearRule?.length) {
|
|
|
399
|
+ unref(skipUnwrap.actionItemRefs)[index].checked = true;
|
|
|
400
|
+ // 生成对应清除告警的数组长度
|
|
|
401
|
+ unref(skipUnwrap.actionItemRefs)[index].clearRuleList = [
|
|
|
402
|
+ ...new Array(action?.doContext?.clearRule?.length).keys(),
|
|
|
403
|
+ ];
|
|
|
404
|
+ // 推迟执行时机-DOM渲染完毕在执行
|
|
|
405
|
+ nextTick(async () => {
|
|
|
406
|
+ unref(skipUnwrap.actionItemRefs)[index].refItem.clearRuleRefs.value.map(
|
|
|
407
|
+ (item, index) => {
|
|
|
408
|
+ // 回显启用规则
|
|
|
409
|
+ item.currentIndex =
|
|
|
410
|
+ map[action.doContext.clearRule[index].triggerCondition.schedule.type];
|
|
|
411
|
+ item.scheduleData = action.doContext.clearRule[index].triggerCondition.schedule;
|
|
|
412
|
+ item.isUpdate = true;
|
|
|
413
|
+ item.alarmScheduleRef.scheduleData =
|
|
|
414
|
+ action.doContext.clearRule[index].triggerCondition.schedule;
|
|
|
415
|
+ item.setFieldsFormValueFun({
|
|
|
416
|
+ triggered:
|
|
|
417
|
+ action.doContext.clearRule[index].triggerCondition.condition.spec.type,
|
|
|
418
|
+ device: action.doContext.clearRule[index].entityType,
|
|
|
419
|
+ triggerType: action.doContext.clearRule[index].triggerType,
|
|
|
420
|
+ type1:
|
|
|
421
|
+ action.doContext.clearRule[index].triggerCondition.condition.condition[0].key
|
|
|
422
|
+ .type,
|
|
|
423
|
+ type2:
|
|
|
424
|
+ action.doContext.clearRule[index].triggerCondition.condition.condition[0].key
|
|
|
425
|
+ .key,
|
|
|
426
|
+ operationType:
|
|
|
427
|
+ action.doContext.clearRule[index].triggerCondition.condition.condition[0]
|
|
|
428
|
+ .valueType,
|
|
|
429
|
+ detail: action.doContext.clearRule[index].triggerCondition.alarmDetails,
|
|
|
430
|
+ entityId: action.doContext.clearRule[index].entityId,
|
|
|
431
|
+ replaceValue:
|
|
|
432
|
+ action.doContext.clearRule[index].triggerCondition.condition.spec.predicate
|
|
|
433
|
+ .defaultValue,
|
|
|
434
|
+ time: action.doContext.clearRule[index].triggerCondition.condition.spec
|
|
|
435
|
+ .predicate.defaultValue,
|
|
|
436
|
+ timeUnit:
|
|
|
437
|
+ action.doContext.clearRule[index].triggerCondition.condition.spec.unit,
|
|
|
438
|
+ });
|
|
|
439
|
+ if (action.doContext.clearRule[index].entityId != undefined) {
|
|
|
440
|
+ selectDeviceId.value = action.doContext.clearRule[index].entityId;
|
|
|
441
|
+ }
|
|
|
442
|
+ //fengtao-把设备id回传给子组件
|
|
|
443
|
+ item.updateFieldAttributeFunc(selectDeviceId.value, provideOrgid.value);
|
|
|
444
|
+ item.updateFieldDeviceId(
|
|
|
445
|
+ deviceList.value,
|
|
|
446
|
+ provideOrgid.value,
|
|
|
447
|
+ isUpdate.value,
|
|
|
448
|
+ getMasterDeviceList.value
|
|
|
449
|
+ );
|
|
|
450
|
+ //fengtao
|
|
|
451
|
+ // 单独设置operationType值 操作符类型 NUMERIC|String|Boolean|DATE_TIME
|
|
|
452
|
+ item.operationType =
|
|
|
453
|
+ action.doContext.clearRule[
|
|
|
454
|
+ index
|
|
|
455
|
+ ].triggerCondition.condition.condition[0].valueType;
|
396
|
}
|
456
|
}
|
397
|
- //fengtao-把设备id回传给子组件
|
|
|
398
|
- item.updateFieldAttributeFunc(selectDeviceId.value, provideOrgid.value);
|
|
|
399
|
- item.updateFieldDeviceId(
|
|
|
400
|
- deviceList.value,
|
|
|
401
|
- provideOrgid.value,
|
|
|
402
|
- isUpdate.value,
|
|
|
403
|
- getMasterDeviceList.value
|
|
|
404
|
- );
|
|
|
405
|
- //fengtao
|
|
|
406
|
- // 单独设置operationType值 操作符类型 NUMERIC|String|Boolean|DATE_TIME
|
|
|
407
|
- item.operationType =
|
|
|
408
|
- action.doContext.clearRule[
|
|
|
409
|
- index
|
|
|
410
|
- ].triggerCondition.condition.condition[0].valueType;
|
|
|
411
|
- }
|
|
|
412
|
- );
|
457
|
+ );
|
413
|
|
458
|
|
414
|
- const ConditionScreeningForm = await unref(skipUnwrap.actionItemRefs)[
|
|
|
415
|
- index
|
|
|
416
|
- ].getRefItemConditionScreeningRefs();
|
459
|
+ const ConditionScreeningForm = await unref(skipUnwrap.actionItemRefs)[
|
|
|
460
|
+ index
|
|
|
461
|
+ ].getRefItemConditionScreeningRefs();
|
417
|
|
462
|
|
418
|
- // 循环设置条件筛选值。TODO:此处设置顺序有问题
|
|
|
419
|
- action.doContext.clearRule.map((rule, ruleIndex) => {
|
|
|
420
|
- // 生成对应条件筛选的数组个数
|
|
|
421
|
- unref(skipUnwrap.actionItemRefs)[index].setConditionScreeningList([
|
|
|
422
|
- ...new Array(
|
|
|
423
|
- action.doContext.clearRule[
|
|
|
424
|
- ruleIndex
|
|
|
425
|
- ].triggerCondition.condition.condition.length
|
|
|
426
|
- ).keys(),
|
|
|
427
|
- ]);
|
|
|
428
|
- nextTick(() => {
|
|
|
429
|
- const richTextList = [];
|
|
|
430
|
- rule.triggerCondition.condition.condition.forEach((item, conditionIndex) => {
|
|
|
431
|
- //TODO-fengtao之前是Number( item.predicate.value.defaultValue)-发现回显是Invalide Time
|
|
|
432
|
- const formItem = {
|
|
|
433
|
- operation: item.predicate.operation,
|
|
|
434
|
- value:
|
|
|
435
|
- item.valueType === 'DATE_TIME'
|
|
|
436
|
- ? formatToDateTime(
|
|
|
437
|
- Number(item.predicate.value.defaultValue),
|
|
|
438
|
- 'YYYY-MM-DD HH:mm:ss'
|
|
|
439
|
- )
|
|
|
440
|
- : String(item.predicate.value.defaultValue),
|
|
|
441
|
- ignoreCase:
|
|
|
442
|
- item.valueType === 'STRING' ? item.predicate.ignoreCase : undefined,
|
|
|
443
|
- };
|
|
|
444
|
- //TODO-fengtao之前是Number( item.predicate.value.defaultValue)-发现回显是Invalide Time
|
|
|
445
|
- richTextList.push({
|
|
|
446
|
- // 查询中文操作符
|
|
|
447
|
- operation: findOperation(item.valueType, item.predicate.operation).label,
|
|
|
448
|
- value:
|
|
|
449
|
- item.valueType === 'DATE_TIME'
|
|
|
450
|
- ? formatToDateTime(
|
|
|
451
|
- item.predicate.value.defaultValue,
|
|
|
452
|
- 'YYYY-MM-DD HH:mm:ss'
|
|
|
453
|
- )
|
|
|
454
|
- : String(item.predicate.value.defaultValue),
|
|
|
455
|
- attribute: item?.key?.key,
|
463
|
+ // 循环设置条件筛选值。TODO:此处设置顺序有问题
|
|
|
464
|
+ action.doContext.clearRule.map((rule, ruleIndex) => {
|
|
|
465
|
+ // 生成对应条件筛选的数组个数
|
|
|
466
|
+ unref(skipUnwrap.actionItemRefs)[index].setConditionScreeningList([
|
|
|
467
|
+ ...new Array(
|
|
|
468
|
+ action.doContext.clearRule[
|
|
|
469
|
+ ruleIndex
|
|
|
470
|
+ ].triggerCondition.condition.condition.length
|
|
|
471
|
+ ).keys(),
|
|
|
472
|
+ ]);
|
|
|
473
|
+ nextTick(() => {
|
|
|
474
|
+ const richTextList = [];
|
|
|
475
|
+ rule.triggerCondition.condition.condition.forEach((item, conditionIndex) => {
|
|
|
476
|
+ //TODO-fengtao之前是Number( item.predicate.value.defaultValue)-发现回显是Invalide Time
|
|
|
477
|
+ const formItem = {
|
|
|
478
|
+ operation: item.predicate.operation,
|
|
|
479
|
+ value:
|
|
|
480
|
+ item.valueType === 'DATE_TIME'
|
|
|
481
|
+ ? formatToDateTime(
|
|
|
482
|
+ Number(item.predicate.value.defaultValue),
|
|
|
483
|
+ 'YYYY-MM-DD HH:mm:ss'
|
|
|
484
|
+ )
|
|
|
485
|
+ : String(item.predicate.value.defaultValue),
|
|
|
486
|
+ ignoreCase:
|
|
|
487
|
+ item.valueType === 'STRING' ? item.predicate.ignoreCase : undefined,
|
|
|
488
|
+ };
|
|
|
489
|
+ //TODO-fengtao之前是Number( item.predicate.value.defaultValue)-发现回显是Invalide Time
|
|
|
490
|
+ richTextList.push({
|
|
|
491
|
+ // 查询中文操作符
|
|
|
492
|
+ operation: findOperation(item.valueType, item.predicate.operation).label,
|
|
|
493
|
+ value:
|
|
|
494
|
+ item.valueType === 'DATE_TIME'
|
|
|
495
|
+ ? formatToDateTime(
|
|
|
496
|
+ item.predicate.value.defaultValue,
|
|
|
497
|
+ 'YYYY-MM-DD HH:mm:ss'
|
|
|
498
|
+ )
|
|
|
499
|
+ : String(item.predicate.value.defaultValue),
|
|
|
500
|
+ attribute: item?.key?.key,
|
|
|
501
|
+ });
|
|
|
502
|
+ //TODO-fengtao之前是Number( item.predicate.value.defaultValue)-发现回显是Invalide Time
|
|
|
503
|
+ ConditionScreeningForm[ruleIndex].value[conditionIndex].setFieldsValue(
|
|
|
504
|
+ formItem
|
|
|
505
|
+ );
|
456
|
});
|
506
|
});
|
457
|
- //TODO-fengtao之前是Number( item.predicate.value.defaultValue)-发现回显是Invalide Time
|
|
|
458
|
- ConditionScreeningForm[ruleIndex].value[conditionIndex].setFieldsValue(
|
|
|
459
|
- formItem
|
|
|
460
|
- );
|
507
|
+ unref(skipUnwrap.actionItemRefs)[index].setRichText(richTextList, ruleIndex);
|
461
|
});
|
508
|
});
|
462
|
- unref(skipUnwrap.actionItemRefs)[index].setRichText(richTextList, ruleIndex);
|
|
|
463
|
});
|
509
|
});
|
464
|
});
|
510
|
});
|
|
|
511
|
+ }
|
|
|
512
|
+ nextTick(() => {
|
|
|
513
|
+ setEditFields(skipUnwrap.actionItemRefs, editEntryIdData);
|
465
|
});
|
514
|
});
|
466
|
- }
|
|
|
467
|
- nextTick(() => {
|
|
|
468
|
- setEditFields(skipUnwrap.actionItemRefs, editEntryIdData);
|
|
|
469
|
});
|
515
|
});
|
470
|
});
|
516
|
});
|
|
|
517
|
+ }
|
|
|
518
|
+ if (unref(isUpdate) === 3) isView.value = false;
|
|
|
519
|
+ setDrawerProps({
|
|
|
520
|
+ showFooter: unref(isView),
|
|
|
521
|
+ loading: false,
|
471
|
});
|
522
|
});
|
472
|
- }
|
|
|
473
|
- if (unref(isUpdate) === 3) isView.value = false;
|
|
|
474
|
- setDrawerProps({
|
|
|
475
|
- showFooter: unref(isView),
|
|
|
476
|
- loading: false,
|
|
|
477
|
});
|
523
|
});
|
478
|
-});
|
|
|
479
|
|
524
|
|
480
|
-
|
|
|
481
|
-// 设置设备的options
|
|
|
482
|
-const setEditFields = (linkAge, deviceList) => {
|
|
|
483
|
- unref(linkAge).map((item) => {
|
|
|
484
|
- //TODO-fengtao
|
|
|
485
|
- item.updateFieldDeviceId(deviceList, orgId, isUpdate, getMasterDeviceList);
|
|
|
486
|
- //TODO-fengtao
|
|
|
487
|
- });
|
|
|
488
|
-};
|
|
|
489
|
-// 设置告警配置options
|
|
|
490
|
-const setEditAlarmConfig = (linkAge, alarmConfigList) => {
|
|
|
491
|
- unref(linkAge).map((item) => {
|
|
|
492
|
- item.updateEditFieldAlarmConfig(alarmConfigList);
|
|
|
493
|
- });
|
|
|
494
|
-};
|
|
|
495
|
-// 监听组织变化更新设备列表
|
|
|
496
|
-const deviceList = ref([]);
|
|
|
497
|
-const getMasterDeviceList = ref([]);
|
|
|
498
|
-const orgId = ref('');
|
|
|
499
|
-const alarmConfigList = ref([]);
|
|
|
500
|
-watch(organizationId, async (newValue: string) => {
|
|
|
501
|
- if (!newValue) return;
|
|
|
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
|
|
|
510
|
- setFields(skipUnwrap.triggerItemRefs, true);
|
|
|
511
|
- setFields(skipUnwrap.conditionItemRefs, true);
|
|
|
512
|
- setFields(skipUnwrap.actionItemRefs, true);
|
|
|
513
|
- const data = await getOrganizationAlarmConfig({ organizationId: newValue });
|
|
|
514
|
- alarmConfigList.value = data.map((item) => ({ label: item.name, value: item.id }));
|
|
|
515
|
- setAlarmConfig(skipUnwrap.actionItemRefs, true);
|
|
|
516
|
-});
|
|
|
517
|
-
|
|
|
518
|
-// 根据上面组织变化动态改变触发器,执行条件,执行动作的设备值
|
|
|
519
|
-function setFields(linkAge, isOrganizationChange = false) {
|
|
|
520
|
- unref(linkAge).map((item) => {
|
|
|
521
|
- isOrganizationChange && item.resetFieldsValueFunc();
|
525
|
+ // 设置设备的options
|
|
|
526
|
+ const setEditFields = (linkAge, deviceList) => {
|
|
|
527
|
+ unref(linkAge).map((item) => {
|
|
|
528
|
+ //TODO-fengtao
|
|
|
529
|
+ item.updateFieldDeviceId(deviceList, orgId, isUpdate, getMasterDeviceList);
|
|
|
530
|
+ //TODO-fengtao
|
|
|
531
|
+ });
|
|
|
532
|
+ };
|
|
|
533
|
+ // 设置告警配置options
|
|
|
534
|
+ const setEditAlarmConfig = (linkAge, alarmConfigList) => {
|
|
|
535
|
+ unref(linkAge).map((item) => {
|
|
|
536
|
+ item.updateEditFieldAlarmConfig(alarmConfigList);
|
|
|
537
|
+ });
|
|
|
538
|
+ };
|
|
|
539
|
+ // 监听组织变化更新设备列表
|
|
|
540
|
+ const deviceList = ref([]);
|
|
|
541
|
+ const getMasterDeviceList = ref([]);
|
|
|
542
|
+ const orgId = ref('');
|
|
|
543
|
+ const alarmConfigList = ref([]);
|
|
|
544
|
+ watch(organizationId, async (newValue: string) => {
|
|
|
545
|
+ if (!newValue) return;
|
|
|
546
|
+ const { items } = await screenLinkPageByDeptIdGetDevice({ organizationId: newValue });
|
522
|
//TODO fengtao
|
547
|
//TODO fengtao
|
523
|
- item.updateFieldDeviceId(deviceList, orgId, isUpdate, getMasterDeviceList);
|
548
|
+ getMasterDeviceList.value = await byOganizationIdGetMasterDevice(newValue);
|
524
|
//TODO fengtao
|
549
|
//TODO fengtao
|
|
|
550
|
+ deviceList.value = items.map((item) => ({ label: item.name, value: item.tbDeviceId }));
|
|
|
551
|
+ //TODO fengtao
|
|
|
552
|
+ orgId.value = newValue;
|
|
|
553
|
+ //TODO fengtao
|
|
|
554
|
+ setFields(skipUnwrap.triggerItemRefs, true);
|
|
|
555
|
+ setFields(skipUnwrap.conditionItemRefs, true);
|
|
|
556
|
+ setFields(skipUnwrap.actionItemRefs, true);
|
|
|
557
|
+ const data = await getOrganizationAlarmConfig({ organizationId: newValue });
|
|
|
558
|
+ alarmConfigList.value = data.map((item) => ({ label: item.name, value: item.id }));
|
|
|
559
|
+ setAlarmConfig(skipUnwrap.actionItemRefs, true);
|
525
|
});
|
560
|
});
|
526
|
-}
|
|
|
527
|
-function setAlarmConfig(linkAge, isOrganizationChange = false) {
|
|
|
528
|
- unref(linkAge).map((item) => {
|
|
|
529
|
- isOrganizationChange && item.resetFieldsValueFunc();
|
|
|
530
|
- item.updateFieldAlarmConfig(alarmConfigList);
|
|
|
531
|
- });
|
|
|
532
|
-}
|
|
|
533
|
-// 添加触发器
|
|
|
534
|
-const addTrigger = () => {
|
|
|
535
|
- unref(triggerData).push(Date.now());
|
|
|
536
|
- nextTick(() => {
|
|
|
537
|
- setFields(skipUnwrap.triggerItemRefs);
|
|
|
538
|
- });
|
|
|
539
|
-};
|
|
|
540
|
-// 添加执行条件
|
|
|
541
|
-const addCondition = () => {
|
|
|
542
|
- unref(conditionData).push(Date.now());
|
|
|
543
|
- nextTick(() => {
|
|
|
544
|
- setFields(skipUnwrap.conditionItemRefs);
|
|
|
545
|
- });
|
|
|
546
|
-};
|
|
|
547
|
-// 添加执行动作
|
|
|
548
|
-const addAction = () => {
|
|
|
549
|
- unref(actionData).push(Date.now());
|
|
|
550
|
- nextTick(() => {
|
|
|
551
|
- setFields(skipUnwrap.actionItemRefs);
|
|
|
552
|
- });
|
|
|
553
|
-};
|
|
|
554
|
|
561
|
|
555
|
-/**
|
|
|
556
|
- * 获取触发器、执行条件、执行动作表单值--多个
|
|
|
557
|
- */
|
|
|
558
|
-const getFormValueFunc = () => {
|
|
|
559
|
- getTriggerFormValue.value = unref(skipUnwrap.triggerItemRefs)?.map((item) =>
|
|
|
560
|
- genTriggerOrConditionData(item.getFieldsValueFunc())
|
|
|
561
|
- );
|
|
|
562
|
- getConditionFormValue.value = unref(skipUnwrap.conditionItemRefs)?.map((item) =>
|
|
|
563
|
- genTriggerOrConditionData(item.getFieldsValueFunc())
|
|
|
564
|
- );
|
|
|
565
|
- getActionFormValue.value = unref(skipUnwrap.actionItemRefs)?.map((item) =>
|
|
|
566
|
- genActionData(item.getFieldsValueFunc())
|
|
|
567
|
- );
|
|
|
568
|
-};
|
|
|
569
|
-const handleSubmit = async () => {
|
|
|
570
|
- let basicFormValue = await validate();
|
|
|
571
|
- if (!basicFormValue) return;
|
|
|
572
|
- for (const item of unref(skipUnwrap.actionItemRefs)) {
|
|
|
573
|
- const valid = await item.validateForm();
|
|
|
574
|
- if (!valid) return;
|
|
|
575
|
- }
|
|
|
576
|
- try {
|
|
|
577
|
- setDrawerProps({ confirmLoading: true });
|
|
|
578
|
- getFormValueFunc();
|
|
|
579
|
- const postAddOrEditData = {
|
|
|
580
|
- ...basicFormValue,
|
|
|
581
|
- triggers: !unref(getTriggerFormValue).length ? null : unref(getTriggerFormValue),
|
|
|
582
|
- doConditions: !unref(getConditionFormValue).length ? null : unref(getConditionFormValue),
|
|
|
583
|
- doActions: unref(getActionFormValue).flat(),
|
|
|
584
|
- id: unref(id),
|
|
|
585
|
- tenantId: unref(tenantId),
|
|
|
586
|
- };
|
|
|
587
|
- await screenLinkPageAddApi(postAddOrEditData, unref(isUpdate));
|
|
|
588
|
- createMessage.success(`${unref(isUpdate) ? '编辑' : '新增'}成功`);
|
|
|
589
|
- closeDrawer();
|
|
|
590
|
- handleClose();
|
|
|
591
|
- emit('success');
|
|
|
592
|
- } finally {
|
|
|
593
|
- setDrawerProps({ confirmLoading: false });
|
562
|
+ // 根据上面组织变化动态改变触发器,执行条件,执行动作的设备值
|
|
|
563
|
+ function setFields(linkAge, isOrganizationChange = false) {
|
|
|
564
|
+ unref(linkAge).map((item) => {
|
|
|
565
|
+ isOrganizationChange && item.resetFieldsValueFunc();
|
|
|
566
|
+ //TODO fengtao
|
|
|
567
|
+ item.updateFieldDeviceId(deviceList, orgId, isUpdate, getMasterDeviceList);
|
|
|
568
|
+ //TODO fengtao
|
|
|
569
|
+ });
|
594
|
}
|
570
|
}
|
595
|
-};
|
|
|
596
|
-// 删除
|
|
|
597
|
-const deleteTriggerOrCondition = ({ index, title }) => {
|
|
|
598
|
- if (title === '触发器') {
|
|
|
599
|
- unref(triggerData).splice(index, 1);
|
|
|
600
|
- } else if (title === '执行条件') {
|
|
|
601
|
- unref(conditionData).splice(index, 1);
|
571
|
+ function setAlarmConfig(linkAge, isOrganizationChange = false) {
|
|
|
572
|
+ unref(linkAge).map((item) => {
|
|
|
573
|
+ isOrganizationChange && item.resetFieldsValueFunc();
|
|
|
574
|
+ item.updateFieldAlarmConfig(alarmConfigList);
|
|
|
575
|
+ });
|
602
|
}
|
576
|
}
|
603
|
-};
|
|
|
604
|
-const deleteAction = (actionIndex) => {
|
|
|
605
|
- unref(actionData).splice(actionIndex, 1);
|
|
|
606
|
- unref(arr).splice(actionIndex, 1);
|
|
|
607
|
-};
|
|
|
608
|
-const arr = ref([]);
|
|
|
609
|
-const getActionFormArr = () => {
|
|
|
610
|
- arr.value = unref(skipUnwrap.actionItemRefs).map((item) => item.getFieldsValue());
|
|
|
611
|
-};
|
|
|
612
|
-const handleClose = () => {
|
|
|
613
|
- id.value = undefined;
|
|
|
614
|
- tenantId.value = undefined;
|
|
|
615
|
- organizationId.value = undefined;
|
|
|
616
|
- isView.value = true;
|
|
|
617
|
- getTriggerFormValue.value = [];
|
|
|
618
|
- getConditionFormValue.value = [];
|
|
|
619
|
- getActionFormValue.value = [];
|
|
|
620
|
- triggerData.value = [];
|
|
|
621
|
- conditionData.value = [];
|
|
|
622
|
- actionData.value = [];
|
|
|
623
|
- unref(skipUnwrap.triggerItemRefs).map((item) => {
|
|
|
624
|
- item.resetFieldsValueFunc();
|
|
|
625
|
- });
|
|
|
626
|
- unref(skipUnwrap.conditionItemRefs).map((item) => {
|
|
|
627
|
- item.resetFieldsValueFunc();
|
|
|
628
|
- });
|
|
|
629
|
- unref(skipUnwrap.actionItemRefs).map((item) => {
|
|
|
630
|
- item.resetFieldsValueFunc();
|
|
|
631
|
- });
|
|
|
632
|
- window.localStorage.removeItem('isViewDisabledBtn')
|
|
|
633
|
- // window.localStorage.setItem('isViewDisabledBtn', 'no')
|
|
|
634
|
-};
|
577
|
+ // 添加触发器
|
|
|
578
|
+ const addTrigger = () => {
|
|
|
579
|
+ unref(triggerData).push(Date.now());
|
|
|
580
|
+ nextTick(() => {
|
|
|
581
|
+ setFields(skipUnwrap.triggerItemRefs);
|
|
|
582
|
+ });
|
|
|
583
|
+ };
|
|
|
584
|
+ // 添加执行条件
|
|
|
585
|
+ const addCondition = () => {
|
|
|
586
|
+ unref(conditionData).push(Date.now());
|
|
|
587
|
+ nextTick(() => {
|
|
|
588
|
+ setFields(skipUnwrap.conditionItemRefs);
|
|
|
589
|
+ });
|
|
|
590
|
+ };
|
|
|
591
|
+ // 添加执行动作
|
|
|
592
|
+ const addAction = () => {
|
|
|
593
|
+ unref(actionData).push(Date.now());
|
|
|
594
|
+ nextTick(() => {
|
|
|
595
|
+ setFields(skipUnwrap.actionItemRefs);
|
|
|
596
|
+ });
|
|
|
597
|
+ };
|
|
|
598
|
+
|
|
|
599
|
+ /**
|
|
|
600
|
+ * 获取触发器、执行条件、执行动作表单值--多个
|
|
|
601
|
+ */
|
|
|
602
|
+ const getFormValueFunc = () => {
|
|
|
603
|
+ getTriggerFormValue.value = unref(skipUnwrap.triggerItemRefs)?.map((item) =>
|
|
|
604
|
+ genTriggerOrConditionData(item.getFieldsValueFunc())
|
|
|
605
|
+ );
|
|
|
606
|
+ getConditionFormValue.value = unref(skipUnwrap.conditionItemRefs)?.map((item) =>
|
|
|
607
|
+ genTriggerOrConditionData(item.getFieldsValueFunc())
|
|
|
608
|
+ );
|
|
|
609
|
+ getActionFormValue.value = unref(skipUnwrap.actionItemRefs)?.map((item) =>
|
|
|
610
|
+ genActionData(item.getFieldsValueFunc())
|
|
|
611
|
+ );
|
|
|
612
|
+ };
|
|
|
613
|
+ const handleSubmit = async () => {
|
|
|
614
|
+ let basicFormValue = await validate();
|
|
|
615
|
+ if (!basicFormValue) return;
|
|
|
616
|
+ for (const item of unref(skipUnwrap.actionItemRefs)) {
|
|
|
617
|
+ const valid = await item.validateForm();
|
|
|
618
|
+ if (!valid) return;
|
|
|
619
|
+ }
|
|
|
620
|
+ try {
|
|
|
621
|
+ setDrawerProps({ confirmLoading: true });
|
|
|
622
|
+ getFormValueFunc();
|
|
|
623
|
+ const postAddOrEditData = {
|
|
|
624
|
+ ...basicFormValue,
|
|
|
625
|
+ triggers: !unref(getTriggerFormValue).length ? null : unref(getTriggerFormValue),
|
|
|
626
|
+ doConditions: !unref(getConditionFormValue).length ? null : unref(getConditionFormValue),
|
|
|
627
|
+ doActions: unref(getActionFormValue).flat(),
|
|
|
628
|
+ id: unref(id),
|
|
|
629
|
+ tenantId: unref(tenantId),
|
|
|
630
|
+ };
|
|
|
631
|
+ await screenLinkPageAddApi(postAddOrEditData, unref(isUpdate));
|
|
|
632
|
+ createMessage.success(`${unref(isUpdate) ? '编辑' : '新增'}成功`);
|
|
|
633
|
+ closeDrawer();
|
|
|
634
|
+ handleClose();
|
|
|
635
|
+ emit('success');
|
|
|
636
|
+ } finally {
|
|
|
637
|
+ setDrawerProps({ confirmLoading: false });
|
|
|
638
|
+ }
|
|
|
639
|
+ };
|
|
|
640
|
+ // 删除
|
|
|
641
|
+ const deleteTriggerOrCondition = ({ index, title }) => {
|
|
|
642
|
+ if (title === '触发器') {
|
|
|
643
|
+ unref(triggerData).splice(index, 1);
|
|
|
644
|
+ } else if (title === '执行条件') {
|
|
|
645
|
+ unref(conditionData).splice(index, 1);
|
|
|
646
|
+ }
|
|
|
647
|
+ };
|
|
|
648
|
+ const deleteAction = (actionIndex) => {
|
|
|
649
|
+ unref(actionData).splice(actionIndex, 1);
|
|
|
650
|
+ unref(arr).splice(actionIndex, 1);
|
|
|
651
|
+ };
|
|
|
652
|
+ const arr = ref([]);
|
|
|
653
|
+ const getActionFormArr = () => {
|
|
|
654
|
+ arr.value = unref(skipUnwrap.actionItemRefs).map((item) => item.getFieldsValue());
|
|
|
655
|
+ };
|
|
|
656
|
+ const handleClose = () => {
|
|
|
657
|
+ id.value = undefined;
|
|
|
658
|
+ tenantId.value = undefined;
|
|
|
659
|
+ organizationId.value = undefined;
|
|
|
660
|
+ isView.value = true;
|
|
|
661
|
+ getTriggerFormValue.value = [];
|
|
|
662
|
+ getConditionFormValue.value = [];
|
|
|
663
|
+ getActionFormValue.value = [];
|
|
|
664
|
+ triggerData.value = [];
|
|
|
665
|
+ conditionData.value = [];
|
|
|
666
|
+ actionData.value = [];
|
|
|
667
|
+ unref(skipUnwrap.triggerItemRefs).map((item) => {
|
|
|
668
|
+ item.resetFieldsValueFunc();
|
|
|
669
|
+ });
|
|
|
670
|
+ unref(skipUnwrap.conditionItemRefs).map((item) => {
|
|
|
671
|
+ item.resetFieldsValueFunc();
|
|
|
672
|
+ });
|
|
|
673
|
+ unref(skipUnwrap.actionItemRefs).map((item) => {
|
|
|
674
|
+ item.resetFieldsValueFunc();
|
|
|
675
|
+ });
|
|
|
676
|
+ window.localStorage.removeItem('isViewDisabledBtn');
|
|
|
677
|
+ // window.localStorage.setItem('isViewDisabledBtn', 'no')
|
|
|
678
|
+ };
|
635
|
</script>
|
679
|
</script>
|
636
|
|
680
|
|
637
|
<style lang="less" scoped>
|
681
|
<style lang="less" scoped>
|
638
|
-//TODO-fengtao
|
|
|
639
|
-///移除选择框默认样式(24px)否则超出默认宽度会造成页面样式错乱
|
|
|
640
|
-:deep(.ant-select-selector) {
|
|
|
641
|
- padding-right: 0px !important;
|
|
|
642
|
-}
|
682
|
+ //TODO-fengtao
|
|
|
683
|
+ ///移除选择框默认样式(24px)否则超出默认宽度会造成页面样式错乱
|
|
|
684
|
+ :deep(.ant-select-selector) {
|
|
|
685
|
+ padding-right: 0px !important;
|
|
|
686
|
+ }
|
643
|
|
687
|
|
644
|
-:deep(.ant-select-selection-overflow) {
|
|
|
645
|
- max-width: 10vw !important;
|
|
|
646
|
-}
|
688
|
+ :deep(.ant-select-selection-overflow) {
|
|
|
689
|
+ max-width: 10vw !important;
|
|
|
690
|
+ }
|
647
|
|
691
|
|
648
|
-//TODO-fengtao
|
692
|
+ //TODO-fengtao
|
649
|
</style> |
693
|
</style> |