|
@@ -4,31 +4,29 @@ |
|
@@ -4,31 +4,29 @@ |
4
|
v-bind="$attrs"
|
4
|
v-bind="$attrs"
|
5
|
@register="registerDrawer"
|
5
|
@register="registerDrawer"
|
6
|
showFooter
|
6
|
showFooter
|
7
|
- :title="getTitle"
|
|
|
8
|
- width="1000px"
|
|
|
9
|
- @ok="handleSubmit"
|
7
|
+ width="50vw"
|
|
|
8
|
+ @ok="handleSubmit(drawerStatus)"
|
10
|
@close="handleClose"
|
9
|
@close="handleClose"
|
11
|
>
|
10
|
>
|
12
|
<div>
|
11
|
<div>
|
|
|
12
|
+ <!-- 基础表单 -->
|
13
|
<BasicForm @register="registerForm" />
|
13
|
<BasicForm @register="registerForm" />
|
|
|
14
|
+ <!-- 基础表单 -->
|
14
|
<!-- 触发器 -->
|
15
|
<!-- 触发器 -->
|
15
|
<div style="border-radius: 4px">
|
16
|
<div style="border-radius: 4px">
|
16
|
<template
|
17
|
<template
|
17
|
- v-for="(item, index) in isUpdate == false ? addTriggerPushData : editTriggerPushData"
|
18
|
+ v-for="(item, index) in !drawerStatus ? triggerData : editTriggerData"
|
18
|
:key="index"
|
19
|
:key="index"
|
19
|
>
|
20
|
>
|
20
|
<span style="display: none">{{ item + index }}</span>
|
21
|
<span style="display: none">{{ item + index }}</span>
|
21
|
- <span style="position: relative; top: 3.2vh; left: 0.5vw">触发器 {{ index + 1 }}</span>
|
|
|
22
|
- <div style="display: block">
|
|
|
23
|
- <AddTriggerForm
|
|
|
24
|
- ref="refTriggerChild"
|
|
|
25
|
- :editTriggerFather="isUpdate == false ? 1 : item"
|
|
|
26
|
- :newFilterMapFather="isUpdate == false ? 1 : newFilterMap"
|
|
|
27
|
- :deviceInfo="getDeviceInfo"
|
|
|
28
|
- />
|
|
|
29
|
- </div>
|
|
|
30
|
- <div style="height: 3vh"></div>
|
22
|
+ <span style="position: relative; top: 3.2vh; left: 0.6vw">触发器 {{ index + 1 }}</span>
|
|
|
23
|
+ <useTriggerCpn
|
|
|
24
|
+ ref="triggerBindRef"
|
|
|
25
|
+ :bindTriggerFather="!drawerStatus ? 1 : item"
|
|
|
26
|
+ :bindTriggerEntryIdFather="!drawerStatus ? 1 : getTriggerFatherEntryIdData"
|
|
|
27
|
+ />
|
31
|
</template>
|
28
|
</template>
|
|
|
29
|
+ <!-- 按钮 -->
|
32
|
<div
|
30
|
<div
|
33
|
style="
|
31
|
style="
|
34
|
display: flex;
|
32
|
display: flex;
|
|
@@ -39,47 +37,47 @@ |
|
@@ -39,47 +37,47 @@ |
39
|
"
|
37
|
"
|
40
|
>
|
38
|
>
|
41
|
<div style="display: flex; width: 4vw; height: 4vh">
|
39
|
<div style="display: flex; width: 4vw; height: 4vh">
|
42
|
- <Button type="primary" style="border-radius: 2px" class="mt-5" @click="addTrigger"
|
|
|
43
|
- >新增触发器</Button
|
40
|
+ <Button
|
|
|
41
|
+ type="primary"
|
|
|
42
|
+ style="border-radius: 2px"
|
|
|
43
|
+ class="mt-5"
|
|
|
44
|
+ @click="triggerClickAdd(drawerStatus)"
|
|
|
45
|
+ >触发器</Button
|
44
|
>
|
46
|
>
|
45
|
</div>
|
47
|
</div>
|
46
|
<div style="display: flex; width: 4vw; height: 4vh">
|
48
|
<div style="display: flex; width: 4vw; height: 4vh">
|
47
|
<Button
|
49
|
<Button
|
48
|
- v-if="addTriggerPushData.length != 0 || editTriggerPushData.length != 0"
|
50
|
+ v-if="triggerData.length !== 0 || editTriggerData.length !== 0"
|
49
|
type="default"
|
51
|
type="default"
|
50
|
style="border-radius: 2px; background-color: rgba(237, 111, 111, 1)"
|
52
|
style="border-radius: 2px; background-color: rgba(237, 111, 111, 1)"
|
51
|
class="mt-5"
|
53
|
class="mt-5"
|
52
|
- @click="removeTrigger"
|
54
|
+ @click="triggerClickRemove(drawerStatus)"
|
53
|
>
|
55
|
>
|
54
|
<span style="color: white">删除</span></Button
|
56
|
<span style="color: white">删除</span></Button
|
55
|
>
|
57
|
>
|
56
|
</div>
|
58
|
</div>
|
57
|
</div>
|
59
|
</div>
|
|
|
60
|
+ <!-- 按钮 -->
|
58
|
</div>
|
61
|
</div>
|
|
|
62
|
+ <!-- 触发器 -->
|
59
|
<div style="height: 5vh"></div>
|
63
|
<div style="height: 5vh"></div>
|
60
|
<!-- 执行条件 -->
|
64
|
<!-- 执行条件 -->
|
61
|
- <div style="border-radius: 4px" class="condition-style">
|
65
|
+ <div style="border-radius: 4px">
|
62
|
<template
|
66
|
<template
|
63
|
- v-for="(item, index) in isUpdate == false
|
|
|
64
|
- ? addConditionPushData
|
|
|
65
|
- : editConditionPushData"
|
67
|
+ v-for="(item, index) in !drawerStatus ? conditionData : editConditionData"
|
66
|
:key="index"
|
68
|
:key="index"
|
67
|
>
|
69
|
>
|
68
|
<span style="display: none">{{ item + index }}</span>
|
70
|
<span style="display: none">{{ item + index }}</span>
|
69
|
- <span style="position: relative; top: 3.2vh; left: 0.5vw"
|
71
|
+ <span style="position: relative; top: 3.2vh; left: 0.6vw"
|
70
|
>执行条件 {{ index + 1 }}</span
|
72
|
>执行条件 {{ index + 1 }}</span
|
71
|
>
|
73
|
>
|
72
|
-
|
|
|
73
|
- <div>
|
|
|
74
|
- <AddConditiForm
|
|
|
75
|
- :editConditionFather="isUpdate == false ? 1 : item"
|
|
|
76
|
- :newConditionMapFather="isUpdate == false ? 1 : newConditionFilterMap"
|
|
|
77
|
- :deviceInfo1="getDeviceInfo1"
|
|
|
78
|
- ref="refConditionChild"
|
|
|
79
|
- />
|
|
|
80
|
- </div>
|
|
|
81
|
- <div style="height: 3vh"></div>
|
74
|
+ <useConditionCpn
|
|
|
75
|
+ ref="conditionBindRef"
|
|
|
76
|
+ :bindConditionFather="!drawerStatus ? 1 : item"
|
|
|
77
|
+ :bindConditionEntryIdFather="!drawerStatus ? 1 : getConditionFatherEntryIdData"
|
|
|
78
|
+ />
|
82
|
</template>
|
79
|
</template>
|
|
|
80
|
+ <!-- 按钮 -->
|
83
|
<div
|
81
|
<div
|
84
|
style="
|
82
|
style="
|
85
|
display: flex;
|
83
|
display: flex;
|
|
@@ -90,45 +88,45 @@ |
|
@@ -90,45 +88,45 @@ |
90
|
"
|
88
|
"
|
91
|
>
|
89
|
>
|
92
|
<div style="display: flex; width: 4vw; height: 4vh">
|
90
|
<div style="display: flex; width: 4vw; height: 4vh">
|
93
|
- <Button type="primary" style="border-radius: 2px" class="mt-5" @click="addCondition"
|
|
|
94
|
- >新增执行条件</Button
|
91
|
+ <Button
|
|
|
92
|
+ type="primary"
|
|
|
93
|
+ style="border-radius: 2px"
|
|
|
94
|
+ class="mt-5"
|
|
|
95
|
+ @click="conditionClickAdd(drawerStatus)"
|
|
|
96
|
+ >执行条件</Button
|
95
|
>
|
97
|
>
|
96
|
</div>
|
98
|
</div>
|
97
|
<div style="display: flex; width: 4vw; height: 4vh">
|
99
|
<div style="display: flex; width: 4vw; height: 4vh">
|
98
|
<Button
|
100
|
<Button
|
99
|
- v-if="addConditionPushData.length != 0 || editConditionPushData.length != 0"
|
|
|
100
|
- style="border-radius: 2px; background-color: rgba(237, 111, 111, 1)"
|
101
|
+ v-if="conditionData.length !== 0 || editConditionData.length !== 0"
|
101
|
type="default"
|
102
|
type="default"
|
|
|
103
|
+ style="border-radius: 2px; background-color: rgba(237, 111, 111, 1)"
|
102
|
class="mt-5"
|
104
|
class="mt-5"
|
103
|
- @click="removeCondition"
|
105
|
+ @click="conditionClickRemove(drawerStatus)"
|
104
|
>
|
106
|
>
|
105
|
<span style="color: white">删除</span></Button
|
107
|
<span style="color: white">删除</span></Button
|
106
|
>
|
108
|
>
|
107
|
</div>
|
109
|
</div>
|
108
|
</div>
|
110
|
</div>
|
|
|
111
|
+ <!-- 按钮 -->
|
109
|
</div>
|
112
|
</div>
|
110
|
- <!-- 执行动作 -->
|
113
|
+ <!-- 执行条件 -->
|
111
|
<div style="height: 5vh"></div>
|
114
|
<div style="height: 5vh"></div>
|
|
|
115
|
+ <!-- 执行动作 -->
|
112
|
<div style="border-radius: 4px">
|
116
|
<div style="border-radius: 4px">
|
113
|
<template
|
117
|
<template
|
114
|
- v-for="(item, index) in isUpdate == false ? addActionPushData : editActionPushData"
|
118
|
+ v-for="(item, index) in !drawerStatus ? actionData : editActionData"
|
115
|
:key="index"
|
119
|
:key="index"
|
116
|
>
|
120
|
>
|
117
|
<span style="display: none">{{ item + index }}</span>
|
121
|
<span style="display: none">{{ item + index }}</span>
|
118
|
- <span style="position: relative; top: 4.2vh; left: 0.65vw"
|
|
|
119
|
- >执行动作 {{ index + 1 }}</span
|
|
|
120
|
- >
|
|
|
121
|
-
|
|
|
122
|
- <div>
|
|
|
123
|
- <AddActionForm
|
|
|
124
|
- :editActionFather="isUpdate == false ? 1 : item"
|
|
|
125
|
- :newActionMapFather="isUpdate == false ? 1 : newActionFilterMap"
|
|
|
126
|
- :deviceInfo2="getDeviceInfo2"
|
|
|
127
|
- ref="refActionChild"
|
|
|
128
|
- />
|
|
|
129
|
- </div>
|
|
|
130
|
- <div style="height: 3vh"></div>
|
122
|
+ <span style="position: relative; top: 3.6vh; left: 1vw">执行动作 {{ index + 1 }}</span>
|
|
|
123
|
+ <useActionCpn
|
|
|
124
|
+ ref="actionBindRef"
|
|
|
125
|
+ :bindActionFather="!drawerStatus ? 1 : item"
|
|
|
126
|
+ :bindActionEntryIdFather="!drawerStatus ? 1 : getActionFatherEntryIdData"
|
|
|
127
|
+ />
|
131
|
</template>
|
128
|
</template>
|
|
|
129
|
+ <!-- 按钮 -->
|
132
|
<div
|
130
|
<div
|
133
|
style="
|
131
|
style="
|
134
|
display: flex;
|
132
|
display: flex;
|
|
@@ -139,737 +137,366 @@ |
|
@@ -139,737 +137,366 @@ |
139
|
"
|
137
|
"
|
140
|
>
|
138
|
>
|
141
|
<div style="display: flex; width: 4vw; height: 4vh">
|
139
|
<div style="display: flex; width: 4vw; height: 4vh">
|
142
|
- <Button type="primary" style="border-radius: 2px" class="mt-5" @click="addAction"
|
|
|
143
|
- >新增执行动作</Button
|
140
|
+ <Button
|
|
|
141
|
+ type="primary"
|
|
|
142
|
+ style="border-radius: 2px"
|
|
|
143
|
+ class="mt-5"
|
|
|
144
|
+ @click="actionClickAdd(drawerStatus)"
|
|
|
145
|
+ >执行动作</Button
|
144
|
>
|
146
|
>
|
145
|
</div>
|
147
|
</div>
|
146
|
<div style="display: flex; width: 4vw; height: 4vh">
|
148
|
<div style="display: flex; width: 4vw; height: 4vh">
|
147
|
<Button
|
149
|
<Button
|
148
|
- v-if="addActionPushData.length !== 0 || editActionPushData.length !== 0"
|
|
|
149
|
- style="border-radius: 2px; background-color: rgba(237, 111, 111, 1)"
|
150
|
+ v-if="actionData.length !== 0 || editActionData.length !== 0"
|
150
|
type="default"
|
151
|
type="default"
|
|
|
152
|
+ style="border-radius: 2px; background-color: rgba(237, 111, 111, 1)"
|
151
|
class="mt-5"
|
153
|
class="mt-5"
|
152
|
- @click="removeAction"
|
154
|
+ @click="actionClickRemove(drawerStatus)"
|
153
|
>
|
155
|
>
|
154
|
<span style="color: white">删除</span></Button
|
156
|
<span style="color: white">删除</span></Button
|
155
|
>
|
157
|
>
|
156
|
</div>
|
158
|
</div>
|
157
|
</div>
|
159
|
</div>
|
158
|
- <div style="height: 5vh"></div>
|
160
|
+ <!-- 按钮 -->
|
159
|
</div>
|
161
|
</div>
|
|
|
162
|
+ <!-- 执行动作 -->
|
160
|
</div>
|
163
|
</div>
|
161
|
</BasicDrawer>
|
164
|
</BasicDrawer>
|
162
|
</div>
|
165
|
</div>
|
163
|
</template>
|
166
|
</template>
|
164
|
<script lang="ts">
|
167
|
<script lang="ts">
|
165
|
- import { defineComponent, ref, computed, unref, reactive, getCurrentInstance, watch } from 'vue';
|
|
|
166
|
- import { BasicForm, useForm } from '/@/components/Form';
|
|
|
167
|
- import { formSchema, getData } from './config';
|
168
|
+ import { defineComponent, reactive, ref, getCurrentInstance, watch } from 'vue';
|
168
|
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
|
169
|
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
|
|
|
170
|
+ import { formSchema, changeOriginId } from './config';
|
|
|
171
|
+ import { BasicForm, useForm } from '/@/components/Form';
|
|
|
172
|
+ import useTriggerCpn from './cpns/trigger.vue';
|
|
|
173
|
+ import useConditionCpn from './cpns/condition.vue';
|
|
|
174
|
+ import useActionCpn from './cpns/action.vue';
|
|
|
175
|
+ import { Button } from '/@/components/Button';
|
|
|
176
|
+ import { formatTriggerData, formatConditionData } from './cpns/format-data/index';
|
|
|
177
|
+ import { useMessage } from '/@/hooks/web/useMessage';
|
169
|
import {
|
178
|
import {
|
170
|
screenLinkPageAddApi,
|
179
|
screenLinkPageAddApi,
|
171
|
- screenLinkPageUpdateApi,
|
|
|
172
|
screenLinkPageByDeptIdGetDevice,
|
180
|
screenLinkPageByDeptIdGetDevice,
|
|
|
181
|
+ screenLinkPageUpdateApi,
|
173
|
} from '/@/api/ruleengine/ruleengineApi';
|
182
|
} from '/@/api/ruleengine/ruleengineApi';
|
174
|
- import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
175
|
- import AddTriggerForm from './addForm/trigger.vue';
|
|
|
176
|
- import AddConditiForm from './addForm/condition.vue';
|
|
|
177
|
- import AddActionForm from './addForm/doaction.vue';
|
|
|
178
|
- import { IAddTrigger } from './index';
|
|
|
179
|
- import { Button } from '/@/components/Button';
|
|
|
180
|
|
183
|
|
181
|
export default defineComponent({
|
184
|
export default defineComponent({
|
182
|
name: 'ConfigDrawer',
|
185
|
name: 'ConfigDrawer',
|
183
|
components: {
|
186
|
components: {
|
184
|
BasicDrawer,
|
187
|
BasicDrawer,
|
185
|
BasicForm,
|
188
|
BasicForm,
|
186
|
- AddTriggerForm,
|
|
|
187
|
- AddConditiForm,
|
|
|
188
|
- AddActionForm,
|
189
|
+ useTriggerCpn,
|
|
|
190
|
+ useConditionCpn,
|
|
|
191
|
+ useActionCpn,
|
189
|
Button,
|
192
|
Button,
|
190
|
},
|
193
|
},
|
191
|
- emits: ['success', 'register', 'registerForm'],
|
194
|
+ emits: ['register', 'success'],
|
192
|
setup(_, { emit }) {
|
195
|
setup(_, { emit }) {
|
193
|
const { proxy } = getCurrentInstance() as any;
|
196
|
const { proxy } = getCurrentInstance() as any;
|
194
|
- const lastEditRefTriggerChildDataArray = ref<[]>([]);
|
|
|
195
|
- const lastRefTriggerChildDataArray = ref<[]>([]);
|
|
|
196
|
- const lastRefConditionChildDataArray = ref<[]>([]);
|
|
|
197
|
- const lastRefActionChildDataArray = ref<[]>([]);
|
|
|
198
|
- let refTriggerChildData: any = reactive({});
|
|
|
199
|
- let refConditionChildData: any = reactive({});
|
|
|
200
|
- let refActionChildData: any = reactive({});
|
|
|
201
|
- const addTriggerData = reactive<IAddTrigger>({
|
|
|
202
|
- triggerType: '',
|
|
|
203
|
- entityId: '',
|
|
|
204
|
- touchWay: '',
|
|
|
205
|
- attributeChoose: '',
|
|
|
206
|
- compare: '',
|
|
|
207
|
- value: '',
|
|
|
208
|
- });
|
|
|
209
|
- const addTriggerPushData = ref<[]>([]);
|
|
|
210
|
- const addConditionPushData = ref<[]>([]);
|
|
|
211
|
- const addActionPushData = ref<[]>([]);
|
|
|
212
|
- //edit data
|
|
|
213
|
- const editTriggerPushData = ref<[]>([]);
|
|
|
214
|
- const editConditionPushData = ref<[]>([]);
|
|
|
215
|
- const editActionPushData = ref<[]>([]);
|
|
|
216
|
- const getChildData = ref(null);
|
|
|
217
|
- const refTriggerChild = ref(null);
|
|
|
218
|
- const refConditionChild = ref(null);
|
|
|
219
|
- const refActionChild = ref(null);
|
|
|
220
|
- const getConditionChildData = ref(null);
|
|
|
221
|
const { createMessage } = useMessage();
|
197
|
const { createMessage } = useMessage();
|
222
|
- const isUpdate = ref(true);
|
|
|
223
|
- let getAllFormData: any = reactive({});
|
|
|
224
|
- let getValuesFormData: any = reactive({});
|
198
|
+ const triggerData = reactive([]);
|
|
|
199
|
+ const conditionData = reactive([]);
|
|
|
200
|
+ const actionData = reactive([1]);
|
|
|
201
|
+ const triggerBindRef = ref(null);
|
|
|
202
|
+ const conditionBindRef = ref(null);
|
|
|
203
|
+ const actionBindRef = ref(null);
|
|
|
204
|
+ let getTriggerFormValue: any = reactive({});
|
|
|
205
|
+ let getConditionFormValue: any = reactive({});
|
|
|
206
|
+ let getActionFormValue: any = reactive({});
|
|
|
207
|
+ const drawerStatus = ref(true);
|
|
|
208
|
+ let postAddOrEditData: any = reactive({});
|
|
|
209
|
+ let concatTrigger: any = reactive([]);
|
|
|
210
|
+ let concatCondition: any = reactive([]);
|
|
|
211
|
+ let concatAction: any = reactive([]);
|
|
|
212
|
+ let optionsItemDeviceId: any = ref([]);
|
|
|
213
|
+ let editTriggerData: any = ref([]);
|
|
|
214
|
+ let editConditionData: any = ref([]);
|
|
|
215
|
+ let editActionData: any = ref([]);
|
|
|
216
|
+ let getTriggerFatherEntryIdData: any = reactive([]);
|
|
|
217
|
+ let getConditionFatherEntryIdData: any = reactive([]);
|
|
|
218
|
+ let getActionFatherEntryIdData: any = reactive([]);
|
|
|
219
|
+ const editEntryIdData: any = ref([]);
|
225
|
const getId = ref('');
|
220
|
const getId = ref('');
|
226
|
const getTenantId = ref('');
|
221
|
const getTenantId = ref('');
|
227
|
- const getDeviceInfo = ref(null);
|
|
|
228
|
- const getDeviceInfo1 = ref(null);
|
|
|
229
|
- const getDeviceInfo2 = ref(null);
|
|
|
230
|
- const newFilterMap = ref<[]>([]);
|
|
|
231
|
- const newConditionFilterMap = ref<[]>([]);
|
|
|
232
|
- const newActionFilterMap = ref<[]>([]);
|
|
|
233
|
- let filterNewConditionArr = [];
|
|
|
234
|
- const pushEditArray = ref<any>([{}]);
|
|
|
235
|
- const pushEditConditionArray = ref<any>([{}]);
|
|
|
236
|
- const pushEditActionArray = ref<any>([{}]);
|
|
|
237
|
- let filterArrayTrigger = [];
|
|
|
238
|
- const filterArrayCondition = ref<[]>([]);
|
|
|
239
|
- const filterArrayAction = ref<[]>([]);
|
|
|
240
|
- let filterNewTriggerArr = [];
|
|
|
241
|
- let triggersObj = {
|
|
|
242
|
- triggers: [],
|
|
|
243
|
- };
|
|
|
244
|
- let conditionsObj = {
|
|
|
245
|
- doConditions: [],
|
|
|
246
|
- };
|
|
|
247
|
- let actionsObj = {
|
|
|
248
|
- doActions: [],
|
|
|
249
|
- };
|
|
|
250
|
- let optionsItemArray = ref<[]>([]);
|
|
|
251
|
- const isNoChange = ref(false);
|
|
|
252
|
- let kongTriggerObj = {};
|
|
|
253
|
- let kongConditionObj = {};
|
|
|
254
|
- let kongActionObj = {};
|
|
|
255
|
- let optionsEditArray = ref<[]>([]);
|
|
|
256
|
- const oldOrigzaition = ref('');
|
|
|
257
|
-
|
|
|
258
|
- const [registerForm, { resetFields, setFieldsValue, validateFields }] = useForm({
|
222
|
+ const [registerForm, { resetFields, validate, setFieldsValue }] = useForm({
|
259
|
labelWidth: 120,
|
223
|
labelWidth: 120,
|
260
|
schemas: formSchema,
|
224
|
schemas: formSchema,
|
261
|
showActionButtonGroup: false,
|
225
|
showActionButtonGroup: false,
|
262
|
});
|
226
|
});
|
263
|
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
|
227
|
const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
|
264
|
- await resetFields();
|
|
|
265
|
setDrawerProps({ confirmLoading: false });
|
228
|
setDrawerProps({ confirmLoading: false });
|
266
|
- isUpdate.value = !!data?.isUpdate;
|
|
|
267
|
- if (!unref(isUpdate)) {
|
229
|
+ drawerStatus.value = data.isUpdate;
|
|
|
230
|
+ if (!drawerStatus.value) {
|
|
|
231
|
+ triggerData.length = 0;
|
|
|
232
|
+ conditionData.length = 0;
|
|
|
233
|
+ actionData.length = 0;
|
|
|
234
|
+ resetFields();
|
|
|
235
|
+ defaultAddAction();
|
268
|
try {
|
236
|
try {
|
269
|
- refTriggerChildData = {};
|
|
|
270
|
- refConditionChildData = {};
|
|
|
271
|
- refActionChildData = {};
|
|
|
272
|
- getAllFormData = {};
|
|
|
273
|
- triggersObj = {
|
|
|
274
|
- triggers: [],
|
|
|
275
|
- };
|
|
|
276
|
- conditionsObj = {
|
|
|
277
|
- doConditions: [],
|
|
|
278
|
- };
|
|
|
279
|
- actionsObj = {
|
|
|
280
|
- doActions: [],
|
|
|
281
|
- };
|
|
|
282
|
- filterNewTriggerArr.length = 0;
|
|
|
283
|
- filterNewConditionArr.length = 0;
|
|
|
284
|
- lastRefTriggerChildDataArray.value.length = 0;
|
|
|
285
|
- lastRefConditionChildDataArray.value.length = 0;
|
|
|
286
|
- lastRefActionChildDataArray.value.length = 0;
|
|
|
287
|
- editTriggerPushData.value.length = 0;
|
|
|
288
|
- editConditionPushData.value.length = 0;
|
|
|
289
|
- editActionPushData.value.length = 0;
|
|
|
290
|
- addTriggerPushData.value.length = 0;
|
|
|
291
|
- addConditionPushData.value.length = 0;
|
|
|
292
|
- addActionPushData.value.length = 0;
|
|
|
293
|
- handleClose();
|
|
|
294
|
- optionsItemArray.value.length = 0;
|
|
|
295
|
- optionsItemArray.value = [];
|
|
|
296
|
- optionsEditArray.value = [];
|
|
|
297
|
- optionsEditArray.value.length = 0;
|
|
|
298
|
- try {
|
|
|
299
|
- proxy.$refs.refTriggerChild?.resetFieldsValueFunc();
|
|
|
300
|
- proxy.$refs.refTriggerChild?.clearSelectDevice();
|
|
|
301
|
- proxy.$refs.refTriggerChild?.clearSelectAttribute();
|
|
|
302
|
- proxy.$refs.refConditionChild?.resetFieldsValueFunc();
|
|
|
303
|
- proxy.$refs.refConditionChild?.clearSelectDevice();
|
|
|
304
|
- proxy.$refs.refActionChild?.resetFieldsValueFunc();
|
|
|
305
|
- proxy.$refs.refActionChild?.clearSelectDevice();
|
|
|
306
|
- clearActionsAllDevice();
|
|
|
307
|
- resetActionsAllArrayFunc();
|
|
|
308
|
- } catch {}
|
|
|
309
|
- } catch (e) {
|
|
|
310
|
- return e;
|
|
|
311
|
- }
|
237
|
+ proxy.$refs.triggerBindRef?.resetFieldsValueFunc();
|
|
|
238
|
+ proxy.$refs.triggerBindRef?.clearSelectDevice();
|
|
|
239
|
+ proxy.$refs.triggerBindRef?.clearSelectAttribute();
|
|
|
240
|
+ proxy.$refs.conditionBindRef?.resetFieldsValueFunc();
|
|
|
241
|
+ proxy.$refs.conditionBindRef?.clearSelectDevice();
|
|
|
242
|
+ proxy.$refs.conditionBindRef?.clearSelectAttribute();
|
|
|
243
|
+ proxy.$refs.actionBindRef?.clearSelectDevice();
|
|
|
244
|
+ proxy.$refs.actionBindRef.resetFieldsValueFunc();
|
|
|
245
|
+ } catch {}
|
312
|
} else {
|
246
|
} else {
|
313
|
- try {
|
|
|
314
|
- optionsEditArray.value = [];
|
|
|
315
|
- optionsEditArray.value.length = 0;
|
|
|
316
|
- kongTriggerObj = {};
|
|
|
317
|
- kongConditionObj = {};
|
|
|
318
|
- kongActionObj = {};
|
|
|
319
|
- pushEditArray.value = [];
|
|
|
320
|
- pushEditArray.value.length = 0;
|
|
|
321
|
- pushEditConditionArray.value.length = 0;
|
|
|
322
|
- pushEditConditionArray.value = [];
|
|
|
323
|
- pushEditActionArray.value = [];
|
|
|
324
|
- pushEditActionArray.value.length = 0;
|
|
|
325
|
- newFilterMap.value = [];
|
|
|
326
|
- newConditionFilterMap.value = [];
|
|
|
327
|
- newActionFilterMap.value = [];
|
|
|
328
|
- clearAllArrayFunc();
|
|
|
329
|
- editTriggerPushData.value = [];
|
|
|
330
|
- editTriggerPushData.value.length = 0;
|
|
|
331
|
- editConditionPushData.value = [];
|
|
|
332
|
- editConditionPushData.value.length = 0;
|
|
|
333
|
- editActionPushData.value = [];
|
|
|
334
|
- editActionPushData.value.length = 0;
|
|
|
335
|
- lastEditRefTriggerChildDataArray.value = [];
|
|
|
336
|
- getId.value = data.record.id;
|
|
|
337
|
- getTenantId.value = data.record.tenantId;
|
|
|
338
|
- await setFieldsValue({
|
|
|
339
|
- ...data.record,
|
|
|
340
|
- });
|
|
|
341
|
- editTriggerPushData.value = data.record.triggers;
|
|
|
342
|
- isNoChange.value = true;
|
|
|
343
|
- editConditionPushData.value = data.record.doConditions;
|
|
|
344
|
- editActionPushData.value = data.record.doActions;
|
|
|
345
|
- const options = await screenLinkPageByDeptIdGetDevice({
|
|
|
346
|
- organizationId: data.record.organizationId,
|
|
|
347
|
- });
|
|
|
348
|
- data.record.triggers.forEach((f1) => {
|
|
|
349
|
- options.items?.forEach((f2) => {
|
|
|
350
|
- if (f2.tbDeviceId == f1.entityId) {
|
|
|
351
|
- newFilterMap.value.push({
|
|
|
352
|
- value: f2.tbDeviceId,
|
|
|
353
|
- label: f2.name,
|
|
|
354
|
- } as never);
|
|
|
355
|
- }
|
|
|
356
|
- });
|
|
|
357
|
- });
|
|
|
358
|
- data.record.doConditions.forEach((f1) => {
|
|
|
359
|
- options.items?.forEach((f2) => {
|
|
|
360
|
- if (f2.tbDeviceId == f1.entityId) {
|
|
|
361
|
- newConditionFilterMap.value.push({
|
|
|
362
|
- value: f2.tbDeviceId,
|
|
|
363
|
- label: f2.name,
|
|
|
364
|
- } as never);
|
|
|
365
|
- }
|
|
|
366
|
- });
|
247
|
+ emit('success');
|
|
|
248
|
+ editTriggerData.value.length = 0;
|
|
|
249
|
+ editConditionData.value.length = 0;
|
|
|
250
|
+ editActionData.value.length = 0;
|
|
|
251
|
+ editEntryIdData.value.length = 0;
|
|
|
252
|
+ await setFieldsValue({
|
|
|
253
|
+ ...data.record,
|
|
|
254
|
+ });
|
|
|
255
|
+ getId.value = data.record.id;
|
|
|
256
|
+ getTenantId.value = data.record.tenantId;
|
|
|
257
|
+ editTriggerData.value = data.record.triggers;
|
|
|
258
|
+ editConditionData.value = data.record.doConditions;
|
|
|
259
|
+ editActionData.value = data.record.doActions;
|
|
|
260
|
+ const options = await screenLinkPageByDeptIdGetDevice({
|
|
|
261
|
+ organizationId: data.record.organizationId,
|
|
|
262
|
+ });
|
|
|
263
|
+ data.record.triggers.forEach((f1) => {
|
|
|
264
|
+ options.items?.forEach((f2) => {
|
|
|
265
|
+ if (f2.tbDeviceId == f1.entityId) {
|
|
|
266
|
+ getTriggerFatherEntryIdData.push({
|
|
|
267
|
+ value: f2.tbDeviceId,
|
|
|
268
|
+ label: f2.name,
|
|
|
269
|
+ } as never);
|
|
|
270
|
+ }
|
367
|
});
|
271
|
});
|
368
|
- data.record.doActions.forEach((f1) => {
|
|
|
369
|
- options.items?.forEach((f2) => {
|
|
|
370
|
- if (f2.tbDeviceId == f1.deviceId) {
|
|
|
371
|
- newActionFilterMap.value.push({
|
|
|
372
|
- value: f2.tbDeviceId,
|
|
|
373
|
- label: f2.name,
|
|
|
374
|
- } as never);
|
|
|
375
|
- }
|
|
|
376
|
- });
|
272
|
+ });
|
|
|
273
|
+ data.record.doConditions.forEach((f1) => {
|
|
|
274
|
+ options.items?.forEach((f2) => {
|
|
|
275
|
+ if (f2.tbDeviceId == f1.entityId) {
|
|
|
276
|
+ getConditionFatherEntryIdData.push({
|
|
|
277
|
+ value: f2.tbDeviceId,
|
|
|
278
|
+ label: f2.name,
|
|
|
279
|
+ } as never);
|
|
|
280
|
+ }
|
377
|
});
|
281
|
});
|
378
|
- optionsEditArray.value = options.items.map((v) => {
|
|
|
379
|
- return {
|
|
|
380
|
- value: v.tbDeviceId,
|
|
|
381
|
- label: v.name,
|
|
|
382
|
- };
|
282
|
+ });
|
|
|
283
|
+ data.record.doActions.forEach((f1) => {
|
|
|
284
|
+ options.items?.forEach((f2) => {
|
|
|
285
|
+ if (f2.tbDeviceId == f1.deviceId) {
|
|
|
286
|
+ getActionFatherEntryIdData.push({
|
|
|
287
|
+ value: f2.tbDeviceId,
|
|
|
288
|
+ label: f2.name,
|
|
|
289
|
+ } as never);
|
|
|
290
|
+ }
|
383
|
});
|
291
|
});
|
384
|
- setTimeout(() => {
|
|
|
385
|
- proxy.$refs.refTriggerChild?.updateFieldDeviceId(optionsEditArray.value);
|
|
|
386
|
- proxy.$refs.refConditionChild?.updateFieldDeviceId(optionsEditArray.value);
|
|
|
387
|
- proxy.$refs.refActionChild?.updateFieldDeviceId(optionsEditArray.value);
|
|
|
388
|
- }, 20);
|
|
|
389
|
- emit('success');
|
|
|
390
|
- } catch (e) {
|
|
|
391
|
- return e;
|
|
|
392
|
- }
|
292
|
+ });
|
|
|
293
|
+ editEntryIdData.value = options.items.map((v) => {
|
|
|
294
|
+ return {
|
|
|
295
|
+ value: v.tbDeviceId,
|
|
|
296
|
+ label: v.name,
|
|
|
297
|
+ };
|
|
|
298
|
+ });
|
|
|
299
|
+ setTimeout(() => {
|
|
|
300
|
+ proxy.$refs.triggerBindRef?.updateFieldDeviceId(editEntryIdData.value);
|
|
|
301
|
+ proxy.$refs.conditionBindRef?.updateFieldDeviceId(editEntryIdData.value);
|
|
|
302
|
+ proxy.$refs.actionBindRef?.updateFieldDeviceId(editEntryIdData.value);
|
|
|
303
|
+ }, 10);
|
393
|
}
|
304
|
}
|
394
|
});
|
305
|
});
|
395
|
- const getTitle = computed(() => (!unref(isUpdate) ? '新增场景联动' : '编辑场景联动'));
|
|
|
396
|
- const handleClose = () => {
|
|
|
397
|
- editTriggerPushData.value.length = 0;
|
|
|
398
|
- pushEditArray.value.length = 0;
|
|
|
399
|
- pushEditConditionArray.value.length = 0;
|
|
|
400
|
- pushEditActionArray.value.length = 0;
|
|
|
401
|
- lastRefTriggerChildDataArray.value.length = 0;
|
|
|
402
|
- lastRefTriggerChildDataArray.value = [];
|
|
|
403
|
- lastRefConditionChildDataArray.value.length = 0;
|
|
|
404
|
- lastRefActionChildDataArray.value.length = 0;
|
|
|
405
|
- lastRefActionChildDataArray.value = [];
|
|
|
406
|
- filterArrayTrigger.length = 0;
|
|
|
407
|
- filterArrayCondition.value.length = 0;
|
|
|
408
|
- filterArrayAction.value.length = 0;
|
|
|
409
|
- proxy.$refs.refTriggerChild?.resetFieldsValueFunc();
|
|
|
410
|
- proxy.$refs.refTriggerChild?.clearSelectDevice();
|
|
|
411
|
- proxy.$refs.refTriggerChild?.clearSelectAttribute();
|
|
|
412
|
- proxy.$refs.refConditionChild?.resetFieldsValueFunc();
|
|
|
413
|
- proxy.$refs.refConditionChild?.clearSelectDevice();
|
|
|
414
|
- proxy.$refs.refActionChild?.resetFieldsValueFunc();
|
|
|
415
|
- proxy.$refs.refActionChild?.clearSelectDevice();
|
|
|
416
|
- };
|
|
|
417
|
-
|
|
|
418
|
- const clearAllArrayFunc = () => {
|
|
|
419
|
- unref(addTriggerPushData).length = 0;
|
|
|
420
|
- unref(addConditionPushData).length = 0;
|
|
|
421
|
- unref(addActionPushData).length = 0;
|
|
|
422
|
- lastRefTriggerChildDataArray.value.length = 0;
|
|
|
423
|
- lastRefConditionChildDataArray.value.length = 0;
|
|
|
424
|
- lastRefActionChildDataArray.value.length = 0;
|
|
|
425
|
- lastEditRefTriggerChildDataArray.value.length = 0;
|
|
|
426
|
- };
|
|
|
427
|
- const resetActionsAllArrayFunc = () => {
|
|
|
428
|
- try {
|
|
|
429
|
- proxy.$refs.refActionChild.resetFieldsValueFunc();
|
|
|
430
|
- } catch (e) {
|
|
|
431
|
- return e;
|
|
|
432
|
- }
|
|
|
433
|
- };
|
|
|
434
|
- const clearActionsAllDevice = () => {
|
|
|
435
|
- try {
|
|
|
436
|
- proxy.$refs.refActionChild.clearSelectDevice();
|
|
|
437
|
- } catch (e) {
|
|
|
438
|
- return e;
|
|
|
439
|
- }
|
|
|
440
|
- };
|
|
|
441
|
-
|
|
|
442
|
- watch(getData, async (newV: string) => {
|
|
|
443
|
- oldOrigzaition.value = newV;
|
|
|
444
|
- const options = await screenLinkPageByDeptIdGetDevice({ organizationId: newV });
|
|
|
445
|
- optionsItemArray.value = options.items.map((v) => {
|
306
|
+ watch(changeOriginId, async (newV: string) => {
|
|
|
307
|
+ const result = await screenLinkPageByDeptIdGetDevice({ organizationId: newV });
|
|
|
308
|
+ optionsItemDeviceId.value = result.items.map((v) => {
|
446
|
return {
|
309
|
return {
|
447
|
value: v.tbDeviceId,
|
310
|
value: v.tbDeviceId,
|
448
|
label: v.name,
|
311
|
label: v.name,
|
449
|
};
|
312
|
};
|
450
|
});
|
313
|
});
|
451
|
setTimeout(() => {
|
314
|
setTimeout(() => {
|
452
|
- proxy.$refs.refTriggerChild?.updateFieldDeviceId(optionsItemArray.value);
|
|
|
453
|
- proxy.$refs.refConditionChild?.updateFieldDeviceId(optionsItemArray.value);
|
|
|
454
|
- proxy.$refs.refActionChild?.updateFieldDeviceId(optionsItemArray.value);
|
315
|
+ proxy.$refs.triggerBindRef?.updateFieldDeviceId(optionsItemDeviceId.value);
|
|
|
316
|
+ proxy.$refs.conditionBindRef?.updateFieldDeviceId(optionsItemDeviceId.value);
|
|
|
317
|
+ proxy.$refs.actionBindRef?.updateFieldDeviceId(optionsItemDeviceId.value);
|
455
|
}, 10);
|
318
|
}, 10);
|
456
|
});
|
319
|
});
|
457
|
|
320
|
|
458
|
- //获取触发器方法
|
|
|
459
|
- const refTriggerChildDataFunc = () => {
|
|
|
460
|
- try {
|
|
|
461
|
- refTriggerChildData = proxy.$refs.refTriggerChild.getFieldsValueFunc();
|
|
|
462
|
- } catch (e) {
|
|
|
463
|
- return e;
|
|
|
464
|
- }
|
|
|
465
|
- };
|
|
|
466
|
- //获取执行条件方法
|
|
|
467
|
- const refConditionChildDataFunc = () => {
|
321
|
+ /**
|
|
|
322
|
+ * 获取触发器表单值
|
|
|
323
|
+ */
|
|
|
324
|
+ const getTriggerFormValueFunc = () => {
|
468
|
try {
|
325
|
try {
|
469
|
- refConditionChildData = proxy.$refs.refConditionChild.getFieldsValueFunc();
|
|
|
470
|
- } catch (e) {
|
|
|
471
|
- return e;
|
|
|
472
|
- }
|
326
|
+ getTriggerFormValue = proxy.$refs.triggerBindRef.getFieldsValueFunc();
|
|
|
327
|
+ } catch {}
|
473
|
};
|
328
|
};
|
474
|
- //获取执行动作方法
|
|
|
475
|
- const refActionChildDataFunc = () => {
|
|
|
476
|
- try {
|
|
|
477
|
- refActionChildData = proxy.$refs.refActionChild.getFieldsValueFunc();
|
|
|
478
|
- } catch (e) {
|
|
|
479
|
- return e;
|
329
|
+ const triggerClickAdd = (e) => {
|
|
|
330
|
+ if (!e) {
|
|
|
331
|
+ getTriggerFormValueFunc();
|
|
|
332
|
+ triggerData.push(getTriggerFormValue as never);
|
|
|
333
|
+ setTimeout(() => {
|
|
|
334
|
+ proxy.$refs.triggerBindRef?.updateFieldDeviceId(optionsItemDeviceId.value);
|
|
|
335
|
+ }, 10);
|
|
|
336
|
+ } else {
|
|
|
337
|
+ //TODO
|
|
|
338
|
+ editTriggerData.value.push(getTriggerFormValue);
|
480
|
}
|
339
|
}
|
481
|
};
|
340
|
};
|
482
|
-
|
|
|
483
|
- const getDefaultValue = () => {
|
|
|
484
|
- if (!unref(isUpdate)) {
|
|
|
485
|
- refTriggerChildDataFunc();
|
|
|
486
|
- refConditionChildDataFunc();
|
|
|
487
|
- refActionChildDataFunc();
|
|
|
488
|
- let newTriggerArray = addTriggerPushData.value.concat(refTriggerChildData);
|
|
|
489
|
- let newConditionArray = addConditionPushData.value.concat(refConditionChildData);
|
|
|
490
|
- let newActionArray = addActionPushData.value.concat(refActionChildData);
|
|
|
491
|
- (newTriggerArray as any) = newTriggerArray.map((m: any) => {
|
|
|
492
|
- return {
|
|
|
493
|
- triggerType: m?.triggerType,
|
|
|
494
|
- entityId: m?.entityId || m?.entityId1 || m?.entityId2,
|
|
|
495
|
- triggerCondition: {
|
|
|
496
|
- condition: [
|
|
|
497
|
- {
|
|
|
498
|
- key: {
|
|
|
499
|
- key: m.type2 == null ? 'CO2' : m.type2,
|
|
|
500
|
- type: m.type1 == null ? 'TIME_SERIES' : m.type1,
|
|
|
501
|
- },
|
|
|
502
|
- valueType: 'NUMERIC',
|
|
|
503
|
- predicate: {
|
|
|
504
|
- type: 'NUMERIC',
|
|
|
505
|
- value: {
|
|
|
506
|
- defaultValue: Number(m.value),
|
|
|
507
|
- },
|
|
|
508
|
- operation: m.operation == null ? 'EQUAL' : m.operation,
|
|
|
509
|
- },
|
|
|
510
|
- },
|
|
|
511
|
- ],
|
|
|
512
|
- spec: {
|
|
|
513
|
- type: 'SIMPLE',
|
|
|
514
|
- },
|
|
|
515
|
- },
|
|
|
516
|
- };
|
|
|
517
|
- });
|
|
|
518
|
- (newConditionArray as any) = newConditionArray.map((m: any) => {
|
|
|
519
|
- return {
|
|
|
520
|
- triggerType: m?.triggerType,
|
|
|
521
|
- entityId: m?.entityId,
|
|
|
522
|
- triggerCondition: {
|
|
|
523
|
- condition: [
|
|
|
524
|
- {
|
|
|
525
|
- key: {
|
|
|
526
|
- key: m.type == null ? 'CO2' : m.type,
|
|
|
527
|
- type: 'TIME_SERIES',
|
|
|
528
|
- },
|
|
|
529
|
- valueType: 'NUMERIC',
|
|
|
530
|
- // value: {},
|
|
|
531
|
- predicate: {
|
|
|
532
|
- type: 'NUMERIC',
|
|
|
533
|
- value: {
|
|
|
534
|
- defaultValue: Number(m.value) == null ? 0 : Number(m.value),
|
|
|
535
|
- },
|
|
|
536
|
- operation: m.operation,
|
|
|
537
|
- },
|
|
|
538
|
- },
|
|
|
539
|
- ],
|
|
|
540
|
- spec: {
|
|
|
541
|
- type: 'SIMPLE',
|
|
|
542
|
- },
|
|
|
543
|
- },
|
|
|
544
|
- };
|
|
|
545
|
- });
|
|
|
546
|
- newTriggerArray.shift();
|
|
|
547
|
- newConditionArray.shift();
|
|
|
548
|
- newActionArray.shift();
|
|
|
549
|
- delete getAllFormData.id;
|
|
|
550
|
- delete getAllFormData.getTenantId;
|
|
|
551
|
- triggersObj = {
|
|
|
552
|
- triggers: newTriggerArray,
|
|
|
553
|
- };
|
|
|
554
|
- conditionsObj = {
|
|
|
555
|
- doConditions: newConditionArray,
|
|
|
556
|
- };
|
|
|
557
|
- actionsObj = {
|
|
|
558
|
- doActions: newActionArray,
|
|
|
559
|
- };
|
|
|
560
|
- Object.assign(getAllFormData, triggersObj, conditionsObj, actionsObj);
|
341
|
+ const triggerClickRemove = (e) => {
|
|
|
342
|
+ if (!e) {
|
|
|
343
|
+ triggerData.pop();
|
561
|
} else {
|
344
|
} else {
|
562
|
- editTriggerPushData.value.forEach((f) => {
|
|
|
563
|
- kongTriggerObj = f;
|
|
|
564
|
- pushEditArray.value.push(kongTriggerObj);
|
|
|
565
|
- });
|
|
|
566
|
- editConditionPushData.value.forEach((f) => {
|
|
|
567
|
- kongConditionObj = f;
|
|
|
568
|
- pushEditConditionArray.value.push(kongConditionObj);
|
|
|
569
|
- });
|
|
|
570
|
- editActionPushData.value.forEach((f) => {
|
|
|
571
|
- kongActionObj = f;
|
|
|
572
|
- pushEditActionArray.value.push(kongActionObj);
|
|
|
573
|
- });
|
|
|
574
|
- refTriggerChildDataFunc();
|
|
|
575
|
- let newTriggerArray = pushEditArray.value.concat(refTriggerChildData);
|
|
|
576
|
- newTriggerArray = newTriggerArray.filter((f) => Object.keys(f).length !== 0);
|
|
|
577
|
- newTriggerArray.shift();
|
|
|
578
|
- triggersObj = {
|
|
|
579
|
- triggers: isNoChange.value ? editTriggerPushData.value : newTriggerArray,
|
|
|
580
|
- };
|
|
|
581
|
- refConditionChildDataFunc();
|
|
|
582
|
- let newConditionArray = pushEditConditionArray.value.concat(refConditionChildData);
|
|
|
583
|
- newConditionArray = newConditionArray.filter((f) => Object.keys(f).length !== 0);
|
|
|
584
|
- newConditionArray.shift();
|
|
|
585
|
- conditionsObj = {
|
|
|
586
|
- doConditions: newConditionArray,
|
|
|
587
|
- };
|
|
|
588
|
- refActionChildDataFunc();
|
|
|
589
|
- let newActionArray = pushEditActionArray.value.concat(refActionChildData);
|
|
|
590
|
- newActionArray = newActionArray.filter((f) => Object.keys(f).length !== 0);
|
|
|
591
|
- newActionArray.shift();
|
|
|
592
|
- actionsObj = {
|
|
|
593
|
- doActions: newActionArray,
|
|
|
594
|
- };
|
|
|
595
|
- Object.assign(getAllFormData, triggersObj, conditionsObj, actionsObj);
|
345
|
+ editTriggerData.value.pop();
|
596
|
}
|
346
|
}
|
597
|
};
|
347
|
};
|
598
|
|
348
|
|
599
|
- const handleSubmit = async () => {
|
|
|
600
|
- if (!unref(isUpdate)) {
|
|
|
601
|
- getDefaultValue();
|
|
|
602
|
- getValuesFormData = await validateFields();
|
|
|
603
|
- if (!getValuesFormData) return;
|
|
|
604
|
- let isKongNum = 0;
|
|
|
605
|
- getAllFormData.doActions.forEach((f) => {
|
|
|
606
|
- isKongNum = Object.keys(f).length;
|
|
|
607
|
- });
|
|
|
608
|
- if (getAllFormData.doActions.length == 1 && isKongNum == 0)
|
|
|
609
|
- return createMessage.error('请填写执行动作');
|
|
|
610
|
- Object.assign(getAllFormData, getValuesFormData);
|
|
|
611
|
- await screenLinkPageAddApi(getAllFormData);
|
|
|
612
|
- createMessage.success('场景联动新增成功');
|
|
|
613
|
- closeDrawer();
|
|
|
614
|
- emit('success');
|
|
|
615
|
- } else {
|
|
|
616
|
- getDefaultValue();
|
|
|
617
|
- getValuesFormData = await validateFields();
|
|
|
618
|
- Object.assign(getAllFormData, getValuesFormData);
|
|
|
619
|
- getAllFormData.id = getId.value;
|
|
|
620
|
- getAllFormData.tenantId = getTenantId.value;
|
|
|
621
|
- refTriggerChildData = {};
|
|
|
622
|
- refConditionChildData = {};
|
|
|
623
|
- refActionChildData = {};
|
|
|
624
|
- pushEditArray.value.length = 0;
|
|
|
625
|
- pushEditConditionArray.value.length = 0;
|
|
|
626
|
- pushEditActionArray.value.length = 0;
|
|
|
627
|
- await screenLinkPageUpdateApi(getAllFormData);
|
|
|
628
|
- createMessage.success('场景联动编辑成功');
|
|
|
629
|
- closeDrawer();
|
|
|
630
|
- emit('success');
|
|
|
631
|
- }
|
349
|
+ /**
|
|
|
350
|
+ * 获取执行条件表单值
|
|
|
351
|
+ */
|
|
|
352
|
+ const getConditionFormValueFunc = () => {
|
|
|
353
|
+ try {
|
|
|
354
|
+ getConditionFormValue = proxy.$refs.conditionBindRef.getFieldsValueFunc();
|
|
|
355
|
+ } catch {}
|
632
|
};
|
356
|
};
|
633
|
- //新增触发器
|
|
|
634
|
- const addTrigger = () => {
|
|
|
635
|
- if (!unref(isUpdate)) {
|
|
|
636
|
- refTriggerChildDataFunc();
|
|
|
637
|
- unref(addTriggerPushData).push(refTriggerChildData as never);
|
357
|
+ const conditionClickAdd = (e) => {
|
|
|
358
|
+ if (!e) {
|
|
|
359
|
+ getConditionFormValueFunc();
|
|
|
360
|
+ conditionData.push(getConditionFormValue as never);
|
638
|
setTimeout(() => {
|
361
|
setTimeout(() => {
|
639
|
- proxy.$refs.refTriggerChild?.updateFieldDeviceId(optionsItemArray.value);
|
|
|
640
|
- }, 20);
|
362
|
+ proxy.$refs.conditionBindRef?.updateFieldDeviceId(optionsItemDeviceId.value);
|
|
|
363
|
+ }, 10);
|
641
|
} else {
|
364
|
} else {
|
642
|
- isNoChange.value = false;
|
|
|
643
|
- unref(editTriggerPushData).push(refTriggerChildData as never);
|
|
|
644
|
- refTriggerChildDataFunc();
|
|
|
645
|
- pushEditArray.value.push(refTriggerChildData);
|
|
|
646
|
- pushEditArray.value = pushEditArray.value.map((m) => {
|
|
|
647
|
- return {
|
|
|
648
|
- triggerType: m?.triggerType,
|
|
|
649
|
- entityId: m?.entityId || m?.entityId1 || m?.entityId2,
|
|
|
650
|
- triggerCondition: {
|
|
|
651
|
- condition: [
|
|
|
652
|
- {
|
|
|
653
|
- key: {
|
|
|
654
|
- key: m.type2 == null ? 'CO2' : m.type2,
|
|
|
655
|
- type: m.type1 == null ? 'TIME_SERIES' : m.type1,
|
|
|
656
|
- },
|
|
|
657
|
- valueType: 'NUMERIC',
|
|
|
658
|
- predicate: {
|
|
|
659
|
- type: 'NUMERIC',
|
|
|
660
|
- value: {
|
|
|
661
|
- defaultValue: Number(m.value),
|
|
|
662
|
- },
|
|
|
663
|
- operation: m.operation == null ? 'EQUAL' : m.operation,
|
|
|
664
|
- },
|
|
|
665
|
- },
|
|
|
666
|
- ],
|
|
|
667
|
- spec: {
|
|
|
668
|
- type: 'SIMPLE',
|
|
|
669
|
- },
|
|
|
670
|
- },
|
|
|
671
|
- };
|
|
|
672
|
- });
|
|
|
673
|
- try {
|
|
|
674
|
- setTimeout(() => {
|
|
|
675
|
- proxy.$refs.refTriggerChild?.updateFieldDeviceId({
|
|
|
676
|
- status: 'edit',
|
|
|
677
|
- item: optionsEditArray.value,
|
|
|
678
|
- });
|
|
|
679
|
- }, 20);
|
|
|
680
|
- } catch (e) {
|
|
|
681
|
- return e;
|
|
|
682
|
- }
|
|
|
683
|
- refTriggerChildData = {};
|
365
|
+ //TODO
|
684
|
}
|
366
|
}
|
685
|
};
|
367
|
};
|
686
|
- const removeTrigger = () => {
|
|
|
687
|
- if (!unref(isUpdate)) {
|
|
|
688
|
- try {
|
|
|
689
|
- unref(addTriggerPushData).pop();
|
|
|
690
|
- } catch (e) {
|
|
|
691
|
- return e;
|
|
|
692
|
- }
|
368
|
+ const conditionClickRemove = (e) => {
|
|
|
369
|
+ if (!e) {
|
|
|
370
|
+ conditionData.pop();
|
693
|
} else {
|
371
|
} else {
|
694
|
- try {
|
|
|
695
|
- unref(editTriggerPushData).pop();
|
|
|
696
|
- } catch (e) {
|
|
|
697
|
- return e;
|
|
|
698
|
- }
|
372
|
+ editConditionData.value.pop();
|
699
|
}
|
373
|
}
|
700
|
};
|
374
|
};
|
701
|
|
375
|
|
702
|
- //新增执行条件
|
|
|
703
|
- const addCondition = () => {
|
|
|
704
|
- if (!unref(isUpdate)) {
|
|
|
705
|
- refConditionChildDataFunc();
|
|
|
706
|
- unref(addConditionPushData).push(refConditionChildData as never);
|
|
|
707
|
- try {
|
|
|
708
|
- setTimeout(() => {
|
|
|
709
|
- proxy.$refs.refConditionChild?.updateFieldDeviceId(optionsItemArray.value);
|
|
|
710
|
- }, 20);
|
|
|
711
|
- } catch (e) {
|
|
|
712
|
- return e;
|
|
|
713
|
- }
|
|
|
714
|
- } else {
|
|
|
715
|
- isNoChange.value = false;
|
|
|
716
|
- unref(editConditionPushData).push(refConditionChildData as never);
|
|
|
717
|
- refConditionChildDataFunc();
|
|
|
718
|
- pushEditConditionArray.value.push(refConditionChildData);
|
|
|
719
|
- pushEditConditionArray.value = pushEditConditionArray.value.map((m) => {
|
|
|
720
|
- return {
|
|
|
721
|
- triggerType: m?.triggerType,
|
|
|
722
|
- entityId: m?.entityId,
|
|
|
723
|
- triggerCondition: {
|
|
|
724
|
- condition: [
|
|
|
725
|
- {
|
|
|
726
|
- key: {
|
|
|
727
|
- key: m.type == null ? 'CO2' : m.type,
|
|
|
728
|
- type: 'TIME_SERIES',
|
|
|
729
|
- },
|
|
|
730
|
- valueType: 'NUMERIC',
|
|
|
731
|
- // value: {},
|
|
|
732
|
- predicate: {
|
|
|
733
|
- type: 'NUMERIC',
|
|
|
734
|
- value: {
|
|
|
735
|
- defaultValue: Number(m.value) == null ? 0 : Number(m.value),
|
|
|
736
|
- },
|
|
|
737
|
- operation: m.operation,
|
|
|
738
|
- },
|
|
|
739
|
- },
|
|
|
740
|
- ],
|
|
|
741
|
- spec: {
|
|
|
742
|
- type: 'SIMPLE',
|
|
|
743
|
- },
|
|
|
744
|
- },
|
|
|
745
|
- };
|
|
|
746
|
- });
|
|
|
747
|
- try {
|
|
|
748
|
- setTimeout(() => {
|
|
|
749
|
- proxy.$refs.refConditionChild?.updateFieldDeviceId({
|
|
|
750
|
- status: 'edit',
|
|
|
751
|
- item: optionsEditArray.value,
|
|
|
752
|
- });
|
|
|
753
|
- }, 20);
|
|
|
754
|
- } catch (e) {
|
|
|
755
|
- return e;
|
|
|
756
|
- }
|
|
|
757
|
- refConditionChildData = {};
|
376
|
+ /**
|
|
|
377
|
+ * 获取执行动作表单值
|
|
|
378
|
+ */
|
|
|
379
|
+ const getActionFormValueFunc = () => {
|
|
|
380
|
+ try {
|
|
|
381
|
+ getActionFormValue = proxy.$refs.actionBindRef.getFieldsValueFunc();
|
|
|
382
|
+ } catch {}
|
|
|
383
|
+ };
|
|
|
384
|
+ //默认新增执行动作
|
|
|
385
|
+ const defaultAddAction = () => {
|
|
|
386
|
+ if (actionData.length == 0) {
|
|
|
387
|
+ actionClickAdd(false);
|
758
|
}
|
388
|
}
|
759
|
};
|
389
|
};
|
760
|
- const removeCondition = () => {
|
|
|
761
|
- if (!unref(isUpdate)) {
|
|
|
762
|
- try {
|
|
|
763
|
- unref(addConditionPushData).pop();
|
|
|
764
|
- } catch (e) {
|
|
|
765
|
- return e;
|
|
|
766
|
- }
|
390
|
+ const actionClickAdd = (e) => {
|
|
|
391
|
+ if (!e) {
|
|
|
392
|
+ getActionFormValueFunc();
|
|
|
393
|
+ actionData.push(getActionFormValue as never);
|
|
|
394
|
+ setTimeout(() => {
|
|
|
395
|
+ proxy.$refs.actionBindRef?.updateFieldDeviceId(optionsItemDeviceId.value);
|
|
|
396
|
+ }, 10);
|
767
|
} else {
|
397
|
} else {
|
768
|
- try {
|
|
|
769
|
- unref(editConditionPushData).pop();
|
|
|
770
|
- } catch (e) {
|
|
|
771
|
- return e;
|
|
|
772
|
- }
|
398
|
+ //TODO
|
773
|
}
|
399
|
}
|
774
|
};
|
400
|
};
|
775
|
-
|
|
|
776
|
- //默认新增执行动作
|
|
|
777
|
- const defaultAddAction = () => {
|
|
|
778
|
- if (unref(addActionPushData).length == 0) {
|
|
|
779
|
- addAction();
|
401
|
+ const actionClickRemove = (e) => {
|
|
|
402
|
+ if (!e) {
|
|
|
403
|
+ actionData.pop();
|
|
|
404
|
+ } else {
|
|
|
405
|
+ editActionData.value.pop();
|
780
|
}
|
406
|
}
|
781
|
};
|
407
|
};
|
782
|
- //新增执行动作
|
|
|
783
|
- const addAction = () => {
|
|
|
784
|
- if (!unref(isUpdate)) {
|
|
|
785
|
- refActionChildDataFunc();
|
|
|
786
|
- unref(addActionPushData).push(refActionChildData as never);
|
|
|
787
|
- try {
|
|
|
788
|
- setTimeout(() => {
|
|
|
789
|
- proxy.$refs.refActionChild.updateFieldDeviceId(optionsItemArray.value);
|
|
|
790
|
- }, 20);
|
|
|
791
|
- } catch (e) {
|
|
|
792
|
- return e;
|
|
|
793
|
- }
|
408
|
+ const submitOrEditFunc = (e) => {
|
|
|
409
|
+ if (!e) {
|
|
|
410
|
+ getTriggerFormValueFunc();
|
|
|
411
|
+ concatTrigger = triggerData.concat(getTriggerFormValue);
|
|
|
412
|
+ //去除第一个空对象
|
|
|
413
|
+ concatTrigger.shift();
|
|
|
414
|
+ concatTrigger = concatTrigger.map((m) => formatTriggerData(m));
|
|
|
415
|
+ getConditionFormValueFunc();
|
|
|
416
|
+ concatCondition = conditionData.concat(getConditionFormValue);
|
|
|
417
|
+ //去除第一个空对象
|
|
|
418
|
+ concatCondition.shift();
|
|
|
419
|
+ concatCondition = concatCondition.map((m) => formatConditionData(m));
|
|
|
420
|
+ getActionFormValueFunc();
|
|
|
421
|
+ concatAction = actionData.concat(getActionFormValue);
|
|
|
422
|
+ // 去除第一个空对象;
|
|
|
423
|
+ concatAction.shift();
|
794
|
} else {
|
424
|
} else {
|
795
|
- isNoChange.value = false;
|
|
|
796
|
- unref(editActionPushData).push(refActionChildData as never);
|
|
|
797
|
- refActionChildDataFunc();
|
|
|
798
|
- pushEditActionArray.value.push(refActionChildData);
|
|
|
799
|
- try {
|
|
|
800
|
- setTimeout(() => {
|
|
|
801
|
- proxy.$refs.refActionChild.updateFieldDeviceId({
|
|
|
802
|
- status: 'edit',
|
|
|
803
|
- item: optionsEditArray.value,
|
|
|
804
|
- });
|
|
|
805
|
- }, 20);
|
|
|
806
|
- } catch (e) {
|
|
|
807
|
- return e;
|
|
|
808
|
- }
|
|
|
809
|
- refActionChildData = {};
|
425
|
+ //TODO
|
810
|
}
|
426
|
}
|
811
|
};
|
427
|
};
|
812
|
- const removeAction = () => {
|
|
|
813
|
- if (!unref(isUpdate)) {
|
|
|
814
|
- try {
|
|
|
815
|
- unref(addActionPushData).pop();
|
|
|
816
|
- } catch (e) {
|
|
|
817
|
- return e;
|
|
|
818
|
- }
|
428
|
+
|
|
|
429
|
+ const handleSubmit = async (e) => {
|
|
|
430
|
+ let basicFormValue = await validate();
|
|
|
431
|
+ if (!basicFormValue) return;
|
|
|
432
|
+ if (!e) {
|
|
|
433
|
+ submitOrEditFunc(e);
|
|
|
434
|
+ let isKongNum = 0;
|
|
|
435
|
+ concatAction.forEach((f) => {
|
|
|
436
|
+ isKongNum = Object.keys(f).length;
|
|
|
437
|
+ });
|
|
|
438
|
+ if (concatAction.length == 1 && isKongNum == 0)
|
|
|
439
|
+ return createMessage.error('请填写执行动作');
|
|
|
440
|
+ postAddOrEditData = {
|
|
|
441
|
+ ...basicFormValue,
|
|
|
442
|
+ ...{
|
|
|
443
|
+ triggers: concatTrigger,
|
|
|
444
|
+ },
|
|
|
445
|
+ ...{
|
|
|
446
|
+ doConditions: concatCondition,
|
|
|
447
|
+ },
|
|
|
448
|
+ ...{
|
|
|
449
|
+ doActions: concatAction,
|
|
|
450
|
+ },
|
|
|
451
|
+ };
|
|
|
452
|
+ await screenLinkPageAddApi(postAddOrEditData);
|
|
|
453
|
+ createMessage.success('新增成功');
|
|
|
454
|
+ closeDrawer();
|
|
|
455
|
+ emit('success');
|
819
|
} else {
|
456
|
} else {
|
820
|
- try {
|
|
|
821
|
- unref(editActionPushData).pop();
|
|
|
822
|
- } catch (e) {
|
|
|
823
|
- return e;
|
|
|
824
|
- }
|
457
|
+ submitOrEditFunc(e);
|
|
|
458
|
+ postAddOrEditData = {
|
|
|
459
|
+ ...basicFormValue,
|
|
|
460
|
+ ...{ id: getId.value },
|
|
|
461
|
+ ...{ tenantId: getTenantId.value },
|
|
|
462
|
+ };
|
|
|
463
|
+ await screenLinkPageUpdateApi(postAddOrEditData);
|
|
|
464
|
+ createMessage.success('编辑成功');
|
|
|
465
|
+ closeDrawer();
|
|
|
466
|
+ emit('success');
|
825
|
}
|
467
|
}
|
826
|
};
|
468
|
};
|
|
|
469
|
+ const handleClose = () => {
|
|
|
470
|
+ closeDrawer();
|
|
|
471
|
+ };
|
827
|
|
472
|
|
828
|
return {
|
473
|
return {
|
829
|
- handleClose,
|
|
|
830
|
- newFilterMap,
|
|
|
831
|
- newConditionFilterMap,
|
|
|
832
|
- newActionFilterMap,
|
|
|
833
|
- editTriggerPushData,
|
|
|
834
|
- editConditionPushData,
|
|
|
835
|
- editActionPushData,
|
|
|
836
|
- isUpdate,
|
|
|
837
|
- clearActionsAllDevice,
|
|
|
838
|
- getDeviceInfo,
|
|
|
839
|
- getDeviceInfo1,
|
|
|
840
|
- getDeviceInfo2,
|
|
|
841
|
- resetActionsAllArrayFunc,
|
|
|
842
|
- addActionPushData,
|
|
|
843
|
- defaultAddAction,
|
|
|
844
|
- refActionChild,
|
|
|
845
|
- addAction,
|
|
|
846
|
- removeAction,
|
|
|
847
|
- addConditionPushData,
|
|
|
848
|
- refConditionChild,
|
|
|
849
|
- addCondition,
|
|
|
850
|
- removeCondition,
|
|
|
851
|
- clearAllArrayFunc,
|
|
|
852
|
- removeTrigger,
|
|
|
853
|
- addTriggerPushData,
|
|
|
854
|
- addTriggerData,
|
|
|
855
|
- addTrigger,
|
|
|
856
|
- getConditionChildData,
|
|
|
857
|
- refTriggerChild,
|
|
|
858
|
- getChildData,
|
|
|
859
|
- getAllFormData,
|
|
|
860
|
registerDrawer,
|
474
|
registerDrawer,
|
861
|
registerForm,
|
475
|
registerForm,
|
862
|
- getTitle,
|
476
|
+ triggerData,
|
|
|
477
|
+ triggerClickAdd,
|
|
|
478
|
+ triggerClickRemove,
|
|
|
479
|
+ conditionClickAdd,
|
|
|
480
|
+ conditionClickRemove,
|
|
|
481
|
+ actionClickAdd,
|
|
|
482
|
+ actionClickRemove,
|
|
|
483
|
+ triggerBindRef,
|
|
|
484
|
+ conditionBindRef,
|
|
|
485
|
+ actionBindRef,
|
863
|
handleSubmit,
|
486
|
handleSubmit,
|
|
|
487
|
+ handleClose,
|
|
|
488
|
+ drawerStatus,
|
|
|
489
|
+ conditionData,
|
|
|
490
|
+ actionData,
|
|
|
491
|
+ editTriggerData,
|
|
|
492
|
+ editConditionData,
|
|
|
493
|
+ editActionData,
|
|
|
494
|
+ getTriggerFatherEntryIdData,
|
|
|
495
|
+ getConditionFatherEntryIdData,
|
|
|
496
|
+ getActionFatherEntryIdData,
|
864
|
};
|
497
|
};
|
865
|
},
|
498
|
},
|
866
|
});
|
499
|
});
|
867
|
</script>
|
500
|
</script>
|
868
|
|
501
|
|
869
|
-<style lang="less" scoped>
|
|
|
870
|
- .condition-style {
|
|
|
871
|
- :deep .ant-calendar-picker {
|
|
|
872
|
- width: 24.9vw !important;
|
|
|
873
|
- }
|
|
|
874
|
- }
|
|
|
875
|
-</style> |
502
|
+<style lang="less" scoped></style> |