Showing
5 changed files
with
200 additions
and
159 deletions
@@ -53,9 +53,7 @@ | @@ -53,9 +53,7 @@ | ||
53 | :DetailTemplateCpnData="!isStep3FatherAddOrEditStatus ? 1 : item" | 53 | :DetailTemplateCpnData="!isStep3FatherAddOrEditStatus ? 1 : item" |
54 | /> | 54 | /> |
55 | <AlarmRuleConditionsCpn | 55 | <AlarmRuleConditionsCpn |
56 | - :getFatherData="getConditionData" | ||
57 | - :ref="`AlarmRuleConditionsRef${index}`" | ||
58 | - @register="registerAlarmRuleConditionsModal" | 56 | + :ref="conditionRefs.AlarmRuleConditionsRef" |
59 | @getAllFieldsRule="getAlarmRuleConditionsValFunc" | 57 | @getAllFieldsRule="getAlarmRuleConditionsValFunc" |
60 | /> | 58 | /> |
61 | <EnableRuleCpn | 59 | <EnableRuleCpn |
@@ -290,10 +288,7 @@ | @@ -290,10 +288,7 @@ | ||
290 | props: ['step3FatherEmitCpnData', 'step3FatherEmitCpnStatus'], | 288 | props: ['step3FatherEmitCpnData', 'step3FatherEmitCpnStatus'], |
291 | setup(props) { | 289 | setup(props) { |
292 | const getConditionData = ref([]); | 290 | const getConditionData = ref([]); |
293 | - let currentAlarmCondition: any = reactive({ | ||
294 | - key: 0, | ||
295 | - data: {}, | ||
296 | - }); | 291 | + const getConditionData1 = ref([{ key: 0, data: {} }]); |
297 | const clickConditionData = ref([]); | 292 | const clickConditionData = ref([]); |
298 | const { proxy } = getCurrentInstance() as any; | 293 | const { proxy } = getCurrentInstance() as any; |
299 | const createAlarmRuleData: any = ref([1]); | 294 | const createAlarmRuleData: any = ref([1]); |
@@ -308,6 +303,9 @@ | @@ -308,6 +303,9 @@ | ||
308 | const formatEnableRule: any = ref([]); | 303 | const formatEnableRule: any = ref([]); |
309 | const formatClearEnableRule: any = ref([]); | 304 | const formatClearEnableRule: any = ref([]); |
310 | const formatEditClearEnableRule: any = ref([]); | 305 | const formatEditClearEnableRule: any = ref([]); |
306 | + const conditionRefs = { | ||
307 | + AlarmRuleConditionsRef: ref([]), | ||
308 | + }; | ||
311 | let alaramsObj: any = reactive({ | 309 | let alaramsObj: any = reactive({ |
312 | alarmType: null, | 310 | alarmType: null, |
313 | propagate: null, | 311 | propagate: null, |
@@ -329,8 +327,6 @@ | @@ -329,8 +327,6 @@ | ||
329 | let val10: any = ref(null); | 327 | let val10: any = ref(null); |
330 | const formatEditRuleData: any = ref([]); | 328 | const formatEditRuleData: any = ref([]); |
331 | const formatEditEnableData: any = ref([]); | 329 | const formatEditEnableData: any = ref([]); |
332 | - const [registerAlarmRuleConditionsModal, { openModal: openModalAlarmRuleConditions }] = | ||
333 | - useModal(); | ||
334 | const [registerEnableRuleModal, { openModal: openModalEnableRule }] = useModal(); | 330 | const [registerEnableRuleModal, { openModal: openModalEnableRule }] = useModal(); |
335 | const [ | 331 | const [ |
336 | registerClearAlarmRuleConditionsModal, | 332 | registerClearAlarmRuleConditionsModal, |
@@ -422,23 +418,27 @@ | @@ -422,23 +418,27 @@ | ||
422 | } | 418 | } |
423 | }; | 419 | }; |
424 | const clickAddAlarmRuleConditionsFunc = (e, i) => { | 420 | const clickAddAlarmRuleConditionsFunc = (e, i) => { |
425 | - openModalAlarmRuleConditions(true); | 421 | + getConditionData.value = []; |
422 | + | ||
426 | //获取对应下标 | 423 | //获取对应下标 |
427 | - currentAlarmCondition.key = i; | ||
428 | - currentAlarmCondition.data = clickConditionData.value; | ||
429 | - currentAlarmCondition = clickConditionData.value; | ||
430 | - // if (e === true) { | ||
431 | - // nextTick(() => { | ||
432 | - // proxy.$refs['AlarmRuleConditionsRef' + i].resetDataFunc(); | ||
433 | - // }); | ||
434 | - // } else { | ||
435 | - // nextTick(() => { | ||
436 | - // proxy.$refs['AlarmRuleConditionsRef' + i].resetDataFunc(); | ||
437 | - // }); | ||
438 | - // } | ||
439 | - proxy.$refs['AlarmRuleConditionsRef' + i].resetDataFunc(); | 424 | + let currentAlarmCondition = { key: 0, data: {} }; |
425 | + let isUpdate = false; | ||
426 | + getConditionData1.value.forEach((obj) => { | ||
427 | + if (obj.data.length != undefined && obj.key == i) { | ||
428 | + currentAlarmCondition.key = i; | ||
429 | + currentAlarmCondition.data = obj.data; | ||
430 | + isUpdate = true; | ||
431 | + } | ||
432 | + }); | ||
433 | + getConditionData.value.push(currentAlarmCondition); | ||
434 | + conditionRefs.AlarmRuleConditionsRef.value.map((item, index) => { | ||
435 | + if (i === index) { | ||
436 | + nextTick(() => { | ||
437 | + item.resetDataFunc(index, currentAlarmCondition, isUpdate); | ||
438 | + }); | ||
439 | + } | ||
440 | + }); | ||
440 | }; | 441 | }; |
441 | - console.log('data', currentAlarmCondition); | ||
442 | 442 | ||
443 | const clickAddEnableRuleFunc = () => { | 443 | const clickAddEnableRuleFunc = () => { |
444 | nextTick(() => { | 444 | nextTick(() => { |
@@ -462,10 +462,17 @@ | @@ -462,10 +462,17 @@ | ||
462 | console.log('获取condition的值', e); | 462 | console.log('获取condition的值', e); |
463 | formatAlarmRuleConditions.value.push(e); | 463 | formatAlarmRuleConditions.value.push(e); |
464 | clickConditionData.value = e; | 464 | clickConditionData.value = e; |
465 | - currentAlarmCondition = getConditionData.value; | ||
466 | - // formatEditRuleData.value.push({ | ||
467 | - // condition: e, | ||
468 | - // } as never); | 465 | + let addValue = undefined; |
466 | + getConditionData1.value.forEach((obj) => { | ||
467 | + if (obj.data.length != undefined && obj.key == e.key) { | ||
468 | + obj.data = e.data; | ||
469 | + } else { | ||
470 | + addValue = e; | ||
471 | + } | ||
472 | + }); | ||
473 | + if (addValue != undefined) { | ||
474 | + getConditionData1.value.push(addValue); | ||
475 | + } | ||
469 | }; | 476 | }; |
470 | const getClearAlarmRuleConditionsValFunc = (e) => { | 477 | const getClearAlarmRuleConditionsValFunc = (e) => { |
471 | formatClearAlarmRuleConditions.value.push({ | 478 | formatClearAlarmRuleConditions.value.push({ |
@@ -689,9 +696,15 @@ | @@ -689,9 +696,15 @@ | ||
689 | ); | 696 | ); |
690 | return formatMap; | 697 | return formatMap; |
691 | }; | 698 | }; |
699 | + | ||
692 | const formatEnableRuleFuncData = (v) => { | 700 | const formatEnableRuleFuncData = (v) => { |
693 | return formatEnableRuleData(formatAlarmRuleConditionsData1(v)?.schedule); | 701 | return formatEnableRuleData(formatAlarmRuleConditionsData1(v)?.schedule); |
694 | }; | 702 | }; |
703 | + | ||
704 | + const forMatAddConditionFunc = (e) => { | ||
705 | + let formatMap = e.data.map((f: any) => formatAlarmRuleConditionsData(f)); | ||
706 | + return formatMap; | ||
707 | + }; | ||
695 | return { | 708 | return { |
696 | registerForm, | 709 | registerForm, |
697 | registerFormHighSetting, | 710 | registerFormHighSetting, |
@@ -703,7 +716,6 @@ | @@ -703,7 +716,6 @@ | ||
703 | clickAddAlarmRuleConditionsFunc, | 716 | clickAddAlarmRuleConditionsFunc, |
704 | AlarmRuleConditionsRef, | 717 | AlarmRuleConditionsRef, |
705 | EnableRuleRef, | 718 | EnableRuleRef, |
706 | - registerAlarmRuleConditionsModal, | ||
707 | registerEnableRuleModal, | 719 | registerEnableRuleModal, |
708 | getAlarmRuleConditionsValFunc, | 720 | getAlarmRuleConditionsValFunc, |
709 | formatAlarmRuleConditions, | 721 | formatAlarmRuleConditions, |
@@ -745,6 +757,9 @@ | @@ -745,6 +757,9 @@ | ||
745 | formatEditEnableRuleFunc, | 757 | formatEditEnableRuleFunc, |
746 | updateCpnSchemaSelectEnableFunc, | 758 | updateCpnSchemaSelectEnableFunc, |
747 | getConditionData, | 759 | getConditionData, |
760 | + getConditionData1, | ||
761 | + forMatAddConditionFunc, | ||
762 | + conditionRefs, | ||
748 | }; | 763 | }; |
749 | }, | 764 | }, |
750 | }); | 765 | }); |
@@ -34,24 +34,17 @@ export const keyColumns: BasicColumn[] = [ | @@ -34,24 +34,17 @@ export const keyColumns: BasicColumn[] = [ | ||
34 | { | 34 | { |
35 | title: '键名', | 35 | title: '键名', |
36 | dataIndex: 'key1', | 36 | dataIndex: 'key1', |
37 | - width: 200, | 37 | + width: 100, |
38 | }, | 38 | }, |
39 | { | 39 | { |
40 | title: '键类型', | 40 | title: '键类型', |
41 | dataIndex: 'type', | 41 | dataIndex: 'type', |
42 | - width: 200, | ||
43 | - }, | ||
44 | -]; | ||
45 | -export const columnsView: BasicColumn[] = [ | ||
46 | - { | ||
47 | - title: '键名', | ||
48 | - dataIndex: 'key1', | ||
49 | - width: 200, | 42 | + width: 100, |
50 | }, | 43 | }, |
51 | { | 44 | { |
52 | title: '操作', | 45 | title: '操作', |
53 | dataIndex: 'operation', | 46 | dataIndex: 'operation', |
54 | - width: 200, | 47 | + width: 100, |
55 | format: (text: string, record: Recordable) => { | 48 | format: (text: string, record: Recordable) => { |
56 | const findDay = [ | 49 | const findDay = [ |
57 | { label: '等于', value: 'EQUAL' }, | 50 | { label: '等于', value: 'EQUAL' }, |
@@ -80,9 +73,50 @@ export const columnsView: BasicColumn[] = [ | @@ -80,9 +73,50 @@ export const columnsView: BasicColumn[] = [ | ||
80 | { | 73 | { |
81 | title: '值', | 74 | title: '值', |
82 | dataIndex: 'value1', | 75 | dataIndex: 'value1', |
83 | - width: 200, | 76 | + width: 80, |
84 | }, | 77 | }, |
85 | ]; | 78 | ]; |
79 | +// export const columnsView: BasicColumn[] = [ | ||
80 | +// { | ||
81 | +// title: '键名', | ||
82 | +// dataIndex: 'key1', | ||
83 | +// width: 200, | ||
84 | +// }, | ||
85 | +// { | ||
86 | +// title: '操作', | ||
87 | +// dataIndex: 'operation', | ||
88 | +// width: 200, | ||
89 | +// format: (text: string, record: Recordable) => { | ||
90 | +// const findDay = [ | ||
91 | +// { label: '等于', value: 'EQUAL' }, | ||
92 | +// { label: '不等于', value: 'NOT_EQUAL' }, | ||
93 | +// { label: '开始于', value: 'STARTS_WITH' }, | ||
94 | +// { label: '结束于', value: 'ENDS_WITH' }, | ||
95 | +// { label: '包含', value: 'CONTAINS' }, | ||
96 | +// { label: '不包含', value: 'NOT_CONTAINS' }, | ||
97 | +// { label: '等于', value: 'EQUAL' }, | ||
98 | +// { label: '不等于', value: 'NOT_EQUAL' }, | ||
99 | +// { label: '大于', value: 'GREATER' }, | ||
100 | +// { label: '小于', value: 'LESS' }, | ||
101 | +// { label: '大于或等于', value: 'GREATER_OR_EQUAL' }, | ||
102 | +// { label: '小于或等于', value: 'LESS_OR_EQUAL' }, | ||
103 | +// ]; | ||
104 | +// const findRuleByValue = findDay.find((f) => { | ||
105 | +// if (f.value == record.operation) { | ||
106 | +// return f.label; | ||
107 | +// } | ||
108 | +// }); | ||
109 | +// if (findRuleByValue) { | ||
110 | +// return findRuleByValue.label; | ||
111 | +// } | ||
112 | +// }, | ||
113 | +// }, | ||
114 | +// { | ||
115 | +// title: '值', | ||
116 | +// dataIndex: 'value1', | ||
117 | +// width: 200, | ||
118 | +// }, | ||
119 | +// ]; | ||
86 | 120 | ||
87 | export const DescDetailSchema: DescItem[] = [ | 121 | export const DescDetailSchema: DescItem[] = [ |
88 | { | 122 | { |
@@ -46,6 +46,12 @@ export const isComplex = (type: string) => { | @@ -46,6 +46,12 @@ export const isComplex = (type: string) => { | ||
46 | 46 | ||
47 | export const formSchema: FormSchema[] = [ | 47 | export const formSchema: FormSchema[] = [ |
48 | { | 48 | { |
49 | + field: 'id', | ||
50 | + label: '', | ||
51 | + component: 'InputNumber', | ||
52 | + ifShow: false, | ||
53 | + }, | ||
54 | + { | ||
49 | field: 'type', | 55 | field: 'type', |
50 | label: '键类型', | 56 | label: '键类型', |
51 | colProps: { span: 13 }, | 57 | colProps: { span: 13 }, |
@@ -47,7 +47,6 @@ | @@ -47,7 +47,6 @@ | ||
47 | const getIsWhereType: any = ref(null); | 47 | const getIsWhereType: any = ref(null); |
48 | const isUpdate = ref(true); | 48 | const isUpdate = ref(true); |
49 | const getValue: any = ref(null); | 49 | const getValue: any = ref(null); |
50 | - const setId: any = ref(1); | ||
51 | const getKeyAndValArr = ref<[]>([]); | 50 | const getKeyAndValArr = ref<[]>([]); |
52 | 51 | ||
53 | const getTitle = computed(() => (!unref(isUpdate) ? '新增键名筛选器' : '编辑键名筛选器')); | 52 | const getTitle = computed(() => (!unref(isUpdate) ? '新增键名筛选器' : '编辑键名筛选器')); |
@@ -103,61 +102,38 @@ | @@ -103,61 +102,38 @@ | ||
103 | 102 | ||
104 | const handleSubmit = () => { | 103 | const handleSubmit = () => { |
105 | let mapGetKeyAndValArr = []; | 104 | let mapGetKeyAndValArr = []; |
105 | + getValue.value = getFieldsValue(); | ||
106 | if (!unref(isUpdate)) { | 106 | if (!unref(isUpdate)) { |
107 | - getValue.value = getFieldsValue(); | ||
108 | getKeyAndValArr.value.push(getValue.value); | 107 | getKeyAndValArr.value.push(getValue.value); |
109 | - mapGetKeyAndValArr = getKeyAndValArr.value.map((m: any) => { | ||
110 | - return { | ||
111 | - key: { | ||
112 | - type: m.type, | ||
113 | - key: m.key1, | ||
114 | - }, | ||
115 | - valueType: m.type1, | ||
116 | - value: m.value1, | ||
117 | - predicate: { | ||
118 | - type: m.type1, | ||
119 | - operation: m.operation, | ||
120 | - value: { | ||
121 | - defaultValue: m.value1, | ||
122 | - }, | ||
123 | - }, | ||
124 | - }; | ||
125 | - }); | ||
126 | - | ||
127 | - setId.value += 1; | ||
128 | - getValue.value.id = setId.value; | ||
129 | - // emit('success', getValue.value); | ||
130 | - // closeModal(); | ||
131 | - } else { | ||
132 | - getValue.value = getFieldsValue(); | ||
133 | - getKeyAndValArr.value.push(getValue.value); | ||
134 | - mapGetKeyAndValArr = getKeyAndValArr.value.map((m: any) => { | ||
135 | - return { | ||
136 | - key: { | ||
137 | - type: m.type, | ||
138 | - key: m.value1, | ||
139 | - }, | ||
140 | - valueType: m.type1, | ||
141 | - value: m.value1, | ||
142 | - predicate: { | ||
143 | - type: m.type1, | ||
144 | - operation: m.operation, | ||
145 | - value: { | ||
146 | - defaultValue: m.value1, | ||
147 | - }, | 108 | + } |
109 | + mapGetKeyAndValArr = getKeyAndValArr.value.map((m: any, index) => { | ||
110 | + return { | ||
111 | + key: { | ||
112 | + id: index, | ||
113 | + type: m.type, | ||
114 | + key: m.key1, | ||
115 | + }, | ||
116 | + valueType: m.type1, | ||
117 | + value: m.value1, | ||
118 | + predicate: { | ||
119 | + type: m.type1, | ||
120 | + operation: m.operation, | ||
121 | + value: { | ||
122 | + defaultValue: m.value1, | ||
148 | }, | 123 | }, |
149 | - }; | ||
150 | - }); | ||
151 | - setId.value += 9999; | ||
152 | - getValue.value.id = setId.value; | 124 | + }, |
125 | + }; | ||
126 | + }); | ||
127 | + if (!unref(isUpdate)) { | ||
128 | + getValue.value.id = getKeyAndValArr.value.length - 1; | ||
153 | } | 129 | } |
154 | - emit('success', mapGetKeyAndValArr, getValue.value); | 130 | + |
131 | + emit('success', mapGetKeyAndValArr, getValue.value, unref(isUpdate)); | ||
155 | closeModal(); | 132 | closeModal(); |
156 | }; | 133 | }; |
157 | const handleCancel = () => { | 134 | const handleCancel = () => { |
158 | return; | 135 | return; |
159 | }; | 136 | }; |
160 | - | ||
161 | const n = ref(1); | 137 | const n = ref(1); |
162 | 138 | ||
163 | function add() { | 139 | function add() { |
@@ -205,6 +181,7 @@ | @@ -205,6 +181,7 @@ | ||
205 | removeSchemaByFiled([`field${field}a`, `field${field}b`, `${field}`]); | 181 | removeSchemaByFiled([`field${field}a`, `field${field}b`, `${field}`]); |
206 | n.value--; | 182 | n.value--; |
207 | } | 183 | } |
184 | + | ||
208 | watch(isWhereType, (v) => { | 185 | watch(isWhereType, (v) => { |
209 | switch (v) { | 186 | switch (v) { |
210 | case 'STRING': | 187 | case 'STRING': |
@@ -9,10 +9,12 @@ | @@ -9,10 +9,12 @@ | ||
9 | @cancel="handleCancel" | 9 | @cancel="handleCancel" |
10 | > | 10 | > |
11 | <CollapseContainer title="键名筛选器" class="border mb-8"> | 11 | <CollapseContainer title="键名筛选器" class="border mb-8"> |
12 | - <div class="table-style"> | 12 | + <div class="table-style" |
13 | + >{{ currentIndex }} | ||
14 | + {{ getTableApiData.value }} | ||
13 | <BasicTable | 15 | <BasicTable |
14 | :showIndexColumn="false" | 16 | :showIndexColumn="false" |
15 | - :dataSource="getTableApiData" | 17 | + :dataSource="getTableApiData.value" |
16 | @register="registerTable" | 18 | @register="registerTable" |
17 | > | 19 | > |
18 | <template #toolbar> | 20 | <template #toolbar> |
@@ -41,24 +43,24 @@ | @@ -41,24 +43,24 @@ | ||
41 | </BasicTable> | 43 | </BasicTable> |
42 | </div> | 44 | </div> |
43 | </CollapseContainer> | 45 | </CollapseContainer> |
44 | - <CollapseContainer title="筛选器预览" class="border mb-8"> | ||
45 | - <!-- <p v-for="(item, index) in detailData" :key="index">{{ item }}</p> --> | ||
46 | - <Description | ||
47 | - v-for="(item, index) in detailData" | ||
48 | - :key="index" | ||
49 | - :column="3" | ||
50 | - :data="item" | ||
51 | - :schema="schema" | ||
52 | - /> | ||
53 | - </CollapseContainer> | 46 | + <!-- <CollapseContainer title="筛选器预览" class="border mb-8">--> |
47 | + <!-- <!– <p v-for="(item, index) in detailData" :key="index">{{ item }}</p> –>--> | ||
48 | + <!-- <Description--> | ||
49 | + <!-- v-for="(item, index) in detailData"--> | ||
50 | + <!-- :key="index"--> | ||
51 | + <!-- :column="3"--> | ||
52 | + <!-- :data="item"--> | ||
53 | + <!-- :schema="schema"--> | ||
54 | + <!-- />--> | ||
55 | + <!-- </CollapseContainer>--> | ||
54 | <BasicForm :showResetButton="false" :showSubmitButton="false" @register="registerForm" /> | 56 | <BasicForm :showResetButton="false" :showSubmitButton="false" @register="registerForm" /> |
55 | </BasicModal> | 57 | </BasicModal> |
56 | <KeyValueModal @register="registerModal" @success="handleSuccess" /> | 58 | <KeyValueModal @register="registerModal" @success="handleSuccess" /> |
57 | </div> | 59 | </div> |
58 | </template> | 60 | </template> |
59 | <script lang="ts"> | 61 | <script lang="ts"> |
60 | - import { defineComponent, ref, computed, unref, reactive, watch } from 'vue'; | ||
61 | - import { BasicModal, useModalInner } from '/@/components/Modal'; | 62 | + import { defineComponent, ref, computed, unref, reactive, nextTick } from 'vue'; |
63 | + import { BasicModal } from '/@/components/Modal'; | ||
62 | import { BasicForm, useForm } from '/@/components/Form'; | 64 | import { BasicForm, useForm } from '/@/components/Form'; |
63 | import { formSchema, keyColumns, DescDetailSchema } from './config'; | 65 | import { formSchema, keyColumns, DescDetailSchema } from './config'; |
64 | import { CollapseContainer } from '/@/components/Container/index'; | 66 | import { CollapseContainer } from '/@/components/Container/index'; |
@@ -119,14 +121,9 @@ | @@ -119,14 +121,9 @@ | ||
119 | setup(props, { emit }) { | 121 | setup(props, { emit }) { |
120 | let getKeyAndValueChildData = ref<[]>([]); | 122 | let getKeyAndValueChildData = ref<[]>([]); |
121 | const getTableApiData: any = ref([]); | 123 | const getTableApiData: any = ref([]); |
122 | - const newFilterArray: any = ref([]); | ||
123 | - const newFilterViewArray: any = ref([]); | ||
124 | - const newFilterKeyArray: any = ref([]); | ||
125 | - const newFilterKeyViewArray: any = ref([]); | ||
126 | const detailData: any = ref([]); | 124 | const detailData: any = ref([]); |
127 | - const receiveData: any = ref(null); | 125 | + const currentIndex = ref(0); |
128 | const lastValues: any = ref(null); | 126 | const lastValues: any = ref(null); |
129 | - const addOrUpdateData: any = ref(null); | ||
130 | const isUpdate = ref(true); | 127 | const isUpdate = ref(true); |
131 | const watchCurrentAlarmConditionValue = reactive({ | 128 | const watchCurrentAlarmConditionValue = reactive({ |
132 | key: 0, | 129 | key: 0, |
@@ -139,9 +136,7 @@ | @@ -139,9 +136,7 @@ | ||
139 | }); | 136 | }); |
140 | const [registerModal, { openModal }] = useModal(); | 137 | const [registerModal, { openModal }] = useModal(); |
141 | const getTitle = computed(() => (!unref(isUpdate) ? '添加报警规则条件' : '编辑报警规则条件')); | 138 | const getTitle = computed(() => (!unref(isUpdate) ? '添加报警规则条件' : '编辑报警规则条件')); |
142 | - const [register, { closeModal }] = useModalInner((data) => { | ||
143 | - isUpdate.value = !!data?.isUpdate; | ||
144 | - }); | 139 | + const [register, { closeModal, openModal: openCondition }] = useModal(); |
145 | const [registerTable, { reload, setTableData: setFunc }] = useTable({ | 140 | const [registerTable, { reload, setTableData: setFunc }] = useTable({ |
146 | title: '键名筛选器', | 141 | title: '键名筛选器', |
147 | columns: keyColumns, | 142 | columns: keyColumns, |
@@ -157,86 +152,99 @@ | @@ -157,86 +152,99 @@ | ||
157 | }, | 152 | }, |
158 | }); | 153 | }); |
159 | const handleSubmit = () => { | 154 | const handleSubmit = () => { |
160 | - if (!unref(isUpdate)) { | ||
161 | - addOrUpdateData.value = getFieldsValue(); | ||
162 | - getTableApiData.value.push(addOrUpdateData.value); | ||
163 | - detailData.value.push(addOrUpdateData.value); | ||
164 | - } | ||
165 | lastValues.value = getFieldsValue(); | 155 | lastValues.value = getFieldsValue(); |
166 | - watchCurrentAlarmConditionValue.key = | ||
167 | - props.getFatherData?.key == undefined ? 0 : props.getFatherData?.key; | ||
168 | - watchCurrentAlarmConditionValue.data = getKeyAndValueChildData.value; | 156 | + watchCurrentAlarmConditionValue.key = currentIndex.value; |
157 | + let allTableDatas = []; | ||
158 | + getTableApiData.value.forEach((tableObj) => { | ||
159 | + let key = { type: tableObj.type, key: tableObj.key1 }; | ||
160 | + let predicate = { | ||
161 | + operation: tableObj.operation, | ||
162 | + type: tableObj.type1, | ||
163 | + value: { | ||
164 | + defaultValue: tableObj.value1, | ||
165 | + }, | ||
166 | + }; | ||
167 | + allTableDatas.push({ | ||
168 | + key: key, | ||
169 | + predicate: predicate, | ||
170 | + value: tableObj.value1, | ||
171 | + valueType: tableObj.type1, | ||
172 | + }); | ||
173 | + }); | ||
174 | + watchCurrentAlarmConditionValue.data = allTableDatas; | ||
169 | emit('getAllFieldsRule', watchCurrentAlarmConditionValue, lastValues.value); | 175 | emit('getAllFieldsRule', watchCurrentAlarmConditionValue, lastValues.value); |
170 | closeModal(); | 176 | closeModal(); |
171 | }; | 177 | }; |
172 | - | ||
173 | - // cosnt getFieldsValueFunc=()=>{ | ||
174 | - // return watchCurrentAlarmConditionValue.data | ||
175 | - // } | ||
176 | - const resetDataFunc = () => { | 178 | + const resetDataFunc = (j, currentAlarmCondition, update) => { |
179 | + isUpdate.value = update; | ||
180 | + openCondition(true); | ||
181 | + currentIndex.value = j; | ||
177 | resetFields(); | 182 | resetFields(); |
178 | getTableApiData.value = []; | 183 | getTableApiData.value = []; |
179 | getTableApiData.value.length = 0; | 184 | getTableApiData.value.length = 0; |
180 | detailData.value = []; | 185 | detailData.value = []; |
181 | detailData.value.length = 0; | 186 | detailData.value.length = 0; |
182 | - // getKeyAndValueChildData.value.length = 0; | ||
183 | console.log('father', props.getFatherData); | 187 | console.log('father', props.getFatherData); |
184 | - let condition = {}; | ||
185 | - if (props.getFatherData.length != 0) { | ||
186 | - for (let i in props.getFatherData.data) { | ||
187 | - getTableApiData.value = props.getFatherData.data[i].condition.condition; | ||
188 | - } | ||
189 | - getTableApiData.value = getTableApiData.value.map((m) => { | ||
190 | - return { | ||
191 | - key1: m.key.key, | ||
192 | - type: m.key.type, | 188 | + let index = 0; |
189 | + if (currentAlarmCondition.data.length != undefined) { | ||
190 | + for (let i in currentAlarmCondition.data) { | ||
191 | + let obj = { | ||
192 | + id: index, | ||
193 | + key1: currentAlarmCondition.data[i].key.key, | ||
194 | + type: currentAlarmCondition.data[i].key.type, | ||
195 | + operation: currentAlarmCondition.data[i].predicate.operation, | ||
196 | + value1: currentAlarmCondition.data[i].value, | ||
193 | }; | 197 | }; |
194 | - }); | 198 | + getTableApiData.value.push(obj); |
199 | + index++; | ||
200 | + } | ||
195 | } | 201 | } |
196 | - console.log('condition', condition); | 202 | + nextTick(() => { |
203 | + setFunc(getTableApiData.value); | ||
204 | + }); | ||
197 | }; | 205 | }; |
198 | 206 | ||
199 | - watch( | ||
200 | - () => props.getFatherData, | ||
201 | - (v) => { | ||
202 | - console.log(1); | ||
203 | - console.log(v); | ||
204 | - } | ||
205 | - ); | ||
206 | - | ||
207 | - const handleCancel = () => { | ||
208 | - resetDataFunc(); | ||
209 | - }; | 207 | + const handleCancel = () => {}; |
210 | const handleAddKey = () => { | 208 | const handleAddKey = () => { |
211 | setTimeout(() => { | 209 | setTimeout(() => { |
212 | openModal(true, { | 210 | openModal(true, { |
213 | isUpdate: false, | 211 | isUpdate: false, |
214 | }); | 212 | }); |
215 | - }, 30); | 213 | + }, 10); |
216 | }; | 214 | }; |
217 | const handleEdit = (record: Recordable) => { | 215 | const handleEdit = (record: Recordable) => { |
218 | openModal(true, { | 216 | openModal(true, { |
219 | isUpdate: true, | 217 | isUpdate: true, |
220 | record, | 218 | record, |
221 | }); | 219 | }); |
222 | - newFilterArray.value = getTableApiData.value.filter((item) => item.id !== record.id); | ||
223 | - getTableApiData.value = newFilterArray.value; | ||
224 | - newFilterViewArray.value = detailData.value.filter((item) => item.id !== record.id); | ||
225 | - detailData.value = newFilterViewArray.value; | ||
226 | reload(); | 220 | reload(); |
227 | }; | 221 | }; |
228 | const handleDelete = (record: Recordable) => { | 222 | const handleDelete = (record: Recordable) => { |
229 | - newFilterKeyArray.value = getTableApiData.value.filter((item) => item.id !== record.id); | ||
230 | - getTableApiData.value = newFilterKeyArray.value; | ||
231 | - newFilterKeyViewArray.value = detailData.value.filter((item) => item.id !== record.id); | ||
232 | - detailData.value = newFilterKeyViewArray.value; | 223 | + let newGetTableApiData = []; |
224 | + getTableApiData.value.forEach((currentTable) => { | ||
225 | + if (currentTable.id != record.id) { | ||
226 | + newGetTableApiData.push(currentTable as never); | ||
227 | + } | ||
228 | + }); | ||
229 | + getTableApiData.value = newGetTableApiData; | ||
230 | + setFunc(getTableApiData.value); | ||
233 | reload(); | 231 | reload(); |
234 | }; | 232 | }; |
235 | - const handleSuccess = (v, v1) => { | 233 | + const handleSuccess = (v, v1, isUpdate) => { |
234 | + if (isUpdate) { | ||
235 | + getTableApiData.value.forEach((tableValue) => { | ||
236 | + if (tableValue.id == v1.id) { | ||
237 | + tableValue.key1 = v1.key1; | ||
238 | + tableValue.operation = v1.operation; | ||
239 | + tableValue.type = v1.type; | ||
240 | + tableValue.type1 = v1.type1; | ||
241 | + tableValue.value1 = v1.value1; | ||
242 | + } | ||
243 | + }); | ||
244 | + } else { | ||
245 | + getTableApiData.value.push(v1); | ||
246 | + } | ||
236 | getKeyAndValueChildData.value = v; | 247 | getKeyAndValueChildData.value = v; |
237 | - receiveData.value = v1; | ||
238 | - getTableApiData.value.push(receiveData.value); | ||
239 | - detailData.value.push(receiveData.value); | ||
240 | setFunc(getTableApiData.value); | 248 | setFunc(getTableApiData.value); |
241 | reload(); | 249 | reload(); |
242 | }; | 250 | }; |
@@ -257,6 +265,7 @@ | @@ -257,6 +265,7 @@ | ||
257 | handleSubmit, | 265 | handleSubmit, |
258 | register, | 266 | register, |
259 | getTitle, | 267 | getTitle, |
268 | + currentIndex, | ||
260 | }; | 269 | }; |
261 | }, | 270 | }, |
262 | }); | 271 | }); |