...
|
...
|
@@ -11,6 +11,8 @@ |
11
|
11
|
<!-- 触发器 -->
|
12
|
12
|
<div>
|
13
|
13
|
<template v-for="(item, index) in addTriggerPushData" :key="index">
|
|
14
|
+ <span style="display: none">{{ item + index }}</span>
|
|
15
|
+ <span style="position: relative; top: 3.2vh; left: 0.3vw">触发器{{ index + 1 }}</span>
|
14
|
16
|
<div>
|
15
|
17
|
<AddTriggerForm :deviceInfo="getDeviceInfo" ref="refTriggerChild" />
|
16
|
18
|
</div>
|
...
|
...
|
@@ -19,7 +21,7 @@ |
19
|
21
|
<div
|
20
|
22
|
style="
|
21
|
23
|
display: flex;
|
22
|
|
- width: 13vw;
|
|
24
|
+ width: 11vw;
|
23
|
25
|
height: 4vh;
|
24
|
26
|
flex-direction: row;
|
25
|
27
|
justify-content: space-between;
|
...
|
...
|
@@ -27,12 +29,17 @@ |
27
|
29
|
>
|
28
|
30
|
<div style="display: flex; width: 4vw; height: 4vh">
|
29
|
31
|
<Button type="primary" style="border-radius: 10px" class="mt-5" @click="addTrigger"
|
30
|
|
- ><PlusCircleOutlined />新增触发器</Button
|
|
32
|
+ >新增触发器</Button
|
31
|
33
|
>
|
32
|
34
|
</div>
|
33
|
35
|
<div style="display: flex; width: 4vw; height: 4vh">
|
34
|
|
- <Button type="error" style="border-radius: 10px" class="mt-5" @click="removeTrigger"
|
35
|
|
- ><PlusCircleOutlined />删除</Button
|
|
36
|
+ <Button
|
|
37
|
+ type="default"
|
|
38
|
+ style="border-radius: 10px; background-color: rgba(237, 111, 111, 1)"
|
|
39
|
+ class="mt-5"
|
|
40
|
+ @click="removeTrigger"
|
|
41
|
+ >
|
|
42
|
+ <span style="color: white">删除</span></Button
|
36
|
43
|
>
|
37
|
44
|
</div>
|
38
|
45
|
</div>
|
...
|
...
|
@@ -41,6 +48,9 @@ |
41
|
48
|
<!-- 执行条件 -->
|
42
|
49
|
<div>
|
43
|
50
|
<template v-for="(item, index) in addConditionPushData" :key="index">
|
|
51
|
+ <span style="display: none">{{ item + index }}</span>
|
|
52
|
+ <span style="position: relative; top: 3.2vh; left: 0.3vw">执行条件{{ index + 1 }}</span>
|
|
53
|
+
|
44
|
54
|
<div>
|
45
|
55
|
<AddConditiForm :deviceInfo1="getDeviceInfo1" ref="refConditionChild" />
|
46
|
56
|
</div>
|
...
|
...
|
@@ -49,7 +59,7 @@ |
49
|
59
|
<div
|
50
|
60
|
style="
|
51
|
61
|
display: flex;
|
52
|
|
- width: 13vw;
|
|
62
|
+ width: 11vw;
|
53
|
63
|
height: 4vh;
|
54
|
64
|
flex-direction: row;
|
55
|
65
|
justify-content: space-between;
|
...
|
...
|
@@ -57,12 +67,17 @@ |
57
|
67
|
>
|
58
|
68
|
<div style="display: flex; width: 4vw; height: 4vh">
|
59
|
69
|
<Button type="primary" style="border-radius: 10px" class="mt-5" @click="addCondition"
|
60
|
|
- ><PlusCircleOutlined />新增执行条件</Button
|
|
70
|
+ >新增执行条件</Button
|
61
|
71
|
>
|
62
|
72
|
</div>
|
63
|
73
|
<div style="display: flex; width: 4vw; height: 4vh">
|
64
|
|
- <Button type="error" style="border-radius: 10px" class="mt-5" @click="removeCondition"
|
65
|
|
- ><PlusCircleOutlined />删除</Button
|
|
74
|
+ <Button
|
|
75
|
+ style="border-radius: 10px; background-color: rgba(237, 111, 111, 1)"
|
|
76
|
+ type="default"
|
|
77
|
+ class="mt-5"
|
|
78
|
+ @click="removeCondition"
|
|
79
|
+ >
|
|
80
|
+ <span style="color: white">删除</span></Button
|
66
|
81
|
>
|
67
|
82
|
</div>
|
68
|
83
|
</div>
|
...
|
...
|
@@ -71,6 +86,9 @@ |
71
|
86
|
<div style="height: 5vh"></div>
|
72
|
87
|
<div>
|
73
|
88
|
<template v-for="(item, index) in addActionPushData" :key="index">
|
|
89
|
+ <span style="display: none">{{ item + index }}</span>
|
|
90
|
+ <span style="position: relative; top: 4.2vh; left: 0.65vw">执行动作{{ index + 1 }}</span>
|
|
91
|
+
|
74
|
92
|
<div>
|
75
|
93
|
<AddActionForm :deviceInfo2="getDeviceInfo2" ref="refActionChild" />
|
76
|
94
|
</div>
|
...
|
...
|
@@ -79,7 +97,7 @@ |
79
|
97
|
<div
|
80
|
98
|
style="
|
81
|
99
|
display: flex;
|
82
|
|
- width: 13vw;
|
|
100
|
+ width: 11vw;
|
83
|
101
|
height: 4vh;
|
84
|
102
|
flex-direction: row;
|
85
|
103
|
justify-content: space-between;
|
...
|
...
|
@@ -87,15 +105,21 @@ |
87
|
105
|
>
|
88
|
106
|
<div style="display: flex; width: 4vw; height: 4vh">
|
89
|
107
|
<Button type="primary" style="border-radius: 10px" class="mt-5" @click="addAction"
|
90
|
|
- ><PlusCircleOutlined />新增执行动作</Button
|
|
108
|
+ >新增执行动作</Button
|
91
|
109
|
>
|
92
|
110
|
</div>
|
93
|
111
|
<div style="display: flex; width: 4vw; height: 4vh">
|
94
|
|
- <Button type="error" style="border-radius: 10px" class="mt-5" @click="removeAction"
|
95
|
|
- ><PlusCircleOutlined />删除</Button
|
|
112
|
+ <Button
|
|
113
|
+ style="border-radius: 10px; background-color: rgba(237, 111, 111, 1)"
|
|
114
|
+ type="default"
|
|
115
|
+ class="mt-5"
|
|
116
|
+ @click="removeAction"
|
|
117
|
+ >
|
|
118
|
+ <span style="color: white">删除</span></Button
|
96
|
119
|
>
|
97
|
120
|
</div>
|
98
|
121
|
</div>
|
|
122
|
+ <div style="height: 5vh"></div>
|
99
|
123
|
</div>
|
100
|
124
|
</BasicDrawer>
|
101
|
125
|
</template>
|
...
|
...
|
@@ -104,11 +128,7 @@ |
104
|
128
|
import { BasicForm, useForm } from '/@/components/Form';
|
105
|
129
|
import { formSchema, getData } from './config';
|
106
|
130
|
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
|
107
|
|
- import {
|
108
|
|
- screenLinkPageAddApi,
|
109
|
|
- // screenLinkPageUpdateApi,
|
110
|
|
- // screenLinkPageByDeptIdGetDevice,
|
111
|
|
- } from '/@/api/ruleengine/ruleengineApi';
|
|
131
|
+ import { screenLinkPageAddApi, screenLinkPageUpdateApi } from '/@/api/ruleengine/ruleengineApi';
|
112
|
132
|
import { useMessage } from '/@/hooks/web/useMessage';
|
113
|
133
|
import AddTriggerForm from './addForm/trigger.vue';
|
114
|
134
|
import AddConditiForm from './addForm/condition.vue';
|
...
|
...
|
@@ -118,9 +138,17 @@ |
118
|
138
|
|
119
|
139
|
export default defineComponent({
|
120
|
140
|
name: 'ConfigDrawer',
|
121
|
|
- components: { BasicDrawer, BasicForm, AddTriggerForm, AddConditiForm, AddActionForm, Button },
|
|
141
|
+ components: {
|
|
142
|
+ BasicDrawer,
|
|
143
|
+ BasicForm,
|
|
144
|
+ AddTriggerForm,
|
|
145
|
+ AddConditiForm,
|
|
146
|
+ AddActionForm,
|
|
147
|
+ Button,
|
|
148
|
+ },
|
122
|
149
|
emits: ['success', 'register', 'registerForm'],
|
123
|
150
|
setup(_, { emit }) {
|
|
151
|
+ const { proxy } = getCurrentInstance();
|
124
|
152
|
const lastRefTriggerChildDataArray = ref<[]>([]);
|
125
|
153
|
const lastRefConditionChildDataArray = ref<[]>([]);
|
126
|
154
|
const lastRefActionChildDataArray = ref<[]>([]);
|
...
|
...
|
@@ -159,7 +187,6 @@ |
159
|
187
|
const addTriggerPushData = ref<[]>([]);
|
160
|
188
|
const addConditionPushData = ref<[]>([]);
|
161
|
189
|
const addActionPushData = ref<[]>([]);
|
162
|
|
- const { proxy } = getCurrentInstance();
|
163
|
190
|
const getChildData = ref(null);
|
164
|
191
|
const refTriggerChild = ref(null);
|
165
|
192
|
const refConditionChild = ref(null);
|
...
|
...
|
@@ -167,13 +194,13 @@ |
167
|
194
|
const getConditionChildData = ref(null);
|
168
|
195
|
const { createMessage } = useMessage();
|
169
|
196
|
const isUpdate = ref(true);
|
170
|
|
- let getAllFormData: any = reactive({});
|
|
197
|
+ const getAllFormData: any = reactive({});
|
171
|
198
|
let getValuesFormData: any = reactive({});
|
172
|
|
- let getId = ref('');
|
173
|
|
- let getTenantId = ref('');
|
174
|
|
- let getDeviceInfo = ref(null);
|
175
|
|
- let getDeviceInfo1 = ref(null);
|
176
|
|
- let getDeviceInfo2 = ref(null);
|
|
199
|
+ const getId = ref('');
|
|
200
|
+ const getTenantId = ref('');
|
|
201
|
+ const getDeviceInfo = ref(null);
|
|
202
|
+ const getDeviceInfo1 = ref(null);
|
|
203
|
+ const getDeviceInfo2 = ref(null);
|
177
|
204
|
|
178
|
205
|
const [registerForm, { resetFields, setFieldsValue, validateFields }] = useForm({
|
179
|
206
|
labelWidth: 120,
|
...
|
...
|
@@ -194,9 +221,8 @@ |
194
|
221
|
} catch (e) {
|
195
|
222
|
return e;
|
196
|
223
|
}
|
197
|
|
- }
|
198
|
|
- //编辑
|
199
|
|
- if (unref(isUpdate)) {
|
|
224
|
+ } else {
|
|
225
|
+ //编辑
|
200
|
226
|
getId.value = data.record.id;
|
201
|
227
|
getTenantId.value = data.record.tenantId;
|
202
|
228
|
await setFieldsValue({
|
...
|
...
|
@@ -259,14 +285,17 @@ |
259
|
285
|
}
|
260
|
286
|
};
|
261
|
287
|
|
262
|
|
- const getDefaultValue = async () => {
|
263
|
|
- getValuesFormData = await validateFields();
|
|
288
|
+ const getDefaultValue = () => {
|
264
|
289
|
refTriggerChildDataFunc();
|
265
|
290
|
refConditionChildDataFunc();
|
266
|
291
|
refActionChildDataFunc();
|
267
|
|
- lastRefTriggerChildDataArray.value.push(refTriggerChildData.value);
|
268
|
|
- lastRefConditionChildDataArray.value.push(refConditionChildData.value);
|
269
|
|
- lastRefActionChildDataArray.value.push(refActionChildData.value);
|
|
292
|
+ lastRefTriggerChildDataArray.value.push(refTriggerChildData.value as never);
|
|
293
|
+ lastRefConditionChildDataArray.value.push(refConditionChildData.value as never);
|
|
294
|
+ lastRefActionChildDataArray.value.push(refActionChildData.value as never);
|
|
295
|
+ //删除第一个
|
|
296
|
+ lastRefTriggerChildDataArray.value.shift();
|
|
297
|
+ lastRefConditionChildDataArray.value.shift();
|
|
298
|
+ lastRefActionChildDataArray.value.shift();
|
270
|
299
|
const triggersObj = {
|
271
|
300
|
triggers: lastRefTriggerChildDataArray.value,
|
272
|
301
|
};
|
...
|
...
|
@@ -276,52 +305,66 @@ |
276
|
305
|
const actionsObj = {
|
277
|
306
|
actions: lastRefActionChildDataArray.value,
|
278
|
307
|
};
|
279
|
|
- Object.assign(getAllFormData, getValuesFormData, triggersObj, conditionsObj, actionsObj);
|
|
308
|
+ Object.assign(getAllFormData, triggersObj, conditionsObj, actionsObj);
|
280
|
309
|
if (!unref(isUpdate)) {
|
281
|
310
|
delete getAllFormData.id;
|
282
|
311
|
delete getAllFormData.getTenantId;
|
283
|
312
|
}
|
284
|
313
|
};
|
285
|
314
|
|
286
|
|
- async function handleSubmit() {
|
|
315
|
+ const handleSubmit = async () => {
|
287
|
316
|
if (!unref(isUpdate)) {
|
288
|
317
|
getDefaultValue();
|
289
|
|
- console.log(getAllFormData);
|
|
318
|
+ getValuesFormData = await validateFields();
|
|
319
|
+ if (!getValuesFormData) return;
|
|
320
|
+ Object.assign(getAllFormData, getValuesFormData);
|
290
|
321
|
await screenLinkPageAddApi(getAllFormData);
|
291
|
322
|
createMessage.success('场景联动新增成功');
|
292
|
323
|
closeDrawer();
|
293
|
324
|
emit('success');
|
294
|
325
|
} else {
|
295
|
326
|
getDefaultValue();
|
|
327
|
+ getAllFormData.id = getId.value;
|
|
328
|
+ getAllFormData.tenantId = getTenantId.value;
|
|
329
|
+ await screenLinkPageUpdateApi(getAllFormData);
|
296
|
330
|
createMessage.success('场景联动编辑成功');
|
297
|
331
|
closeDrawer();
|
298
|
332
|
emit('success');
|
299
|
333
|
}
|
300
|
|
- }
|
|
334
|
+ };
|
|
335
|
+
|
301
|
336
|
//新增触发器
|
302
|
337
|
const addTrigger = () => {
|
303
|
|
- unref(addTriggerPushData).push(addTriggerData);
|
|
338
|
+ unref(addTriggerPushData).push(addTriggerData as never);
|
304
|
339
|
refTriggerChildDataFunc();
|
305
|
340
|
lastRefTriggerChildData.value = refTriggerChildData.value;
|
306
|
|
- lastRefTriggerChildDataArray.value.push(lastRefTriggerChildData.value);
|
|
341
|
+ lastRefTriggerChildDataArray.value.push(lastRefTriggerChildData.value as never);
|
307
|
342
|
};
|
308
|
343
|
const removeTrigger = () => {
|
309
|
|
- unref(addTriggerPushData).splice(0, 1);
|
310
|
|
- lastRefTriggerChildDataArray.value.splice(0, 1);
|
311
|
|
- getAllFormData.triggers.splice(0, 1);
|
|
344
|
+ try {
|
|
345
|
+ unref(addTriggerPushData).splice(0, 1);
|
|
346
|
+ lastRefTriggerChildDataArray.value.splice(0, 1);
|
|
347
|
+ getAllFormData.triggers.splice(0, 1);
|
|
348
|
+ } catch (e) {
|
|
349
|
+ return e;
|
|
350
|
+ }
|
312
|
351
|
};
|
313
|
352
|
|
314
|
353
|
//新增执行条件
|
315
|
354
|
const addCondition = () => {
|
316
|
|
- unref(addConditionPushData).push(addConditionData);
|
|
355
|
+ unref(addConditionPushData).push(addConditionData as never);
|
317
|
356
|
refConditionChildDataFunc();
|
318
|
357
|
lastRefConditionChildData.value = refConditionChildData.value;
|
319
|
|
- lastRefConditionChildDataArray.value.push(lastRefConditionChildData.value);
|
|
358
|
+ lastRefConditionChildDataArray.value.push(lastRefConditionChildData.value as never);
|
320
|
359
|
};
|
321
|
360
|
const removeCondition = () => {
|
322
|
|
- unref(addConditionPushData).splice(0, 1);
|
323
|
|
- lastRefConditionChildDataArray.value.splice(0, 1);
|
324
|
|
- getAllFormData.conditions.splice(0, 1);
|
|
361
|
+ try {
|
|
362
|
+ unref(addConditionPushData).splice(0, 1);
|
|
363
|
+ lastRefConditionChildDataArray.value.splice(0, 1);
|
|
364
|
+ getAllFormData.conditions.splice(0, 1);
|
|
365
|
+ } catch (e) {
|
|
366
|
+ return e;
|
|
367
|
+ }
|
325
|
368
|
};
|
326
|
369
|
|
327
|
370
|
//新增执行动作
|
...
|
...
|
@@ -331,15 +374,19 @@ |
331
|
374
|
}
|
332
|
375
|
};
|
333
|
376
|
const addAction = () => {
|
334
|
|
- unref(addActionPushData).push(addActionData);
|
|
377
|
+ unref(addActionPushData).push(addActionData as never);
|
335
|
378
|
refActionChildDataFunc();
|
336
|
379
|
lastRefActionChildData.value = refActionChildData.value;
|
337
|
|
- lastRefActionChildDataArray.value.push(lastRefActionChildData.value);
|
|
380
|
+ lastRefActionChildDataArray.value.push(lastRefActionChildData.value as never);
|
338
|
381
|
};
|
339
|
382
|
const removeAction = () => {
|
340
|
|
- unref(addActionPushData).splice(0, 1);
|
341
|
|
- lastRefActionChildDataArray.value.splice(0, 1);
|
342
|
|
- getAllFormData.actions.splice(0, 1);
|
|
383
|
+ try {
|
|
384
|
+ unref(addActionPushData).splice(0, 1);
|
|
385
|
+ lastRefActionChildDataArray.value.splice(0, 1);
|
|
386
|
+ getAllFormData.actions.splice(0, 1);
|
|
387
|
+ } catch (e) {
|
|
388
|
+ return e;
|
|
389
|
+ }
|
343
|
390
|
};
|
344
|
391
|
|
345
|
392
|
return {
|
...
|
...
|
|