Showing
6 changed files
with
131 additions
and
84 deletions
... | ... | @@ -145,7 +145,7 @@ |
145 | 145 | @register="registerModal3" |
146 | 146 | /> |
147 | 147 | |
148 | - <!-- 清除条件的 --> | |
148 | + <!-- 清除条件 --> | |
149 | 149 | <!-- 详情模板 --> |
150 | 150 | <DetailTemplate |
151 | 151 | v-if="isRuleAlarmRuleConditions == 4" |
... | ... | @@ -222,7 +222,9 @@ |
222 | 222 | const ruleObj: any = ref({}); |
223 | 223 | const ruleLastObj: any = ref({}); |
224 | 224 | const enableObj: any = ref({}); |
225 | + const enableClearObj: any = ref({}); | |
225 | 226 | const additionalObj: any = ref({}); |
227 | + const addClearitionalObj: any = ref({}); | |
226 | 228 | const isWhereTypeValue = ref(null); |
227 | 229 | const ruleTemplateData: any = ref(null); |
228 | 230 | const enableTemplateData: any = ref(null); |
... | ... | @@ -415,7 +417,7 @@ |
415 | 417 | } |
416 | 418 | }); |
417 | 419 | ruleTemplateData.value = ` |
418 | - 键名:${v.key}...操作:${findRuleByValue?.label}...值:${v.value1} | |
420 | + 键名:${v.key1}...操作:${findRuleByValue?.label}...值:${v.value1} | |
419 | 421 | `; |
420 | 422 | |
421 | 423 | ruleLastObj.value = v1; |
... | ... | @@ -443,7 +445,7 @@ |
443 | 445 | { |
444 | 446 | key: { |
445 | 447 | type: ruleObj.value?.type, |
446 | - key: ruleObj.value?.key, | |
448 | + key: ruleObj.value?.key1, | |
447 | 449 | }, |
448 | 450 | valueType: ruleObj.value.type1, |
449 | 451 | predicate, |
... | ... | @@ -466,7 +468,7 @@ |
466 | 468 | }; |
467 | 469 | //启用规则 |
468 | 470 | const getAllClearFieldsEnabFunc = (v) => { |
469 | - enableObj.value = v; | |
471 | + enableClearObj.value = v; | |
470 | 472 | const findDay = [ |
471 | 473 | { |
472 | 474 | label: '星期一', |
... | ... | @@ -533,7 +535,7 @@ |
533 | 535 | } |
534 | 536 | }); |
535 | 537 | ruleClearTemplateData.value = ` |
536 | - 键名:${v.key}...操作:${findRuleByValue?.label}...值:${v.value1} | |
538 | + 键名:${v.key1}...操作:${findRuleByValue?.label}...值:${v.value1} | |
537 | 539 | `; |
538 | 540 | |
539 | 541 | ruleLastObj.value = v1; |
... | ... | @@ -561,7 +563,7 @@ |
561 | 563 | { |
562 | 564 | key: { |
563 | 565 | type: ruleObj.value?.type, |
564 | - key: ruleObj.value?.key, | |
566 | + key: ruleObj.value?.key1, | |
565 | 567 | }, |
566 | 568 | valueType: ruleObj.value.type1, |
567 | 569 | predicate, |
... | ... | @@ -572,11 +574,21 @@ |
572 | 574 | const getValueConditon = { |
573 | 575 | condition: getCondition, |
574 | 576 | }; |
575 | - Object.assign(additionalObj.value, getValueConditon); | |
577 | + Object.assign(addClearitionalObj.value, getValueConditon); | |
576 | 578 | }; |
577 | - | |
578 | 579 | const handleFormStep3toStep4Next = async () => { |
579 | 580 | try { |
581 | + const scheduleClearValue = { | |
582 | + type: enableClearObj.value.schedule, | |
583 | + daysOfWeek: enableClearObj.value.daysOfWeek, | |
584 | + // endsOn: enableClearObj.value.endsOn, | |
585 | + // startsOn: enableClearObj.value.startOn, | |
586 | + timezone: enableClearObj.value.timezone, | |
587 | + }; | |
588 | + const getClearSchedule = { | |
589 | + schedule: scheduleClearValue, | |
590 | + }; | |
591 | + const getClearAdditionalProp = Object.assign({}, detailObj.value, getClearSchedule); | |
580 | 592 | const scheduleValue = { |
581 | 593 | type: enableObj.value.schedule, |
582 | 594 | daysOfWeek: enableObj.value.daysOfWeek, |
... | ... | @@ -595,8 +607,8 @@ |
595 | 607 | ); |
596 | 608 | const getScheduleAndClearAlarmDetails = Object.assign( |
597 | 609 | {}, |
598 | - getAdditionalProp, | |
599 | - additionalObj.value | |
610 | + getClearAdditionalProp, | |
611 | + addClearitionalObj.value | |
600 | 612 | ); |
601 | 613 | const getIsWhereTypeValue: any = isWhereTypeValue.value; |
602 | 614 | const getAdditionalPropObj = { | ... | ... |
... | ... | @@ -30,10 +30,10 @@ export const isTimeAll = (type: string) => { |
30 | 30 | return type === TriggerEnum.IS_SCENE_ACT; |
31 | 31 | }; |
32 | 32 | |
33 | -export const columns: BasicColumn[] = [ | |
33 | +export const keyColumns: BasicColumn[] = [ | |
34 | 34 | { |
35 | 35 | title: '键名', |
36 | - dataIndex: 'key', | |
36 | + dataIndex: 'key1', | |
37 | 37 | width: 200, |
38 | 38 | }, |
39 | 39 | { |
... | ... | @@ -45,19 +45,48 @@ export const columns: BasicColumn[] = [ |
45 | 45 | export const columnsView: BasicColumn[] = [ |
46 | 46 | { |
47 | 47 | title: '键名', |
48 | - dataIndex: 'key', | |
48 | + dataIndex: 'key1', | |
49 | 49 | width: 200, |
50 | 50 | }, |
51 | 51 | { |
52 | - title: '键类型', | |
53 | - dataIndex: 'type', | |
52 | + title: '操作', | |
53 | + dataIndex: 'operation', | |
54 | + width: 200, | |
55 | + format: (text: string, record: Recordable) => { | |
56 | + const findDay = [ | |
57 | + { label: '等于', value: 'EQUAL' }, | |
58 | + { label: '不等于', value: 'NOT_EQUAL' }, | |
59 | + { label: '开始于', value: 'STARTS_WITH' }, | |
60 | + { label: '结束于', value: 'ENDS_WITH' }, | |
61 | + { label: '包含', value: 'CONTAINS' }, | |
62 | + { label: '不包含', value: 'NOT_CONTAINS' }, | |
63 | + { label: '等于', value: 'EQUAL' }, | |
64 | + { label: '不等于', value: 'NOT_EQUAL' }, | |
65 | + { label: '大于', value: 'GREATER' }, | |
66 | + { label: '小于', value: 'LESS' }, | |
67 | + { label: '大于或等于', value: 'GREATER_OR_EQUAL' }, | |
68 | + { label: '小于或等于', value: 'LESS_OR_EQUAL' }, | |
69 | + ]; | |
70 | + const findRuleByValue = findDay.find((f) => { | |
71 | + if (f.value == record.operation) { | |
72 | + return f.label; | |
73 | + } | |
74 | + }); | |
75 | + if (findRuleByValue) { | |
76 | + return findRuleByValue.label; | |
77 | + } | |
78 | + }, | |
79 | + }, | |
80 | + { | |
81 | + title: '值', | |
82 | + dataIndex: 'value1', | |
54 | 83 | width: 200, |
55 | 84 | }, |
56 | 85 | ]; |
57 | 86 | |
58 | 87 | export const DescDetailSchema: DescItem[] = [ |
59 | 88 | { |
60 | - field: 'key', | |
89 | + field: 'key1', | |
61 | 90 | label: '键名', |
62 | 91 | }, |
63 | 92 | { | ... | ... |
... | ... | @@ -57,7 +57,7 @@ export const formSchema: FormSchema[] = [ |
57 | 57 | }, |
58 | 58 | }, |
59 | 59 | { |
60 | - field: 'key', | |
60 | + field: 'key1', | |
61 | 61 | label: '键名', |
62 | 62 | colProps: { span: 24 }, |
63 | 63 | component: 'Input', |
... | ... | @@ -74,7 +74,7 @@ export const formSchema: FormSchema[] = [ |
74 | 74 | ifShow: ({ values }) => isShiDu(Reflect.get(values, 'type')), |
75 | 75 | }, |
76 | 76 | { |
77 | - field: 'key', | |
77 | + field: 'key1', | |
78 | 78 | label: '键名', |
79 | 79 | colProps: { span: 24 }, |
80 | 80 | component: 'Input', |
... | ... | @@ -89,7 +89,7 @@ export const formSchema: FormSchema[] = [ |
89 | 89 | ifShow: ({ values }) => isWenDu(Reflect.get(values, 'type')), |
90 | 90 | }, |
91 | 91 | { |
92 | - field: 'key', | |
92 | + field: 'key1', | |
93 | 93 | label: '键名', |
94 | 94 | colProps: { span: 24 }, |
95 | 95 | component: 'Input', | ... | ... |
... | ... | @@ -22,7 +22,8 @@ |
22 | 22 | emits: ['success', 'register'], |
23 | 23 | setup(_, { emit }) { |
24 | 24 | const isUpdate = ref(true); |
25 | - const getValue: any = ref(null); | |
25 | + const getValue: any = ref({}); | |
26 | + const setId: any = ref(1); | |
26 | 27 | const getTitle = computed(() => (!unref(isUpdate) ? '新增键名筛选器' : '编辑键名筛选器')); |
27 | 28 | const [registerForm, { getFieldsValue, setFieldsValue, resetFields }] = useForm({ |
28 | 29 | labelWidth: 120, |
... | ... | @@ -31,11 +32,9 @@ |
31 | 32 | const [register, { closeModal }] = useModalInner(async (data) => { |
32 | 33 | isUpdate.value = !!data?.isUpdate; |
33 | 34 | if (!unref(isUpdate)) { |
34 | - console.log('新增键名筛选器'); | |
35 | 35 | resetFields(); |
36 | 36 | } |
37 | 37 | if (unref(isUpdate)) { |
38 | - console.log('编辑键名筛选器'); | |
39 | 38 | setFieldsValue({ |
40 | 39 | ...data.record, |
41 | 40 | }); |
... | ... | @@ -44,8 +43,23 @@ |
44 | 43 | |
45 | 44 | const handleSubmit = () => { |
46 | 45 | getValue.value = getFieldsValue(); |
46 | + setId.value += 1; | |
47 | + getValue.value.id = setId.value; | |
47 | 48 | emit('success', getValue.value); |
48 | 49 | closeModal(); |
50 | + // if (!unref(isUpdate)) { | |
51 | + // getValue.value = getFieldsValue(); | |
52 | + // console.log(getValue.value); | |
53 | + // } | |
54 | + // if (unref(isUpdate)) { | |
55 | + // getValue.value = getFieldsValue(); | |
56 | + // console.log(getValue.value); | |
57 | + // } | |
58 | + // setTimeout(() => { | |
59 | + // emit('success', getValue.value); | |
60 | + // closeModal(); | |
61 | + // }, 20); | |
62 | + // // getValue.value = getFieldsValue(); | |
49 | 63 | }; |
50 | 64 | const handleCancel = () => { |
51 | 65 | return; | ... | ... |
... | ... | @@ -7,7 +7,13 @@ |
7 | 7 | @ok="handleSubmit" |
8 | 8 | > |
9 | 9 | <CollapseContainer title="键名筛选器" class="border mb-8"> |
10 | - <BasicTable :resizeHeightOffset="200" @register="registerTable" :dataSource="getTableApiData"> | |
10 | + <BasicTable | |
11 | + :showIndexColumn="false" | |
12 | + :resizeHeightOffset="200" | |
13 | + @register="registerTable" | |
14 | + :dataSource="getTableApiData" | |
15 | + > | |
16 | + > | |
11 | 17 | <template #toolbar> |
12 | 18 | <a-button type="primary" @click="handleAddKey"> 新增键名筛选器 </a-button> |
13 | 19 | </template> |
... | ... | @@ -39,6 +45,7 @@ |
39 | 45 | :columns="columnsView" |
40 | 46 | :dataSource="detailData" |
41 | 47 | :pagination="false" |
48 | + :showIndexColumn="false" | |
42 | 49 | /> |
43 | 50 | </CollapseContainer> |
44 | 51 | <BasicForm :showResetButton="false" :showSubmitButton="false" @register="registerForm" /> |
... | ... | @@ -46,10 +53,10 @@ |
46 | 53 | <KeyValueModal @register="registerModal" @success="handleSuccess" /> |
47 | 54 | </template> |
48 | 55 | <script lang="ts"> |
49 | - import { defineComponent, ref, computed, unref } from 'vue'; | |
56 | + import { defineComponent, ref, computed, unref, getCurrentInstance } from 'vue'; | |
50 | 57 | import { BasicModal, useModalInner } from '/@/components/Modal'; |
51 | 58 | import { BasicForm, useForm } from '/@/components/Form'; |
52 | - import { formSchema, columns, DescDetailSchema, columnsView } from './config'; | |
59 | + import { formSchema, keyColumns, DescDetailSchema, columnsView } from './config'; | |
53 | 60 | import { CollapseContainer } from '/@/components/Container/index'; |
54 | 61 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
55 | 62 | import { useModal } from '/@/components/Modal'; |
... | ... | @@ -67,10 +74,12 @@ |
67 | 74 | }, |
68 | 75 | emits: ['success', 'register', 'getAllFieldsRule', 'getLastAllFieldsRule'], |
69 | 76 | setup(_, { emit }) { |
77 | + const { proxy } = getCurrentInstance(); | |
70 | 78 | const getTableApiData: any = ref([]); |
71 | 79 | const detailData: any = ref([]); |
72 | 80 | const receiveData: any = ref(null); |
73 | 81 | const lastValues: any = ref(null); |
82 | + const addOrUpdateData: any = ref(null); | |
74 | 83 | const isUpdate = ref(true); |
75 | 84 | const [registerForm, { getFieldsValue, resetFields }] = useForm({ |
76 | 85 | labelWidth: 120, |
... | ... | @@ -83,10 +92,11 @@ |
83 | 92 | }); |
84 | 93 | const [registerTable, { reload }] = useTable({ |
85 | 94 | title: '键名筛选器', |
86 | - columns, | |
95 | + columns: keyColumns, | |
87 | 96 | bordered: true, |
88 | 97 | showIndexColumn: false, |
89 | 98 | pagination: false, |
99 | + autoCreateKey: true, | |
90 | 100 | actionColumn: { |
91 | 101 | width: 180, |
92 | 102 | title: '操作', |
... | ... | @@ -94,12 +104,11 @@ |
94 | 104 | slots: { customRender: 'action' }, |
95 | 105 | }, |
96 | 106 | }); |
97 | - | |
98 | 107 | const handleSubmit = () => { |
99 | - if (unref(isUpdate.value)) { | |
100 | - const values = getFieldsValue(); | |
101 | - getTableApiData.value.push(values); | |
102 | - detailData.value.push(values); | |
108 | + if (!unref(isUpdate)) { | |
109 | + addOrUpdateData.value = getFieldsValue(); | |
110 | + getTableApiData.value.push(addOrUpdateData.value); | |
111 | + detailData.value.push(addOrUpdateData.value); | |
103 | 112 | } |
104 | 113 | lastValues.value = getFieldsValue(); |
105 | 114 | emit('getAllFieldsRule', receiveData.value, lastValues.value); |
... | ... | @@ -125,15 +134,48 @@ |
125 | 134 | }; |
126 | 135 | const handleDelete = (record: Recordable) => { |
127 | 136 | console.log(record); |
128 | - getTableApiData.value.splice(0, 1); | |
129 | - detailData.value.splice(0, 1); | |
137 | + console.log(getTableApiData.value); | |
138 | + // const getIndex = getTableApiData.value.indexOf((i) => { | |
139 | + // return i.key; | |
140 | + // }); | |
141 | + const newFilterArray = getTableApiData.value.filter((item) => item.id !== record.id); | |
142 | + getTableApiData.value = newFilterArray; | |
143 | + // getTableApiData.value.splice(getIndex, 1); | |
144 | + | |
145 | + // console.log(getTableApiData.value); | |
146 | + // delete getTableApiData.value[findByKeyDel]; | |
147 | + // getTableApiData.value.slice(0, getTableApiData.value.length - 1); | |
148 | + // detailData.value.slice(0, detailData.value.length - 1); | |
149 | + // if (record) { | |
150 | + // getTableApiData.value = getTableApiData.value.length - 1; | |
151 | + // detailData.value = detailData.value.length - 1; | |
152 | + // } | |
130 | 153 | reload(); |
131 | 154 | }; |
132 | 155 | const handleSuccess = (v) => { |
133 | 156 | receiveData.value = v; |
134 | 157 | setTimeout(() => { |
135 | 158 | doFunc(); |
136 | - }, 10); | |
159 | + }, 20); | |
160 | + // if (!unref(isUpdate)) { | |
161 | + // console.log(v); | |
162 | + // // receiveData.value = v; | |
163 | + // setTimeout(() => { | |
164 | + // // doFunc(); | |
165 | + // getTableApiData.value.push(v); | |
166 | + // detailData.value.push(v); | |
167 | + // }, 10); | |
168 | + // } | |
169 | + // if (unref(isUpdate)) { | |
170 | + // console.log(v); | |
171 | + // // receiveData.value = v; | |
172 | + // setTimeout(() => { | |
173 | + // // doFunc(); | |
174 | + // getTableApiData.value.push(v); | |
175 | + // updateTableDataRecord(v.key, v); | |
176 | + // detailData.value.push(v); | |
177 | + // }, 10); | |
178 | + // } | |
137 | 179 | }; |
138 | 180 | const doFunc = () => { |
139 | 181 | getTableApiData.value.push(receiveData.value); | ... | ... |
src/views/ruleengine/scenelinkage/addForm/1.json
deleted
100644 → 0
1 | -{ | |
2 | - "name": "设备测试3", | |
3 | - "defaultRuleChainId": "354c7210-5d97-11ec-8ac9-f38ed935ea2a", | |
4 | - "description": "设备测试3", | |
5 | - "transportType": "CoAP", | |
6 | - "profileData": { | |
7 | - "alarms": [ | |
8 | - { | |
9 | - "alarmType": "设备测试3", | |
10 | - "propagate": true, | |
11 | - "propagateRelationTypes": [ | |
12 | - "设备测试3" | |
13 | - ], | |
14 | - "createRules": { | |
15 | - "MAJOR": { | |
16 | - "alarmDetails": "设备测试3", | |
17 | - "schedule": { | |
18 | - "type": "ANY_TIME" | |
19 | - }, | |
20 | - "condition": { | |
21 | - "condition": [ | |
22 | - { | |
23 | - "key": { | |
24 | - "type": "TIME_SERIES", | |
25 | - "key": "CO2" | |
26 | - }, | |
27 | - "valueType": "COMPLEX", | |
28 | - "predicate": { | |
29 | - "operation": "LESS_OR_EQUAL", | |
30 | - "value": { | |
31 | - "defaultValue": 2 | |
32 | - }, | |
33 | - "type": "COMPLEX" | |
34 | - } | |
35 | - } | |
36 | - ], | |
37 | - "spec": { | |
38 | - "type": "DURATION" | |
39 | - } | |
40 | - } | |
41 | - } | |
42 | - } | |
43 | - } | |
44 | - ] | |
45 | - }, | |
46 | - "alarmProfile": { | |
47 | - "alarmContactId": "a3004ddd-db8f-487c-aea0-4f6f3efc59a9", | |
48 | - "messageMode": "PHONE_MESSAGE" | |
49 | - } | |
50 | -} |