Commit 1169197e71c3461e9226aeafe3110c2c6b0e3ed0

Authored by xp.Huang
2 parents 9cea2287 c715577b

Merge branch 'ft-dev' into 'main'

fix

See merge request huang/yun-teng-iot-front!162
... ... @@ -310,10 +310,11 @@
310 310 isGetStepThreeData,
311 311 alarmProfileData.alarmProfile.alarmContactId == '' ? null : alarmProfileData
312 312 );
313   - await deviceConfigAddOrEdit(postDeviceConfogData.value);
314   - createMessage.success('新增成功');
315   - closeModal();
316   - emit('success');
  313 + console.log('总对象', postDeviceConfogData.value);
  314 + // await deviceConfigAddOrEdit(postDeviceConfogData.value);
  315 + // createMessage.success('新增成功');
  316 + // closeModal();
  317 + // emit('success');
317 318 } else if (isUpdate.value == 2) {
318 319 const id = {
319 320 id: postEditId,
... ...
... ... @@ -14,8 +14,8 @@
14 14 :before-upload="beforeUploadqrcodePic"
15 15 >
16 16 <img
17   - v-if="peresonalPic"
18   - :src="peresonalPic !== '' ? peresonalPic : echoPic"
  17 + v-if="peresonalPic || echoPic"
  18 + :src="peresonalPic != '' ? peresonalPic : echoPic"
19 19 alt="avatar"
20 20 style="width: 6.25rem; height: 6.25rem"
21 21 />
... ... @@ -55,6 +55,7 @@
55 55 setup(_, { emit }) {
56 56 const { createMessage } = useMessage();
57 57 const echoPic = ref('');
  58 + const peresonalPic = ref('');
58 59 const [register, { validate, setFieldsValue, resetFields }] = useForm({
59 60 labelWidth: 100,
60 61 schemas: step1Schemas,
... ... @@ -70,21 +71,15 @@
70 71 //回显数据
71 72 const setStepOneFieldsValueFunc = (v) => {
72 73 setFieldsValue(v);
73   - console.log(v);
74   - if (v.image !== null) {
75   - echoPic.value = v.image;
76   - }
  74 + echoPic.value = v.image;
77 75 };
78   - const peresonalPic = ref('');
79   -
80 76 const resetIconFunc = () => {
81 77 peresonalPic.value = '';
  78 + echoPic.value = '';
82 79 };
83   -
84 80 const editIconFunc = (v) => {
85 81 peresonalPic.value = v;
86 82 };
87   -
88 83 const customUploadqrcodePic = async ({ file }) => {
89 84 if (beforeUploadqrcodePic(file)) {
90 85 const formData = new FormData();
... ...
... ... @@ -91,7 +91,7 @@
91 91 if (e == 1) {
92 92 for (let i = 0; i < alarmsData.value.length; i++) {
93 93 const ii = i;
94   - addObj = await proxy.$refs['commonCpnsRef' + ii].getStep3AllDataFunc(e);
  94 + addObj = await proxy.$refs['commonCpnsRef' + ii].getStep3AllDataFunc(1);
95 95 alarmsData.value.push(addObj);
96 96 alarmsData.value.shift();
97 97 }
... ... @@ -102,7 +102,7 @@
102 102 */
103 103 for (let i = 0; i < echoEditData.value.length; i++) {
104 104 const ii = i;
105   - editObj = await proxy.$refs['commonCpnsRef' + ii].getStep3AllDataFunc(e);
  105 + editObj = await proxy.$refs['commonCpnsRef' + ii].getStep3AllDataFunc(2);
106 106 alarmsData.value.push(editObj);
107 107 }
108 108 }
... ... @@ -119,6 +119,8 @@
119 119 const clickAddAlaramRuleFunc = async () => {
120 120 try {
121 121 alarmsData.value.push(1);
  122 + // proxy.$refs['commonCpnsRef' + 0].updateCpnSchemaSelectEnableFunc();
  123 + // proxy.$refs['commonCpnsRef' + 1].updateCpnSchemaSelectEnableFunc();
122 124 if (getIsEchoEditStatus.value) {
123 125 echoEditData.value.push(1);
124 126 }
... ...
... ... @@ -53,6 +53,7 @@
53 53 :DetailTemplateCpnData="!isStep3FatherAddOrEditStatus ? 1 : item"
54 54 />
55 55 <AlarmRuleConditionsCpn
  56 + :getFatherData="getConditionData"
56 57 :ref="`AlarmRuleConditionsRef${index}`"
57 58 @register="registerAlarmRuleConditionsModal"
58 59 @getAllFieldsRule="getAlarmRuleConditionsValFunc"
... ... @@ -67,7 +68,7 @@
67 68 <a-button
68 69 style="border-radius: 10px"
69 70 class="mt-5"
70   - @click="clickAddAlarmRuleConditionsFunc(isStep3FatherAddOrEditStatus, index)"
  71 + @click="clickAddAlarmRuleConditionsFunc(item, index)"
71 72 ><PlusCircleOutlined
72 73 /></a-button>
73 74 <div>
... ... @@ -79,7 +80,7 @@
79 80 :key="index1"
80 81 >
81 82 <p v-if="index1 == index && !isStep3FatherAddOrEditStatus">
82   - 报警规则条件:{{ formatAlarmRuleConditionsFunc(item1) }}
  83 + 报警规则条件:{{ formatAlarmRuleConditionsData(item1.data[0]) }}
83 84 </p>
84 85 </template>
85 86 </div>
... ... @@ -99,7 +100,7 @@
99 100 formatEditRuleData.length > 0
100 101 "
101 102 >
102   - <p> 报警规则条件:{{ formatEditRuleDataFunc(item11) }} </p>
  103 + <p> 报警规则条件:{{ formatEditRuleDataFunc(item11, index11) }} </p>
103 104 </div>
104 105 </template>
105 106 </div>
... ... @@ -288,6 +289,12 @@
288 289 },
289 290 props: ['step3FatherEmitCpnData', 'step3FatherEmitCpnStatus'],
290 291 setup(props) {
  292 + const getConditionData = ref([]);
  293 + let currentAlarmCondition: any = reactive({
  294 + key: 0,
  295 + data: {},
  296 + });
  297 + const clickConditionData = ref([]);
291 298 const { proxy } = getCurrentInstance() as any;
292 299 const createAlarmRuleData: any = ref([1]);
293 300 const createEditAlarmRuleData: any = ref([]);
... ... @@ -317,12 +324,11 @@
317 324 let val4: any = reactive({});
318 325 let val5: any = reactive({});
319 326 let val6: any = ref([]);
320   - let val7 = ref(null);
  327 + let val7: any = ref(null);
321 328 let val9: any = ref([]);
322 329 let val10: any = ref(null);
323 330 const formatEditRuleData: any = ref([]);
324 331 const formatEditEnableData: any = ref([]);
325   -
326 332 const [registerAlarmRuleConditionsModal, { openModal: openModalAlarmRuleConditions }] =
327 333 useModal();
328 334 const [registerEnableRuleModal, { openModal: openModalEnableRule }] = useModal();
... ... @@ -378,16 +384,19 @@
378 384 });
379 385 const clickAddCreateRuleFunc = () => {
380 386 let i = 1;
381   - i++;
382   - console.log(i);
  387 + i--;
383 388 createAlarmRuleData.value.push(1);
384 389 nextTick(() => {
385   - proxy.$refs.AlarmRuleConditionsRef?.resetDataFunc();
  390 + // proxy.$refs['AlarmSeverityRef' + i].updateSchemaSelectDisableFunc();
386 391 });
387 392 if (isStep3FatherAddOrEditStatus.value) {
388 393 createEditAlarmRuleData.value.push(1);
389 394 }
390 395 };
  396 + const updateCpnSchemaSelectEnableFunc = () => {
  397 + proxy.$refs['AlarmSeverityRef' + 0].updateSchemaSelectEnableFunc();
  398 + proxy.$refs['AlarmSeverityRef' + 1].updateSchemaSelectEnableFunc();
  399 + };
391 400 /**
392 401 * 获取清除报警规则数据
393 402 */
... ... @@ -414,17 +423,23 @@
414 423 };
415 424 const clickAddAlarmRuleConditionsFunc = (e, i) => {
416 425 openModalAlarmRuleConditions(true);
417   - console.log(i);
418   - if (e === true) {
419   - nextTick(() => {
420   - proxy.$refs.AlarmRuleConditionsRef?.resetDataFunc();
421   - });
422   - } else {
423   - nextTick(() => {
424   - proxy.$refs.AlarmRuleConditionsRef?.resetDataFunc();
425   - });
426   - }
  426 + //获取对应下标
  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();
427 440 };
  441 + console.log('data', currentAlarmCondition);
  442 +
428 443 const clickAddEnableRuleFunc = () => {
429 444 nextTick(() => {
430 445 openModalEnableRule(true);
... ... @@ -444,12 +459,13 @@
444 459 });
445 460 };
446 461 const getAlarmRuleConditionsValFunc = (e) => {
447   - formatAlarmRuleConditions.value.push({
448   - condition: e,
449   - } as never);
450   - formatEditRuleData.value.push({
451   - condition: e,
452   - } as never);
  462 + console.log('获取condition的值', e);
  463 + formatAlarmRuleConditions.value.push(e);
  464 + clickConditionData.value = e;
  465 + currentAlarmCondition = getConditionData.value;
  466 + // formatEditRuleData.value.push({
  467 + // condition: e,
  468 + // } as never);
453 469 };
454 470 const getClearAlarmRuleConditionsValFunc = (e) => {
455 471 formatClearAlarmRuleConditions.value.push({
... ... @@ -457,10 +473,10 @@
457 473 } as never);
458 474 };
459 475 const formatAlarmRuleConditionsFunc = (e) => {
460   - let formatMap = e.condition.map((f: any) => formatAlarmRuleConditionsData(f));
461   - return formatMap;
  476 + // let formatMap = e.condition.map((f: any) => formatAlarmRuleConditionsData(f));
  477 + // return formatMap;
462 478 };
463   - const formatEditRuleDataFunc = (e) => {
  479 + const formatEditRuleDataFunc = (e, i) => {
464 480 let formatMap = e.condition.map((f: any) => formatAlarmRuleConditionsData(f));
465 481 return formatMap;
466 482 };
... ... @@ -483,7 +499,6 @@
483 499 let formatMap = formatEnableRuleData(e);
484 500 return formatMap;
485 501 };
486   -
487 502 const formatClearEnableRuleFunc = (e) => {
488 503 let formatMap = formatEnableRuleData(e);
489 504 return formatMap;
... ... @@ -526,32 +541,40 @@
526 541 };
527 542 }
528 543 if (e == 1) {
  544 + alaramsObj.createRules;
529 545 for (let i = 0; i < createAlarmRuleData.value.length; i++) {
530   - const iii = i;
531   - val4 = proxy.$refs['AlarmSeverityRef' + iii].getFieldsValueFunc();
532   - val5 = proxy.$refs['DetailTemplateRef' + iii].getFieldsValueFunc();
533   - val6.value = proxy.$refs['AlarmRuleConditionsRef' + iii].getFieldsValueFunc();
534   - val7.value = proxy.$refs['EnableRuleRef' + iii].getFieldsValueFunc();
535   - alaramsObj.createRules[val4?.default] = {
536   - ...val5,
537   - ...{
538   - schedule: val7.value == undefined ? undefined : val7.value,
539   - },
540   - ...{
541   - condition: {
542   - condition: val6.value == undefined ? undefined : val6.value,
543   - },
544   - },
545   - };
  546 + formatAlarmRuleConditions.value.forEach((f, ii) => {
  547 + if (ii == i) {
  548 + val4 = proxy.$refs['AlarmSeverityRef' + ii].getFieldsValueFunc();
  549 + val5 = proxy.$refs['DetailTemplateRef' + ii].getFieldsValueFunc();
  550 + console.log(f.data);
  551 + formatEnableRule.value.forEach((f1, i1) => {
  552 + if (i1 === ii) {
  553 + alaramsObj.createRules[val4?.default] = {
  554 + ...val5,
  555 + ...{
  556 + schedule: f1,
  557 + },
  558 + ...{
  559 + condition: {
  560 + condition: f.data,
  561 + },
  562 + },
  563 + };
  564 + }
  565 + });
  566 + }
  567 + });
546 568 }
547   - } else {
  569 + } else if (e == 2) {
  570 + console.log('edit');
548 571 for (let i = 0; i < createEditAlarmRuleData.value.length; i++) {
549 572 const iiii = i;
550 573 val4 = proxy.$refs['AlarmSeverityRef' + iiii].getFieldsValueFunc();
551 574 val5 = proxy.$refs['DetailTemplateRef' + iiii].getFieldsValueFunc();
552 575 val6.value = proxy.$refs['AlarmRuleConditionsRef' + iiii].getFieldsValueFunc();
553   - val7.value = proxy.$refs['EnableRuleRef' + iiii].getFieldsValueFunc();
554 576 console.log(val6.value);
  577 + val7.value = proxy.$refs['EnableRuleRef' + iiii].getFieldsValueFunc();
555 578 alaramsObj.createRules[val4?.default] = {
556 579 ...val5,
557 580 ...{
... ... @@ -598,6 +621,10 @@
598 621 alaramsObj.id = '';
599 622 formatEditRuleData.value.length = 0;
600 623 formatEditEnableData.value.length = 0;
  624 + val6.value.length = 0;
  625 + val7.value = null;
  626 + val9.value.length = 0;
  627 + val10.value = null;
601 628 } catch {}
602 629 };
603 630 /**
... ... @@ -716,6 +743,8 @@
716 743 formatEditRuleDataFunc,
717 744 formatEditEnableData,
718 745 formatEditEnableRuleFunc,
  746 + updateCpnSchemaSelectEnableFunc,
  747 + getConditionData,
719 748 };
720 749 },
721 750 });
... ...
... ... @@ -57,7 +57,7 @@
57 57 </div>
58 58 </template>
59 59 <script lang="ts">
60   - import { defineComponent, ref, computed, unref } from 'vue';
  60 + import { defineComponent, ref, computed, unref, reactive, watch } from 'vue';
61 61 import { BasicModal, useModalInner } from '/@/components/Modal';
62 62 import { BasicForm, useForm } from '/@/components/Form';
63 63 import { formSchema, keyColumns, DescDetailSchema } from './config';
... ... @@ -114,8 +114,9 @@
114 114 TableAction,
115 115 Description,
116 116 },
  117 + props: ['getFatherData'],
117 118 emits: ['success', 'register', 'getAllFieldsRule', 'getLastAllFieldsRule'],
118   - setup(_, { emit }) {
  119 + setup(props, { emit }) {
119 120 let getKeyAndValueChildData = ref<[]>([]);
120 121 const getTableApiData: any = ref([]);
121 122 const newFilterArray: any = ref([]);
... ... @@ -127,6 +128,11 @@
127 128 const lastValues: any = ref(null);
128 129 const addOrUpdateData: any = ref(null);
129 130 const isUpdate = ref(true);
  131 + const watchCurrentAlarmConditionValue = reactive({
  132 + key: 0,
  133 + data: {},
  134 + });
  135 +
130 136 const [registerForm, { getFieldsValue, resetFields }] = useForm({
131 137 labelWidth: 120,
132 138 schemas: formSchema,
... ... @@ -157,22 +163,47 @@
157 163 detailData.value.push(addOrUpdateData.value);
158 164 }
159 165 lastValues.value = getFieldsValue();
160   - emit('getAllFieldsRule', getKeyAndValueChildData.value, lastValues.value);
  166 + watchCurrentAlarmConditionValue.key =
  167 + props.getFatherData?.key == undefined ? 0 : props.getFatherData?.key;
  168 + watchCurrentAlarmConditionValue.data = getKeyAndValueChildData.value;
  169 + emit('getAllFieldsRule', watchCurrentAlarmConditionValue, lastValues.value);
161 170 closeModal();
162 171 };
163 172
164   - const getFieldsValueFunc = () => {
165   - return getKeyAndValueChildData.value;
166   - };
  173 + // cosnt getFieldsValueFunc=()=>{
  174 + // return watchCurrentAlarmConditionValue.data
  175 + // }
167 176 const resetDataFunc = () => {
  177 + resetFields();
168 178 getTableApiData.value = [];
169 179 getTableApiData.value.length = 0;
170 180 detailData.value = [];
171 181 detailData.value.length = 0;
172   - getKeyAndValueChildData.value.length = 0;
173   - resetFields();
  182 + // getKeyAndValueChildData.value.length = 0;
  183 + 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,
  193 + };
  194 + });
  195 + }
  196 + console.log('condition', condition);
174 197 };
175 198
  199 + watch(
  200 + () => props.getFatherData,
  201 + (v) => {
  202 + console.log(1);
  203 + console.log(v);
  204 + }
  205 + );
  206 +
176 207 const handleCancel = () => {
177 208 resetDataFunc();
178 209 };
... ... @@ -226,7 +257,6 @@
226 257 handleSubmit,
227 258 register,
228 259 getTitle,
229   - getFieldsValueFunc,
230 260 };
231 261 },
232 262 });
... ...
... ... @@ -67,11 +67,17 @@
67 67 },
68 68 });
69 69 };
70   - // const setFieldsValueFunc = (v) => {
71   - // setFieldsValue({
72   - // default: v,
73   - // });
74   - // };
  70 + const updateSchemaSelectEnableFunc = () => {
  71 + updateSchema({
  72 + field: 'default',
  73 + componentProps: ({ formModel }) => {
  74 + console.log(formModel);
  75 + return {
  76 + options: item,
  77 + };
  78 + },
  79 + });
  80 + };
75 81 const setFieldsValueFunc = () => {
76 82 if (props.AlarmSeverityCpnData != 1) {
77 83 let newArr = Object.keys(props.AlarmSeverityCpnData);
... ... @@ -89,6 +95,7 @@
89 95 getFieldsValueFunc,
90 96 registerForm,
91 97 setFieldsValueFunc,
  98 + updateSchemaSelectEnableFunc,
92 99 };
93 100 },
94 101 });
... ...