Commit 05e72343a328d0524474a2b7111aa04f95e3d351
Merge branch 'ft-dev' into 'main'
fix:修复设备配置第三步点击新增数据一样的问题,fix:修改场景联动一些字段 See merge request huang/yun-teng-iot-front!127
Showing
5 changed files
with
223 additions
and
230 deletions
... | ... | @@ -65,7 +65,7 @@ function dynamicImport( |
65 | 65 | |
66 | 66 | // Turn background objects into routing objects |
67 | 67 | export function transformObjToRoute<T = AppRouteModule>(routeList: AppRouteModule[]): T[] { |
68 | - routeList.forEach((route) => { | |
68 | + routeList?.forEach((route) => { | |
69 | 69 | const component = route.component as string; |
70 | 70 | if (component) { |
71 | 71 | if (component.toUpperCase() === 'LAYOUT') { | ... | ... |
... | ... | @@ -89,25 +89,7 @@ |
89 | 89 | :key="index2" |
90 | 90 | > |
91 | 91 | <p v-if="index2 == createIndex && !getStepThreeEditStatus" |
92 | - >报警规则条件:{{ | |
93 | - v2.predicate.operation == 'EQUAL' | |
94 | - ? v2.key.key + '等于' + v2.predicate.value.defaultValue | |
95 | - : v2.predicate.operation == 'STARTS_WITH' | |
96 | - ? v2.key.key + '开始于' + v2.predicate.value.defaultValue | |
97 | - : v2.predicate.operation == 'ENDS_WITH' | |
98 | - ? v2.key.key + '结束于' + v2.predicate.value.defaultValue | |
99 | - : v2.predicate.operation == 'NOT_CONTAINS' | |
100 | - ? v2.key.key + '不包含' + v2.predicate.value.defaultValue | |
101 | - : v2.predicate.operation == 'NOT_EQUAL' | |
102 | - ? v2.key.key + '不等于' + v2.predicate.value.defaultValue | |
103 | - : v2.predicate.operation == 'GREATER' | |
104 | - ? v2.key.key + '大于' + v2.predicate.value.defaultValue | |
105 | - : v2.predicate.operation == 'LESS' | |
106 | - ? v2.key.key + '小于' + v2.predicate.value.defaultValue | |
107 | - : v2.predicate.operation == 'GREATER_OR_EQUAL' | |
108 | - ? v2.key.key + '大于或等于' + v2.predicate.value.defaultValue | |
109 | - : v2.key.key + '小于或等于' + v2.predicate.value.defaultValue | |
110 | - }}</p | |
92 | + >报警规则条件:{{ formatAddRuleFunc(v2) }}</p | |
111 | 93 | > |
112 | 94 | <p v-if="index2 == createIndex && getStepThreeEditStatus" |
113 | 95 | >报警规则条件:{{ openRuleConditionComp(v2) }}</p |
... | ... | @@ -462,9 +444,7 @@ |
462 | 444 | schedule: {}, |
463 | 445 | }); |
464 | 446 | let kongRuleConditionObj = reactive({ |
465 | - condition: { | |
466 | - condition: {}, | |
467 | - }, | |
447 | + condition: {}, | |
468 | 448 | }); |
469 | 449 | let fliterTempRuleConditionTempArr = ref<[]>([]); |
470 | 450 | let fliterTempOpenRuleTempArr = ref<[]>([]); |
... | ... | @@ -829,7 +809,10 @@ |
829 | 809 | addNewOpenRule.schedule = enableObj.value as never; |
830 | 810 | addNewRuleTem.condition.condition = ruleObj.value as never; |
831 | 811 | tempOpenRuleTempArr.value.push(addNewOpenRule.schedule as never); |
832 | - tempRuleConditionTempArr.value.push(addNewRuleTem.condition.condition as never); | |
812 | + tempRuleConditionTempArr.value.push({ | |
813 | + condition: addNewRuleTem.condition.condition, | |
814 | + }); | |
815 | + console.log(tempRuleConditionTempArr.value); | |
833 | 816 | }; |
834 | 817 | |
835 | 818 | const getClearOpenRuleAndRuleCondition = () => { |
... | ... | @@ -867,7 +850,7 @@ |
867 | 850 | }); |
868 | 851 | |
869 | 852 | tempRuleConditionTempArr.value.forEach((f3) => { |
870 | - kongRuleConditionObj.condition.condition = f3; | |
853 | + kongRuleConditionObj.condition = f3; | |
871 | 854 | }); |
872 | 855 | |
873 | 856 | createRulesObj.value[addChangeSeverity.value?.default] = { |
... | ... | @@ -920,11 +903,44 @@ |
920 | 903 | //规则条件 |
921 | 904 | const getAllFieldsRuleFunc = (v) => { |
922 | 905 | ruleObj.value = v; |
923 | - let splitRuleObj = {}; | |
924 | - ruleObj.value.forEach((f) => { | |
925 | - splitRuleObj = f; | |
906 | + // let splitRuleObj = {}; | |
907 | + // ruleObj.value.forEach((f) => { | |
908 | + // splitRuleObj = f; | |
909 | + // }); | |
910 | + // fliterTempRuleConditionTempArr.value.push(splitRuleObj as never); | |
911 | + // fliterTempRuleConditionTempArr.value = ruleObj.value; | |
912 | + addNewRuleTem.condition.condition = ruleObj.value as never; | |
913 | + fliterTempRuleConditionTempArr.value.push({ | |
914 | + condition: addNewRuleTem.condition.condition, | |
915 | + }); | |
916 | + console.log(fliterTempRuleConditionTempArr.value); | |
917 | + }; | |
918 | + //格式化新增 | |
919 | + const formatAddRuleFunc = (v) => { | |
920 | + console.log(v.condition); | |
921 | + let kongFormatObj = {}; | |
922 | + v.condition.forEach((f) => { | |
923 | + kongFormatObj = | |
924 | + f.predicate.operation == 'EQUAL' | |
925 | + ? f.key.key + '等于' + f.predicate.value.defaultValue | |
926 | + : f.predicate.operation == 'STARTS_WITH' | |
927 | + ? f.key.key + '开始于' + f.predicate.value.defaultValue | |
928 | + : f.predicate.operation == 'ENDS_WITH' | |
929 | + ? f.key.key + '结束于' + f.predicate.value.defaultValue | |
930 | + : f.predicate.operation == 'NOT_CONTAINS' | |
931 | + ? f.key.key + '不包含' + f.predicate.value.defaultValue | |
932 | + : f.predicate.operation == 'NOT_EQUAL' | |
933 | + ? f.key.key + '不等于' + f.predicate.value.defaultValue | |
934 | + : f.predicate.operation == 'GREATER' | |
935 | + ? f.key.key + '大于' + f.predicate.value.defaultValue | |
936 | + : f.predicate.operation == 'LESS' | |
937 | + ? f.key.key + '小于' + f.predicate.value.defaultValue | |
938 | + : f.predicate.operation == 'GREATER_OR_EQUAL' | |
939 | + ? f.key.key + '大于或等于' + f.predicate.value.defaultValue | |
940 | + : f.key.key + '小于或等于' + f.predicate.value.defaultValue; | |
926 | 941 | }); |
927 | - fliterTempRuleConditionTempArr.value.push(splitRuleObj as never); | |
942 | + console.log(kongFormatObj); | |
943 | + return kongFormatObj; | |
928 | 944 | }; |
929 | 945 | //清除报警规则 |
930 | 946 | //启用规则 |
... | ... | @@ -1057,6 +1073,7 @@ |
1057 | 1073 | }; |
1058 | 1074 | |
1059 | 1075 | return { |
1076 | + formatAddRuleFunc, | |
1060 | 1077 | getFilterStepThreeClearDetailEditArr, |
1061 | 1078 | getIsShowAddRule, |
1062 | 1079 | openRuleConditionComp, | ... | ... |
... | ... | @@ -14,13 +14,13 @@ import { copyTransFun } from '/@/utils/fnUtils'; |
14 | 14 | */ |
15 | 15 | |
16 | 16 | export enum TriggerEnum { |
17 | - IS_DEVICE_ACT = 'DEVICE_ACT', | |
18 | - IS_TIME_ACT = 'TIME_ACT', | |
19 | - IS_SCENE_ACT = 'SCENE_ACT', | |
17 | + IS_DEVICE_ACT = 'DEVICE_TRIGGER', | |
18 | + IS_TIME_ACT = 'SCHEDULE_TRIGGER', | |
19 | + IS_SCENE_ACT = 'SCENE_TRIGGER', | |
20 | 20 | IS_HAND_ACT = 'HAND_ACT', |
21 | 21 | IS_MSG_NOTIFY = 'MSG_NOTIFY', |
22 | 22 | IS_DEVICE_STATUS = 'DEVICE_STATUS', |
23 | - IS_TIME_ALL = 'TIME_ALL', | |
23 | + IS_TIME_ALL = 'SCHEDULE_TRIGGER', | |
24 | 24 | } |
25 | 25 | |
26 | 26 | export enum AttributeActionEnum { |
... | ... | @@ -37,6 +37,7 @@ export enum AttrAndWenDuEnum { |
37 | 37 | export const isShiDu = (type: string) => { |
38 | 38 | return type === AttrAndWenDuEnum.IS_SHIDU; |
39 | 39 | }; |
40 | + | |
40 | 41 | export const isWenDu = (type: string) => { |
41 | 42 | return type === AttrAndWenDuEnum.IS_WENDU_ACT; |
42 | 43 | }; |
... | ... | @@ -77,13 +78,13 @@ export const columns: BasicColumn[] = [ |
77 | 78 | }, |
78 | 79 | { |
79 | 80 | title: '触发方式', |
80 | - dataIndex: 'triggerEvent', | |
81 | + dataIndex: 'triggerType', | |
81 | 82 | format: (text: string, record: Recordable) => { |
82 | - return record.triggers[0]?.triggerEvent == 'DEVICE_ACT' | |
83 | + return record.triggers[0]?.triggerType == 'DEVICE_TRIGGER' | |
83 | 84 | ? '设备触发' |
84 | - : record.triggers[0]?.triggerEvent == 'TIME_ACT' | |
85 | + : record.triggers[0]?.triggerType == 'SCHEDULE_TRIGGER' | |
85 | 86 | ? '定时触发' |
86 | - : record.triggers[0]?.triggerEvent == 'SCENE_ACT' | |
87 | + : record.triggers[0]?.triggerType == 'SCENE_TRIGGER' | |
87 | 88 | ? '场景触发' |
88 | 89 | : '手动触发'; |
89 | 90 | }, |
... | ... | @@ -190,19 +191,6 @@ export const formSchema: FormSchema[] = [ |
190 | 191 | maxLength: 255, |
191 | 192 | placeholder: '请输入描述', |
192 | 193 | }, |
193 | - dynamicRules: () => { | |
194 | - return [ | |
195 | - { | |
196 | - required: false, | |
197 | - validator: (_, value) => { | |
198 | - if (String(value).length > 255) { | |
199 | - return Promise.reject('字数不超过255个字'); | |
200 | - } | |
201 | - return Promise.resolve(); | |
202 | - }, | |
203 | - }, | |
204 | - ]; | |
205 | - }, | |
206 | 194 | }, |
207 | 195 | ]; |
208 | 196 | |
... | ... | @@ -229,19 +217,6 @@ export const searchFormSchema: FormSchema[] = [ |
229 | 217 | maxLength: 36, |
230 | 218 | placeholder: '请输入名称', |
231 | 219 | }, |
232 | - dynamicRules: () => { | |
233 | - return [ | |
234 | - { | |
235 | - required: false, | |
236 | - validator: (_, value) => { | |
237 | - if (String(value).length > 36) { | |
238 | - return Promise.reject('字数不超过36个字'); | |
239 | - } | |
240 | - return Promise.resolve(); | |
241 | - }, | |
242 | - }, | |
243 | - ]; | |
244 | - }, | |
245 | 220 | }, |
246 | 221 | { |
247 | 222 | field: 'status', |
... | ... | @@ -260,15 +235,15 @@ export const searchFormSchema: FormSchema[] = [ |
260 | 235 | |
261 | 236 | export const useTriggerDrawerSchema: FormSchema[] = [ |
262 | 237 | { |
263 | - field: 'triggerEvent', | |
238 | + field: 'triggerType', | |
264 | 239 | label: '', |
265 | 240 | component: 'Select', |
266 | 241 | componentProps: { |
267 | 242 | placeholder: '设备触发', |
268 | 243 | options: [ |
269 | - { label: '设备触发', value: 'DEVICE_ACT' }, | |
270 | - { label: '定时触发', value: 'TIME_ACT' }, | |
271 | - { label: '场景触发', value: 'SCENE_ACT' }, | |
244 | + { label: '设备触发', value: 'DEVICE_TRIGGER' }, | |
245 | + { label: '定时触发', value: 'SCHEDULE_TRIGGER' }, | |
246 | + { label: '场景触发', value: 'SCENE_TRIGGER' }, | |
272 | 247 | { label: '手动触发', value: 'HAND_ACT' }, |
273 | 248 | ], |
274 | 249 | }, |
... | ... | @@ -282,9 +257,9 @@ export const useTriggerDrawerSchema: FormSchema[] = [ |
282 | 257 | placeholder: '请选择设备', |
283 | 258 | }, |
284 | 259 | ifShow: ({ values }) => |
285 | - !isTime(Reflect.get(values, 'triggerEvent')) && | |
286 | - !isScene(Reflect.get(values, 'triggerEvent')) && | |
287 | - !isHand(Reflect.get(values, 'triggerEvent')), | |
260 | + !isTime(Reflect.get(values, 'triggerType')) && | |
261 | + !isScene(Reflect.get(values, 'triggerType')) && | |
262 | + !isHand(Reflect.get(values, 'triggerType')), | |
288 | 263 | colProps: { |
289 | 264 | span: 12, |
290 | 265 | }, |
... | ... | @@ -300,7 +275,7 @@ export const useTriggerDrawerSchema: FormSchema[] = [ |
300 | 275 | colProps: { |
301 | 276 | span: 12, |
302 | 277 | }, |
303 | - ifShow: ({ values }) => isTime(Reflect.get(values, 'triggerEvent')), | |
278 | + ifShow: ({ values }) => isTime(Reflect.get(values, 'triggerType')), | |
304 | 279 | }, |
305 | 280 | { |
306 | 281 | field: 'touchWay', |
... | ... | @@ -314,9 +289,9 @@ export const useTriggerDrawerSchema: FormSchema[] = [ |
314 | 289 | ], |
315 | 290 | }, |
316 | 291 | ifShow: ({ values }) => |
317 | - !isTime(Reflect.get(values, 'triggerEvent')) && | |
318 | - !isScene(Reflect.get(values, 'triggerEvent')) && | |
319 | - !isHand(Reflect.get(values, 'triggerEvent')), | |
292 | + !isTime(Reflect.get(values, 'triggerType')) && | |
293 | + !isScene(Reflect.get(values, 'triggerType')) && | |
294 | + !isHand(Reflect.get(values, 'triggerType')), | |
320 | 295 | colProps: { span: 12 }, |
321 | 296 | }, |
322 | 297 | { |
... | ... | @@ -334,9 +309,9 @@ export const useTriggerDrawerSchema: FormSchema[] = [ |
334 | 309 | colProps: { span: 12 }, |
335 | 310 | ifShow: ({ values }) => |
336 | 311 | isUpAndDown(Reflect.get(values, 'touchWay')) && |
337 | - !isTime(Reflect.get(values, 'triggerEvent')) && | |
338 | - !isScene(Reflect.get(values, 'triggerEvent')) && | |
339 | - !isHand(Reflect.get(values, 'triggerEvent')), | |
312 | + !isTime(Reflect.get(values, 'triggerType')) && | |
313 | + !isScene(Reflect.get(values, 'triggerType')) && | |
314 | + !isHand(Reflect.get(values, 'triggerType')), | |
340 | 315 | }, |
341 | 316 | { |
342 | 317 | field: 'attributeChoose', |
... | ... | @@ -350,9 +325,9 @@ export const useTriggerDrawerSchema: FormSchema[] = [ |
350 | 325 | ], |
351 | 326 | }, |
352 | 327 | ifShow: ({ values }) => |
353 | - !isTime(Reflect.get(values, 'triggerEvent')) && | |
354 | - !isScene(Reflect.get(values, 'triggerEvent')) && | |
355 | - !isHand(Reflect.get(values, 'triggerEvent')) && | |
328 | + !isTime(Reflect.get(values, 'triggerType')) && | |
329 | + !isScene(Reflect.get(values, 'triggerType')) && | |
330 | + !isHand(Reflect.get(values, 'triggerType')) && | |
356 | 331 | !isUpAndDown(Reflect.get(values, 'touchWay')), |
357 | 332 | colProps: { span: 12 }, |
358 | 333 | }, |
... | ... | @@ -373,9 +348,9 @@ export const useTriggerDrawerSchema: FormSchema[] = [ |
373 | 348 | ifShow: ({ values }) => |
374 | 349 | isWenDu(Reflect.get(values, 'attributeChoose')) && |
375 | 350 | !isUpAndDown(Reflect.get(values, 'touchWay')) && |
376 | - !isTime(Reflect.get(values, 'triggerEvent')) && | |
377 | - !isScene(Reflect.get(values, 'triggerEvent')) && | |
378 | - !isHand(Reflect.get(values, 'triggerEvent')), | |
351 | + !isTime(Reflect.get(values, 'triggerType')) && | |
352 | + !isScene(Reflect.get(values, 'triggerType')) && | |
353 | + !isHand(Reflect.get(values, 'triggerType')), | |
379 | 354 | colProps: { span: 12 }, |
380 | 355 | }, |
381 | 356 | { |
... | ... | @@ -390,9 +365,9 @@ export const useTriggerDrawerSchema: FormSchema[] = [ |
390 | 365 | ifShow: ({ values }) => |
391 | 366 | isWenDu(Reflect.get(values, 'attributeChoose')) && |
392 | 367 | !isUpAndDown(Reflect.get(values, 'touchWay')) && |
393 | - !isTime(Reflect.get(values, 'triggerEvent')) && | |
394 | - !isScene(Reflect.get(values, 'triggerEvent')) && | |
395 | - !isHand(Reflect.get(values, 'triggerEvent')), | |
368 | + !isTime(Reflect.get(values, 'triggerType')) && | |
369 | + !isScene(Reflect.get(values, 'triggerType')) && | |
370 | + !isHand(Reflect.get(values, 'triggerType')), | |
396 | 371 | colProps: { |
397 | 372 | span: 12, |
398 | 373 | }, |
... | ... | @@ -413,7 +388,7 @@ export const useTriggerDrawerSchema: FormSchema[] = [ |
413 | 388 | { label: '场景触发器3', value: '3' }, |
414 | 389 | ], |
415 | 390 | }, |
416 | - ifShow: ({ values }) => isScene(Reflect.get(values, 'triggerEvent')), | |
391 | + ifShow: ({ values }) => isScene(Reflect.get(values, 'triggerType')), | |
417 | 392 | }, |
418 | 393 | |
419 | 394 | { |
... | ... | @@ -426,29 +401,20 @@ export const useTriggerDrawerSchema: FormSchema[] = [ |
426 | 401 | componentProps: { |
427 | 402 | placeholder: '暂不实现', |
428 | 403 | }, |
429 | - ifShow: ({ values }) => isHand(Reflect.get(values, 'triggerEvent')), | |
430 | - }, | |
431 | - { | |
432 | - field: '0', | |
433 | - component: 'Input', | |
434 | - label: ' ', | |
435 | - colProps: { | |
436 | - span: 12, | |
437 | - }, | |
438 | - slot: 'add', | |
404 | + ifShow: ({ values }) => isHand(Reflect.get(values, 'triggerType')), | |
439 | 405 | }, |
440 | 406 | ]; |
441 | 407 | |
442 | 408 | export const useConditionDrawerSchema: FormSchema[] = [ |
443 | 409 | { |
444 | - field: 'status', | |
410 | + field: 'triggerType', | |
445 | 411 | label: '', |
446 | 412 | component: 'Select', |
447 | 413 | componentProps: { |
448 | 414 | placeholder: '设备状态', |
449 | 415 | options: [ |
450 | - { label: '设备触发', value: 'DEVICE_STATUS' }, | |
451 | - { label: '时间范围', value: 'TIME_ALL' }, | |
416 | + { label: '设备触发', value: 'DEVICE_TRIGGER' }, | |
417 | + { label: '时间范围', value: 'SCHEDULE_TRIGGER' }, | |
452 | 418 | ], |
453 | 419 | }, |
454 | 420 | colProps: { span: 12 }, |
... | ... | @@ -460,7 +426,7 @@ export const useConditionDrawerSchema: FormSchema[] = [ |
460 | 426 | componentProps: { |
461 | 427 | placeholder: '请选择设备', |
462 | 428 | }, |
463 | - ifShow: ({ values }) => !isTimeAll(Reflect.get(values, 'status')), | |
429 | + ifShow: ({ values }) => !isTimeAll(Reflect.get(values, 'triggerType')), | |
464 | 430 | colProps: { |
465 | 431 | span: 12, |
466 | 432 | }, |
... | ... | @@ -475,7 +441,7 @@ export const useConditionDrawerSchema: FormSchema[] = [ |
475 | 441 | colProps: { |
476 | 442 | span: 12, |
477 | 443 | }, |
478 | - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'status')), | |
444 | + ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'triggerType')), | |
479 | 445 | }, |
480 | 446 | { |
481 | 447 | field: 'updateTime', |
... | ... | @@ -487,7 +453,7 @@ export const useConditionDrawerSchema: FormSchema[] = [ |
487 | 453 | colProps: { |
488 | 454 | span: 12, |
489 | 455 | }, |
490 | - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'status')), | |
456 | + ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'triggerType')), | |
491 | 457 | }, |
492 | 458 | { |
493 | 459 | field: 'property', |
... | ... | @@ -500,19 +466,7 @@ export const useConditionDrawerSchema: FormSchema[] = [ |
500 | 466 | { label: 'wendu', value: 'WENDU' }, |
501 | 467 | ], |
502 | 468 | }, |
503 | - ifShow: ({ values }) => !isTimeAll(Reflect.get(values, 'status')), | |
504 | - colProps: { span: 12 }, | |
505 | - }, | |
506 | - { | |
507 | - field: 'wu', | |
508 | - label: '', | |
509 | - component: 'Input', | |
510 | - componentProps: { | |
511 | - placeholder: '无', | |
512 | - style: { | |
513 | - visibility: 'hidden', | |
514 | - }, | |
515 | - }, | |
469 | + ifShow: ({ values }) => !isTimeAll(Reflect.get(values, 'triggerType')), | |
516 | 470 | colProps: { span: 12 }, |
517 | 471 | }, |
518 | 472 | { |
... | ... | @@ -530,7 +484,7 @@ export const useConditionDrawerSchema: FormSchema[] = [ |
530 | 484 | ], |
531 | 485 | }, |
532 | 486 | ifShow: ({ values }) => |
533 | - isShiDu(Reflect.get(values, 'property')) && !isTimeAll(Reflect.get(values, 'status')), | |
487 | + isShiDu(Reflect.get(values, 'property')) && !isTimeAll(Reflect.get(values, 'triggerType')), | |
534 | 488 | colProps: { span: 12 }, |
535 | 489 | }, |
536 | 490 | { |
... | ... | @@ -543,7 +497,7 @@ export const useConditionDrawerSchema: FormSchema[] = [ |
543 | 497 | }, |
544 | 498 | |
545 | 499 | ifShow: ({ values }) => |
546 | - isShiDu(Reflect.get(values, 'property')) && !isTimeAll(Reflect.get(values, 'status')), | |
500 | + isShiDu(Reflect.get(values, 'property')) && !isTimeAll(Reflect.get(values, 'triggerType')), | |
547 | 501 | colProps: { |
548 | 502 | span: 12, |
549 | 503 | }, |
... | ... | @@ -564,7 +518,7 @@ export const useConditionDrawerSchema: FormSchema[] = [ |
564 | 518 | ], |
565 | 519 | }, |
566 | 520 | ifShow: ({ values }) => |
567 | - isWenDu(Reflect.get(values, 'property')) && !isTimeAll(Reflect.get(values, 'status')), | |
521 | + isWenDu(Reflect.get(values, 'property')) && !isTimeAll(Reflect.get(values, 'triggerType')), | |
568 | 522 | colProps: { span: 12 }, |
569 | 523 | }, |
570 | 524 | { |
... | ... | @@ -576,20 +530,11 @@ export const useConditionDrawerSchema: FormSchema[] = [ |
576 | 530 | placeholder: '请输入比较值', |
577 | 531 | }, |
578 | 532 | ifShow: ({ values }) => |
579 | - isWenDu(Reflect.get(values, 'property')) && !isTimeAll(Reflect.get(values, 'status')), | |
533 | + isWenDu(Reflect.get(values, 'property')) && !isTimeAll(Reflect.get(values, 'triggerType')), | |
580 | 534 | colProps: { |
581 | 535 | span: 12, |
582 | 536 | }, |
583 | 537 | }, |
584 | - { | |
585 | - field: '0', | |
586 | - component: 'Input', | |
587 | - label: ' ', | |
588 | - colProps: { | |
589 | - span: 12, | |
590 | - }, | |
591 | - slot: 'add', | |
592 | - }, | |
593 | 538 | ]; |
594 | 539 | |
595 | 540 | export const useActionDrawerSchema: FormSchema[] = [ |
... | ... | @@ -602,7 +547,7 @@ export const useActionDrawerSchema: FormSchema[] = [ |
602 | 547 | options: [ |
603 | 548 | { label: '设备输出', value: 'DEVICE_OUT' }, |
604 | 549 | { label: '消息通知', value: 'MSG_NOTIFY' }, |
605 | - { label: '场景联动', value: 'SCENE_ACT' }, | |
550 | + { label: '场景联动', value: 'SCENE_TRIGGER' }, | |
606 | 551 | ], |
607 | 552 | }, |
608 | 553 | colProps: { span: 12 }, |
... | ... | @@ -621,7 +566,7 @@ export const useActionDrawerSchema: FormSchema[] = [ |
621 | 566 | }, |
622 | 567 | }, |
623 | 568 | { |
624 | - field: 'command', | |
569 | + field: 'doContext', | |
625 | 570 | component: 'Input', |
626 | 571 | label: '', |
627 | 572 | componentProps: { |
... | ... | @@ -635,18 +580,6 @@ export const useActionDrawerSchema: FormSchema[] = [ |
635 | 580 | }, |
636 | 581 | }, |
637 | 582 | { |
638 | - field: 'wu1', | |
639 | - label: '', | |
640 | - component: 'Input', | |
641 | - componentProps: { | |
642 | - placeholder: '无', | |
643 | - style: { | |
644 | - visibility: 'hidden', | |
645 | - }, | |
646 | - }, | |
647 | - colProps: { span: 12 }, | |
648 | - }, | |
649 | - { | |
650 | 583 | field: 'wu2', |
651 | 584 | component: 'Input', |
652 | 585 | label: '', |
... | ... | @@ -702,13 +635,4 @@ export const useActionDrawerSchema: FormSchema[] = [ |
702 | 635 | colProps: { span: 12 }, |
703 | 636 | ifShow: ({ values }) => isScene(Reflect.get(values, 'outTarget')), |
704 | 637 | }, |
705 | - { | |
706 | - field: '0', | |
707 | - component: 'Input', | |
708 | - label: ' ', | |
709 | - colProps: { | |
710 | - span: 12, | |
711 | - }, | |
712 | - slot: 'add', | |
713 | - }, | |
714 | 638 | ]; | ... | ... |
1 | 1 | export interface IAddTrigger { |
2 | - id: string; | |
3 | - triggerEvent: string; | |
2 | + triggerType: string; | |
4 | 3 | deviceId: string; |
5 | 4 | touchWay: string; |
6 | 5 | attributeChoose: string; |
... | ... | @@ -9,18 +8,15 @@ export interface IAddTrigger { |
9 | 8 | } |
10 | 9 | |
11 | 10 | export interface IAddCondition { |
12 | - id: string; | |
13 | - status: string; | |
11 | + triggerType: string; | |
14 | 12 | deviceId: string; |
15 | 13 | createTime: string; |
16 | 14 | updateTime: string; |
17 | - property: string; | |
18 | 15 | compare: string; |
19 | 16 | value: string; |
20 | 17 | } |
21 | 18 | |
22 | 19 | export interface IAddAction { |
23 | - id: string; | |
24 | 20 | outTarget: string; |
25 | 21 | deviceId: string; |
26 | 22 | command: string; | ... | ... |
... | ... | @@ -6,6 +6,7 @@ |
6 | 6 | :title="getTitle" |
7 | 7 | width="1000px" |
8 | 8 | @ok="handleSubmit" |
9 | + @close="handleClose" | |
9 | 10 | > |
10 | 11 | <div> |
11 | 12 | <BasicForm @register="registerForm" /> |
... | ... | @@ -56,7 +57,7 @@ |
56 | 57 | </div> |
57 | 58 | <div style="height: 5vh"></div> |
58 | 59 | <!-- 执行条件 --> |
59 | - <div> | |
60 | + <div class="condition-style"> | |
60 | 61 | <template |
61 | 62 | v-for="(item, index) in isUpdate == false ? addConditionPushData : editConditionPushData" |
62 | 63 | :key="index" |
... | ... | @@ -195,8 +196,7 @@ |
195 | 196 | const refConditionChildData: any = ref({}); |
196 | 197 | const refActionChildData: any = ref({}); |
197 | 198 | const addTriggerData = reactive<IAddTrigger>({ |
198 | - id: Date.now() + Math.random() + '', | |
199 | - triggerEvent: '', | |
199 | + triggerType: '', | |
200 | 200 | deviceId: '', |
201 | 201 | touchWay: '', |
202 | 202 | attributeChoose: '', |
... | ... | @@ -204,44 +204,37 @@ |
204 | 204 | value: '', |
205 | 205 | }); |
206 | 206 | const editTriggerData = reactive<IAddTrigger>({ |
207 | - id: Date.now() + Math.random() + '', | |
208 | - triggerEvent: '请选择设备触发', | |
207 | + triggerType: '', | |
209 | 208 | deviceId: '请选择设备', |
210 | - touchWay: '请选择出发方式', | |
209 | + touchWay: '请选择触发方式', | |
211 | 210 | attributeChoose: '请选择属性', |
212 | 211 | compare: '', |
213 | 212 | value: '', |
214 | 213 | }); |
215 | 214 | const addConditionData = reactive<IAddCondition>({ |
216 | - id: Date.now() + Math.random() + '', | |
217 | - status: '', | |
215 | + triggerType: '', | |
218 | 216 | deviceId: '', |
219 | 217 | createTime: '', |
220 | 218 | updateTime: '', |
221 | - property: '', | |
222 | 219 | compare: '', |
223 | 220 | value: '', |
224 | 221 | }); |
225 | 222 | const editConditionData = reactive<IAddCondition>({ |
226 | - id: Date.now() + Math.random() + '', | |
227 | - status: '', | |
228 | - deviceId: '', | |
223 | + deviceId: '请选择设备', | |
229 | 224 | createTime: '', |
230 | 225 | updateTime: '', |
231 | - property: '请选择', | |
226 | + triggerType: '', | |
232 | 227 | compare: '', |
233 | 228 | value: '', |
234 | 229 | }); |
235 | 230 | const addActionData = reactive<IAddAction>({ |
236 | - id: Date.now() + Math.random() + '', | |
237 | 231 | outTarget: '', |
238 | 232 | deviceId: '', |
239 | 233 | command: '', |
240 | 234 | sceneLinkageId: '', |
241 | 235 | }); |
242 | 236 | const editActionData = reactive<IAddAction>({ |
243 | - id: Date.now() + Math.random() + '', | |
244 | - outTarget: '请选择触发方式', | |
237 | + outTarget: '', | |
245 | 238 | deviceId: '请选择设备', |
246 | 239 | command: '请输入执行命令', |
247 | 240 | sceneLinkageId: '', |
... | ... | @@ -260,7 +253,7 @@ |
260 | 253 | const getConditionChildData = ref(null); |
261 | 254 | const { createMessage } = useMessage(); |
262 | 255 | const isUpdate = ref(true); |
263 | - const getAllFormData: any = reactive({}); | |
256 | + let getAllFormData: any = reactive({}); | |
264 | 257 | let getValuesFormData: any = reactive({}); |
265 | 258 | const getId = ref(''); |
266 | 259 | const getTenantId = ref(''); |
... | ... | @@ -270,18 +263,25 @@ |
270 | 263 | const newFilterMap = ref<[]>([]); |
271 | 264 | const newConditionFilterMap = ref<[]>([]); |
272 | 265 | const newActionFilterMap = ref<[]>([]); |
273 | - const filterNewTriggerArr = ref<[]>([]); | |
274 | - const filterNewConditionArr = ref<[]>([]); | |
275 | - const filterNewActionArr = ref<[]>([]); | |
276 | - const pushEditArray = ref<[]>([]); | |
277 | - const pushEditConditionArray = ref<[]>([]); | |
278 | - const pushEditActionArray = ref<[]>([]); | |
279 | - const filterArrayTrigger = ref<[]>([]); | |
266 | + let filterNewConditionArr = []; | |
267 | + let filterNewActionArr = []; | |
268 | + const pushEditArray = []; | |
269 | + const pushEditConditionArray = []; | |
270 | + const pushEditActionArray = []; | |
271 | + let filterArrayTrigger = []; | |
280 | 272 | const filterArrayCondition = ref<[]>([]); |
281 | 273 | const filterArrayAction = ref<[]>([]); |
282 | - const filterArrayTriggerObj = ref({}); | |
283 | - const filterArrayConditionObj = ref({}); | |
284 | - const filterArrayActionObj = ref({}); | |
274 | + let filterNewTriggerArr = []; | |
275 | + | |
276 | + let triggersObj = { | |
277 | + triggers: [], | |
278 | + }; | |
279 | + let conditionsObj = { | |
280 | + doConditions: [], | |
281 | + }; | |
282 | + let actionsObj = { | |
283 | + doActions: [], | |
284 | + }; | |
285 | 285 | |
286 | 286 | const [registerForm, { resetFields, setFieldsValue, validateFields }] = useForm({ |
287 | 287 | labelWidth: 120, |
... | ... | @@ -295,16 +295,24 @@ |
295 | 295 | isUpdate.value = !!data?.isUpdate; |
296 | 296 | if (!unref(isUpdate)) { |
297 | 297 | try { |
298 | - proxy.$refs.refTriggerChild.resetFieldsValueFunc(); | |
299 | - proxy.$refs.refConditionChild.resetFieldsValueFunc(); | |
300 | - proxy.$refs.refActionChild.resetFieldsValueFunc(); | |
298 | + triggersObj = { | |
299 | + triggers: [], | |
300 | + }; | |
301 | + filterNewTriggerArr.length = 0; | |
302 | + filterNewConditionArr.length = 0; | |
301 | 303 | lastRefTriggerChildDataArray.value.length = 0; |
302 | 304 | lastRefConditionChildDataArray.value.length = 0; |
303 | 305 | lastRefActionChildDataArray.value.length = 0; |
304 | 306 | editTriggerPushData.value.length = 0; |
307 | + editConditionPushData.value.length = 0; | |
308 | + editActionPushData.value.length = 0; | |
305 | 309 | addTriggerPushData.value.length = 0; |
306 | 310 | addConditionPushData.value.length = 0; |
307 | 311 | addActionPushData.value.length = 0; |
312 | + handleClose(); | |
313 | + proxy.$refs.refTriggerChild.resetFieldsValueFunc(); | |
314 | + proxy.$refs.refConditionChild.resetFieldsValueFunc(); | |
315 | + proxy.$refs.refActionChild.resetFieldsValueFunc(); | |
308 | 316 | } catch (e) { |
309 | 317 | return e; |
310 | 318 | } |
... | ... | @@ -316,7 +324,9 @@ |
316 | 324 | editTriggerPushData.value = []; |
317 | 325 | editTriggerPushData.value.length = 0; |
318 | 326 | editConditionPushData.value = []; |
327 | + editConditionPushData.value.length = 0; | |
319 | 328 | editActionPushData.value = []; |
329 | + editActionPushData.value.length = 0; | |
320 | 330 | lastEditRefTriggerChildDataArray.value = []; |
321 | 331 | getId.value = data.record.id; |
322 | 332 | getTenantId.value = data.record.tenantId; |
... | ... | @@ -365,6 +375,16 @@ |
365 | 375 | } |
366 | 376 | }); |
367 | 377 | const getTitle = computed(() => (!unref(isUpdate) ? '新增场景联动' : '编辑场景联动')); |
378 | + const handleClose = () => { | |
379 | + pushEditArray.length = 0; | |
380 | + lastRefTriggerChildDataArray.value.length = 0; | |
381 | + lastRefTriggerChildDataArray.value = []; | |
382 | + lastRefConditionChildDataArray.value.length = 0; | |
383 | + lastRefActionChildDataArray.value.length = 0; | |
384 | + filterArrayTrigger.length = 0; | |
385 | + filterArrayCondition.value.length = 0; | |
386 | + filterArrayAction.value.length = 0; | |
387 | + }; | |
368 | 388 | |
369 | 389 | const clearAllArrayFunc = () => { |
370 | 390 | unref(addTriggerPushData).length = 0; |
... | ... | @@ -430,54 +450,81 @@ |
430 | 450 | lastRefTriggerChildDataArray.value.push(refTriggerChildData.value as never); |
431 | 451 | lastRefConditionChildDataArray.value.push(refConditionChildData.value as never); |
432 | 452 | lastRefActionChildDataArray.value.push(refActionChildData.value as never); |
433 | - const triggersObj = { | |
453 | + triggersObj = { | |
434 | 454 | triggers: lastRefTriggerChildDataArray.value, |
435 | 455 | }; |
436 | - const conditionsObj = { | |
456 | + conditionsObj = { | |
437 | 457 | doConditions: lastRefConditionChildDataArray.value, |
438 | 458 | }; |
439 | - const actionsObj = { | |
459 | + actionsObj = { | |
440 | 460 | doActions: lastRefActionChildDataArray.value, |
441 | 461 | }; |
462 | + | |
442 | 463 | Object.assign(getAllFormData, triggersObj, conditionsObj, actionsObj); |
443 | 464 | } else { |
444 | 465 | refTriggerChildDataFunc(); |
445 | 466 | refConditionChildDataFunc(); |
446 | 467 | refActionChildDataFunc(); |
447 | - pushEditArray.value.push(refTriggerChildData.value as never); | |
448 | - pushEditConditionArray.value.push(refConditionChildData.value as never); | |
449 | - pushEditActionArray.value.push(refActionChildData.value as never); | |
450 | - filterArrayTrigger.value = editTriggerPushData.value.filter( | |
451 | - (f) => f?.triggerEvent !== '' | |
468 | + pushEditArray.push(refTriggerChildData.value as never); | |
469 | + pushEditConditionArray.push(refConditionChildData.value as never); | |
470 | + pushEditActionArray.push(refActionChildData.value as never); | |
471 | + pushEditArray.forEach((f) => { | |
472 | + editTriggerPushData.value.push(f as never); | |
473 | + }); | |
474 | + pushEditConditionArray.forEach((f) => { | |
475 | + editConditionPushData.value.push(f as never); | |
476 | + }); | |
477 | + pushEditActionArray.forEach((f) => { | |
478 | + editActionPushData.value.push(f as never); | |
479 | + }); | |
480 | + const filterTwoArrayTrigger = editTriggerPushData.value.filter((f) => | |
481 | + f?.hasOwnProperty('id') | |
452 | 482 | ); |
453 | - filterArrayCondition.value = editTriggerPushData.value.filter((f) => f?.property !== ''); | |
454 | 483 | |
455 | - filterArrayAction.value = editTriggerPushData.value.filter((f) => f?.outTarget !== ''); | |
484 | + const filterTwoArrayCondition = editConditionPushData.value.filter((f) => | |
485 | + f?.hasOwnProperty('id') | |
486 | + ); | |
487 | + | |
488 | + const filterTwoArrayAction = editActionPushData.value.filter((f) => | |
489 | + f?.hasOwnProperty('id') | |
490 | + ); | |
456 | 491 | |
457 | - pushEditArray.value.forEach((f) => { | |
458 | - filterArrayTriggerObj.value = f; | |
459 | - filterArrayTrigger.value.push(filterArrayTriggerObj.value as never); | |
492 | + const filterThreeArrayTrigger = editTriggerPushData.value.filter( | |
493 | + (f) => f?.deviceId == '' | |
494 | + ); | |
495 | + const filterThreeArrayCondition = editConditionPushData.value.filter( | |
496 | + (f) => f?.deviceId == '' | |
497 | + ); | |
498 | + const filterThreeArrayAction = editActionPushData.value.filter((f) => f?.deviceId == ''); | |
499 | + const filterFourArrayTrigger = filterThreeArrayTrigger.filter( | |
500 | + (f) => f?.triggerType !== '' | |
501 | + ); | |
502 | + const filterFourArrayCondition = filterThreeArrayCondition.filter( | |
503 | + (f) => f?.triggerType !== '' | |
504 | + ); | |
505 | + | |
506 | + const filterFourArrayAction = filterThreeArrayAction.filter((f) => f?.outTarget !== ''); | |
507 | + | |
508 | + filterFourArrayTrigger.forEach((f) => { | |
509 | + filterTwoArrayTrigger.push(f); | |
460 | 510 | }); |
461 | - pushEditConditionArray.value.forEach((f) => { | |
462 | - filterArrayConditionObj.value = f; | |
463 | - filterArrayCondition.value.push(filterArrayConditionObj.value as never); | |
511 | + filterFourArrayCondition.forEach((f) => { | |
512 | + filterTwoArrayCondition.push(f); | |
464 | 513 | }); |
465 | - | |
466 | - pushEditActionArray.value.forEach((f) => { | |
467 | - filterArrayActionObj.value = f; | |
468 | - filterArrayAction.value.push(filterArrayActionObj.value as never); | |
514 | + filterFourArrayAction.forEach((f) => { | |
515 | + filterTwoArrayAction.push(f); | |
469 | 516 | }); |
470 | 517 | |
471 | - const triggersObj = { | |
472 | - triggers: filterArrayTrigger.value, | |
518 | + let editTriggersObj = { | |
519 | + triggers: filterTwoArrayTrigger, | |
473 | 520 | }; |
474 | - const conditionsObj = { | |
475 | - doConditions: filterArrayCondition.value, | |
521 | + let editConditionsObj = { | |
522 | + doConditions: filterTwoArrayCondition, | |
476 | 523 | }; |
477 | - const actionsObj = { | |
478 | - doActions: filterArrayAction.value, | |
524 | + let editActionsObj = { | |
525 | + doActions: filterTwoArrayAction, | |
479 | 526 | }; |
480 | - Object.assign(getAllFormData, triggersObj, conditionsObj, actionsObj); | |
527 | + Object.assign(getAllFormData, editTriggersObj, editConditionsObj, editActionsObj); | |
481 | 528 | } |
482 | 529 | }; |
483 | 530 | |
... | ... | @@ -518,14 +565,14 @@ |
518 | 565 | unref(addTriggerPushData).push(addTriggerData as never); |
519 | 566 | refTriggerChildDataFunc(); |
520 | 567 | lastRefTriggerChildData.value = refTriggerChildData.value; |
521 | - filterNewTriggerArr.value.push(lastRefTriggerChildData.value as never); | |
522 | - lastRefTriggerChildDataArray.value = filterNewTriggerArr.value.filter( | |
568 | + filterNewTriggerArr.push(lastRefTriggerChildData.value as never); | |
569 | + (lastRefTriggerChildDataArray.value as never[]) = filterNewTriggerArr.filter( | |
523 | 570 | (v) => Object.keys(v).length !== 0 |
524 | 571 | ); |
525 | 572 | } else { |
526 | 573 | refTriggerChildDataFunc(); |
527 | - pushEditArray.value.push(refTriggerChildData.value); | |
528 | - unref(editTriggerPushData).push(editTriggerData as never); | |
574 | + pushEditArray.push(refTriggerChildData.value as never); | |
575 | + unref(editTriggerPushData).push(addTriggerData as never); | |
529 | 576 | } |
530 | 577 | }; |
531 | 578 | const removeTrigger = () => { |
... | ... | @@ -539,7 +586,7 @@ |
539 | 586 | } else { |
540 | 587 | try { |
541 | 588 | unref(editTriggerPushData).splice(0, 1); |
542 | - lastEditRefTriggerChildDataArray.value.splice(0, 1); | |
589 | + lastEditRefTriggerChildDataArray.value.pop(); | |
543 | 590 | } catch (e) { |
544 | 591 | return e; |
545 | 592 | } |
... | ... | @@ -558,14 +605,14 @@ |
558 | 605 | unref(addConditionPushData).push(addConditionData as never); |
559 | 606 | refConditionChildDataFunc(); |
560 | 607 | lastRefConditionChildData.value = refConditionChildData.value; |
561 | - filterNewConditionArr.value.push(lastRefConditionChildData.value as never); | |
562 | - lastRefConditionChildDataArray.value = filterNewConditionArr.value.filter( | |
608 | + filterNewConditionArr.push(lastRefConditionChildData.value as never); | |
609 | + (lastRefConditionChildDataArray.value as never[]) = filterNewConditionArr.filter( | |
563 | 610 | (v) => Object.keys(v).length !== 0 |
564 | 611 | ); |
565 | 612 | } else { |
566 | 613 | refConditionChildDataFunc(); |
567 | - pushEditConditionArray.value.push(refConditionChildData.value); | |
568 | - unref(editConditionPushData).push(editConditionData as never); | |
614 | + pushEditConditionArray.push(refConditionChildData.value as never); | |
615 | + unref(editConditionPushData).push(addConditionData as never); | |
569 | 616 | } |
570 | 617 | }; |
571 | 618 | const removeCondition = () => { |
... | ... | @@ -579,7 +626,7 @@ |
579 | 626 | } else { |
580 | 627 | try { |
581 | 628 | unref(editConditionPushData).splice(0, 1); |
582 | - lastEditRefConditionChildDataArray.value.splice(0, 1); | |
629 | + lastEditRefConditionChildDataArray.value.pop(); | |
583 | 630 | } catch (e) { |
584 | 631 | return e; |
585 | 632 | } |
... | ... | @@ -598,14 +645,14 @@ |
598 | 645 | unref(addActionPushData).push(addActionData as never); |
599 | 646 | refActionChildDataFunc(); |
600 | 647 | lastRefActionChildData.value = refActionChildData.value; |
601 | - filterNewActionArr.value.push(lastRefActionChildData.value as never); | |
602 | - lastRefActionChildDataArray.value = filterNewActionArr.value.filter( | |
648 | + filterNewActionArr.push(lastRefActionChildData.value as never); | |
649 | + (lastRefActionChildDataArray.value as never[]) = filterNewActionArr.filter( | |
603 | 650 | (v) => Object.keys(v).length !== 0 |
604 | 651 | ); |
605 | 652 | } else { |
606 | 653 | refActionChildDataFunc(); |
607 | - pushEditActionArray.value.push(refActionChildData.value); | |
608 | - unref(editActionPushData).push(editActionData as never); | |
654 | + pushEditActionArray.push(refActionChildData.value as never); | |
655 | + unref(editActionPushData).push(addActionData as never); | |
609 | 656 | } |
610 | 657 | }; |
611 | 658 | const removeAction = () => { |
... | ... | @@ -619,7 +666,7 @@ |
619 | 666 | } else { |
620 | 667 | try { |
621 | 668 | unref(editActionPushData).splice(0, 1); |
622 | - lastEditRefActionChildDataArray.value.splice(0, 1); | |
669 | + lastEditRefActionChildDataArray.value.pop(); | |
623 | 670 | } catch (e) { |
624 | 671 | return e; |
625 | 672 | } |
... | ... | @@ -627,6 +674,7 @@ |
627 | 674 | }; |
628 | 675 | |
629 | 676 | return { |
677 | + handleClose, | |
630 | 678 | defaultAddTrigger, |
631 | 679 | defaultAddCondition, |
632 | 680 | newFilterMap, |
... | ... | @@ -667,3 +715,11 @@ |
667 | 715 | }, |
668 | 716 | }); |
669 | 717 | </script> |
718 | + | |
719 | +<style lang="less" scoped> | |
720 | + .condition-style { | |
721 | + :deep .ant-calendar-picker { | |
722 | + width: 24.9vw !important; | |
723 | + } | |
724 | + } | |
725 | +</style> | ... | ... |