Showing
7 changed files
with
373 additions
and
1496 deletions
... | ... | @@ -7,29 +7,7 @@ |
7 | 7 | :showResetButton="false" |
8 | 8 | :showSubmitButton="false" |
9 | 9 | @register="registerCondition" |
10 | - > | |
11 | - <template #add="{ field }"> | |
12 | - <Button | |
13 | - style="margin-left: -99px; margin-top: 0px; display: inline-block" | |
14 | - v-if="Number(field) === 0" | |
15 | - :style="addHideButton > 1 ? 'display:none' : 'display:inline-block'" | |
16 | - @click="add" | |
17 | - type="primary" | |
18 | - >+新增执行条件</Button | |
19 | - > | |
20 | - | |
21 | - <Button | |
22 | - style="margin-left: -95px; margin-top: 20px" | |
23 | - v-if="field > 0" | |
24 | - @click="add" | |
25 | - type="primary" | |
26 | - >+新增执行条件</Button | |
27 | - > | |
28 | - <Button style="margin-left: 10px" v-if="field > 0" @click="del(field)" type="primary" | |
29 | - >删除</Button | |
30 | - > | |
31 | - </template> | |
32 | - </BasicForm> | |
10 | + /> | |
33 | 11 | </div> |
34 | 12 | </CollapseContainer> |
35 | 13 | </template> |
... | ... | @@ -38,40 +16,24 @@ |
38 | 16 | import { CollapseContainer } from '/@/components/Container/index'; |
39 | 17 | import { BasicForm, useForm } from '/@/components/Form/index'; |
40 | 18 | import { Input } from 'ant-design-vue'; |
41 | - import { Button } from '/@/components/Button'; | |
42 | - import { useConditionDrawerSchema, isShiDu, isTimeAll } from '../config.d'; | |
19 | + import { useConditionDrawerSchema } from '../config'; | |
43 | 20 | import { screenLinkPageByDeptIdGetDevice } from '/@/api/ruleengine/ruleengineApi'; |
44 | 21 | |
45 | 22 | export default defineComponent({ |
46 | - components: { CollapseContainer, BasicForm, [Input.name]: Input, Button }, | |
47 | - // eslint-disable-next-line vue/require-prop-types | |
23 | + components: { CollapseContainer, BasicForm, [Input.name]: Input }, | |
48 | 24 | props: ['deviceInfo1'], |
49 | - emits: ['eDoConditionGetAddPushValueData'], | |
50 | - setup(props, { emit }) { | |
51 | - const addHideButton = ref(1); | |
52 | - const getAddPushValueData: any = ref([]); | |
53 | 25 | |
54 | - const [ | |
55 | - registerCondition, | |
56 | - { | |
57 | - setFieldsValue, | |
58 | - resetFields, | |
59 | - updateSchema, | |
60 | - appendSchemaByField, | |
61 | - removeSchemaByFiled, | |
62 | - getFieldsValue, | |
63 | - }, | |
64 | - ] = useForm({ | |
26 | + setup(props) { | |
27 | + const fieldValue: any = ref({}); | |
28 | + const [registerCondition, { getFieldsValue, updateSchema }] = useForm({ | |
65 | 29 | labelWidth: 100, |
66 | 30 | schemas: useConditionDrawerSchema, |
67 | 31 | actionColOptions: { span: 24 }, |
68 | 32 | }); |
69 | - let isJudge = ref(1); | |
70 | - if (isJudge.value == 1) { | |
71 | - setTimeout(() => { | |
72 | - resetFields(); | |
73 | - }, 1000); | |
74 | - } | |
33 | + const getFieldsValueFunc = () => { | |
34 | + fieldValue.value = getFieldsValue(); | |
35 | + return fieldValue.value; | |
36 | + }; | |
75 | 37 | watch( |
76 | 38 | () => props.deviceInfo1, |
77 | 39 | async (newV) => { |
... | ... | @@ -87,20 +49,6 @@ |
87 | 49 | }); |
88 | 50 | } |
89 | 51 | ); |
90 | - //回显数据 | |
91 | - const setFieldsFormValue = (v) => { | |
92 | - setFieldsValue(v); | |
93 | - }; | |
94 | - const getAllFields = (getV: any) => { | |
95 | - getV = { | |
96 | - data: getFieldsValue(), | |
97 | - count: 1, | |
98 | - }; | |
99 | - return getV; | |
100 | - }; | |
101 | - function funcResetFields() { | |
102 | - resetFields(); | |
103 | - } | |
104 | 52 | //新增清空设备选择 |
105 | 53 | const clearSelectDevice = () => { |
106 | 54 | updateSchema({ |
... | ... | @@ -118,353 +66,11 @@ |
118 | 66 | }, |
119 | 67 | }); |
120 | 68 | }; |
121 | - | |
122 | - const n = ref(1); | |
123 | - function add() { | |
124 | - const pushValue = getFieldsValue(); | |
125 | - getAddPushValueData.value.push(pushValue); | |
126 | - emit('eDoConditionGetAddPushValueData', { | |
127 | - data: getAddPushValueData.value, | |
128 | - count: 2, | |
129 | - }); | |
130 | - addHideButton.value++; | |
131 | - if (addHideButton.value == 3) { | |
132 | - setTimeout(() => { | |
133 | - let getDom1 = document.getElementById('1') as HTMLElement; | |
134 | - getDom1.style.display = 'none'; | |
135 | - }, 500); | |
136 | - } | |
137 | - if (addHideButton.value == 4) { | |
138 | - setTimeout(() => { | |
139 | - let getDom2 = document.getElementById('2') as HTMLElement; | |
140 | - getDom2.style.display = 'none'; | |
141 | - let getDom41 = document.getElementById('1') as HTMLElement; | |
142 | - getDom41.style.display = 'none'; | |
143 | - }, 500); | |
144 | - } | |
145 | - if (addHideButton.value == 5) { | |
146 | - setTimeout(() => { | |
147 | - let getDom3 = document.getElementById('3') as HTMLElement; | |
148 | - getDom3.style.display = 'none'; | |
149 | - let getDom51 = document.getElementById('1') as HTMLElement; | |
150 | - getDom51.style.display = 'none'; | |
151 | - let getDom52 = document.getElementById('2') as HTMLElement; | |
152 | - getDom52.style.display = 'none'; | |
153 | - }, 500); | |
154 | - } | |
155 | - if (addHideButton.value == 6) { | |
156 | - setTimeout(() => { | |
157 | - let getDom4 = document.getElementById('4') as HTMLElement; | |
158 | - getDom4.style.display = 'none'; | |
159 | - let getDom61 = document.getElementById('1') as HTMLElement; | |
160 | - getDom61.style.display = 'none'; | |
161 | - let getDom62 = document.getElementById('2') as HTMLElement; | |
162 | - getDom62.style.display = 'none'; | |
163 | - let getDom63 = document.getElementById('3') as HTMLElement; | |
164 | - getDom63.style.display = 'none'; | |
165 | - }, 500); | |
166 | - } | |
167 | - if (addHideButton.value == 7) { | |
168 | - setTimeout(() => { | |
169 | - let getDom7 = document.getElementById('5') as HTMLElement; | |
170 | - getDom7.style.display = 'none'; | |
171 | - let getDom71 = document.getElementById('1') as HTMLElement; | |
172 | - getDom71.style.display = 'none'; | |
173 | - let getDom72 = document.getElementById('2') as HTMLElement; | |
174 | - getDom72.style.display = 'none'; | |
175 | - let getDom73 = document.getElementById('3') as HTMLElement; | |
176 | - getDom73.style.display = 'none'; | |
177 | - let getDom74 = document.getElementById('4') as HTMLElement; | |
178 | - getDom74.style.display = 'none'; | |
179 | - }, 500); | |
180 | - } | |
181 | - | |
182 | - appendSchemaByField( | |
183 | - { | |
184 | - field: `kong${n.value}`, | |
185 | - label: `执行条件${n.value + 1 + `.........`}`, | |
186 | - component: 'Slider', | |
187 | - colProps: { span: 24 }, | |
188 | - }, | |
189 | - '' | |
190 | - ); | |
191 | - appendSchemaByField( | |
192 | - { | |
193 | - field: `status${n.value}`, | |
194 | - label: '', | |
195 | - component: 'Select', | |
196 | - componentProps: { | |
197 | - placeholder: '设备状态', | |
198 | - options: [ | |
199 | - { label: '设备触发', value: 'DEVICE_STATUS' }, | |
200 | - { label: '时间范围', value: 'TIME_ALL' }, | |
201 | - ], | |
202 | - }, | |
203 | - colProps: { span: 12 }, | |
204 | - }, | |
205 | - '' | |
206 | - ); | |
207 | - appendSchemaByField( | |
208 | - { | |
209 | - field: `deviceId${n.value}`, | |
210 | - label: '', | |
211 | - component: 'Select', | |
212 | - componentProps: { | |
213 | - placeholder: '请选择设备', | |
214 | - }, | |
215 | - ifShow: ({ values }) => !isTimeAll(Reflect.get(values, 'status')), | |
216 | - colProps: { | |
217 | - span: 12, | |
218 | - }, | |
219 | - }, | |
220 | - '' | |
221 | - ); | |
222 | - appendSchemaByField( | |
223 | - { | |
224 | - field: `createTime${n.value}`, | |
225 | - label: '', | |
226 | - component: 'DatePicker', | |
227 | - componentProps: { | |
228 | - placeholder: '请选择起始时间', | |
229 | - }, | |
230 | - colProps: { | |
231 | - span: 12, | |
232 | - }, | |
233 | - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'status')), | |
234 | - }, | |
235 | - '' | |
236 | - ); | |
237 | - appendSchemaByField( | |
238 | - { | |
239 | - field: `updateTime${n.value}`, | |
240 | - label: '', | |
241 | - component: 'DatePicker', | |
242 | - componentProps: { | |
243 | - placeholder: '请选择结束时间', | |
244 | - }, | |
245 | - colProps: { | |
246 | - span: 12, | |
247 | - }, | |
248 | - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'status')), | |
249 | - }, | |
250 | - '' | |
251 | - ); | |
252 | - appendSchemaByField( | |
253 | - { | |
254 | - field: `property${n.value}`, | |
255 | - label: '', | |
256 | - component: 'Select', | |
257 | - componentProps: { | |
258 | - placeholder: '请选择或者输入属性', | |
259 | - options: [ | |
260 | - { label: 'shidu', value: 'SHINDU' }, | |
261 | - { label: 'wendu', value: 'WENDU' }, | |
262 | - ], | |
263 | - }, | |
264 | - ifShow: ({ values }) => !isTimeAll(Reflect.get(values, 'status')), | |
265 | - colProps: { span: 12 }, | |
266 | - }, | |
267 | - '' | |
268 | - ); | |
269 | - appendSchemaByField( | |
270 | - { | |
271 | - field: `wu${n.value}`, | |
272 | - label: '', | |
273 | - component: 'Input', | |
274 | - componentProps: { | |
275 | - placeholder: '无', | |
276 | - style: { | |
277 | - visibility: 'hidden', | |
278 | - }, | |
279 | - }, | |
280 | - colProps: { span: 12 }, | |
281 | - }, | |
282 | - '' | |
283 | - ); | |
284 | - appendSchemaByField( | |
285 | - { | |
286 | - field: `compare${n.value}`, | |
287 | - label: '', | |
288 | - component: 'Select', | |
289 | - componentProps: { | |
290 | - placeholder: '', | |
291 | - options: [ | |
292 | - { label: '=', value: '0' }, | |
293 | - { label: '<', value: '1' }, | |
294 | - { label: '>', value: '2' }, | |
295 | - { label: '<=', value: '3' }, | |
296 | - { label: '>=', value: '4' }, | |
297 | - ], | |
298 | - }, | |
299 | - ifShow: ({ values }) => | |
300 | - isShiDu(Reflect.get(values, 'property')) && !isTimeAll(Reflect.get(values, 'status')), | |
301 | - colProps: { span: 12 }, | |
302 | - }, | |
303 | - '' | |
304 | - ); | |
305 | - appendSchemaByField( | |
306 | - { | |
307 | - field: `value${n.value}`, | |
308 | - component: 'Input', | |
309 | - label: '', | |
310 | - componentProps: { | |
311 | - placeholder: '请输入比较值', | |
312 | - }, | |
313 | - ifShow: ({ values }) => | |
314 | - isShiDu(Reflect.get(values, 'property')) && !isTimeAll(Reflect.get(values, 'status')), | |
315 | - colProps: { | |
316 | - span: 12, | |
317 | - }, | |
318 | - }, | |
319 | - '' | |
320 | - ); | |
321 | - | |
322 | - appendSchemaByField( | |
323 | - { | |
324 | - field: `compareWendu${n.value}`, | |
325 | - label: '', | |
326 | - component: 'Select', | |
327 | - componentProps: { | |
328 | - placeholder: '', | |
329 | - options: [ | |
330 | - { label: '=', value: '0' }, | |
331 | - { label: '<', value: '1' }, | |
332 | - { label: '>', value: '2' }, | |
333 | - { label: '<=', value: '3' }, | |
334 | - { label: '>=', value: '4' }, | |
335 | - ], | |
336 | - }, | |
337 | - ifShow: ({ values }) => | |
338 | - isShiDu(Reflect.get(values, 'property')) && !isTimeAll(Reflect.get(values, 'status')), | |
339 | - colProps: { span: 12 }, | |
340 | - }, | |
341 | - '' | |
342 | - ); | |
343 | - appendSchemaByField( | |
344 | - { | |
345 | - field: `valueWendu${n.value}`, | |
346 | - component: 'Input', | |
347 | - label: '', | |
348 | - componentProps: { | |
349 | - placeholder: '请输入比较值', | |
350 | - }, | |
351 | - ifShow: ({ values }) => | |
352 | - isShiDu(Reflect.get(values, 'property')) && !isTimeAll(Reflect.get(values, 'status')), | |
353 | - colProps: { | |
354 | - span: 12, | |
355 | - }, | |
356 | - }, | |
357 | - '' | |
358 | - ); | |
359 | - | |
360 | - appendSchemaByField( | |
361 | - { | |
362 | - field: `${n.value}`, | |
363 | - component: 'Input', | |
364 | - label: ' ', | |
365 | - colProps: { | |
366 | - span: 12, | |
367 | - }, | |
368 | - slot: 'add', | |
369 | - }, | |
370 | - '' | |
371 | - ); | |
372 | - n.value++; | |
373 | - } | |
374 | - function del(field) { | |
375 | - addHideButton.value--; | |
376 | - if (addHideButton.value == 2) { | |
377 | - setTimeout(() => { | |
378 | - let getDom1 = document.getElementById('1') as HTMLElement; | |
379 | - getDom1.style.display = 'flex'; | |
380 | - }, 500); | |
381 | - } | |
382 | - if (addHideButton.value == 3) { | |
383 | - setTimeout(() => { | |
384 | - let getDom2 = document.getElementById('2') as HTMLElement; | |
385 | - getDom2.style.display = 'flex'; | |
386 | - let getDom21 = document.getElementById('1') as HTMLElement; | |
387 | - getDom21.style.display = 'none'; | |
388 | - }, 500); | |
389 | - } | |
390 | - if (addHideButton.value == 4) { | |
391 | - setTimeout(() => { | |
392 | - let getDom3 = document.getElementById('3') as HTMLElement; | |
393 | - getDom3.style.display = 'flex'; | |
394 | - let getDom31 = document.getElementById('1') as HTMLElement; | |
395 | - getDom31.style.display = 'none'; | |
396 | - let getDom32 = document.getElementById('2') as HTMLElement; | |
397 | - getDom32.style.display = 'none'; | |
398 | - }, 500); | |
399 | - } | |
400 | - if (addHideButton.value == 5) { | |
401 | - setTimeout(() => { | |
402 | - let getDom4 = document.getElementById('4') as HTMLElement; | |
403 | - getDom4.style.display = 'flex'; | |
404 | - let getDom41 = document.getElementById('1') as HTMLElement; | |
405 | - getDom41.style.display = 'none'; | |
406 | - let getDom42 = document.getElementById('2') as HTMLElement; | |
407 | - getDom42.style.display = 'none'; | |
408 | - let getDom43 = document.getElementById('3') as HTMLElement; | |
409 | - getDom43.style.display = 'none'; | |
410 | - }, 500); | |
411 | - } | |
412 | - if (addHideButton.value == 6) { | |
413 | - setTimeout(() => { | |
414 | - let getDom5 = document.getElementById('5') as HTMLElement; | |
415 | - getDom5.style.display = 'flex'; | |
416 | - let getDom51 = document.getElementById('1') as HTMLElement; | |
417 | - getDom51.style.display = 'none'; | |
418 | - let getDom52 = document.getElementById('2') as HTMLElement; | |
419 | - getDom52.style.display = 'none'; | |
420 | - let getDom53 = document.getElementById('3') as HTMLElement; | |
421 | - getDom53.style.display = 'none'; | |
422 | - let getDom54 = document.getElementById('4') as HTMLElement; | |
423 | - getDom54.style.display = 'none'; | |
424 | - }, 500); | |
425 | - } | |
426 | - if (addHideButton.value == 7) { | |
427 | - setTimeout(() => { | |
428 | - let getDom7 = document.getElementById('6') as HTMLElement; | |
429 | - getDom7.style.display = 'flex'; | |
430 | - let getDom71 = document.getElementById('1') as HTMLElement; | |
431 | - getDom71.style.display = 'none'; | |
432 | - let getDom72 = document.getElementById('2') as HTMLElement; | |
433 | - getDom72.style.display = 'none'; | |
434 | - let getDom73 = document.getElementById('3') as HTMLElement; | |
435 | - getDom73.style.display = 'none'; | |
436 | - let getDom74 = document.getElementById('4') as HTMLElement; | |
437 | - getDom74.style.display = 'none'; | |
438 | - let getDom75 = document.getElementById('5') as HTMLElement; | |
439 | - getDom75.style.display = 'none'; | |
440 | - }, 500); | |
441 | - } | |
442 | - removeSchemaByFiled([ | |
443 | - `kong${field}`, | |
444 | - `status${field}`, | |
445 | - `deviceId${field}`, | |
446 | - `createTime${field}`, | |
447 | - `updateTime${field}`, | |
448 | - `property${field}`, | |
449 | - `wu${field}`, | |
450 | - `compare${field}`, | |
451 | - `value${field}`, | |
452 | - `compareWendu${field}`, | |
453 | - `valueWendu${field}`, | |
454 | - `${field}`, | |
455 | - ]); | |
456 | - n.value--; | |
457 | - } | |
458 | 69 | return { |
459 | - addHideButton, | |
460 | - editSelectDevice, | |
461 | 70 | clearSelectDevice, |
462 | - setFieldsFormValue, | |
71 | + editSelectDevice, | |
72 | + getFieldsValueFunc, | |
463 | 73 | registerCondition, |
464 | - add, | |
465 | - del, | |
466 | - getAllFields, | |
467 | - funcResetFields, | |
468 | 74 | }; |
469 | 75 | }, |
470 | 76 | }); | ... | ... |
... | ... | @@ -7,29 +7,7 @@ |
7 | 7 | :showSubmitButton="false" |
8 | 8 | :emptySpan="10" |
9 | 9 | @register="registerAction" |
10 | - > | |
11 | - <template #add="{ field }"> | |
12 | - <Button | |
13 | - style="margin-left: -99px; margin-top: 5px; display: inline-block" | |
14 | - v-if="Number(field) === 0" | |
15 | - :style="addHideButton > 1 ? 'display:none' : 'display:inline-block'" | |
16 | - @click="add" | |
17 | - type="primary" | |
18 | - >+新增执行动作</Button | |
19 | - > | |
20 | - <br /> | |
21 | - <Button | |
22 | - style="margin-left: -98px; margin-top: -5px" | |
23 | - v-if="field > 0" | |
24 | - @click="add" | |
25 | - type="primary" | |
26 | - >+新增执行动作</Button | |
27 | - > | |
28 | - <Button style="margin-left: 10px" v-if="field > 0" @click="del(field)" type="primary" | |
29 | - >删除</Button | |
30 | - > | |
31 | - </template> | |
32 | - </BasicForm> | |
10 | + /> | |
33 | 11 | </div> |
34 | 12 | </CollapseContainer> |
35 | 13 | </template> |
... | ... | @@ -38,40 +16,27 @@ |
38 | 16 | import { CollapseContainer } from '/@/components/Container/index'; |
39 | 17 | import { BasicForm, useForm } from '/@/components/Form/index'; |
40 | 18 | import { Input } from 'ant-design-vue'; |
41 | - import { Button } from '/@/components/Button'; | |
42 | - import { useActionDrawerSchema, isMsg, isScene } from '../config.d'; | |
19 | + import { useActionDrawerSchema } from '../config'; | |
43 | 20 | import { screenLinkPageByDeptIdGetDevice } from '/@/api/ruleengine/ruleengineApi'; |
44 | 21 | |
45 | 22 | export default defineComponent({ |
46 | - components: { CollapseContainer, BasicForm, [Input.name]: Input, Button }, | |
47 | - // eslint-disable-next-line vue/require-prop-types | |
23 | + components: { CollapseContainer, BasicForm, [Input.name]: Input }, | |
48 | 24 | props: ['deviceInfo2'], |
49 | - emits: ['eDoactionGetAddPushValueData'], | |
50 | - setup(props, { emit }) { | |
51 | - const addHideButton = ref(1); | |
52 | - const getAddPushValueData: any = ref([]); | |
53 | 25 | |
54 | - const [ | |
55 | - registerAction, | |
56 | - { | |
57 | - setFieldsValue, | |
58 | - resetFields, | |
59 | - updateSchema, | |
60 | - appendSchemaByField, | |
61 | - getFieldsValue, | |
62 | - removeSchemaByFiled, | |
63 | - }, | |
64 | - ] = useForm({ | |
26 | + setup(props) { | |
27 | + const fieldValue: any = ref({}); | |
28 | + const [registerAction, { getFieldsValue, resetFields, updateSchema }] = useForm({ | |
65 | 29 | labelWidth: 100, |
66 | 30 | schemas: useActionDrawerSchema, |
67 | 31 | actionColOptions: { span: 24 }, |
68 | 32 | }); |
69 | - let isJudge = ref(1); | |
70 | - if (isJudge.value == 1) { | |
71 | - setTimeout(() => { | |
72 | - resetFields(); | |
73 | - }, 1000); | |
74 | - } | |
33 | + const getFieldsValueFunc = () => { | |
34 | + fieldValue.value = getFieldsValue(); | |
35 | + return fieldValue.value; | |
36 | + }; | |
37 | + const resetFieldsValueFunc = () => { | |
38 | + resetFields(); | |
39 | + }; | |
75 | 40 | watch( |
76 | 41 | () => props.deviceInfo2, |
77 | 42 | async (newV) => { |
... | ... | @@ -87,20 +52,6 @@ |
87 | 52 | }); |
88 | 53 | } |
89 | 54 | ); |
90 | - //回显数据 | |
91 | - const setFieldsFormValue = (v) => { | |
92 | - setFieldsValue(v); | |
93 | - }; | |
94 | - const getAllFields = (getV: any) => { | |
95 | - getV = { | |
96 | - data: getFieldsValue(), | |
97 | - count: 1, | |
98 | - }; | |
99 | - return getV; | |
100 | - }; | |
101 | - function funcResetFields() { | |
102 | - resetFields(); | |
103 | - } | |
104 | 55 | //新增清空设备选择 |
105 | 56 | const clearSelectDevice = () => { |
106 | 57 | updateSchema({ |
... | ... | @@ -118,319 +69,12 @@ |
118 | 69 | }, |
119 | 70 | }); |
120 | 71 | }; |
121 | - const n = ref(1); | |
122 | - function add() { | |
123 | - const pushValue = getFieldsValue(); | |
124 | - | |
125 | - getAddPushValueData.value.push(pushValue); | |
126 | - emit('eDoactionGetAddPushValueData', { | |
127 | - data: getAddPushValueData.value, | |
128 | - count: 2, | |
129 | - }); | |
130 | - addHideButton.value++; | |
131 | - if (addHideButton.value == 3) { | |
132 | - setTimeout(() => { | |
133 | - let getDom1 = document.getElementById('1') as HTMLElement; | |
134 | - getDom1.style.display = 'none'; | |
135 | - }, 500); | |
136 | - } | |
137 | - if (addHideButton.value == 4) { | |
138 | - setTimeout(() => { | |
139 | - let getDom2 = document.getElementById('2') as HTMLElement; | |
140 | - getDom2.style.display = 'none'; | |
141 | - let getDom41 = document.getElementById('1') as HTMLElement; | |
142 | - getDom41.style.display = 'none'; | |
143 | - }, 500); | |
144 | - } | |
145 | - if (addHideButton.value == 5) { | |
146 | - setTimeout(() => { | |
147 | - let getDom3 = document.getElementById('3') as HTMLElement; | |
148 | - getDom3.style.display = 'none'; | |
149 | - let getDom51 = document.getElementById('1') as HTMLElement; | |
150 | - getDom51.style.display = 'none'; | |
151 | - let getDom52 = document.getElementById('2') as HTMLElement; | |
152 | - getDom52.style.display = 'none'; | |
153 | - }, 500); | |
154 | - } | |
155 | - if (addHideButton.value == 6) { | |
156 | - setTimeout(() => { | |
157 | - let getDom4 = document.getElementById('4') as HTMLElement; | |
158 | - getDom4.style.display = 'none'; | |
159 | - let getDom61 = document.getElementById('1') as HTMLElement; | |
160 | - getDom61.style.display = 'none'; | |
161 | - let getDom62 = document.getElementById('2') as HTMLElement; | |
162 | - getDom62.style.display = 'none'; | |
163 | - let getDom63 = document.getElementById('3') as HTMLElement; | |
164 | - getDom63.style.display = 'none'; | |
165 | - }, 500); | |
166 | - } | |
167 | - if (addHideButton.value == 7) { | |
168 | - setTimeout(() => { | |
169 | - let getDom7 = document.getElementById('5') as HTMLElement; | |
170 | - getDom7.style.display = 'none'; | |
171 | - let getDom71 = document.getElementById('1') as HTMLElement; | |
172 | - getDom71.style.display = 'none'; | |
173 | - let getDom72 = document.getElementById('2') as HTMLElement; | |
174 | - getDom72.style.display = 'none'; | |
175 | - let getDom73 = document.getElementById('3') as HTMLElement; | |
176 | - getDom73.style.display = 'none'; | |
177 | - let getDom74 = document.getElementById('4') as HTMLElement; | |
178 | - getDom74.style.display = 'none'; | |
179 | - }, 500); | |
180 | - } | |
181 | - | |
182 | - appendSchemaByField( | |
183 | - { | |
184 | - field: `kong${n.value}`, | |
185 | - label: `执行动作${n.value + 1 + `.......`}`, | |
186 | - component: 'Slider', | |
187 | - colProps: { span: 24 }, | |
188 | - }, | |
189 | - '' | |
190 | - ); | |
191 | - appendSchemaByField( | |
192 | - { | |
193 | - field: `outTarget${n.value}`, | |
194 | - label: '', | |
195 | - component: 'Select', | |
196 | - componentProps: { | |
197 | - placeholder: '设备输出', | |
198 | - options: [ | |
199 | - { label: '设备输出', value: 'DEVICE_OUT' }, | |
200 | - { label: '消息通知', value: 'MSG_NOTIFY' }, | |
201 | - { label: '场景联动', value: 'SCENE_ACT' }, | |
202 | - ], | |
203 | - }, | |
204 | - colProps: { span: 12 }, | |
205 | - }, | |
206 | - '' | |
207 | - ); | |
208 | - appendSchemaByField( | |
209 | - { | |
210 | - field: `deviceId${n.value}`, | |
211 | - label: '', | |
212 | - component: 'Select', | |
213 | - componentProps: { | |
214 | - placeholder: '请选择设备', | |
215 | - }, | |
216 | - ifShow: ({ values }) => | |
217 | - !isScene(Reflect.get(values, 'outTarget')) && | |
218 | - !isMsg(Reflect.get(values, 'outTarget')), | |
219 | - colProps: { | |
220 | - span: 12, | |
221 | - }, | |
222 | - }, | |
223 | - '' | |
224 | - ); | |
225 | - appendSchemaByField( | |
226 | - { | |
227 | - field: `command${n.value}`, | |
228 | - component: 'Input', | |
229 | - label: '', | |
230 | - componentProps: { | |
231 | - placeholder: '请输入下发指定', | |
232 | - }, | |
233 | - ifShow: ({ values }) => | |
234 | - !isScene(Reflect.get(values, 'outTarget')) && | |
235 | - !isMsg(Reflect.get(values, 'outTarget')), | |
236 | - colProps: { | |
237 | - span: 12, | |
238 | - }, | |
239 | - }, | |
240 | - '' | |
241 | - ); | |
242 | - appendSchemaByField( | |
243 | - { | |
244 | - field: `wu1${n.value}`, | |
245 | - label: '', | |
246 | - component: 'Input', | |
247 | - componentProps: { | |
248 | - placeholder: '无', | |
249 | - style: { | |
250 | - visibility: 'hidden', | |
251 | - }, | |
252 | - }, | |
253 | - colProps: { span: 12 }, | |
254 | - }, | |
255 | - '' | |
256 | - ); | |
257 | - appendSchemaByField( | |
258 | - { | |
259 | - field: `wu2${n.value}`, | |
260 | - component: 'Input', | |
261 | - label: '', | |
262 | - componentProps: { | |
263 | - placeholder: '暂不实现', | |
264 | - }, | |
265 | - colProps: { | |
266 | - span: 12, | |
267 | - }, | |
268 | - ifShow: ({ values }) => isMsg(Reflect.get(values, 'outTarget')), | |
269 | - }, | |
270 | - '' | |
271 | - ); | |
272 | - appendSchemaByField( | |
273 | - { | |
274 | - field: 'wu3', | |
275 | - label: '', | |
276 | - component: 'Input', | |
277 | - componentProps: { | |
278 | - placeholder: '无', | |
279 | - style: { | |
280 | - visibility: 'hidden', | |
281 | - }, | |
282 | - }, | |
283 | - colProps: { span: 12 }, | |
284 | - ifShow: ({ values }) => isMsg(Reflect.get(values, 'outTarget')), | |
285 | - }, | |
286 | - '' | |
287 | - ); | |
288 | - appendSchemaByField( | |
289 | - { | |
290 | - field: `sceneLinkageId${n.value}`, | |
291 | - label: '', | |
292 | - component: 'ApiSelect', | |
293 | - colProps: { | |
294 | - span: 12, | |
295 | - }, | |
296 | - componentProps: { | |
297 | - placeholder: '请选择场景触发器', | |
298 | - options: [ | |
299 | - { label: '场景触发器1', value: '1' }, | |
300 | - { label: '场景触发器2', value: '2' }, | |
301 | - { label: '场景触发器3', value: '3' }, | |
302 | - { label: '场景触发器4', value: '4' }, | |
303 | - ], | |
304 | - }, | |
305 | - ifShow: ({ values }) => isScene(Reflect.get(values, 'outTarget')), | |
306 | - }, | |
307 | - '' | |
308 | - ); | |
309 | - appendSchemaByField( | |
310 | - { | |
311 | - field: 'wu4', | |
312 | - label: '', | |
313 | - component: 'Input', | |
314 | - componentProps: { | |
315 | - placeholder: '无', | |
316 | - style: { | |
317 | - visibility: 'hidden', | |
318 | - }, | |
319 | - }, | |
320 | - colProps: { span: 12 }, | |
321 | - ifShow: ({ values }) => isScene(Reflect.get(values, 'outTarget')), | |
322 | - }, | |
323 | - '' | |
324 | - ); | |
325 | - | |
326 | - appendSchemaByField( | |
327 | - { | |
328 | - field: `${n.value}`, | |
329 | - component: 'Input', | |
330 | - label: ' ', | |
331 | - colProps: { | |
332 | - span: 12, | |
333 | - }, | |
334 | - slot: 'add', | |
335 | - }, | |
336 | - '' | |
337 | - ); | |
338 | - n.value++; | |
339 | - } | |
340 | - | |
341 | - function del(field) { | |
342 | - addHideButton.value--; | |
343 | - if (addHideButton.value == 2) { | |
344 | - setTimeout(() => { | |
345 | - let getDom1 = document.getElementById('1') as HTMLElement; | |
346 | - getDom1.style.display = 'flex'; | |
347 | - }, 500); | |
348 | - } | |
349 | - if (addHideButton.value == 3) { | |
350 | - setTimeout(() => { | |
351 | - let getDom2 = document.getElementById('2') as HTMLElement; | |
352 | - getDom2.style.display = 'flex'; | |
353 | - let getDom21 = document.getElementById('1') as HTMLElement; | |
354 | - getDom21.style.display = 'none'; | |
355 | - }, 500); | |
356 | - } | |
357 | - if (addHideButton.value == 4) { | |
358 | - setTimeout(() => { | |
359 | - let getDom3 = document.getElementById('3') as HTMLElement; | |
360 | - getDom3.style.display = 'flex'; | |
361 | - let getDom31 = document.getElementById('1') as HTMLElement; | |
362 | - getDom31.style.display = 'none'; | |
363 | - let getDom32 = document.getElementById('2') as HTMLElement; | |
364 | - getDom32.style.display = 'none'; | |
365 | - }, 500); | |
366 | - } | |
367 | - if (addHideButton.value == 5) { | |
368 | - setTimeout(() => { | |
369 | - let getDom4 = document.getElementById('4') as HTMLElement; | |
370 | - getDom4.style.display = 'flex'; | |
371 | - let getDom41 = document.getElementById('1') as HTMLElement; | |
372 | - getDom41.style.display = 'none'; | |
373 | - let getDom42 = document.getElementById('2') as HTMLElement; | |
374 | - getDom42.style.display = 'none'; | |
375 | - let getDom43 = document.getElementById('3') as HTMLElement; | |
376 | - getDom43.style.display = 'none'; | |
377 | - }, 500); | |
378 | - } | |
379 | - if (addHideButton.value == 6) { | |
380 | - setTimeout(() => { | |
381 | - let getDom5 = document.getElementById('5') as HTMLElement; | |
382 | - getDom5.style.display = 'flex'; | |
383 | - let getDom51 = document.getElementById('1') as HTMLElement; | |
384 | - getDom51.style.display = 'none'; | |
385 | - let getDom52 = document.getElementById('2') as HTMLElement; | |
386 | - getDom52.style.display = 'none'; | |
387 | - let getDom53 = document.getElementById('3') as HTMLElement; | |
388 | - getDom53.style.display = 'none'; | |
389 | - let getDom54 = document.getElementById('4') as HTMLElement; | |
390 | - getDom54.style.display = 'none'; | |
391 | - }, 500); | |
392 | - } | |
393 | - if (addHideButton.value == 7) { | |
394 | - setTimeout(() => { | |
395 | - let getDom7 = document.getElementById('6') as HTMLElement; | |
396 | - getDom7.style.display = 'flex'; | |
397 | - let getDom71 = document.getElementById('1') as HTMLElement; | |
398 | - getDom71.style.display = 'none'; | |
399 | - let getDom72 = document.getElementById('2') as HTMLElement; | |
400 | - getDom72.style.display = 'none'; | |
401 | - let getDom73 = document.getElementById('3') as HTMLElement; | |
402 | - getDom73.style.display = 'none'; | |
403 | - let getDom74 = document.getElementById('4') as HTMLElement; | |
404 | - getDom74.style.display = 'none'; | |
405 | - let getDom75 = document.getElementById('5') as HTMLElement; | |
406 | - getDom75.style.display = 'none'; | |
407 | - }, 500); | |
408 | - } | |
409 | - removeSchemaByFiled([ | |
410 | - `kong${field}`, | |
411 | - `outTarget${field}`, | |
412 | - `deviceId${field}`, | |
413 | - `command${field}`, | |
414 | - `wu1${field}`, | |
415 | - `wu2${field}`, | |
416 | - `wu3${field}`, | |
417 | - `sceneLinkageId${field}`, | |
418 | - `wu4${field}`, | |
419 | - `${field}`, | |
420 | - ]); | |
421 | - n.value--; | |
422 | - } | |
423 | - | |
424 | 72 | return { |
425 | - addHideButton, | |
426 | - editSelectDevice, | |
427 | 73 | clearSelectDevice, |
428 | - setFieldsFormValue, | |
74 | + editSelectDevice, | |
75 | + resetFieldsValueFunc, | |
76 | + getFieldsValueFunc, | |
429 | 77 | registerAction, |
430 | - add, | |
431 | - del, | |
432 | - getAllFields, | |
433 | - funcResetFields, | |
434 | 78 | }; |
435 | 79 | }, |
436 | 80 | }); | ... | ... |
1 | -/* eslint-disable vue/require-prop-types */ | |
2 | 1 | <template> |
3 | 2 | <div> |
4 | 3 | <CollapseContainer title="触发器" style="background-color: #eeeeee"> |
5 | - <div style="position: relative"> | |
4 | + <div> | |
6 | 5 | <BasicForm |
7 | 6 | :labelWidth="100" |
8 | 7 | :showResetButton="false" |
9 | 8 | :showSubmitButton="false" |
10 | 9 | :emptySpan="10" |
11 | 10 | @register="registerTrigger" |
12 | - > | |
13 | - <template #add="{ field }"> | |
14 | - <Button | |
15 | - style="margin-left: -99px; margin-top: 0px; display: inline-block" | |
16 | - :style="addHideButton > 1 ? 'display:none' : 'display:inline-block'" | |
17 | - v-if="Number(field) === 0" | |
18 | - @click="add" | |
19 | - type="primary" | |
20 | - >+新增触发器</Button | |
21 | - > | |
22 | - <Button | |
23 | - v-if="Number(field) > 0" | |
24 | - style="margin-left: 5px; margin-top: 35px" | |
25 | - @click="add" | |
26 | - type="primary" | |
27 | - >+新增触发器</Button | |
28 | - > | |
29 | - <Button | |
30 | - v-if="Number(field) > 0" | |
31 | - style="margin-left: 10px" | |
32 | - @click="del(field)" | |
33 | - type="primary" | |
34 | - >删除</Button | |
35 | - > | |
36 | - </template> | |
37 | - </BasicForm> | |
11 | + /> | |
38 | 12 | </div> |
39 | 13 | </CollapseContainer> |
40 | 14 | </div> |
... | ... | @@ -44,52 +18,29 @@ |
44 | 18 | import { CollapseContainer } from '/@/components/Container/index'; |
45 | 19 | import { BasicForm, useForm } from '/@/components/Form/index'; |
46 | 20 | import { Input } from 'ant-design-vue'; |
47 | - import { Button } from '/@/components/Button'; | |
48 | - import { | |
49 | - useTriggerDrawerSchema, | |
50 | - isTime, | |
51 | - isUpAndDown, | |
52 | - isWenDu, | |
53 | - isScene, | |
54 | - isHand, | |
55 | - } from '../config.d'; | |
21 | + import { useTriggerDrawerSchema } from '../config'; | |
56 | 22 | import { screenLinkPageByDeptIdGetDevice } from '/@/api/ruleengine/ruleengineApi'; |
57 | 23 | |
58 | 24 | export default defineComponent({ |
59 | - components: { CollapseContainer, BasicForm, [Input.name]: Input, Button }, | |
60 | - // eslint-disable-next-line vue/require-prop-types | |
25 | + components: { CollapseContainer, BasicForm, [Input.name]: Input }, | |
61 | 26 | props: ['deviceInfo'], |
62 | - emits: ['eGetAddPushValueData'], | |
63 | - setup(props, { emit }) { | |
64 | - const getPushValueData: any = ref([]); | |
65 | - const addHideButton = ref(1); | |
66 | - const addHideButtonTemp: any = ref(null); | |
67 | - const getAddPushValueData: any = ref([]); | |
68 | - const [ | |
69 | - registerTrigger, | |
70 | - { | |
71 | - setFieldsValue, | |
72 | - resetFields, | |
73 | - appendSchemaByField, | |
74 | - removeSchemaByFiled, | |
75 | - getFieldsValue, | |
76 | - updateSchema, | |
77 | - }, | |
78 | - ] = useForm({ | |
27 | + setup(props) { | |
28 | + const fieldValue: any = ref({}); | |
29 | + const [registerTrigger, { getFieldsValue, updateSchema }] = useForm({ | |
79 | 30 | labelWidth: 100, |
80 | 31 | schemas: useTriggerDrawerSchema, |
81 | 32 | actionColOptions: { span: 24 }, |
82 | 33 | }); |
83 | - let isJudge = ref(1); | |
84 | - if (isJudge.value == 1) { | |
85 | - setTimeout(() => { | |
86 | - resetFields(); | |
87 | - }, 1000); | |
88 | - } | |
34 | + const getFieldsValueFunc = () => { | |
35 | + fieldValue.value = getFieldsValue(); | |
36 | + return fieldValue.value; | |
37 | + }; | |
89 | 38 | watch( |
90 | 39 | () => props.deviceInfo, |
91 | 40 | async (newV) => { |
41 | + console.log(newV); | |
92 | 42 | const options = await screenLinkPageByDeptIdGetDevice({ organizationId: newV }); |
43 | + console.log(options); | |
93 | 44 | options.items.forEach((v) => { |
94 | 45 | return (v.value = v.id), (v.label = v.name); |
95 | 46 | }); |
... | ... | @@ -101,10 +52,6 @@ |
101 | 52 | }); |
102 | 53 | } |
103 | 54 | ); |
104 | - //回显数据 | |
105 | - const setFieldsFormValue = (v) => { | |
106 | - setFieldsValue(v); | |
107 | - }; | |
108 | 55 | //新增清空设备选择 |
109 | 56 | const clearSelectDevice = () => { |
110 | 57 | updateSchema({ |
... | ... | @@ -122,440 +69,11 @@ |
122 | 69 | }, |
123 | 70 | }); |
124 | 71 | }; |
125 | - const clearGetPushValueDataEmpty = () => { | |
126 | - getPushValueData.value.length = 0; | |
127 | - }; | |
128 | - | |
129 | - const getAllFields = (getV: any) => { | |
130 | - getV = { | |
131 | - data: getFieldsValue(), | |
132 | - count: 1, | |
133 | - }; | |
134 | - return getV; | |
135 | - }; | |
136 | - async function funcResetFields() { | |
137 | - await resetFields(); | |
138 | - } | |
139 | - const addString: any = ref('tiggerEvent1') || ref('tiggerEvent2') || ref('tiggerEvent3'); | |
140 | - | |
141 | - const n = ref(1); | |
142 | - const clearAddTriggerStatusFunc = () => { | |
143 | - // addHideButton.value = 1; | |
144 | - }; | |
145 | - const addClearGetAddPushValueDataArrayIsEmpty = () => { | |
146 | - getAddPushValueData.value = []; | |
147 | - }; | |
148 | - function add() { | |
149 | - const pushValue = getFieldsValue(); | |
150 | - getAddPushValueData.value.push(pushValue); | |
151 | - emit('eGetAddPushValueData', { | |
152 | - data: getAddPushValueData.value, | |
153 | - count: 2, | |
154 | - }); | |
155 | - addHideButton.value++; | |
156 | - addHideButtonTemp.value = addHideButton.value; | |
157 | - addHideButtonTemp.value -= 2; | |
158 | - if (addHideButton.value == 3) { | |
159 | - setTimeout(() => { | |
160 | - let getDom1 = document.getElementById('1') as HTMLElement; | |
161 | - getDom1.style.display = 'none'; | |
162 | - }, 500); | |
163 | - } | |
164 | - if (addHideButton.value == 4) { | |
165 | - setTimeout(() => { | |
166 | - let getDom2 = document.getElementById('2') as HTMLElement; | |
167 | - getDom2.style.display = 'none'; | |
168 | - let getDom41 = document.getElementById('1') as HTMLElement; | |
169 | - getDom41.style.display = 'none'; | |
170 | - }, 500); | |
171 | - } | |
172 | - if (addHideButton.value == 5) { | |
173 | - setTimeout(() => { | |
174 | - let getDom3 = document.getElementById('3') as HTMLElement; | |
175 | - getDom3.style.display = 'none'; | |
176 | - let getDom51 = document.getElementById('1') as HTMLElement; | |
177 | - getDom51.style.display = 'none'; | |
178 | - let getDom52 = document.getElementById('2') as HTMLElement; | |
179 | - getDom52.style.display = 'none'; | |
180 | - }, 500); | |
181 | - } | |
182 | - if (addHideButton.value == 6) { | |
183 | - setTimeout(() => { | |
184 | - let getDom4 = document.getElementById('4') as HTMLElement; | |
185 | - getDom4.style.display = 'none'; | |
186 | - let getDom61 = document.getElementById('1') as HTMLElement; | |
187 | - getDom61.style.display = 'none'; | |
188 | - let getDom62 = document.getElementById('2') as HTMLElement; | |
189 | - getDom62.style.display = 'none'; | |
190 | - let getDom63 = document.getElementById('3') as HTMLElement; | |
191 | - getDom63.style.display = 'none'; | |
192 | - }, 500); | |
193 | - } | |
194 | - if (addHideButton.value == 7) { | |
195 | - setTimeout(() => { | |
196 | - let getDom7 = document.getElementById('5') as HTMLElement; | |
197 | - getDom7.style.display = 'none'; | |
198 | - let getDom71 = document.getElementById('1') as HTMLElement; | |
199 | - getDom71.style.display = 'none'; | |
200 | - let getDom72 = document.getElementById('2') as HTMLElement; | |
201 | - getDom72.style.display = 'none'; | |
202 | - let getDom73 = document.getElementById('3') as HTMLElement; | |
203 | - getDom73.style.display = 'none'; | |
204 | - let getDom74 = document.getElementById('4') as HTMLElement; | |
205 | - getDom74.style.display = 'none'; | |
206 | - }, 500); | |
207 | - } | |
208 | - if (addHideButton.value == 8) { | |
209 | - setTimeout(() => { | |
210 | - let getDom8 = document.getElementById('6') as HTMLElement; | |
211 | - getDom8.style.display = 'none'; | |
212 | - let getDom81 = document.getElementById('1') as HTMLElement; | |
213 | - getDom81.style.display = 'none'; | |
214 | - let getDom82 = document.getElementById('2') as HTMLElement; | |
215 | - getDom82.style.display = 'none'; | |
216 | - let getDom83 = document.getElementById('3') as HTMLElement; | |
217 | - getDom83.style.display = 'none'; | |
218 | - let getDom84 = document.getElementById('4') as HTMLElement; | |
219 | - getDom84.style.display = 'none'; | |
220 | - let getDom85 = document.getElementById('5') as HTMLElement; | |
221 | - getDom85.style.display = 'none'; | |
222 | - }, 500); | |
223 | - } | |
224 | - | |
225 | - appendSchemaByField( | |
226 | - { | |
227 | - field: `kong${n.value}`, | |
228 | - label: `触发器${n.value + 1 + `...........`}`, | |
229 | - component: 'Slider', | |
230 | - colProps: { span: 24 }, | |
231 | - }, | |
232 | - '' | |
233 | - ); | |
234 | - appendSchemaByField( | |
235 | - { | |
236 | - field: `tiggerEvent${n.value}`, | |
237 | - label: '', | |
238 | - component: 'Select', | |
239 | - componentProps: { | |
240 | - placeholder: '设备触发', | |
241 | - options: [ | |
242 | - { label: '设备触发', value: 'DEVICE_ACT' }, | |
243 | - { label: '定时触发', value: 'TIME_ACT' }, | |
244 | - { label: '场景触发', value: 'SCENE_ACT' }, | |
245 | - { label: '手动触发', value: 'HAND_ACT' }, | |
246 | - ], | |
247 | - }, | |
248 | - colProps: { span: 12 }, | |
249 | - }, | |
250 | - '' | |
251 | - ); | |
252 | - appendSchemaByField( | |
253 | - { | |
254 | - field: `deviceId${n.value}`, | |
255 | - label: '', | |
256 | - component: 'Select', | |
257 | - componentProps: { | |
258 | - placeholder: '请选择设备', | |
259 | - }, | |
260 | - ifShow: ({ values }) => | |
261 | - !isTime(Reflect.get(values, addString.value)) && | |
262 | - !isScene(Reflect.get(values, addString.value)) && | |
263 | - !isHand(Reflect.get(values, addString.value)), | |
264 | - colProps: { | |
265 | - span: 12, | |
266 | - }, | |
267 | - }, | |
268 | - '' | |
269 | - ); | |
270 | - appendSchemaByField( | |
271 | - { | |
272 | - field: `no1${n.value}`, | |
273 | - component: 'Input', | |
274 | - label: '', | |
275 | - componentProps: { | |
276 | - placeholder: '请输入Cron表达式', | |
277 | - }, | |
278 | - colProps: { | |
279 | - span: 12, | |
280 | - }, | |
281 | - ifShow: ({ values }) => isTime(Reflect.get(values, addString.value)), | |
282 | - }, | |
283 | - '' | |
284 | - ); | |
285 | - appendSchemaByField( | |
286 | - { | |
287 | - field: `touchWay${n.value}`, | |
288 | - label: '', | |
289 | - component: 'Select', | |
290 | - componentProps: { | |
291 | - placeholder: '属性触发', | |
292 | - options: [ | |
293 | - { label: '属性触发', value: 'ATTRIBUTE_ACT' }, | |
294 | - { label: '上下线触发', value: 'UP_DOWN_ACT' }, | |
295 | - ], | |
296 | - }, | |
297 | - ifShow: ({ values }) => | |
298 | - !isTime(Reflect.get(values, addString.value)) && | |
299 | - !isScene(Reflect.get(values, addString.value)) && | |
300 | - !isHand(Reflect.get(values, addString.value)), | |
301 | - colProps: { span: 12 }, | |
302 | - }, | |
303 | - '' | |
304 | - ); | |
305 | - appendSchemaByField( | |
306 | - { | |
307 | - field: `no2${n.value}`, | |
308 | - label: '', | |
309 | - component: 'Select', | |
310 | - componentProps: { | |
311 | - placeholder: '请选择上下线', | |
312 | - options: [ | |
313 | - { label: '上下线', value: '1' }, | |
314 | - { label: '上线', value: '2' }, | |
315 | - { label: '下线', value: '3' }, | |
316 | - ], | |
317 | - }, | |
318 | - colProps: { span: 12 }, | |
319 | - ifShow: ({ values }) => | |
320 | - isUpAndDown(Reflect.get(values, `touchWay${n.value}`)) && | |
321 | - !isTime(Reflect.get(values, addString.value)) && | |
322 | - !isScene(Reflect.get(values, addString.value)) && | |
323 | - !isHand(Reflect.get(values, addString.value)), | |
324 | - }, | |
325 | - '' | |
326 | - ); | |
327 | - appendSchemaByField( | |
328 | - { | |
329 | - field: `attributeChoose${n.value}`, | |
330 | - label: '', | |
331 | - component: 'Select', | |
332 | - componentProps: { | |
333 | - placeholder: '全部属性', | |
334 | - options: [ | |
335 | - { label: '全部属性', value: 'All_ATTR' }, | |
336 | - { label: 'wendu', value: 'WENDU' }, | |
337 | - ], | |
338 | - }, | |
339 | - colProps: { span: 12 }, | |
340 | - ifShow: ({ values }) => | |
341 | - !isTime(Reflect.get(values, addString.value)) && | |
342 | - !isScene(Reflect.get(values, addString.value)) && | |
343 | - !isHand(Reflect.get(values, addString.value)) && | |
344 | - !isUpAndDown(Reflect.get(values, `touchWay${n.value}`)), | |
345 | - }, | |
346 | - '' | |
347 | - ); | |
348 | - appendSchemaByField( | |
349 | - { | |
350 | - field: `compare${n.value}`, | |
351 | - label: '', | |
352 | - component: 'Select', | |
353 | - componentProps: { | |
354 | - placeholder: '', | |
355 | - options: [ | |
356 | - { label: '=', value: '0' }, | |
357 | - { label: '<', value: '1' }, | |
358 | - { label: '>', value: '2' }, | |
359 | - { label: '<=', value: '3' }, | |
360 | - { label: '>=', value: '4' }, | |
361 | - ], | |
362 | - }, | |
363 | - ifShow: ({ values }) => | |
364 | - isWenDu(Reflect.get(values, 'attributeChoose')) && | |
365 | - !isUpAndDown(Reflect.get(values, `touchWay${n.value}`)) && | |
366 | - !isTime(Reflect.get(values, addString.value)) && | |
367 | - !isScene(Reflect.get(values, addString.value)) && | |
368 | - !isHand(Reflect.get(values, addString.value)), | |
369 | - colProps: { span: 12 }, | |
370 | - }, | |
371 | - '' | |
372 | - ); | |
373 | - appendSchemaByField( | |
374 | - { | |
375 | - field: `value${n.value}`, | |
376 | - component: 'Input', | |
377 | - label: '', | |
378 | - componentProps: { | |
379 | - placeholder: '请输入比较值', | |
380 | - }, | |
381 | - ifShow: ({ values }) => | |
382 | - isWenDu(Reflect.get(values, 'attributeChoose')) && | |
383 | - !isUpAndDown(Reflect.get(values, `touchWay${n.value}`)) && | |
384 | - !isTime(Reflect.get(values, addString.value)) && | |
385 | - !isScene(Reflect.get(values, addString.value)) && | |
386 | - !isHand(Reflect.get(values, addString.value)), | |
387 | - colProps: { | |
388 | - span: 12, | |
389 | - }, | |
390 | - }, | |
391 | - '' | |
392 | - ); | |
393 | - appendSchemaByField( | |
394 | - { | |
395 | - field: `sceneLinkageId${n.value}`, | |
396 | - label: '', | |
397 | - component: 'Select', | |
398 | - colProps: { | |
399 | - span: 12, | |
400 | - }, | |
401 | - ifShow: ({ values }) => isScene(Reflect.get(values, addString.value)), | |
402 | - componentProps: { | |
403 | - placeholder: '请输入场景触发器', | |
404 | - options: [ | |
405 | - { label: '场景触发器1', value: '1' }, | |
406 | - { label: '场景触发器2', value: '2' }, | |
407 | - { label: '场景触发器3', value: '3' }, | |
408 | - ], | |
409 | - }, | |
410 | - }, | |
411 | - '' | |
412 | - ); | |
413 | - appendSchemaByField( | |
414 | - { | |
415 | - field: `no3${n.value}`, | |
416 | - label: '', | |
417 | - component: 'ApiSelect', | |
418 | - colProps: { | |
419 | - span: 12, | |
420 | - }, | |
421 | - componentProps: { | |
422 | - placeholder: '暂不实现', | |
423 | - }, | |
424 | - ifShow: ({ values }) => isHand(Reflect.get(values, addString.value)), | |
425 | - }, | |
426 | - '' | |
427 | - ); | |
428 | - appendSchemaByField( | |
429 | - { | |
430 | - field: `${n.value}`, | |
431 | - component: 'Input', | |
432 | - label: '', | |
433 | - colProps: { | |
434 | - span: 12, | |
435 | - }, | |
436 | - slot: 'add', | |
437 | - }, | |
438 | - '' | |
439 | - ); | |
440 | - n.value++; | |
441 | - } | |
442 | - | |
443 | - function del(field) { | |
444 | - addHideButton.value--; | |
445 | - if (addHideButton.value == 2) { | |
446 | - setTimeout(() => { | |
447 | - let getDom1 = document.getElementById('1') as HTMLElement; | |
448 | - getDom1.style.display = 'flex'; | |
449 | - }, 500); | |
450 | - } | |
451 | - if (addHideButton.value == 3) { | |
452 | - setTimeout(() => { | |
453 | - let getDom2 = document.getElementById('2') as HTMLElement; | |
454 | - getDom2.style.display = 'flex'; | |
455 | - let getDom21 = document.getElementById('1') as HTMLElement; | |
456 | - getDom21.style.display = 'none'; | |
457 | - }, 500); | |
458 | - } | |
459 | - if (addHideButton.value == 4) { | |
460 | - setTimeout(() => { | |
461 | - let getDom3 = document.getElementById('3') as HTMLElement; | |
462 | - getDom3.style.display = 'flex'; | |
463 | - let getDom31 = document.getElementById('1') as HTMLElement; | |
464 | - getDom31.style.display = 'none'; | |
465 | - let getDom32 = document.getElementById('2') as HTMLElement; | |
466 | - getDom32.style.display = 'none'; | |
467 | - }, 500); | |
468 | - } | |
469 | - if (addHideButton.value == 5) { | |
470 | - setTimeout(() => { | |
471 | - let getDom4 = document.getElementById('4') as HTMLElement; | |
472 | - getDom4.style.display = 'flex'; | |
473 | - let getDom41 = document.getElementById('1') as HTMLElement; | |
474 | - getDom41.style.display = 'none'; | |
475 | - let getDom42 = document.getElementById('2') as HTMLElement; | |
476 | - getDom42.style.display = 'none'; | |
477 | - let getDom43 = document.getElementById('3') as HTMLElement; | |
478 | - getDom43.style.display = 'none'; | |
479 | - }, 500); | |
480 | - } | |
481 | - if (addHideButton.value == 6) { | |
482 | - setTimeout(() => { | |
483 | - let getDom5 = document.getElementById('5') as HTMLElement; | |
484 | - getDom5.style.display = 'flex'; | |
485 | - let getDom51 = document.getElementById('1') as HTMLElement; | |
486 | - getDom51.style.display = 'none'; | |
487 | - let getDom52 = document.getElementById('2') as HTMLElement; | |
488 | - getDom52.style.display = 'none'; | |
489 | - let getDom53 = document.getElementById('3') as HTMLElement; | |
490 | - getDom53.style.display = 'none'; | |
491 | - let getDom54 = document.getElementById('4') as HTMLElement; | |
492 | - getDom54.style.display = 'none'; | |
493 | - }, 500); | |
494 | - } | |
495 | - if (addHideButton.value == 7) { | |
496 | - setTimeout(() => { | |
497 | - let getDom7 = document.getElementById('6') as HTMLElement; | |
498 | - getDom7.style.display = 'flex'; | |
499 | - let getDom71 = document.getElementById('1') as HTMLElement; | |
500 | - getDom71.style.display = 'none'; | |
501 | - let getDom72 = document.getElementById('2') as HTMLElement; | |
502 | - getDom72.style.display = 'none'; | |
503 | - let getDom73 = document.getElementById('3') as HTMLElement; | |
504 | - getDom73.style.display = 'none'; | |
505 | - let getDom74 = document.getElementById('4') as HTMLElement; | |
506 | - getDom74.style.display = 'none'; | |
507 | - let getDom75 = document.getElementById('5') as HTMLElement; | |
508 | - getDom75.style.display = 'none'; | |
509 | - }, 500); | |
510 | - } | |
511 | - if (addHideButton.value == 8) { | |
512 | - setTimeout(() => { | |
513 | - let getDom8 = document.getElementById('7') as HTMLElement; | |
514 | - getDom8.style.display = 'flex'; | |
515 | - let getDom81 = document.getElementById('1') as HTMLElement; | |
516 | - getDom81.style.display = 'none'; | |
517 | - let getDom82 = document.getElementById('2') as HTMLElement; | |
518 | - getDom82.style.display = 'none'; | |
519 | - let getDom83 = document.getElementById('3') as HTMLElement; | |
520 | - getDom83.style.display = 'none'; | |
521 | - let getDom84 = document.getElementById('4') as HTMLElement; | |
522 | - getDom84.style.display = 'none'; | |
523 | - let getDom85 = document.getElementById('5') as HTMLElement; | |
524 | - getDom85.style.display = 'none'; | |
525 | - let getDom86 = document.getElementById('6') as HTMLElement; | |
526 | - getDom86.style.display = 'none'; | |
527 | - }, 500); | |
528 | - } | |
529 | - removeSchemaByFiled([ | |
530 | - `kong${field}`, | |
531 | - `tiggerEvent${field}`, | |
532 | - `deviceId${field}`, | |
533 | - `no1${field}`, | |
534 | - `touchWay${field}`, | |
535 | - `no2${field}`, | |
536 | - `attributeChoose${field}`, | |
537 | - `compare${field}`, | |
538 | - `value${field}`, | |
539 | - `sceneLinkageId${field}`, | |
540 | - `no3${field}`, | |
541 | - `${field}`, | |
542 | - ]); | |
543 | - n.value--; | |
544 | - } | |
545 | 72 | return { |
546 | - addClearGetAddPushValueDataArrayIsEmpty, | |
547 | - clearAddTriggerStatusFunc, | |
548 | - addHideButtonTemp, | |
549 | - addHideButton, | |
550 | - editSelectDevice, | |
551 | 73 | clearSelectDevice, |
552 | - clearGetPushValueDataEmpty, | |
553 | - setFieldsFormValue, | |
74 | + editSelectDevice, | |
75 | + getFieldsValueFunc, | |
554 | 76 | registerTrigger, |
555 | - add, | |
556 | - del, | |
557 | - getAllFields, | |
558 | - funcResetFields, | |
559 | 77 | }; |
560 | 78 | }, |
561 | 79 | }); | ... | ... |
src/views/ruleengine/scenelinkage/config.ts
renamed from
src/views/ruleengine/scenelinkage/config.d.ts
... | ... | @@ -168,26 +168,12 @@ export const formSchema: FormSchema[] = [ |
168 | 168 | if (v == undefined) { |
169 | 169 | formModel.deviceId = undefined; |
170 | 170 | const { updateSchema } = formActionType; |
171 | - updateSchema( | |
172 | - { | |
173 | - field: 'deviceId', | |
174 | - componentProps: { | |
175 | - options: undefined, | |
176 | - }, | |
171 | + updateSchema({ | |
172 | + field: 'deviceId', | |
173 | + componentProps: { | |
174 | + options: undefined, | |
177 | 175 | }, |
178 | - { | |
179 | - field: 'deviceId1', | |
180 | - componentProps: { | |
181 | - options: undefined, | |
182 | - }, | |
183 | - }, | |
184 | - { | |
185 | - field: 'deviceId2', | |
186 | - componentProps: { | |
187 | - options: undefined, | |
188 | - }, | |
189 | - } | |
190 | - ); | |
176 | + }); | |
191 | 177 | } else { |
192 | 178 | getData.value = v; |
193 | 179 | } |
... | ... | @@ -482,6 +468,7 @@ export const useConditionDrawerSchema: FormSchema[] = [ |
482 | 468 | { |
483 | 469 | field: 'createTime', |
484 | 470 | component: 'DatePicker', |
471 | + label: '', | |
485 | 472 | componentProps: { |
486 | 473 | placeholder: '请选择起始时间', |
487 | 474 | }, |
... | ... | @@ -493,6 +480,7 @@ export const useConditionDrawerSchema: FormSchema[] = [ |
493 | 480 | { |
494 | 481 | field: 'updateTime', |
495 | 482 | component: 'DatePicker', |
483 | + label: '', | |
496 | 484 | componentProps: { |
497 | 485 | placeholder: '请选择结束时间', |
498 | 486 | }, | ... | ... |
src/views/ruleengine/scenelinkage/index.ts
0 → 100644
1 | +export interface IAddTrigger { | |
2 | + id: string; | |
3 | + triggerEvent: string; | |
4 | + deviceId: string; | |
5 | + touchWay: string; | |
6 | + attributeChoose: string; | |
7 | + compare: string; | |
8 | + value: string; | |
9 | +} | |
10 | + | |
11 | +export interface IAddCondition { | |
12 | + id: string; | |
13 | + status: string; | |
14 | + deviceId: string; | |
15 | + createTime: string; | |
16 | + updateTime: string; | |
17 | + property: string; | |
18 | + compare: string; | |
19 | + value: string; | |
20 | +} | |
21 | + | |
22 | +export interface IAddAction { | |
23 | + id: string; | |
24 | + outTarget: string; | |
25 | + deviceId: string; | |
26 | + command: string; | |
27 | + sceneLinkageId: string; | |
28 | +} | ... | ... |
... | ... | @@ -40,15 +40,16 @@ |
40 | 40 | :getChildrenData="echoEditData" |
41 | 41 | @register="registerDrawer" |
42 | 42 | @success="handleSuccess" |
43 | + ref="sceneLinkAgeDrawerRef" | |
43 | 44 | /> |
44 | 45 | </div> |
45 | 46 | </template> |
46 | 47 | <script lang="ts"> |
47 | - import { defineComponent, reactive } from 'vue'; | |
48 | + import { defineComponent, reactive, getCurrentInstance, ref } from 'vue'; | |
48 | 49 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
49 | 50 | import { useDrawer } from '/@/components/Drawer'; |
50 | 51 | import SceneLinkAgeDrawer from './useDrawer.vue'; |
51 | - import { columns, searchFormSchema } from './config.d'; | |
52 | + import { columns, searchFormSchema } from './config'; | |
52 | 53 | import { useMessage } from '/@/hooks/web/useMessage'; |
53 | 54 | import { screenLinkPageGetApi, screenLinkPageDeleteApi } from '/@/api/ruleengine/ruleengineApi'; |
54 | 55 | |
... | ... | @@ -57,6 +58,8 @@ |
57 | 58 | components: { BasicTable, SceneLinkAgeDrawer, TableAction }, |
58 | 59 | emits: ['default', 'registerTable', 'registerDrawer', 'register'], |
59 | 60 | setup() { |
61 | + const { proxy } = getCurrentInstance(); | |
62 | + const sceneLinkAgeDrawerRef: any = ref(null); | |
60 | 63 | let selectedRowKeys: Array<string> = []; |
61 | 64 | let echoEditData = reactive({}); |
62 | 65 | const [registerDrawer, { openDrawer }] = useDrawer(); |
... | ... | @@ -85,6 +88,14 @@ |
85 | 88 | }); |
86 | 89 | |
87 | 90 | function handleAdd() { |
91 | + try { | |
92 | + proxy.$refs.sceneLinkAgeDrawerRef.clearAllArrayFunc(); | |
93 | + proxy.$refs.sceneLinkAgeDrawerRef.defaultAddAction(); | |
94 | + proxy.$refs.sceneLinkAgeDrawerRef.resetActionsAllArrayFunc(); | |
95 | + proxy.$refs.sceneLinkAgeDrawerRef.clearActionsAllDevice(); | |
96 | + } catch (e) { | |
97 | + return e; | |
98 | + } | |
88 | 99 | openDrawer(true, { |
89 | 100 | isUpdate: false, |
90 | 101 | }); |
... | ... | @@ -117,6 +128,7 @@ |
117 | 128 | reload(); |
118 | 129 | } |
119 | 130 | return { |
131 | + sceneLinkAgeDrawerRef, | |
120 | 132 | useSelectionChange, |
121 | 133 | echoEditData, |
122 | 134 | registerTable, | ... | ... |
... | ... | @@ -8,58 +8,165 @@ |
8 | 8 | @ok="handleSubmit" |
9 | 9 | > |
10 | 10 | <BasicForm @register="registerForm" /> |
11 | + <!-- 触发器 --> | |
11 | 12 | <div> |
12 | - <AddTriggerForm | |
13 | - @eGetAddPushValueData="getAddPushValueDataValueFunc" | |
14 | - ref="getTriggerChildData" | |
15 | - :deviceInfo="getDeviceInfo" | |
16 | - /> | |
13 | + <template v-for="(item, index) in addTriggerPushData" :key="index"> | |
14 | + <div> | |
15 | + <AddTriggerForm :deviceInfo="getDeviceInfo" ref="refTriggerChild" /> | |
16 | + </div> | |
17 | + <div style="height: 3vh"></div> | |
18 | + </template> | |
19 | + <div | |
20 | + style=" | |
21 | + display: flex; | |
22 | + width: 13vw; | |
23 | + height: 4vh; | |
24 | + flex-direction: row; | |
25 | + justify-content: space-between; | |
26 | + " | |
27 | + > | |
28 | + <div style="display: flex; width: 4vw; height: 4vh"> | |
29 | + <Button type="primary" style="border-radius: 10px" class="mt-5" @click="addTrigger" | |
30 | + ><PlusCircleOutlined />新增触发器</Button | |
31 | + > | |
32 | + </div> | |
33 | + <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 | + > | |
37 | + </div> | |
38 | + </div> | |
17 | 39 | </div> |
40 | + <div style="height: 5vh"></div> | |
41 | + <!-- 执行条件 --> | |
18 | 42 | <div> |
19 | - <AddConditiForm | |
20 | - @eDoConditionGetAddPushValueData="getAddDoconditionPushValueDataValueFunc" | |
21 | - ref="getConditionChildData" | |
22 | - :deviceInfo1="getDeviceInfo1" | |
23 | - /> | |
43 | + <template v-for="(item, index) in addConditionPushData" :key="index"> | |
44 | + <div> | |
45 | + <AddConditiForm :deviceInfo1="getDeviceInfo1" ref="refConditionChild" /> | |
46 | + </div> | |
47 | + <div style="height: 3vh"></div> | |
48 | + </template> | |
49 | + <div | |
50 | + style=" | |
51 | + display: flex; | |
52 | + width: 13vw; | |
53 | + height: 4vh; | |
54 | + flex-direction: row; | |
55 | + justify-content: space-between; | |
56 | + " | |
57 | + > | |
58 | + <div style="display: flex; width: 4vw; height: 4vh"> | |
59 | + <Button type="primary" style="border-radius: 10px" class="mt-5" @click="addCondition" | |
60 | + ><PlusCircleOutlined />新增执行条件</Button | |
61 | + > | |
62 | + </div> | |
63 | + <div style="display: flex; width: 4vw; height: 4vh"> | |
64 | + <Button type="error" style="border-radius: 10px" class="mt-5" @click="removeCondition" | |
65 | + ><PlusCircleOutlined />删除</Button | |
66 | + > | |
67 | + </div> | |
68 | + </div> | |
24 | 69 | </div> |
70 | + <!-- 执行动作 --> | |
71 | + <div style="height: 5vh"></div> | |
25 | 72 | <div> |
26 | - <AddActionForm | |
27 | - @eDoactionGetAddPushValueData="getAddDoActionPushValueDataValueFunc" | |
28 | - ref="getChildData" | |
29 | - :deviceInfo2="getDeviceInfo2" | |
30 | - /> | |
73 | + <template v-for="(item, index) in addActionPushData" :key="index"> | |
74 | + <div> | |
75 | + <AddActionForm :deviceInfo2="getDeviceInfo2" ref="refActionChild" /> | |
76 | + </div> | |
77 | + <div style="height: 3vh"></div> | |
78 | + </template> | |
79 | + <div | |
80 | + style=" | |
81 | + display: flex; | |
82 | + width: 13vw; | |
83 | + height: 4vh; | |
84 | + flex-direction: row; | |
85 | + justify-content: space-between; | |
86 | + " | |
87 | + > | |
88 | + <div style="display: flex; width: 4vw; height: 4vh"> | |
89 | + <Button type="primary" style="border-radius: 10px" class="mt-5" @click="addAction" | |
90 | + ><PlusCircleOutlined />新增执行动作</Button | |
91 | + > | |
92 | + </div> | |
93 | + <div style="display: flex; width: 4vw; height: 4vh"> | |
94 | + <Button type="error" style="border-radius: 10px" class="mt-5" @click="removeAction" | |
95 | + ><PlusCircleOutlined />删除</Button | |
96 | + > | |
97 | + </div> | |
98 | + </div> | |
31 | 99 | </div> |
32 | 100 | </BasicDrawer> |
33 | 101 | </template> |
34 | 102 | <script lang="ts"> |
35 | - import { defineComponent, ref, computed, unref, reactive, watch, getCurrentInstance } from 'vue'; | |
103 | + import { defineComponent, ref, computed, unref, reactive, getCurrentInstance, watch } from 'vue'; | |
36 | 104 | import { BasicForm, useForm } from '/@/components/Form'; |
37 | - import { formSchema, getData } from './config.d'; | |
105 | + import { formSchema, getData } from './config'; | |
38 | 106 | import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; |
39 | 107 | import { |
40 | 108 | screenLinkPageAddApi, |
41 | - screenLinkPageUpdateApi, | |
42 | - screenLinkPageByDeptIdGetDevice, | |
109 | + // screenLinkPageUpdateApi, | |
110 | + // screenLinkPageByDeptIdGetDevice, | |
43 | 111 | } from '/@/api/ruleengine/ruleengineApi'; |
44 | 112 | import { useMessage } from '/@/hooks/web/useMessage'; |
45 | 113 | import AddTriggerForm from './addForm/trigger.vue'; |
46 | - import AddActionForm from './addForm/doaction.vue'; | |
47 | 114 | import AddConditiForm from './addForm/condition.vue'; |
115 | + import AddActionForm from './addForm/doaction.vue'; | |
116 | + import { IAddTrigger, IAddCondition, IAddAction } from './index'; | |
117 | + import { Button } from '/@/components/Button'; | |
48 | 118 | |
49 | 119 | export default defineComponent({ |
50 | 120 | name: 'ConfigDrawer', |
51 | - components: { BasicDrawer, BasicForm, AddTriggerForm, AddActionForm, AddConditiForm }, | |
121 | + components: { BasicDrawer, BasicForm, AddTriggerForm, AddConditiForm, AddActionForm, Button }, | |
52 | 122 | emits: ['success', 'register', 'registerForm'], |
53 | 123 | setup(_, { emit }) { |
124 | + const lastRefTriggerChildDataArray = ref<[]>([]); | |
125 | + const lastRefConditionChildDataArray = ref<[]>([]); | |
126 | + const lastRefActionChildDataArray = ref<[]>([]); | |
127 | + const lastRefTriggerChildData: any = ref({}); | |
128 | + const lastRefConditionChildData: any = ref({}); | |
129 | + const lastRefActionChildData: any = ref({}); | |
130 | + const refTriggerChildData: any = ref({}); | |
131 | + const refConditionChildData: any = ref({}); | |
132 | + const refActionChildData: any = ref({}); | |
133 | + const addTriggerData = reactive<IAddTrigger>({ | |
134 | + id: Date.now() + Math.random() + '', | |
135 | + triggerEvent: '', | |
136 | + deviceId: '', | |
137 | + touchWay: '', | |
138 | + attributeChoose: '', | |
139 | + compare: '', | |
140 | + value: '', | |
141 | + }); | |
142 | + const addConditionData = reactive<IAddCondition>({ | |
143 | + id: Date.now() + Math.random() + '', | |
144 | + status: '', | |
145 | + deviceId: '', | |
146 | + createTime: '', | |
147 | + updateTime: '', | |
148 | + property: '', | |
149 | + compare: '', | |
150 | + value: '', | |
151 | + }); | |
152 | + const addActionData = reactive<IAddAction>({ | |
153 | + id: Date.now() + Math.random() + '', | |
154 | + outTarget: '', | |
155 | + deviceId: '', | |
156 | + command: '', | |
157 | + sceneLinkageId: '', | |
158 | + }); | |
159 | + const addTriggerPushData = ref<[]>([]); | |
160 | + const addConditionPushData = ref<[]>([]); | |
161 | + const addActionPushData = ref<[]>([]); | |
54 | 162 | const { proxy } = getCurrentInstance(); |
55 | 163 | const getChildData = ref(null); |
56 | - const getTriggerChildData = ref(null); | |
164 | + const refTriggerChild = ref(null); | |
165 | + const refConditionChild = ref(null); | |
166 | + const refActionChild = ref(null); | |
57 | 167 | const getConditionChildData = ref(null); |
58 | 168 | const { createMessage } = useMessage(); |
59 | 169 | const isUpdate = ref(true); |
60 | - let doConditionsArray: any[] = reactive([]); | |
61 | - let doActionsArray: any[] = reactive([]); | |
62 | - let triggersArray: any[] = reactive([]); | |
63 | 170 | let getAllFormData: any = reactive({}); |
64 | 171 | let getValuesFormData: any = reactive({}); |
65 | 172 | let getId = ref(''); |
... | ... | @@ -67,24 +174,11 @@ |
67 | 174 | let getDeviceInfo = ref(null); |
68 | 175 | let getDeviceInfo1 = ref(null); |
69 | 176 | let getDeviceInfo2 = ref(null); |
70 | - const isCountT = ref(null); | |
71 | - const isAddTriggerT: any = ref([]); | |
72 | - const isCountD = ref(null); | |
73 | - const isAddActionD: any = ref([]); | |
74 | - const isCountC = ref(null); | |
75 | - const isAddConditionD: any = ref([]); | |
76 | 177 | |
77 | - const [registerForm, { resetFields, setFieldsValue, validateFields, getFieldsValue }] = | |
78 | - useForm({ | |
79 | - labelWidth: 120, | |
80 | - schemas: formSchema, | |
81 | - showActionButtonGroup: false, | |
82 | - }); | |
83 | - | |
84 | - watch(getData, (newV) => { | |
85 | - getDeviceInfo.value = newV; | |
86 | - getDeviceInfo1.value = newV; | |
87 | - getDeviceInfo2.value = newV; | |
178 | + const [registerForm, { resetFields, setFieldsValue, validateFields }] = useForm({ | |
179 | + labelWidth: 120, | |
180 | + schemas: formSchema, | |
181 | + showActionButtonGroup: false, | |
88 | 182 | }); |
89 | 183 | |
90 | 184 | const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { |
... | ... | @@ -93,197 +187,184 @@ |
93 | 187 | isUpdate.value = !!data?.isUpdate; |
94 | 188 | |
95 | 189 | if (!unref(isUpdate)) { |
96 | - triggersArray.length = 0; | |
97 | - doConditionsArray.length = 0; | |
98 | - doActionsArray.length = 0; | |
99 | - isAddTriggerT.value.length = 0; | |
100 | - | |
101 | - isAddActionD.value.length = 0; | |
102 | - | |
103 | - isAddConditionD.value.length = 0; | |
104 | - proxy.$refs.getTriggerChildData.addClearGetAddPushValueDataArrayIsEmpty(); | |
105 | - proxy.$refs.getTriggerChildData.clearAddTriggerStatusFunc(); | |
106 | - proxy.$refs.getTriggerChildData.clearGetPushValueDataEmpty(); | |
107 | - proxy.$refs.getTriggerChildData.clearSelectDevice(); | |
108 | - proxy.$refs.getChildData.clearSelectDevice(); | |
109 | - proxy.$refs.getConditionChildData.clearSelectDevice(); | |
110 | - proxy.$refs.getChildData.funcResetFields(); | |
111 | - proxy.$refs.getTriggerChildData.funcResetFields(); | |
112 | - proxy.$refs.getConditionChildData.funcResetFields(); | |
190 | + try { | |
191 | + proxy.$refs.refTriggerChild.clearSelectDevice(); | |
192 | + proxy.$refs.refConditionChild.clearSelectDevice(); | |
193 | + proxy.$refs.refActionChild.clearSelectDevice(); | |
194 | + } catch (e) { | |
195 | + return e; | |
196 | + } | |
113 | 197 | } |
114 | 198 | //编辑 |
115 | 199 | if (unref(isUpdate)) { |
116 | - console.log(data); | |
117 | 200 | getId.value = data.record.id; |
118 | 201 | getTenantId.value = data.record.tenantId; |
119 | 202 | await setFieldsValue({ |
120 | 203 | ...data.record, |
121 | 204 | }); |
122 | - let newMap = null; | |
123 | - let newFilterMap = null; | |
124 | - let newTwoFilterMap = null; | |
125 | - let newFilterTwoFilterMap = null; | |
126 | - const options = await screenLinkPageByDeptIdGetDevice({ | |
127 | - organizationId: data.record.organizationId, | |
128 | - }); | |
129 | - newMap = options.items.map((m) => { | |
130 | - try { | |
131 | - newTwoFilterMap = data.record?.triggers.map((m1) => { | |
132 | - if (m.id == m1.deviceId) { | |
133 | - return { | |
134 | - value: m.id, | |
135 | - label: m.name, | |
136 | - }; | |
137 | - } | |
138 | - }); | |
139 | - | |
140 | - if (m.id == data.record?.triggers[0].deviceId) { | |
141 | - return { | |
142 | - value: m.id, | |
143 | - label: m.name, | |
144 | - }; | |
145 | - } | |
146 | - } catch (e) {} | |
147 | - }); | |
148 | - newFilterMap = newMap.filter((f) => f !== undefined); | |
149 | - newFilterTwoFilterMap = newTwoFilterMap.filter((f) => f !== undefined); | |
150 | - proxy.$refs.getTriggerChildData.editSelectDevice(newFilterMap); | |
151 | - proxy.$refs.getChildData.editSelectDevice(newFilterMap); | |
152 | - proxy.$refs.getConditionChildData.editSelectDevice(newFilterMap); | |
153 | - | |
154 | - try { | |
155 | - proxy.$refs.getTriggerChildData.setFieldsFormValue({ | |
156 | - triggerEvent: data.record.triggers[0].triggerEvent, | |
157 | - attributeChoose: data.record?.triggers[0].attributeChoose, | |
158 | - touchWay: data.record?.triggers[0].touchWay, | |
159 | - deviceId: data.record?.triggers[0].deviceId, | |
160 | - compare: data.record?.triggers[0].compare, | |
161 | - value: data.record?.triggers[0].value, | |
162 | - sceneLinkageId: data.record?.triggers[0].sceneLinkageId, | |
163 | - }); | |
164 | - proxy.$refs.getConditionChildData.setFieldsFormValue({ | |
165 | - status: data.record?.doConditions[0].status, | |
166 | - deviceId: data.record?.doConditions[0].deviceId, | |
167 | - createTime: data.record?.doConditions[0].createTime, | |
168 | - updateTime: data.record?.doConditions[0].updateTime, | |
169 | - property: data.record?.doConditions[0].property, | |
170 | - compare: data.record?.doConditions[0].compare, | |
171 | - value: data.record?.doConditions[0].value, | |
172 | - }); | |
173 | - proxy.$refs.getChildData.setFieldsFormValue({ | |
174 | - outTarget: data.record?.doActions[0].outTarget, | |
175 | - deviceId: data.record?.doActions[0].deviceId, | |
176 | - command: data.record?.doActions[0].command, | |
177 | - sceneLinkageId: data.record?.doActions[0].sceneLinkageId, | |
178 | - }); | |
179 | - } catch (e) { | |
180 | - return e; | |
181 | - } | |
182 | - } else { | |
183 | - await resetFields(); | |
184 | 205 | } |
185 | 206 | }); |
186 | 207 | const getTitle = computed(() => (!unref(isUpdate) ? '新增场景联动' : '编辑场景联动')); |
187 | - const getAddPushValueDataValueFunc = (v) => { | |
188 | - if (v.count == 2) { | |
189 | - isCountT.value = v.count; | |
190 | - isAddTriggerT.value = v.data; | |
208 | + | |
209 | + const clearAllArrayFunc = () => { | |
210 | + unref(addTriggerPushData).length = 0; | |
211 | + unref(addConditionPushData).length = 0; | |
212 | + unref(addActionPushData).length = 0; | |
213 | + lastRefTriggerChildDataArray.value.length = 0; | |
214 | + lastRefConditionChildDataArray.value.length = 0; | |
215 | + lastRefActionChildDataArray.value.length = 0; | |
216 | + }; | |
217 | + const resetActionsAllArrayFunc = () => { | |
218 | + try { | |
219 | + proxy.$refs.refActionChild.resetFieldsValueFunc(); | |
220 | + } catch (e) { | |
221 | + return e; | |
191 | 222 | } |
192 | 223 | }; |
193 | - const getAddDoActionPushValueDataValueFunc = (v) => { | |
194 | - if (v.count == 2) { | |
195 | - isCountD.value = v.count; | |
196 | - isAddActionD.value = v.data; | |
224 | + const clearActionsAllDevice = () => { | |
225 | + try { | |
226 | + proxy.$refs.refActionChild.clearSelectDevice(); | |
227 | + } catch (e) { | |
228 | + return e; | |
197 | 229 | } |
198 | 230 | }; |
199 | - const getAddDoconditionPushValueDataValueFunc = (v) => { | |
200 | - if (v.count == 2) { | |
201 | - isCountC.value = v.count; | |
202 | - isAddConditionD.value = v.data; | |
231 | + watch(getData, (newV) => { | |
232 | + getDeviceInfo.value = newV; | |
233 | + getDeviceInfo1.value = newV; | |
234 | + getDeviceInfo2.value = newV; | |
235 | + }); | |
236 | + | |
237 | + //触发器方法 | |
238 | + const refTriggerChildDataFunc = () => { | |
239 | + try { | |
240 | + refTriggerChildData.value = proxy.$refs.refTriggerChild.getFieldsValueFunc(); | |
241 | + } catch (e) { | |
242 | + return e; | |
243 | + } | |
244 | + }; | |
245 | + //执行条件方法 | |
246 | + const refConditionChildDataFunc = () => { | |
247 | + try { | |
248 | + refConditionChildData.value = proxy.$refs.refConditionChild.getFieldsValueFunc(); | |
249 | + } catch (e) { | |
250 | + return e; | |
251 | + } | |
252 | + }; | |
253 | + //执行动作方法 | |
254 | + const refActionChildDataFunc = () => { | |
255 | + try { | |
256 | + refActionChildData.value = proxy.$refs.refActionChild.getFieldsValueFunc(); | |
257 | + } catch (e) { | |
258 | + return e; | |
203 | 259 | } |
204 | 260 | }; |
205 | 261 | |
206 | - async function handleSubmit() { | |
262 | + const getDefaultValue = async () => { | |
263 | + getValuesFormData = await validateFields(); | |
264 | + refTriggerChildDataFunc(); | |
265 | + refConditionChildDataFunc(); | |
266 | + refActionChildDataFunc(); | |
267 | + lastRefTriggerChildDataArray.value.push(refTriggerChildData.value); | |
268 | + lastRefConditionChildDataArray.value.push(refConditionChildData.value); | |
269 | + lastRefActionChildDataArray.value.push(refActionChildData.value); | |
270 | + const triggersObj = { | |
271 | + triggers: lastRefTriggerChildDataArray.value, | |
272 | + }; | |
273 | + const conditionsObj = { | |
274 | + conditions: lastRefConditionChildDataArray.value, | |
275 | + }; | |
276 | + const actionsObj = { | |
277 | + actions: lastRefActionChildDataArray.value, | |
278 | + }; | |
279 | + Object.assign(getAllFormData, getValuesFormData, triggersObj, conditionsObj, actionsObj); | |
207 | 280 | if (!unref(isUpdate)) { |
208 | - triggersArray.length = 0; | |
209 | - doConditionsArray.length = 0; | |
210 | - doActionsArray.length = 0; | |
211 | - let res = validateFields(); | |
212 | - if (!res) return; | |
213 | - let getTriggerChildValues = proxy.$refs.getTriggerChildData.getAllFields(); | |
214 | - if (getTriggerChildValues.count === 1) { | |
215 | - triggersArray.push(getTriggerChildValues.data); | |
216 | - } | |
217 | - let getconditionChildValues = proxy.$refs.getConditionChildData.getAllFields(); | |
218 | - if (getconditionChildValues.count === 1) { | |
219 | - doConditionsArray.push(getconditionChildValues.data); | |
220 | - } | |
221 | - let getChildValues = proxy.$refs.getChildData.getAllFields(); | |
222 | - if (getChildValues.count === 1) { | |
223 | - doActionsArray.push(getChildValues.data); | |
224 | - } | |
281 | + delete getAllFormData.id; | |
282 | + delete getAllFormData.getTenantId; | |
283 | + } | |
284 | + }; | |
225 | 285 | |
226 | - getValuesFormData = getFieldsValue(); | |
227 | - Object.assign(getAllFormData, getValuesFormData); | |
228 | - getAllFormData.triggers = | |
229 | - isCountT.value == 2 ? isAddTriggerT.value.concat(triggersArray) : triggersArray; | |
230 | - getAllFormData.doConditions = | |
231 | - isCountC.value == 2 | |
232 | - ? isAddConditionD.value.concat(doConditionsArray) | |
233 | - : doConditionsArray; | |
234 | - getAllFormData.doActions = | |
235 | - isCountD.value == 2 ? isAddActionD.value.concat(doActionsArray) : doActionsArray; | |
236 | - //所有的表单值 | |
286 | + async function handleSubmit() { | |
287 | + if (!unref(isUpdate)) { | |
288 | + getDefaultValue(); | |
289 | + console.log(getAllFormData); | |
237 | 290 | await screenLinkPageAddApi(getAllFormData); |
238 | 291 | createMessage.success('场景联动新增成功'); |
239 | 292 | closeDrawer(); |
240 | 293 | emit('success'); |
241 | - } | |
242 | - if (unref(isUpdate)) { | |
243 | - triggersArray = []; | |
244 | - doConditionsArray = []; | |
245 | - doActionsArray = []; | |
246 | - let getTriggerChildValues = proxy.$refs.getTriggerChildData.getAllFields(); | |
247 | - if (getTriggerChildValues.count === 1) { | |
248 | - triggersArray.push(getTriggerChildValues.data); | |
249 | - } | |
250 | - let getconditionChildValues = proxy.$refs.getConditionChildData.getAllFields(); | |
251 | - if (getconditionChildValues.count === 1) { | |
252 | - doConditionsArray.push(getconditionChildValues.data); | |
253 | - } | |
254 | - let getChildValues = proxy.$refs.getChildData.getAllFields(); | |
255 | - if (getChildValues.count === 1) { | |
256 | - doActionsArray.push(getChildValues.data); | |
257 | - } | |
258 | - getValuesFormData = getFieldsValue(); | |
259 | - | |
260 | - getValuesFormData.id = getId.value; | |
261 | - getValuesFormData.tenantId = getTenantId.value; | |
262 | - Object.assign(getAllFormData, getValuesFormData); | |
263 | - getAllFormData.triggers = | |
264 | - isCountT.value == 2 ? isAddTriggerT.value.concat(triggersArray) : triggersArray; | |
265 | - getAllFormData.doConditions = | |
266 | - isCountC.value == 2 | |
267 | - ? isAddConditionD.value.concat(doConditionsArray) | |
268 | - : doConditionsArray; | |
269 | - getAllFormData.doActions = | |
270 | - isCountD.value == 2 ? isAddActionD.value.concat(doActionsArray) : doActionsArray; | |
271 | - await screenLinkPageUpdateApi(getAllFormData); | |
294 | + } else { | |
295 | + getDefaultValue(); | |
272 | 296 | createMessage.success('场景联动编辑成功'); |
273 | 297 | closeDrawer(); |
274 | 298 | emit('success'); |
275 | 299 | } |
276 | 300 | } |
301 | + //新增触发器 | |
302 | + const addTrigger = () => { | |
303 | + unref(addTriggerPushData).push(addTriggerData); | |
304 | + refTriggerChildDataFunc(); | |
305 | + lastRefTriggerChildData.value = refTriggerChildData.value; | |
306 | + lastRefTriggerChildDataArray.value.push(lastRefTriggerChildData.value); | |
307 | + }; | |
308 | + const removeTrigger = () => { | |
309 | + unref(addTriggerPushData).splice(0, 1); | |
310 | + lastRefTriggerChildDataArray.value.splice(0, 1); | |
311 | + getAllFormData.triggers.splice(0, 1); | |
312 | + }; | |
313 | + | |
314 | + //新增执行条件 | |
315 | + const addCondition = () => { | |
316 | + unref(addConditionPushData).push(addConditionData); | |
317 | + refConditionChildDataFunc(); | |
318 | + lastRefConditionChildData.value = refConditionChildData.value; | |
319 | + lastRefConditionChildDataArray.value.push(lastRefConditionChildData.value); | |
320 | + }; | |
321 | + const removeCondition = () => { | |
322 | + unref(addConditionPushData).splice(0, 1); | |
323 | + lastRefConditionChildDataArray.value.splice(0, 1); | |
324 | + getAllFormData.conditions.splice(0, 1); | |
325 | + }; | |
326 | + | |
327 | + //新增执行动作 | |
328 | + const defaultAddAction = () => { | |
329 | + if (unref(addActionPushData).length == 0) { | |
330 | + addAction(); | |
331 | + } | |
332 | + }; | |
333 | + const addAction = () => { | |
334 | + unref(addActionPushData).push(addActionData); | |
335 | + refActionChildDataFunc(); | |
336 | + lastRefActionChildData.value = refActionChildData.value; | |
337 | + lastRefActionChildDataArray.value.push(lastRefActionChildData.value); | |
338 | + }; | |
339 | + const removeAction = () => { | |
340 | + unref(addActionPushData).splice(0, 1); | |
341 | + lastRefActionChildDataArray.value.splice(0, 1); | |
342 | + getAllFormData.actions.splice(0, 1); | |
343 | + }; | |
344 | + | |
277 | 345 | return { |
278 | - getAddDoconditionPushValueDataValueFunc, | |
279 | - getAddDoActionPushValueDataValueFunc, | |
280 | - getAddPushValueDataValueFunc, | |
281 | - getConditionChildData, | |
282 | - getTriggerChildData, | |
283 | - getChildData, | |
346 | + clearActionsAllDevice, | |
284 | 347 | getDeviceInfo, |
285 | 348 | getDeviceInfo1, |
286 | 349 | getDeviceInfo2, |
350 | + resetActionsAllArrayFunc, | |
351 | + addActionPushData, | |
352 | + defaultAddAction, | |
353 | + refActionChild, | |
354 | + addAction, | |
355 | + removeAction, | |
356 | + addConditionPushData, | |
357 | + refConditionChild, | |
358 | + addCondition, | |
359 | + removeCondition, | |
360 | + clearAllArrayFunc, | |
361 | + removeTrigger, | |
362 | + addTriggerPushData, | |
363 | + addTriggerData, | |
364 | + addTrigger, | |
365 | + getConditionChildData, | |
366 | + refTriggerChild, | |
367 | + getChildData, | |
287 | 368 | getAllFormData, |
288 | 369 | registerDrawer, |
289 | 370 | registerForm, | ... | ... |