Commit 2b3c6c8664e553647cd463675751c860c2505247

Authored by 黄 x
1 parent 030e8c48

fix(front): 修改设备配置BUG【待完善】

... ... @@ -53,9 +53,7 @@
53 53 :DetailTemplateCpnData="!isStep3FatherAddOrEditStatus ? 1 : item"
54 54 />
55 55 <AlarmRuleConditionsCpn
56   - :getFatherData="getConditionData"
57   - :ref="`AlarmRuleConditionsRef${index}`"
58   - @register="registerAlarmRuleConditionsModal"
  56 + :ref="conditionRefs.AlarmRuleConditionsRef"
59 57 @getAllFieldsRule="getAlarmRuleConditionsValFunc"
60 58 />
61 59 <EnableRuleCpn
... ... @@ -290,10 +288,7 @@
290 288 props: ['step3FatherEmitCpnData', 'step3FatherEmitCpnStatus'],
291 289 setup(props) {
292 290 const getConditionData = ref([]);
293   - let currentAlarmCondition: any = reactive({
294   - key: 0,
295   - data: {},
296   - });
  291 + const getConditionData1 = ref([{ key: 0, data: {} }]);
297 292 const clickConditionData = ref([]);
298 293 const { proxy } = getCurrentInstance() as any;
299 294 const createAlarmRuleData: any = ref([1]);
... ... @@ -308,6 +303,9 @@
308 303 const formatEnableRule: any = ref([]);
309 304 const formatClearEnableRule: any = ref([]);
310 305 const formatEditClearEnableRule: any = ref([]);
  306 + const conditionRefs = {
  307 + AlarmRuleConditionsRef: ref([]),
  308 + };
311 309 let alaramsObj: any = reactive({
312 310 alarmType: null,
313 311 propagate: null,
... ... @@ -329,8 +327,6 @@
329 327 let val10: any = ref(null);
330 328 const formatEditRuleData: any = ref([]);
331 329 const formatEditEnableData: any = ref([]);
332   - const [registerAlarmRuleConditionsModal, { openModal: openModalAlarmRuleConditions }] =
333   - useModal();
334 330 const [registerEnableRuleModal, { openModal: openModalEnableRule }] = useModal();
335 331 const [
336 332 registerClearAlarmRuleConditionsModal,
... ... @@ -422,23 +418,27 @@
422 418 }
423 419 };
424 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 443 const clickAddEnableRuleFunc = () => {
444 444 nextTick(() => {
... ... @@ -462,10 +462,17 @@
462 462 console.log('获取condition的值', e);
463 463 formatAlarmRuleConditions.value.push(e);
464 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 477 const getClearAlarmRuleConditionsValFunc = (e) => {
471 478 formatClearAlarmRuleConditions.value.push({
... ... @@ -689,9 +696,15 @@
689 696 );
690 697 return formatMap;
691 698 };
  699 +
692 700 const formatEnableRuleFuncData = (v) => {
693 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 708 return {
696 709 registerForm,
697 710 registerFormHighSetting,
... ... @@ -703,7 +716,6 @@
703 716 clickAddAlarmRuleConditionsFunc,
704 717 AlarmRuleConditionsRef,
705 718 EnableRuleRef,
706   - registerAlarmRuleConditionsModal,
707 719 registerEnableRuleModal,
708 720 getAlarmRuleConditionsValFunc,
709 721 formatAlarmRuleConditions,
... ... @@ -745,6 +757,9 @@
745 757 formatEditEnableRuleFunc,
746 758 updateCpnSchemaSelectEnableFunc,
747 759 getConditionData,
  760 + getConditionData1,
  761 + forMatAddConditionFunc,
  762 + conditionRefs,
748 763 };
749 764 },
750 765 });
... ...
... ... @@ -34,24 +34,17 @@ export const keyColumns: BasicColumn[] = [
34 34 {
35 35 title: '键名',
36 36 dataIndex: 'key1',
37   - width: 200,
  37 + width: 100,
38 38 },
39 39 {
40 40 title: '键类型',
41 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 45 title: '操作',
53 46 dataIndex: 'operation',
54   - width: 200,
  47 + width: 100,
55 48 format: (text: string, record: Recordable) => {
56 49 const findDay = [
57 50 { label: '等于', value: 'EQUAL' },
... ... @@ -80,9 +73,50 @@ export const columnsView: BasicColumn[] = [
80 73 {
81 74 title: '值',
82 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 121 export const DescDetailSchema: DescItem[] = [
88 122 {
... ...
... ... @@ -46,6 +46,12 @@ export const isComplex = (type: string) => {
46 46
47 47 export const formSchema: FormSchema[] = [
48 48 {
  49 + field: 'id',
  50 + label: '',
  51 + component: 'InputNumber',
  52 + ifShow: false,
  53 + },
  54 + {
49 55 field: 'type',
50 56 label: '键类型',
51 57 colProps: { span: 13 },
... ...
... ... @@ -47,7 +47,6 @@
47 47 const getIsWhereType: any = ref(null);
48 48 const isUpdate = ref(true);
49 49 const getValue: any = ref(null);
50   - const setId: any = ref(1);
51 50 const getKeyAndValArr = ref<[]>([]);
52 51
53 52 const getTitle = computed(() => (!unref(isUpdate) ? '新增键名筛选器' : '编辑键名筛选器'));
... ... @@ -103,61 +102,38 @@
103 102
104 103 const handleSubmit = () => {
105 104 let mapGetKeyAndValArr = [];
  105 + getValue.value = getFieldsValue();
106 106 if (!unref(isUpdate)) {
107   - getValue.value = getFieldsValue();
108 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 132 closeModal();
156 133 };
157 134 const handleCancel = () => {
158 135 return;
159 136 };
160   -
161 137 const n = ref(1);
162 138
163 139 function add() {
... ... @@ -205,6 +181,7 @@
205 181 removeSchemaByFiled([`field${field}a`, `field${field}b`, `${field}`]);
206 182 n.value--;
207 183 }
  184 +
208 185 watch(isWhereType, (v) => {
209 186 switch (v) {
210 187 case 'STRING':
... ...
... ... @@ -9,10 +9,12 @@
9 9 @cancel="handleCancel"
10 10 >
11 11 <CollapseContainer title="键名筛选器" class="border mb-8">
12   - <div class="table-style">
  12 + <div class="table-style"
  13 + >{{ currentIndex }}
  14 + {{ getTableApiData.value }}
13 15 <BasicTable
14 16 :showIndexColumn="false"
15   - :dataSource="getTableApiData"
  17 + :dataSource="getTableApiData.value"
16 18 @register="registerTable"
17 19 >
18 20 <template #toolbar>
... ... @@ -41,24 +43,24 @@
41 43 </BasicTable>
42 44 </div>
43 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 + <!-- &lt;!&ndash; <p v-for="(item, index) in detailData" :key="index">{{ item }}</p> &ndash;&gt;-->
  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 56 <BasicForm :showResetButton="false" :showSubmitButton="false" @register="registerForm" />
55 57 </BasicModal>
56 58 <KeyValueModal @register="registerModal" @success="handleSuccess" />
57 59 </div>
58 60 </template>
59 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 64 import { BasicForm, useForm } from '/@/components/Form';
63 65 import { formSchema, keyColumns, DescDetailSchema } from './config';
64 66 import { CollapseContainer } from '/@/components/Container/index';
... ... @@ -119,14 +121,9 @@
119 121 setup(props, { emit }) {
120 122 let getKeyAndValueChildData = ref<[]>([]);
121 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 124 const detailData: any = ref([]);
127   - const receiveData: any = ref(null);
  125 + const currentIndex = ref(0);
128 126 const lastValues: any = ref(null);
129   - const addOrUpdateData: any = ref(null);
130 127 const isUpdate = ref(true);
131 128 const watchCurrentAlarmConditionValue = reactive({
132 129 key: 0,
... ... @@ -139,9 +136,7 @@
139 136 });
140 137 const [registerModal, { openModal }] = useModal();
141 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 140 const [registerTable, { reload, setTableData: setFunc }] = useTable({
146 141 title: '键名筛选器',
147 142 columns: keyColumns,
... ... @@ -157,86 +152,99 @@
157 152 },
158 153 });
159 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 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 175 emit('getAllFieldsRule', watchCurrentAlarmConditionValue, lastValues.value);
170 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 182 resetFields();
178 183 getTableApiData.value = [];
179 184 getTableApiData.value.length = 0;
180 185 detailData.value = [];
181 186 detailData.value.length = 0;
182   - // getKeyAndValueChildData.value.length = 0;
183 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 208 const handleAddKey = () => {
211 209 setTimeout(() => {
212 210 openModal(true, {
213 211 isUpdate: false,
214 212 });
215   - }, 30);
  213 + }, 10);
216 214 };
217 215 const handleEdit = (record: Recordable) => {
218 216 openModal(true, {
219 217 isUpdate: true,
220 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 220 reload();
227 221 };
228 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 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 247 getKeyAndValueChildData.value = v;
237   - receiveData.value = v1;
238   - getTableApiData.value.push(receiveData.value);
239   - detailData.value.push(receiveData.value);
240 248 setFunc(getTableApiData.value);
241 249 reload();
242 250 };
... ... @@ -257,6 +265,7 @@
257 265 handleSubmit,
258 266 register,
259 267 getTitle,
  268 + currentIndex,
260 269 };
261 270 },
262 271 });
... ...