Commit b6d2a34c320b86e866be9c42c267c762c7783969

Authored by xp.Huang
2 parents d8175c88 b65d16e9

Merge branch 'ft-dev' into 'main'

fix:修复场景联动部分编辑问题,主要是数据重复问题,fix:修复租户第一次修改密码时点击新增时闪烁问题

See merge request huang/yun-teng-iot-front!134
@@ -67,26 +67,25 @@ export function createPermissionGuard(router: Router) { @@ -67,26 +67,25 @@ export function createPermissionGuard(router: Router) {
67 const getMenuListData1 = 67 const getMenuListData1 =
68 window.localStorage.getItem('menuListStorage') || (await getMenuList()); 68 window.localStorage.getItem('menuListStorage') || (await getMenuList());
69 const getMenuListData = JSON.parse(getMenuListData1); 69 const getMenuListData = JSON.parse(getMenuListData1);
70 - // const getMenuListData = await getMenuList();  
71 const getHomePage = getMenuListData.find((f) => { 70 const getHomePage = getMenuListData.find((f) => {
72 return f.path == '/dashboard/workbench'; 71 return f.path == '/dashboard/workbench';
73 }); 72 });
74 if (getHomePage?.path == '/dashboard/workbench') { 73 if (getHomePage?.path == '/dashboard/workbench') {
75 setTimeout(() => { 74 setTimeout(() => {
76 router.push('/dashboard/workbench'); 75 router.push('/dashboard/workbench');
77 - }, 200); 76 + }, 1);
78 } else { 77 } else {
79 const routeF = getMenuListData[0]?.children[0]?.path || getMenuListData[0].path; 78 const routeF = getMenuListData[0]?.children[0]?.path || getMenuListData[0].path;
80 setTimeout(() => { 79 setTimeout(() => {
81 router.push(routeF); 80 router.push(routeF);
82 - }, 200); 81 + }, 1);
83 } 82 }
84 } 83 }
85 84
86 if (from.path === LOGIN_PATH && userInfo.value?.needSetPwd == true) { 85 if (from.path === LOGIN_PATH && userInfo.value?.needSetPwd == true) {
87 setTimeout(() => { 86 setTimeout(() => {
88 router.push('/system/password'); 87 router.push('/system/password');
89 - }, 200); 88 + }, 1);
90 } 89 }
91 90
92 if ( 91 if (
@@ -82,6 +82,7 @@ @@ -82,6 +82,7 @@
82 type: '', 82 type: '',
83 configuration: {}, 83 configuration: {},
84 name: '', 84 name: '',
  85 + remark: '',
85 }); 86 });
86 const editTypeFunc = (d) => { 87 const editTypeFunc = (d) => {
87 editType.type = d.type; 88 editType.type = d.type;
@@ -97,6 +98,7 @@ @@ -97,6 +98,7 @@
97 editNextType.type = data.record.type; 98 editNextType.type = data.record.type;
98 editNextType.configuration = data.record; 99 editNextType.configuration = data.record;
99 editNextType.name = data.record.name; 100 editNextType.name = data.record.name;
  101 + editNextType.remark = data.record.remark;
100 proxy.$refs.refTransferConfigMode.setStepOneFieldsValueFunc(editNextType); 102 proxy.$refs.refTransferConfigMode.setStepOneFieldsValueFunc(editNextType);
101 } 103 }
102 }); 104 });
@@ -140,7 +140,6 @@ @@ -140,7 +140,6 @@
140 }); 140 });
141 141
142 const clearValidateFunc = async () => { 142 const clearValidateFunc = async () => {
143 - console.log(1);  
144 await clearValidate(['name']); 143 await clearValidate(['name']);
145 }; 144 };
146 145
@@ -38,21 +38,6 @@ @@ -38,21 +38,6 @@
38 const resetFieldsValueFunc = () => { 38 const resetFieldsValueFunc = () => {
39 resetFields(); 39 resetFields();
40 }; 40 };
41 - // watch(  
42 - // () => props.deviceInfo1,  
43 - // async (newV) => {  
44 - // const options = await screenLinkPageByDeptIdGetDevice({ organizationId: newV });  
45 - // options.items.forEach((v) => {  
46 - // return (v.value = v.id), (v.label = v.name);  
47 - // });  
48 - // updateSchema({  
49 - // field: 'entityId',  
50 - // componentProps: {  
51 - // options: options.items,  
52 - // },  
53 - // });  
54 - // }  
55 - // );  
56 const updateFieldDeviceId = (v) => { 41 const updateFieldDeviceId = (v) => {
57 setTimeout(() => { 42 setTimeout(() => {
58 updateSchema({ 43 updateSchema({
@@ -69,6 +54,22 @@ @@ -69,6 +54,22 @@
69 if (props.editConditionFather !== 1) { 54 if (props.editConditionFather !== 1) {
70 setTimeout(() => { 55 setTimeout(() => {
71 setFieldsValue(props.editConditionFather); 56 setFieldsValue(props.editConditionFather);
  57 + setFieldsValue({
  58 + type:
  59 + props.editConditionFather?.triggerCondition?.condition[0]?.valueType == 'NUMERIC'
  60 + ? 'NUMERIC1'
  61 + : 'NUMERIC2',
  62 + operation1:
  63 + props.editConditionFather?.triggerCondition?.condition[0]?.predicate?.operation,
  64 + operation2:
  65 + props.editConditionFather?.triggerCondition?.condition[0]?.predicate?.operation,
  66 + value1:
  67 + props.editConditionFather?.triggerCondition?.condition[0]?.predicate?.value
  68 + ?.defaultValue,
  69 + value2:
  70 + props.editConditionFather?.triggerCondition?.condition[0]?.predicate?.value
  71 + ?.defaultValue,
  72 + });
72 }, 100); 73 }, 100);
73 } 74 }
74 }; 75 };
@@ -17,7 +17,6 @@ @@ -17,7 +17,6 @@
17 import { BasicForm, useForm } from '/@/components/Form/index'; 17 import { BasicForm, useForm } from '/@/components/Form/index';
18 import { Input } from 'ant-design-vue'; 18 import { Input } from 'ant-design-vue';
19 import { useActionDrawerSchema } from '../config'; 19 import { useActionDrawerSchema } from '../config';
20 - // import { screenLinkPageByDeptIdGetDevice } from '/@/api/ruleengine/ruleengineApi';  
21 20
22 export default defineComponent({ 21 export default defineComponent({
23 components: { CollapseContainer, BasicForm, [Input.name]: Input }, 22 components: { CollapseContainer, BasicForm, [Input.name]: Input },
@@ -34,28 +33,10 @@ @@ -34,28 +33,10 @@
34 const getFieldsValueFunc = () => { 33 const getFieldsValueFunc = () => {
35 fieldValue.value = getFieldsValue(); 34 fieldValue.value = getFieldsValue();
36 return fieldValue.value; 35 return fieldValue.value;
37 - // return new Promise((resolve) => {  
38 - // resolve(fieldValue.value);  
39 - // });  
40 }; 36 };
41 const resetFieldsValueFunc = () => { 37 const resetFieldsValueFunc = () => {
42 resetFields(); 38 resetFields();
43 }; 39 };
44 - // watch(  
45 - // () => props.deviceInfo2,  
46 - // async (newV) => {  
47 - // const options = await screenLinkPageByDeptIdGetDevice({ organizationId: newV });  
48 - // options.items.forEach((v) => {  
49 - // return (v.value = v.id), (v.label = v.name);  
50 - // });  
51 - // updateSchema({  
52 - // field: 'entityId',  
53 - // componentProps: {  
54 - // options: options.items,  
55 - // },  
56 - // });  
57 - // }  
58 - // );  
59 const updateFieldDeviceId = (v) => { 40 const updateFieldDeviceId = (v) => {
60 setTimeout(() => { 41 setTimeout(() => {
61 updateSchema({ 42 updateSchema({
@@ -98,14 +79,6 @@ @@ -98,14 +79,6 @@
98 }, 79 },
99 }); 80 });
100 }; 81 };
101 - // const editSelectDevice = (v) => {  
102 - // updateSchema({  
103 - // field: 'entityId',  
104 - // componentProps: {  
105 - // options: v,  
106 - // },  
107 - // });  
108 - // };  
109 return { 82 return {
110 updateFieldDeviceId, 83 updateFieldDeviceId,
111 clearSelectDevice, 84 clearSelectDevice,
@@ -19,7 +19,6 @@ @@ -19,7 +19,6 @@
19 import { BasicForm, useForm } from '/@/components/Form/index'; 19 import { BasicForm, useForm } from '/@/components/Form/index';
20 import { Input } from 'ant-design-vue'; 20 import { Input } from 'ant-design-vue';
21 import { useTriggerDrawerSchema } from '../config'; 21 import { useTriggerDrawerSchema } from '../config';
22 - // import { screenLinkPageByDeptIdGetDevice } from '/@/api/ruleengine/ruleengineApi';  
23 22
24 export default defineComponent({ 23 export default defineComponent({
25 components: { CollapseContainer, BasicForm, [Input.name]: Input }, 24 components: { CollapseContainer, BasicForm, [Input.name]: Input },
@@ -36,16 +35,6 @@ @@ -36,16 +35,6 @@
36 fieldValue.value = getFieldsValue(); 35 fieldValue.value = getFieldsValue();
37 return fieldValue.value; 36 return fieldValue.value;
38 }; 37 };
39 - // watch(  
40 - // () => props.deviceInfo  
41 - // // async (newV) => {  
42 - // // const options = await screenLinkPageByDeptIdGetDevice({ organizationId: newV });  
43 - // // options.items.forEach((v) => {  
44 - // // return (v.value = v.id), (v.label = v.name);  
45 - // // });  
46 - // // updateFieldDeviceId(options.items);  
47 - // // }  
48 - // );  
49 const updateFieldDeviceId = (v) => { 38 const updateFieldDeviceId = (v) => {
50 setTimeout(() => { 39 setTimeout(() => {
51 updateSchema({ 40 updateSchema({
@@ -65,6 +54,17 @@ @@ -65,6 +54,17 @@
65 if (props.editTriggerFather != 1) { 54 if (props.editTriggerFather != 1) {
66 setTimeout(() => { 55 setTimeout(() => {
67 setFieldsValue(props.editTriggerFather); 56 setFieldsValue(props.editTriggerFather);
  57 + setFieldsValue({
  58 + entityId1: props.editTriggerFather.entityId,
  59 + entityId2: props.editTriggerFather.entityId,
  60 + type1: props.editTriggerFather?.triggerCondition?.condition[0]?.key?.type,
  61 + type2: props.editTriggerFather?.triggerCondition?.condition[0]?.predicate?.type,
  62 + operation:
  63 + props.editTriggerFather?.triggerCondition?.condition[0]?.predicate?.operation,
  64 + value:
  65 + props.editTriggerFather?.triggerCondition?.condition[0]?.predicate?.value
  66 + ?.defaultValue,
  67 + });
68 }, 10); 68 }, 10);
69 } 69 }
70 }; 70 };
@@ -241,6 +241,9 @@ @@ -241,6 +241,9 @@
241 }; 241 };
242 let optionsItemArray = ref<[]>([]); 242 let optionsItemArray = ref<[]>([]);
243 const isNoChange = ref(false); 243 const isNoChange = ref(false);
  244 + let kongTriggerObj = {};
  245 + let kongConditionObj = {};
  246 + let kongActionObj = {};
244 247
245 const [registerForm, { resetFields, setFieldsValue, validateFields }] = useForm({ 248 const [registerForm, { resetFields, setFieldsValue, validateFields }] = useForm({
246 labelWidth: 120, 249 labelWidth: 120,
@@ -289,7 +292,7 @@ @@ -289,7 +292,7 @@
289 proxy.$refs.refActionChild.clearSelectDevice(); 292 proxy.$refs.refActionChild.clearSelectDevice();
290 clearActionsAllDevice(); 293 clearActionsAllDevice();
291 resetActionsAllArrayFunc(); 294 resetActionsAllArrayFunc();
292 - }, 200); 295 + }, 10);
293 } catch (e) { 296 } catch (e) {
294 return e; 297 return e;
295 } 298 }
@@ -298,6 +301,10 @@ @@ -298,6 +301,10 @@
298 } 301 }
299 } else { 302 } else {
300 try { 303 try {
  304 + emit('success');
  305 + kongTriggerObj = {};
  306 + kongConditionObj = {};
  307 + kongActionObj = {};
301 pushEditArray.value = []; 308 pushEditArray.value = [];
302 pushEditArray.value.length = 0; 309 pushEditArray.value.length = 0;
303 pushEditConditionArray.value.length = 0; 310 pushEditConditionArray.value.length = 0;
@@ -454,9 +461,80 @@ @@ -454,9 +461,80 @@
454 refTriggerChildDataFunc(); 461 refTriggerChildDataFunc();
455 refConditionChildDataFunc(); 462 refConditionChildDataFunc();
456 refActionChildDataFunc(); 463 refActionChildDataFunc();
457 - const newTriggerArray = addTriggerPushData.value.concat(refTriggerChildData);  
458 - const newConditionArray = addConditionPushData.value.concat(refConditionChildData);  
459 - const newActionArray = addActionPushData.value.concat(refActionChildData); 464 + let newTriggerArray = addTriggerPushData.value.concat(refTriggerChildData);
  465 + let newConditionArray = addConditionPushData.value.concat(refConditionChildData);
  466 + let newActionArray = addActionPushData.value.concat(refActionChildData);
  467 + newTriggerArray = newTriggerArray.map((m) => {
  468 + return {
  469 + triggerType: m?.triggerType,
  470 + entityId: m?.entityId || m?.entityId1 || m?.entityId2,
  471 + triggerCondition: {
  472 + condition: [
  473 + {
  474 + key: {
  475 + key: m.key1 == null ? 'CO2' : m.key1,
  476 + type: m.type1 == null ? 'TIME_SERIES' : m.type1,
  477 + },
  478 + valueType: m.type2 == null ? 'NUMERIC' : m.type2,
  479 + value: {},
  480 + predicate: {
  481 + type: m.type2 == null ? 'NUMERIC' : m.type2,
  482 + value: {
  483 + defaultValue: Number(m.value) == null ? 0 : Number(m.value),
  484 + },
  485 + operation: m.operation == null ? 'GREATER_OR_EQUAL' : m.operation,
  486 + },
  487 + },
  488 + ],
  489 + spec: {
  490 + type: 'SIMPLE',
  491 + },
  492 + },
  493 + };
  494 + });
  495 + newConditionArray = newConditionArray.map((m) => {
  496 + return {
  497 + triggerType: m?.triggerType,
  498 + entityId: m?.entityId,
  499 + triggerCondition: {
  500 + condition: [
  501 + {
  502 + key: {
  503 + type: 'TIME_SERIES',
  504 + key: 'CO2',
  505 + },
  506 + valueType:
  507 + m.type == 'NUMERIC1'
  508 + ? 'NUMERIC'
  509 + : m.type == 'NUMERIC2'
  510 + ? 'NUMERIC'
  511 + : 'NUMERIC',
  512 + value: {},
  513 + predicate: {
  514 + type:
  515 + m.type == 'NUMERIC1'
  516 + ? 'NUMERIC'
  517 + : m.type == 'NUMERIC2'
  518 + ? 'NUMERIC'
  519 + : 'NUMERIC',
  520 + value: {
  521 + defaultValue:
  522 + Number(m.value1) == null
  523 + ? 0
  524 + : Number(m.value1) || Number(m.value2) == null
  525 + ? 0
  526 + : Number(m.value2),
  527 + },
  528 + operation: m.operation1 || m.operatio2,
  529 + },
  530 + },
  531 + ],
  532 + spec: {
  533 + type: 'SIMPLE',
  534 + },
  535 + },
  536 + };
  537 + });
460 newTriggerArray.shift(); 538 newTriggerArray.shift();
461 newConditionArray.shift(); 539 newConditionArray.shift();
462 newActionArray.shift(); 540 newActionArray.shift();
@@ -473,9 +551,6 @@ @@ -473,9 +551,6 @@
473 }; 551 };
474 Object.assign(getAllFormData, triggersObj, conditionsObj, actionsObj); 552 Object.assign(getAllFormData, triggersObj, conditionsObj, actionsObj);
475 } else { 553 } else {
476 - let kongTriggerObj = {};  
477 - let kongConditionObj = {};  
478 - let kongActionObj = {};  
479 editTriggerPushData.value.forEach((f) => { 554 editTriggerPushData.value.forEach((f) => {
480 kongTriggerObj = f; 555 kongTriggerObj = f;
481 pushEditArray.value.push(kongTriggerObj); 556 pushEditArray.value.push(kongTriggerObj);
@@ -518,7 +593,13 @@ @@ -518,7 +593,13 @@
518 getDefaultValue(); 593 getDefaultValue();
519 getValuesFormData = await validateFields(); 594 getValuesFormData = await validateFields();
520 if (!getValuesFormData) return; 595 if (!getValuesFormData) return;
521 - if (getAllFormData.doActions.length == 0) return createMessage.error('请填写执行动作'); 596 + let isKongNum = 0;
  597 + getAllFormData.doActions.forEach((f) => {
  598 + isKongNum = Object.keys(f).length;
  599 + });
  600 +
  601 + if (getAllFormData.doActions.length == 1 && isKongNum == 0)
  602 + return createMessage.error('请填写执行动作');
522 Object.assign(getAllFormData, getValuesFormData); 603 Object.assign(getAllFormData, getValuesFormData);
523 await screenLinkPageAddApi(getAllFormData); 604 await screenLinkPageAddApi(getAllFormData);
524 createMessage.success('场景联动新增成功'); 605 createMessage.success('场景联动新增成功');
@@ -534,7 +615,6 @@ @@ -534,7 +615,6 @@
534 pushEditArray.value.length = 0; 615 pushEditArray.value.length = 0;
535 pushEditConditionArray.value.length = 0; 616 pushEditConditionArray.value.length = 0;
536 pushEditActionArray.value.length = 0; 617 pushEditActionArray.value.length = 0;
537 - console.log('edit data', getAllFormData);  
538 await screenLinkPageUpdateApi(getAllFormData); 618 await screenLinkPageUpdateApi(getAllFormData);
539 createMessage.success('场景联动编辑成功'); 619 createMessage.success('场景联动编辑成功');
540 closeDrawer(); 620 closeDrawer();
@@ -577,7 +657,7 @@ @@ -577,7 +657,7 @@
577 try { 657 try {
578 setTimeout(() => { 658 setTimeout(() => {
579 proxy.$refs.refTriggerChild.updateFieldDeviceId(optionsItemArray.value); 659 proxy.$refs.refTriggerChild.updateFieldDeviceId(optionsItemArray.value);
580 - }, 150); 660 + }, 50);
581 } catch (e) { 661 } catch (e) {
582 return e; 662 return e;
583 } 663 }
@@ -617,7 +697,7 @@ @@ -617,7 +697,7 @@
617 try { 697 try {
618 setTimeout(() => { 698 setTimeout(() => {
619 proxy.$refs.refTriggerChild.updateFieldDeviceId(optionsItemArray.value); 699 proxy.$refs.refTriggerChild.updateFieldDeviceId(optionsItemArray.value);
620 - }, 150); 700 + }, 50);
621 } catch (e) { 701 } catch (e) {
622 return e; 702 return e;
623 } 703 }
@@ -691,7 +771,7 @@ @@ -691,7 +771,7 @@
691 try { 771 try {
692 setTimeout(() => { 772 setTimeout(() => {
693 proxy.$refs.refConditionChild.updateFieldDeviceId(optionsItemArray.value); 773 proxy.$refs.refConditionChild.updateFieldDeviceId(optionsItemArray.value);
694 - }, 150); 774 + }, 50);
695 } catch (e) { 775 } catch (e) {
696 return e; 776 return e;
697 } 777 }
@@ -746,7 +826,7 @@ @@ -746,7 +826,7 @@
746 try { 826 try {
747 setTimeout(() => { 827 setTimeout(() => {
748 proxy.$refs.refConditionChild.updateFieldDeviceId(optionsItemArray.value); 828 proxy.$refs.refConditionChild.updateFieldDeviceId(optionsItemArray.value);
749 - }, 150); 829 + }, 50);
750 } catch (e) { 830 } catch (e) {
751 return e; 831 return e;
752 } 832 }
@@ -762,7 +842,7 @@ @@ -762,7 +842,7 @@
762 } 842 }
763 } else { 843 } else {
764 try { 844 try {
765 - unref(editConditionPushData).splice(0, 1); 845 + unref(editConditionPushData).pop();
766 } catch (e) { 846 } catch (e) {
767 return e; 847 return e;
768 } 848 }
@@ -783,7 +863,7 @@ @@ -783,7 +863,7 @@
783 try { 863 try {
784 setTimeout(() => { 864 setTimeout(() => {
785 proxy.$refs.refActionChild.updateFieldDeviceId(optionsItemArray.value); 865 proxy.$refs.refActionChild.updateFieldDeviceId(optionsItemArray.value);
786 - }, 150); 866 + }, 50);
787 } catch (e) { 867 } catch (e) {
788 return e; 868 return e;
789 } 869 }
@@ -795,7 +875,7 @@ @@ -795,7 +875,7 @@
795 try { 875 try {
796 setTimeout(() => { 876 setTimeout(() => {
797 proxy.$refs.refActionChild.updateFieldDeviceId(optionsItemArray.value); 877 proxy.$refs.refActionChild.updateFieldDeviceId(optionsItemArray.value);
798 - }, 150); 878 + }, 50);
799 } catch (e) { 879 } catch (e) {
800 return e; 880 return e;
801 } 881 }
@@ -811,7 +891,7 @@ @@ -811,7 +891,7 @@
811 } 891 }
812 } else { 892 } else {
813 try { 893 try {
814 - unref(editActionPushData).splice(0, 1); 894 + unref(editActionPushData).pop();
815 } catch (e) { 895 } catch (e) {
816 return e; 896 return e;
817 } 897 }