Commit befac13fbe09e35fc617e4e85700c47c5db00af9
Merge branch 'ft-dev' into 'main'
fix:修改场景联动页面触发器和执行条件按钮,和选择设备问题,fix:修复设备配置编辑数据回显 See merge request huang/yun-teng-iot-front!128
Showing
8 changed files
with
365 additions
and
221 deletions
... | ... | @@ -120,6 +120,7 @@ |
120 | 120 | const [register, { closeModal }] = useModalInner(async (data) => { |
121 | 121 | isUpdate.value = data.isUpdate; |
122 | 122 | if (isUpdate.value == 1) { |
123 | + proxy.$refs.DeviceProfileStep3Ref.isAddRuleStatusFunc(true); | |
123 | 124 | isShowRule.value = true; |
124 | 125 | isShowOkBtnFalse.value = true; |
125 | 126 | current.value = 0; |
... | ... | @@ -134,6 +135,7 @@ |
134 | 135 | stepThreeData: {}, |
135 | 136 | }); |
136 | 137 | } else if (isUpdate.value == 2) { |
138 | + proxy.$refs.DeviceProfileStep3Ref.isAddRuleStatusFunc(true); | |
137 | 139 | isShowRule.value = true; |
138 | 140 | isShowOkBtnFalse.value = true; |
139 | 141 | current.value = 0; |
... | ... | @@ -153,6 +155,7 @@ |
153 | 155 | getBackendData = await deviceConfigGetDetail(postEditId.value); |
154 | 156 | editData.value = getBackendData; |
155 | 157 | } else if (isUpdate.value == 3) { |
158 | + proxy.$refs.DeviceProfileStep3Ref.isAddRuleStatusFunc(false); | |
156 | 159 | isShowRule.value = false; |
157 | 160 | isShowOkBtnFalse.value = false; |
158 | 161 | current.value = 0; |
... | ... | @@ -215,6 +218,9 @@ |
215 | 218 | stepThreeData: editData.value?.profileData.alarms[0].createRules, |
216 | 219 | stepThreeClearData: editData.value?.profileData.alarms[0].clearRule, |
217 | 220 | }); |
221 | + proxy.$refs.DeviceProfileStep3Ref.setCreateRegisterFormChangeDetailFunc( | |
222 | + editData.value?.profileData.alarms[0].createRules | |
223 | + ); | |
218 | 224 | proxy.$refs.DeviceProfileStep3Ref.setRegisterFormClearChangeDetailFunc({ |
219 | 225 | alarmDetails: editData.value?.profileData.alarms[0].clearRule.alarmDetails, |
220 | 226 | }); |
... | ... | @@ -233,6 +239,9 @@ |
233 | 239 | stepThreeData: editData.value?.profileData.alarms[0].createRules, |
234 | 240 | stepThreeClearData: editData.value?.profileData.alarms[0].clearRule, |
235 | 241 | }); |
242 | + proxy.$refs.DeviceProfileStep3Ref.setCreateRegisterFormChangeDetailFunc( | |
243 | + editData.value?.profileData.alarms[0].createRules | |
244 | + ); | |
236 | 245 | proxy.$refs.DeviceProfileStep3Ref.setRegisterFormClearChangeDetailFunc({ |
237 | 246 | alarmDetails: editData.value?.profileData.alarms[0].clearRule.alarmDetails, |
238 | 247 | }); |
... | ... | @@ -313,6 +322,11 @@ |
313 | 322 | |
314 | 323 | const handleCancel = () => { |
315 | 324 | closeModal(); |
325 | + try { | |
326 | + proxy.$refs.DeviceProfileStep4Ref.clearAlaramContactAndNoticeMethodFunc(); | |
327 | + } catch (e) { | |
328 | + return e; | |
329 | + } | |
316 | 330 | }; |
317 | 331 | return { |
318 | 332 | isShowRule, | ... | ... |
... | ... | @@ -7,6 +7,7 @@ |
7 | 7 | <template #action> |
8 | 8 | <div class="cursor-pointer"> |
9 | 9 | <img |
10 | + v-if="isAddRuleStatus" | |
10 | 11 | style="cursor: pointer" |
11 | 12 | @click="deleteAlarmRule(index)" |
12 | 13 | alt="移除" |
... | ... | @@ -68,10 +69,20 @@ |
68 | 69 | <!-- 报警严重程度 --> |
69 | 70 | <div style="margin-left: 10px; margin-top: 20px" |
70 | 71 | ><BasicForm @register="registerFormCreateAlarm" /> |
72 | + <div | |
73 | + v-for="(i8, index8) in getStepThreeEditStatus ? createAlarmArray : []" | |
74 | + :key="index8" | |
75 | + style="position: relative" | |
76 | + > | |
77 | + <p | |
78 | + style="position: absolute; top: -6vh; left: 6.5vw" | |
79 | + v-if="index8 == createIndex" | |
80 | + >{{ formatAlarmFunc(i8) }}</p | |
81 | + > | |
82 | + </div> | |
71 | 83 | </div> |
72 | 84 | <!-- 报警严重程度 --> |
73 | - | |
74 | - <div style="margin-left: 5px; margin-top: -50px"> | |
85 | + <div style="margin-left: 5px; margin-top: -35px"> | |
75 | 86 | <div style="color: #f5594e" class="ml-4" |
76 | 87 | >报警规则条件: |
77 | 88 | <Button |
... | ... | @@ -131,6 +142,18 @@ |
131 | 142 | <div style="position: absolute; top: -5px; left: 106px; width: 581px"> |
132 | 143 | <BasicForm @register="registerFormChangeDetail" /> |
133 | 144 | </div> |
145 | + <div | |
146 | + v-for="(i7, index7) in getStepThreeEditStatus | |
147 | + ? detailDetailModelArray | |
148 | + : []" | |
149 | + :key="index7" | |
150 | + > | |
151 | + <p | |
152 | + style="margin-top: 1.5vh; margin-left: 5.6vw" | |
153 | + v-if="index7 == createIndex" | |
154 | + >{{ i7 }}</p | |
155 | + > | |
156 | + </div> | |
134 | 157 | </div> |
135 | 158 | <div style="margin-top: 25px; position: relative"> |
136 | 159 | <div style="margin-left: -14px"> |
... | ... | @@ -144,6 +167,7 @@ |
144 | 167 | style="display: inline-block; position: relative; top: -257px; left: 757px" |
145 | 168 | > |
146 | 169 | <img |
170 | + v-if="isAddRuleStatus" | |
147 | 171 | style="cursor: pointer" |
148 | 172 | @click="deleteCondition(index, createIndex)" |
149 | 173 | alt="移除" |
... | ... | @@ -155,7 +179,11 @@ |
155 | 179 | </div> |
156 | 180 | </template> |
157 | 181 | <div> |
158 | - <a-button style="border-radius: 10px" class="mt-5" @click="addCreateRole(index)" | |
182 | + <a-button | |
183 | + v-if="isAddRuleStatus" | |
184 | + style="border-radius: 10px" | |
185 | + class="mt-5" | |
186 | + @click="addCreateRole(index)" | |
159 | 187 | ><PlusCircleOutlined />添加创建条件</a-button |
160 | 188 | > |
161 | 189 | </div> |
... | ... | @@ -209,25 +237,7 @@ |
209 | 237 | <span style="display: none">{{ index4 }}</span> |
210 | 238 | |
211 | 239 | <p v-if="!getStepThreeEditStatus" |
212 | - >报警规则条件:{{ | |
213 | - v4.predicate.operation == 'EQUAL' | |
214 | - ? v4.key.key + '等于' + v4.predicate.value.defaultValue | |
215 | - : v4.predicate.operation == 'STARTS_WITH' | |
216 | - ? v4.key.key + '开始于' + v4.predicate.value.defaultValue | |
217 | - : v4.predicate.operation == 'ENDS_WITH' | |
218 | - ? v4.key.key + '结束于' + v4.predicate.value.defaultValue | |
219 | - : v4.predicate.operation == 'NOT_CONTAINS' | |
220 | - ? v4.key.key + '不包含' + v4.predicate.value.defaultValue | |
221 | - : v4.predicate.operation == 'NOT_EQUAL' | |
222 | - ? v4.key.key + '不等于' + v4.predicate.value.defaultValue | |
223 | - : v4.predicate.operation == 'GREATER' | |
224 | - ? v4.key.key + '大于' + v4.predicate.value.defaultValue | |
225 | - : v4.predicate.operation == 'LESS' | |
226 | - ? v4.key.key + '小于' + v4.predicate.value.defaultValue | |
227 | - : v4.predicate.operation == 'GREATER_OR_EQUAL' | |
228 | - ? v4.key.key + '大于或等于' + v4.predicate.value.defaultValue | |
229 | - : v4.key.key + '小于或等于' + v4.predicate.value.defaultValue | |
230 | - }}</p | |
240 | + >报警规则条件:{{ formatClearRuleFunc(v4) }}</p | |
231 | 241 | > |
232 | 242 | <p v-if="getStepThreeEditStatus" |
233 | 243 | >报警规则条件:{{ openClearRuleConditionComp(v4) }}</p |
... | ... | @@ -295,7 +305,11 @@ |
295 | 305 | <div class="flex justify-center" style="display: fixed; bottom: 100px"> |
296 | 306 | <a-button class="mr-5" @click="prevStep">上一步</a-button> |
297 | 307 | <a-button @click="handleFormStep3toStep4Next">下一步</a-button> |
298 | - <a-button style="margin-left: 20px" type="primary" @click="addAlarmRule" | |
308 | + <a-button | |
309 | + v-if="isAddRuleStatus" | |
310 | + style="margin-left: 20px" | |
311 | + type="primary" | |
312 | + @click="addAlarmRule" | |
299 | 313 | >添加报警规则</a-button |
300 | 314 | > |
301 | 315 | </div> |
... | ... | @@ -336,6 +350,7 @@ |
336 | 350 | emits: ['prev', 'next', 'redo', 'handleFormStep3toStep4Next'], |
337 | 351 | props: ['getAllStepThreeData', 'isAddOrEdit', 'isShowAddRule'], |
338 | 352 | setup(props, { emit }) { |
353 | + const isAddRuleStatus = ref(true); | |
339 | 354 | const { proxy } = getCurrentInstance(); |
340 | 355 | const changeGetDetailValue = ref({}); |
341 | 356 | const changeGetClearDetailValue = ref({}); |
... | ... | @@ -456,6 +471,10 @@ |
456 | 471 | const getFilterStepThreeEditClearArr = ref<[]>([]); |
457 | 472 | const getFilterStepThreeClearDetailEditArr = ref<[]>([]); |
458 | 473 | let getIsShowAddRule = true; |
474 | + | |
475 | + const detailDetailModelArray = ref<[]>([]); | |
476 | + const createAlarmArray = ref<[]>([]); | |
477 | + | |
459 | 478 | // getIsShowAddRule.value = props.isShowAddRule; |
460 | 479 | // console.log(getIsShowAddRule.value); |
461 | 480 | setTimeout(() => { |
... | ... | @@ -465,6 +484,9 @@ |
465 | 484 | const log = (e) => { |
466 | 485 | console.log(e); |
467 | 486 | }; |
487 | + const isAddRuleStatusFunc = (v) => { | |
488 | + isAddRuleStatus.value = v; | |
489 | + }; | |
468 | 490 | //编辑清空操作 |
469 | 491 | const clearProfileDataFunc = () => { |
470 | 492 | profileData.value.splice(0, 1); |
... | ... | @@ -530,8 +552,8 @@ |
530 | 552 | registerFormChangeDetail, |
531 | 553 | { |
532 | 554 | getFieldsValue: getRegisterFormChangeDetail, |
533 | - setFieldsValue: setRegisterFormChangeDetail, | |
534 | 555 | resetFields: resetRegisterFormChangeDetail, |
556 | + // setFieldsValue: setCreateRegisterFormChangeDetail, | |
535 | 557 | }, |
536 | 558 | ] = useForm({ |
537 | 559 | labelWidth: 120, |
... | ... | @@ -606,6 +628,8 @@ |
606 | 628 | getFilterStepThreeEditArr.value = []; |
607 | 629 | getFilterStepThreeEditClearArr.value = []; |
608 | 630 | getStepThreeEditStatus.value = false; |
631 | + detailDetailModelArray.value = []; | |
632 | + createAlarmArray.value = []; | |
609 | 633 | }; |
610 | 634 | const initClearCreateRuleFunc = () => { |
611 | 635 | profileData.value.forEach((f) => { |
... | ... | @@ -635,7 +659,7 @@ |
635 | 659 | const setRegisterFormCreateAlarmFunc = (v) => { |
636 | 660 | setRegisterFormCreateAlarm(v); |
637 | 661 | }; |
638 | - // | |
662 | + | |
639 | 663 | const optionsAlaram = [ |
640 | 664 | { |
641 | 665 | value: 'CRITICAL', |
... | ... | @@ -682,40 +706,29 @@ |
682 | 706 | ? '定时启用' |
683 | 707 | : '自定义启用'; |
684 | 708 | }; |
685 | - const optionsOperation = [ | |
686 | - { label: '等于', value: 'EQUAL' }, | |
687 | - { label: '不等于', value: 'NOT_EQUAL' }, | |
688 | - { label: '开始于', value: 'STARTS_WITH' }, | |
689 | - { label: '结束于', value: 'ENDS_WITH' }, | |
690 | - { label: '包含', value: 'CONTAINS' }, | |
691 | - { label: '不包含', value: 'NOT_CONTAINS' }, | |
692 | - { label: '大于', value: 'GREATER' }, | |
693 | - { label: '小于', value: 'LESS' }, | |
694 | - { label: '大于或等于', value: 'GREATER_OR_EQUAL' }, | |
695 | - { label: '小于或等于', value: 'LESS_OR_EQUAL' }, | |
696 | - ]; | |
697 | 709 | //清除报警规则 |
698 | 710 | const openClearRuleConditionComp = (v4) => { |
699 | 711 | try { |
700 | - let clearRuleObj = {}; | |
701 | - v4.condition.condition?.forEach((f) => { | |
702 | - clearRuleObj = f; | |
712 | + let formatMap = v4.condition.condition.map((f) => { | |
713 | + return f.predicate.operation == 'EQUAL' | |
714 | + ? f.key.key + '等于' + f.predicate.value.defaultValue | |
715 | + : f.predicate.operation == 'STARTS_WITH' | |
716 | + ? f.key.key + '开始于' + f.predicate.value.defaultValue | |
717 | + : f.predicate.operation == 'ENDS_WITH' | |
718 | + ? f.key.key + '结束于' + f.predicate.value.defaultValue | |
719 | + : f.predicate.operation == 'NOT_CONTAINS' | |
720 | + ? f.key.key + '不包含' + f.predicate.value.defaultValue | |
721 | + : f.predicate.operation == 'NOT_EQUAL' | |
722 | + ? f.key.key + '不等于' + f.predicate.value.defaultValue | |
723 | + : f.predicate.operation == 'GREATER' | |
724 | + ? f.key.key + '大于' + f.predicate.value.defaultValue | |
725 | + : f.predicate.operation == 'LESS' | |
726 | + ? f.key.key + '小于' + f.predicate.value.defaultValue | |
727 | + : f.predicate.operation == 'GREATER_OR_EQUAL' | |
728 | + ? f.key.key + '大于或等于' + f.predicate.value.defaultValue | |
729 | + : f.key.key + '小于或等于' + f.predicate.value.defaultValue; | |
703 | 730 | }); |
704 | - return clearRuleObj?.predicate?.operation == 'LESS_OR_EQUAL' | |
705 | - ? clearRuleObj?.key?.key + '小于或等于' + clearRuleObj?.predicate?.value?.defaultValue | |
706 | - : clearRuleObj?.predicate?.operation == 'EQUAL' | |
707 | - ? clearRuleObj?.key?.key + '等于' + clearRuleObj?.predicate?.value?.defaultValue | |
708 | - : clearRuleObj?.predicate?.operation == 'NOT_EQUAL' | |
709 | - ? clearRuleObj?.key?.key + '不等于' + clearRuleObj?.predicate?.value?.defaultValue | |
710 | - : clearRuleObj?.predicate?.operation == 'ENDS_WITH' | |
711 | - ? clearRuleObj?.key?.key + '结束于' + clearRuleObj?.predicate?.value?.defaultValue | |
712 | - : clearRuleObj?.predicate?.operation == 'CONTAINS' | |
713 | - ? clearRuleObj?.key?.key + '包含' + clearRuleObj?.predicate?.value?.defaultValue | |
714 | - : clearRuleObj?.predicate?.operation == 'GREATER' | |
715 | - ? clearRuleObj?.key?.key + '大于' + clearRuleObj?.predicate?.value?.defaultValue | |
716 | - : clearRuleObj?.predicate?.operation == 'LESS' | |
717 | - ? clearRuleObj?.key?.key + '小于' + clearRuleObj?.predicate?.value?.defaultValue | |
718 | - : clearRuleObj?.key?.key + '小于或等于' + clearRuleObj?.predicate?.value?.defaultValue; | |
731 | + return formatMap; | |
719 | 732 | } catch (e) { |
720 | 733 | return e; |
721 | 734 | } |
... | ... | @@ -737,27 +750,26 @@ |
737 | 750 | openRuleConditObj = v2[i]; |
738 | 751 | } |
739 | 752 | } |
740 | - let createRuleObj = {}; | |
741 | - openRuleConditObj?.condition?.condition?.forEach((f) => { | |
742 | - createRuleObj = f; | |
753 | + let formatMap = openRuleConditObj?.condition?.condition.map((f) => { | |
754 | + return f.predicate.operation == 'EQUAL' | |
755 | + ? f.key.key + '等于' + f.predicate.value.defaultValue | |
756 | + : f.predicate.operation == 'STARTS_WITH' | |
757 | + ? f.key.key + '开始于' + f.predicate.value.defaultValue | |
758 | + : f.predicate.operation == 'ENDS_WITH' | |
759 | + ? f.key.key + '结束于' + f.predicate.value.defaultValue | |
760 | + : f.predicate.operation == 'NOT_CONTAINS' | |
761 | + ? f.key.key + '不包含' + f.predicate.value.defaultValue | |
762 | + : f.predicate.operation == 'NOT_EQUAL' | |
763 | + ? f.key.key + '不等于' + f.predicate.value.defaultValue | |
764 | + : f.predicate.operation == 'GREATER' | |
765 | + ? f.key.key + '大于' + f.predicate.value.defaultValue | |
766 | + : f.predicate.operation == 'LESS' | |
767 | + ? f.key.key + '小于' + f.predicate.value.defaultValue | |
768 | + : f.predicate.operation == 'GREATER_OR_EQUAL' | |
769 | + ? f.key.key + '大于或等于' + f.predicate.value.defaultValue | |
770 | + : f.key.key + '小于或等于' + f.predicate.value.defaultValue; | |
743 | 771 | }); |
744 | - return createRuleObj?.predicate?.operation == 'LESS_OR_EQUAL' | |
745 | - ? createRuleObj?.key?.key + '小于或等于' + createRuleObj?.predicate?.value?.defaultValue | |
746 | - : createRuleObj?.predicate?.operation == 'EQUAL' | |
747 | - ? createRuleObj?.key?.key + '等于' + createRuleObj?.predicate?.value?.defaultValue | |
748 | - : createRuleObj?.predicate?.operation == 'NOT_EQUAL' | |
749 | - ? createRuleObj?.key?.key + '不等于' + createRuleObj?.predicate?.value?.defaultValue | |
750 | - : createRuleObj?.predicate?.operation == 'ENDS_WITH' | |
751 | - ? createRuleObj?.key?.key + '结束于' + createRuleObj?.predicate?.value?.defaultValue | |
752 | - : createRuleObj?.predicate?.operation == 'CONTAINS' | |
753 | - ? createRuleObj?.key?.key + '包含' + createRuleObj?.predicate?.value?.defaultValue | |
754 | - : createRuleObj?.predicate?.operation == 'GREATER' | |
755 | - ? createRuleObj?.key?.key + '大于' + createRuleObj?.predicate?.value?.defaultValue | |
756 | - : createRuleObj?.predicate?.operation == 'LESS' | |
757 | - ? createRuleObj?.key?.key + '小于' + createRuleObj?.predicate?.value?.defaultValue | |
758 | - : createRuleObj?.key?.key + | |
759 | - '小于或等于' + | |
760 | - createRuleObj?.predicate?.value?.defaultValue; | |
772 | + return formatMap; | |
761 | 773 | } catch (e) { |
762 | 774 | return e; |
763 | 775 | } |
... | ... | @@ -778,13 +790,25 @@ |
778 | 790 | o[v] = getStepThreeEditArr.value[v]; |
779 | 791 | getFilterStepThreeEditArr.value.push(o as never); |
780 | 792 | }); |
781 | - console.log(getFilterStepThreeEditArr.value); | |
782 | - | |
783 | - // setRegisterFormChangeDetail({ | |
784 | - // alarmDetails: v.stepThreeData[0].createRules['MAJOR'].alarmDetails, | |
785 | - // }); | |
786 | 793 | } |
787 | 794 | }; |
795 | + const setCreateRegisterFormChangeDetailFunc = (v) => { | |
796 | + for (let i in v) { | |
797 | + detailDetailModelArray.value.push(v[i].alarmDetails as never); | |
798 | + createAlarmArray.value.push(i as never); | |
799 | + } | |
800 | + }; | |
801 | + const formatAlarmFunc = (v) => { | |
802 | + return v == 'CRITICAL' | |
803 | + ? '危险' | |
804 | + : v == 'MAJOR' | |
805 | + ? '重要' | |
806 | + : v == 'MINOR' | |
807 | + ? '次要' | |
808 | + : v == 'WARNING' | |
809 | + ? '警告' | |
810 | + : '不确定'; | |
811 | + }; | |
788 | 812 | |
789 | 813 | //清除修改详情模板 |
790 | 814 | const setRegisterFormClearChangeDetailFunc = (v) => { |
... | ... | @@ -812,7 +836,6 @@ |
812 | 836 | tempRuleConditionTempArr.value.push({ |
813 | 837 | condition: addNewRuleTem.condition.condition, |
814 | 838 | }); |
815 | - console.log(tempRuleConditionTempArr.value); | |
816 | 839 | }; |
817 | 840 | |
818 | 841 | const getClearOpenRuleAndRuleCondition = () => { |
... | ... | @@ -903,44 +926,33 @@ |
903 | 926 | //规则条件 |
904 | 927 | const getAllFieldsRuleFunc = (v) => { |
905 | 928 | ruleObj.value = v; |
906 | - // let splitRuleObj = {}; | |
907 | - // ruleObj.value.forEach((f) => { | |
908 | - // splitRuleObj = f; | |
909 | - // }); | |
910 | - // fliterTempRuleConditionTempArr.value.push(splitRuleObj as never); | |
911 | - // fliterTempRuleConditionTempArr.value = ruleObj.value; | |
912 | 929 | addNewRuleTem.condition.condition = ruleObj.value as never; |
913 | 930 | fliterTempRuleConditionTempArr.value.push({ |
914 | 931 | condition: addNewRuleTem.condition.condition, |
915 | 932 | }); |
916 | - console.log(fliterTempRuleConditionTempArr.value); | |
917 | 933 | }; |
918 | 934 | //格式化新增 |
919 | 935 | const formatAddRuleFunc = (v) => { |
920 | - console.log(v.condition); | |
921 | - let kongFormatObj = {}; | |
922 | - v.condition.forEach((f) => { | |
923 | - kongFormatObj = | |
924 | - f.predicate.operation == 'EQUAL' | |
925 | - ? f.key.key + '等于' + f.predicate.value.defaultValue | |
926 | - : f.predicate.operation == 'STARTS_WITH' | |
927 | - ? f.key.key + '开始于' + f.predicate.value.defaultValue | |
928 | - : f.predicate.operation == 'ENDS_WITH' | |
929 | - ? f.key.key + '结束于' + f.predicate.value.defaultValue | |
930 | - : f.predicate.operation == 'NOT_CONTAINS' | |
931 | - ? f.key.key + '不包含' + f.predicate.value.defaultValue | |
932 | - : f.predicate.operation == 'NOT_EQUAL' | |
933 | - ? f.key.key + '不等于' + f.predicate.value.defaultValue | |
934 | - : f.predicate.operation == 'GREATER' | |
935 | - ? f.key.key + '大于' + f.predicate.value.defaultValue | |
936 | - : f.predicate.operation == 'LESS' | |
937 | - ? f.key.key + '小于' + f.predicate.value.defaultValue | |
938 | - : f.predicate.operation == 'GREATER_OR_EQUAL' | |
939 | - ? f.key.key + '大于或等于' + f.predicate.value.defaultValue | |
940 | - : f.key.key + '小于或等于' + f.predicate.value.defaultValue; | |
936 | + let formatMap = v.condition.map((f) => { | |
937 | + return f.predicate.operation == 'EQUAL' | |
938 | + ? f.key.key + '等于' + f.predicate.value.defaultValue | |
939 | + : f.predicate.operation == 'STARTS_WITH' | |
940 | + ? f.key.key + '开始于' + f.predicate.value.defaultValue | |
941 | + : f.predicate.operation == 'ENDS_WITH' | |
942 | + ? f.key.key + '结束于' + f.predicate.value.defaultValue | |
943 | + : f.predicate.operation == 'NOT_CONTAINS' | |
944 | + ? f.key.key + '不包含' + f.predicate.value.defaultValue | |
945 | + : f.predicate.operation == 'NOT_EQUAL' | |
946 | + ? f.key.key + '不等于' + f.predicate.value.defaultValue | |
947 | + : f.predicate.operation == 'GREATER' | |
948 | + ? f.key.key + '大于' + f.predicate.value.defaultValue | |
949 | + : f.predicate.operation == 'LESS' | |
950 | + ? f.key.key + '小于' + f.predicate.value.defaultValue | |
951 | + : f.predicate.operation == 'GREATER_OR_EQUAL' | |
952 | + ? f.key.key + '大于或等于' + f.predicate.value.defaultValue | |
953 | + : f.key.key + '小于或等于' + f.predicate.value.defaultValue; | |
941 | 954 | }); |
942 | - console.log(kongFormatObj); | |
943 | - return kongFormatObj; | |
955 | + return formatMap; | |
944 | 956 | }; |
945 | 957 | //清除报警规则 |
946 | 958 | //启用规则 |
... | ... | @@ -951,14 +963,33 @@ |
951 | 963 | //规则条件 |
952 | 964 | const getAllClearFieldsRuleFunc = (v) => { |
953 | 965 | ruleLastObj.value = v; |
954 | - let splitRuleObj = {}; | |
955 | - ruleLastObj.value.forEach((f) => { | |
956 | - splitRuleObj = f; | |
966 | + addNewRuleTem.condition.condition = ruleLastObj.value as never; | |
967 | + fliterClearTempRuleConditionTempArr.value.push({ | |
968 | + condition: addNewRuleTem.condition.condition, | |
957 | 969 | }); |
958 | - fliterClearTempRuleConditionTempArr.value.push(splitRuleObj as never); | |
959 | - // if (fliterClearTempRuleConditionTempArr.value.length == 0) { | |
960 | - // fliterClearTempRuleConditionTempArr.value = ruleLastObj.value; | |
961 | - // } | |
970 | + }; | |
971 | + | |
972 | + const formatClearRuleFunc = (v) => { | |
973 | + let formatMap = v.condition.map((f) => { | |
974 | + return f.predicate.operation == 'EQUAL' | |
975 | + ? f.key.key + '等于' + f.predicate.value.defaultValue | |
976 | + : f.predicate.operation == 'STARTS_WITH' | |
977 | + ? f.key.key + '开始于' + f.predicate.value.defaultValue | |
978 | + : f.predicate.operation == 'ENDS_WITH' | |
979 | + ? f.key.key + '结束于' + f.predicate.value.defaultValue | |
980 | + : f.predicate.operation == 'NOT_CONTAINS' | |
981 | + ? f.key.key + '不包含' + f.predicate.value.defaultValue | |
982 | + : f.predicate.operation == 'NOT_EQUAL' | |
983 | + ? f.key.key + '不等于' + f.predicate.value.defaultValue | |
984 | + : f.predicate.operation == 'GREATER' | |
985 | + ? f.key.key + '大于' + f.predicate.value.defaultValue | |
986 | + : f.predicate.operation == 'LESS' | |
987 | + ? f.key.key + '小于' + f.predicate.value.defaultValue | |
988 | + : f.predicate.operation == 'GREATER_OR_EQUAL' | |
989 | + ? f.key.key + '大于或等于' + f.predicate.value.defaultValue | |
990 | + : f.key.key + '小于或等于' + f.predicate.value.defaultValue; | |
991 | + }); | |
992 | + return formatMap; | |
962 | 993 | }; |
963 | 994 | |
964 | 995 | //生成uuid |
... | ... | @@ -1073,6 +1104,11 @@ |
1073 | 1104 | }; |
1074 | 1105 | |
1075 | 1106 | return { |
1107 | + isAddRuleStatusFunc, | |
1108 | + isAddRuleStatus, | |
1109 | + formatAlarmFunc, | |
1110 | + createAlarmArray, | |
1111 | + formatClearRuleFunc, | |
1076 | 1112 | formatAddRuleFunc, |
1077 | 1113 | getFilterStepThreeClearDetailEditArr, |
1078 | 1114 | getIsShowAddRule, |
... | ... | @@ -1144,6 +1180,8 @@ |
1144 | 1180 | registerFormCreateAlarm, |
1145 | 1181 | addCreateRole, |
1146 | 1182 | deleteCondition, |
1183 | + setCreateRegisterFormChangeDetailFunc, | |
1184 | + detailDetailModelArray, | |
1147 | 1185 | }; |
1148 | 1186 | }, |
1149 | 1187 | }); | ... | ... |
... | ... | @@ -12,12 +12,12 @@ |
12 | 12 | </CollapseContainer> |
13 | 13 | </template> |
14 | 14 | <script lang="ts"> |
15 | - import { defineComponent, ref, watch } from 'vue'; | |
15 | + import { defineComponent, ref } from 'vue'; | |
16 | 16 | import { CollapseContainer } from '/@/components/Container/index'; |
17 | 17 | import { BasicForm, useForm } from '/@/components/Form/index'; |
18 | 18 | import { Input } from 'ant-design-vue'; |
19 | 19 | import { useConditionDrawerSchema } from '../config'; |
20 | - import { screenLinkPageByDeptIdGetDevice } from '/@/api/ruleengine/ruleengineApi'; | |
20 | + // import { screenLinkPageByDeptIdGetDevice } from '/@/api/ruleengine/ruleengineApi'; | |
21 | 21 | |
22 | 22 | export default defineComponent({ |
23 | 23 | components: { CollapseContainer, BasicForm, [Input.name]: Input }, |
... | ... | @@ -38,21 +38,31 @@ |
38 | 38 | const resetFieldsValueFunc = () => { |
39 | 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 | - }); | |
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) => { | |
57 | + setTimeout(() => { | |
48 | 58 | updateSchema({ |
49 | - field: 'deviceId', | |
59 | + field: 'entityId', | |
50 | 60 | componentProps: { |
51 | - options: options.items, | |
61 | + options: v, | |
52 | 62 | }, |
53 | 63 | }); |
54 | - } | |
55 | - ); | |
64 | + }, 10); | |
65 | + }; | |
56 | 66 | |
57 | 67 | //回显数据 |
58 | 68 | const setFieldsFormValueFun = () => { |
... | ... | @@ -67,7 +77,7 @@ |
67 | 77 | if (props.newConditionMapFather !== 1) { |
68 | 78 | setTimeout(() => { |
69 | 79 | updateSchema({ |
70 | - field: 'deviceId', | |
80 | + field: 'entityId', | |
71 | 81 | componentProps: { |
72 | 82 | options: props.newConditionMapFather, |
73 | 83 | }, |
... | ... | @@ -79,7 +89,7 @@ |
79 | 89 | //新增清空设备选择 |
80 | 90 | const clearSelectDevice = () => { |
81 | 91 | updateSchema({ |
82 | - field: 'deviceId', | |
92 | + field: 'entityId', | |
83 | 93 | componentProps: { |
84 | 94 | options: [], |
85 | 95 | }, |
... | ... | @@ -87,13 +97,14 @@ |
87 | 97 | }; |
88 | 98 | // const editSelectDevice = (v) => { |
89 | 99 | // updateSchema({ |
90 | - // field: 'deviceId', | |
100 | + // field: 'entityId', | |
91 | 101 | // componentProps: { |
92 | 102 | // options: v, |
93 | 103 | // }, |
94 | 104 | // }); |
95 | 105 | // }; |
96 | 106 | return { |
107 | + updateFieldDeviceId, | |
97 | 108 | resetFieldsValueFunc, |
98 | 109 | clearSelectDevice, |
99 | 110 | editSelectDevice, | ... | ... |
... | ... | @@ -12,12 +12,12 @@ |
12 | 12 | </CollapseContainer> |
13 | 13 | </template> |
14 | 14 | <script lang="ts"> |
15 | - import { defineComponent, ref, watch } from 'vue'; | |
15 | + import { defineComponent, ref } from 'vue'; | |
16 | 16 | import { CollapseContainer } from '/@/components/Container/index'; |
17 | 17 | import { BasicForm, useForm } from '/@/components/Form/index'; |
18 | 18 | import { Input } from 'ant-design-vue'; |
19 | 19 | import { useActionDrawerSchema } from '../config'; |
20 | - import { screenLinkPageByDeptIdGetDevice } from '/@/api/ruleengine/ruleengineApi'; | |
20 | + // import { screenLinkPageByDeptIdGetDevice } from '/@/api/ruleengine/ruleengineApi'; | |
21 | 21 | |
22 | 22 | export default defineComponent({ |
23 | 23 | components: { CollapseContainer, BasicForm, [Input.name]: Input }, |
... | ... | @@ -34,25 +34,38 @@ |
34 | 34 | const getFieldsValueFunc = () => { |
35 | 35 | fieldValue.value = getFieldsValue(); |
36 | 36 | return fieldValue.value; |
37 | + // return new Promise((resolve) => { | |
38 | + // resolve(fieldValue.value); | |
39 | + // }); | |
37 | 40 | }; |
38 | 41 | const resetFieldsValueFunc = () => { |
39 | 42 | resetFields(); |
40 | 43 | }; |
41 | - watch( | |
42 | - () => props.deviceInfo2, | |
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 | - }); | |
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) => { | |
60 | + setTimeout(() => { | |
48 | 61 | updateSchema({ |
49 | - field: 'deviceId', | |
62 | + field: 'entityId', | |
50 | 63 | componentProps: { |
51 | - options: options.items, | |
64 | + options: v, | |
52 | 65 | }, |
53 | 66 | }); |
54 | - } | |
55 | - ); | |
67 | + }, 10); | |
68 | + }; | |
56 | 69 | |
57 | 70 | //回显数据 |
58 | 71 | const setFieldsFormValueFun = () => { |
... | ... | @@ -67,7 +80,7 @@ |
67 | 80 | if (props.newActionMapFather !== 1) { |
68 | 81 | setTimeout(() => { |
69 | 82 | updateSchema({ |
70 | - field: 'deviceId', | |
83 | + field: 'entityId', | |
71 | 84 | componentProps: { |
72 | 85 | options: props.newActionMapFather, |
73 | 86 | }, |
... | ... | @@ -79,7 +92,7 @@ |
79 | 92 | //新增清空设备选择 |
80 | 93 | const clearSelectDevice = () => { |
81 | 94 | updateSchema({ |
82 | - field: 'deviceId', | |
95 | + field: 'entityId', | |
83 | 96 | componentProps: { |
84 | 97 | options: [], |
85 | 98 | }, |
... | ... | @@ -87,13 +100,14 @@ |
87 | 100 | }; |
88 | 101 | // const editSelectDevice = (v) => { |
89 | 102 | // updateSchema({ |
90 | - // field: 'deviceId', | |
103 | + // field: 'entityId', | |
91 | 104 | // componentProps: { |
92 | 105 | // options: v, |
93 | 106 | // }, |
94 | 107 | // }); |
95 | 108 | // }; |
96 | 109 | return { |
110 | + updateFieldDeviceId, | |
97 | 111 | clearSelectDevice, |
98 | 112 | editSelectDevice, |
99 | 113 | resetFieldsValueFunc, | ... | ... |
... | ... | @@ -14,12 +14,12 @@ |
14 | 14 | </div> |
15 | 15 | </template> |
16 | 16 | <script lang="ts"> |
17 | - import { defineComponent, ref, watch } from 'vue'; | |
17 | + import { defineComponent, ref } from 'vue'; | |
18 | 18 | import { CollapseContainer } from '/@/components/Container/index'; |
19 | 19 | import { BasicForm, useForm } from '/@/components/Form/index'; |
20 | 20 | import { Input } from 'ant-design-vue'; |
21 | 21 | import { useTriggerDrawerSchema } from '../config'; |
22 | - import { screenLinkPageByDeptIdGetDevice } from '/@/api/ruleengine/ruleengineApi'; | |
22 | + // import { screenLinkPageByDeptIdGetDevice } from '/@/api/ruleengine/ruleengineApi'; | |
23 | 23 | |
24 | 24 | export default defineComponent({ |
25 | 25 | components: { CollapseContainer, BasicForm, [Input.name]: Input }, |
... | ... | @@ -36,20 +36,20 @@ |
36 | 36 | fieldValue.value = getFieldsValue(); |
37 | 37 | return fieldValue.value; |
38 | 38 | }; |
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 | - ); | |
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 | 49 | const updateFieldDeviceId = (v) => { |
50 | 50 | setTimeout(() => { |
51 | 51 | updateSchema({ |
52 | - field: 'deviceId', | |
52 | + field: 'entityId', | |
53 | 53 | componentProps: { |
54 | 54 | options: v, |
55 | 55 | }, |
... | ... | @@ -57,9 +57,7 @@ |
57 | 57 | }, 10); |
58 | 58 | }; |
59 | 59 | const resetFieldsValueFunc = () => { |
60 | - setTimeout(() => { | |
61 | - resetFields(); | |
62 | - }, 100); | |
60 | + resetFields(); | |
63 | 61 | }; |
64 | 62 | |
65 | 63 | //回显数据 |
... | ... | @@ -75,7 +73,7 @@ |
75 | 73 | //新增清空设备选择 |
76 | 74 | const clearSelectDevice = () => { |
77 | 75 | updateSchema({ |
78 | - field: 'deviceId', | |
76 | + field: 'entityId', | |
79 | 77 | componentProps: { |
80 | 78 | options: [], |
81 | 79 | }, |
... | ... | @@ -85,7 +83,7 @@ |
85 | 83 | if (props.newFilterMapFather != 1) { |
86 | 84 | setTimeout(() => { |
87 | 85 | updateSchema({ |
88 | - field: 'deviceId', | |
86 | + field: 'entityId', | |
89 | 87 | componentProps: { |
90 | 88 | options: props.newFilterMapFather, |
91 | 89 | }, | ... | ... |
... | ... | @@ -167,10 +167,10 @@ export const formSchema: FormSchema[] = [ |
167 | 167 | }, |
168 | 168 | onChange: async (v) => { |
169 | 169 | if (v == undefined) { |
170 | - formModel.deviceId = undefined; | |
170 | + formModel.entityId = undefined; | |
171 | 171 | const { updateSchema } = formActionType; |
172 | 172 | updateSchema({ |
173 | - field: 'deviceId', | |
173 | + field: 'entityId', | |
174 | 174 | componentProps: { |
175 | 175 | options: undefined, |
176 | 176 | }, |
... | ... | @@ -250,7 +250,7 @@ export const useTriggerDrawerSchema: FormSchema[] = [ |
250 | 250 | colProps: { span: 12 }, |
251 | 251 | }, |
252 | 252 | { |
253 | - field: 'deviceId', | |
253 | + field: 'entityId', | |
254 | 254 | label: '', |
255 | 255 | component: 'Select', |
256 | 256 | componentProps: { |
... | ... | @@ -420,7 +420,7 @@ export const useConditionDrawerSchema: FormSchema[] = [ |
420 | 420 | colProps: { span: 12 }, |
421 | 421 | }, |
422 | 422 | { |
423 | - field: 'deviceId', | |
423 | + field: 'entityId', | |
424 | 424 | label: '', |
425 | 425 | component: 'Select', |
426 | 426 | componentProps: { |
... | ... | @@ -542,6 +542,7 @@ export const useActionDrawerSchema: FormSchema[] = [ |
542 | 542 | field: 'outTarget', |
543 | 543 | label: '', |
544 | 544 | component: 'Select', |
545 | + required: true, | |
545 | 546 | componentProps: { |
546 | 547 | placeholder: '请选择设备输出', |
547 | 548 | options: [ |
... | ... | @@ -553,7 +554,7 @@ export const useActionDrawerSchema: FormSchema[] = [ |
553 | 554 | colProps: { span: 12 }, |
554 | 555 | }, |
555 | 556 | { |
556 | - field: 'deviceId', | |
557 | + field: 'entityId', | |
557 | 558 | label: '', |
558 | 559 | component: 'Select', |
559 | 560 | componentProps: { | ... | ... |
... | ... | @@ -91,8 +91,8 @@ |
91 | 91 | }); |
92 | 92 | try { |
93 | 93 | setTimeout(() => { |
94 | - proxy.$refs.sceneLinkAgeDrawerRef.defaultAddTrigger(); | |
95 | - proxy.$refs.sceneLinkAgeDrawerRef.defaultAddCondition(); | |
94 | + // proxy.$refs.sceneLinkAgeDrawerRef.defaultAddTrigger(); | |
95 | + // proxy.$refs.sceneLinkAgeDrawerRef.defaultAddCondition(); | |
96 | 96 | proxy.$refs.sceneLinkAgeDrawerRef.defaultAddAction(); |
97 | 97 | }, 50); |
98 | 98 | } catch (e) { | ... | ... |
... | ... | @@ -183,21 +183,18 @@ |
183 | 183 | emits: ['success', 'register', 'registerForm'], |
184 | 184 | setup(_, { emit }) { |
185 | 185 | const { proxy } = getCurrentInstance(); |
186 | - const lastRefTriggerChildDataArray = ref<[]>([]); | |
187 | 186 | const lastEditRefTriggerChildDataArray = ref<[]>([]); |
188 | 187 | const lastEditRefConditionChildDataArray = ref<[]>([]); |
189 | 188 | const lastEditRefActionChildDataArray = ref<[]>([]); |
189 | + const lastRefTriggerChildDataArray = ref<[]>([]); | |
190 | 190 | const lastRefConditionChildDataArray = ref<[]>([]); |
191 | 191 | const lastRefActionChildDataArray = ref<[]>([]); |
192 | - const lastRefTriggerChildData: any = ref({}); | |
193 | - const lastRefConditionChildData: any = ref({}); | |
194 | - const lastRefActionChildData: any = ref({}); | |
195 | - const refTriggerChildData: any = ref({}); | |
196 | - const refConditionChildData: any = ref({}); | |
197 | - const refActionChildData: any = ref({}); | |
192 | + let refTriggerChildData: any = reactive({}); | |
193 | + let refConditionChildData: any = reactive({}); | |
194 | + let refActionChildData: any = reactive({}); | |
198 | 195 | const addTriggerData = reactive<IAddTrigger>({ |
199 | 196 | triggerType: '', |
200 | - deviceId: '', | |
197 | + entityId: '', | |
201 | 198 | touchWay: '', |
202 | 199 | attributeChoose: '', |
203 | 200 | compare: '', |
... | ... | @@ -205,7 +202,7 @@ |
205 | 202 | }); |
206 | 203 | const editTriggerData = reactive<IAddTrigger>({ |
207 | 204 | triggerType: '', |
208 | - deviceId: '请选择设备', | |
205 | + entityId: '请选择设备', | |
209 | 206 | touchWay: '请选择触发方式', |
210 | 207 | attributeChoose: '请选择属性', |
211 | 208 | compare: '', |
... | ... | @@ -213,14 +210,14 @@ |
213 | 210 | }); |
214 | 211 | const addConditionData = reactive<IAddCondition>({ |
215 | 212 | triggerType: '', |
216 | - deviceId: '', | |
213 | + entityId: '', | |
217 | 214 | createTime: '', |
218 | 215 | updateTime: '', |
219 | 216 | compare: '', |
220 | 217 | value: '', |
221 | 218 | }); |
222 | 219 | const editConditionData = reactive<IAddCondition>({ |
223 | - deviceId: '请选择设备', | |
220 | + entityId: '请选择设备', | |
224 | 221 | createTime: '', |
225 | 222 | updateTime: '', |
226 | 223 | triggerType: '', |
... | ... | @@ -229,13 +226,13 @@ |
229 | 226 | }); |
230 | 227 | const addActionData = reactive<IAddAction>({ |
231 | 228 | outTarget: '', |
232 | - deviceId: '', | |
229 | + entityId: '', | |
233 | 230 | command: '', |
234 | 231 | sceneLinkageId: '', |
235 | 232 | }); |
236 | 233 | const editActionData = reactive<IAddAction>({ |
237 | 234 | outTarget: '', |
238 | - deviceId: '请选择设备', | |
235 | + entityId: '请选择设备', | |
239 | 236 | command: '请输入执行命令', |
240 | 237 | sceneLinkageId: '', |
241 | 238 | }); |
... | ... | @@ -282,6 +279,7 @@ |
282 | 279 | let actionsObj = { |
283 | 280 | doActions: [], |
284 | 281 | }; |
282 | + let optionsItemArray = ref<[]>([]); | |
285 | 283 | |
286 | 284 | const [registerForm, { resetFields, setFieldsValue, validateFields }] = useForm({ |
287 | 285 | labelWidth: 120, |
... | ... | @@ -295,9 +293,19 @@ |
295 | 293 | isUpdate.value = !!data?.isUpdate; |
296 | 294 | if (!unref(isUpdate)) { |
297 | 295 | try { |
296 | + refTriggerChildData = {}; | |
297 | + refConditionChildData = {}; | |
298 | + refActionChildData = {}; | |
299 | + getAllFormData = {}; | |
298 | 300 | triggersObj = { |
299 | 301 | triggers: [], |
300 | 302 | }; |
303 | + conditionsObj = { | |
304 | + doConditions: [], | |
305 | + }; | |
306 | + actionsObj = { | |
307 | + doActions: [], | |
308 | + }; | |
301 | 309 | filterNewTriggerArr.length = 0; |
302 | 310 | filterNewConditionArr.length = 0; |
303 | 311 | lastRefTriggerChildDataArray.value.length = 0; |
... | ... | @@ -310,9 +318,21 @@ |
310 | 318 | addConditionPushData.value.length = 0; |
311 | 319 | addActionPushData.value.length = 0; |
312 | 320 | handleClose(); |
313 | - proxy.$refs.refTriggerChild.resetFieldsValueFunc(); | |
314 | - proxy.$refs.refConditionChild.resetFieldsValueFunc(); | |
315 | - proxy.$refs.refActionChild.resetFieldsValueFunc(); | |
321 | + optionsItemArray.value.length = 0; | |
322 | + try { | |
323 | + setTimeout(() => { | |
324 | + proxy.$refs.refTriggerChild.resetFieldsValueFunc(); | |
325 | + proxy.$refs.refTriggerChild.clearSelectDevice(); | |
326 | + proxy.$refs.refConditionChild.resetFieldsValueFunc(); | |
327 | + proxy.$refs.refConditionChild.clearSelectDevice(); | |
328 | + proxy.$refs.refActionChild.resetFieldsValueFunc(); | |
329 | + proxy.$refs.refActionChild.clearSelectDevice(); | |
330 | + clearActionsAllDevice(); | |
331 | + resetActionsAllArrayFunc(); | |
332 | + }, 200); | |
333 | + } catch (e) { | |
334 | + return e; | |
335 | + } | |
316 | 336 | } catch (e) { |
317 | 337 | return e; |
318 | 338 | } |
... | ... | @@ -342,7 +362,7 @@ |
342 | 362 | try { |
343 | 363 | data.record.triggers.forEach((f1) => { |
344 | 364 | options.items?.forEach((f2) => { |
345 | - if (f2.id == f1.deviceId) { | |
365 | + if (f2.id == f1.entityId) { | |
346 | 366 | newFilterMap.value.push({ |
347 | 367 | value: f2.id, |
348 | 368 | label: f2.name, |
... | ... | @@ -353,7 +373,7 @@ |
353 | 373 | |
354 | 374 | data.record.doConditions.forEach((f1) => { |
355 | 375 | options.items?.forEach((f2) => { |
356 | - if (f2.id == f1.deviceId) { | |
376 | + if (f2.id == f1.entityId) { | |
357 | 377 | newConditionFilterMap.value.push({ |
358 | 378 | value: f2.id, |
359 | 379 | label: f2.name, |
... | ... | @@ -363,7 +383,7 @@ |
363 | 383 | }); |
364 | 384 | data.record.doActions.forEach((f1) => { |
365 | 385 | options.items?.forEach((f2) => { |
366 | - if (f2.id == f1.deviceId) { | |
386 | + if (f2.id == f1.entityId) { | |
367 | 387 | newActionFilterMap.value.push({ |
368 | 388 | value: f2.id, |
369 | 389 | label: f2.name, |
... | ... | @@ -381,6 +401,7 @@ |
381 | 401 | lastRefTriggerChildDataArray.value = []; |
382 | 402 | lastRefConditionChildDataArray.value.length = 0; |
383 | 403 | lastRefActionChildDataArray.value.length = 0; |
404 | + lastRefActionChildDataArray.value = []; | |
384 | 405 | filterArrayTrigger.length = 0; |
385 | 406 | filterArrayCondition.value.length = 0; |
386 | 407 | filterArrayAction.value.length = 0; |
... | ... | @@ -409,16 +430,37 @@ |
409 | 430 | return e; |
410 | 431 | } |
411 | 432 | }; |
412 | - watch(getData, (newV) => { | |
413 | - getDeviceInfo.value = newV; | |
414 | - getDeviceInfo1.value = newV; | |
415 | - getDeviceInfo2.value = newV; | |
433 | + watch(getData, async (newV) => { | |
434 | + // getDeviceInfo.value = newV; | |
435 | + // getDeviceInfo1.value = newV; | |
436 | + // getDeviceInfo2.value = newV; | |
437 | + const options = await screenLinkPageByDeptIdGetDevice({ organizationId: newV }); | |
438 | + options.items.forEach((v) => { | |
439 | + return (v.value = v.id), (v.label = v.name); | |
440 | + }); | |
441 | + optionsItemArray.value = options.items; | |
442 | + updateDeviceIdFunc(optionsItemArray.value); | |
443 | + try { | |
444 | + proxy.$refs.refActionChild.updateFieldDeviceId(optionsItemArray.value); | |
445 | + } catch (e) { | |
446 | + return e; | |
447 | + } | |
416 | 448 | }); |
417 | 449 | |
450 | + const updateDeviceIdFunc = (v) => { | |
451 | + try { | |
452 | + proxy.$refs.refTriggerChild.updateFieldDeviceId(v); | |
453 | + proxy.$refs.refConditionChild.updateFieldDeviceId(v); | |
454 | + proxy.$refs.refActionChild.updateFieldDeviceId(v); | |
455 | + } catch (e) { | |
456 | + return e; | |
457 | + } | |
458 | + }; | |
459 | + | |
418 | 460 | //触发器方法 |
419 | 461 | const refTriggerChildDataFunc = () => { |
420 | 462 | try { |
421 | - refTriggerChildData.value = proxy.$refs.refTriggerChild.getFieldsValueFunc(); | |
463 | + refTriggerChildData = proxy.$refs.refTriggerChild.getFieldsValueFunc(); | |
422 | 464 | } catch (e) { |
423 | 465 | return e; |
424 | 466 | } |
... | ... | @@ -426,7 +468,7 @@ |
426 | 468 | //执行条件方法 |
427 | 469 | const refConditionChildDataFunc = () => { |
428 | 470 | try { |
429 | - refConditionChildData.value = proxy.$refs.refConditionChild.getFieldsValueFunc(); | |
471 | + refConditionChildData = proxy.$refs.refConditionChild.getFieldsValueFunc(); | |
430 | 472 | } catch (e) { |
431 | 473 | return e; |
432 | 474 | } |
... | ... | @@ -434,7 +476,7 @@ |
434 | 476 | //执行动作方法 |
435 | 477 | const refActionChildDataFunc = () => { |
436 | 478 | try { |
437 | - refActionChildData.value = proxy.$refs.refActionChild.getFieldsValueFunc(); | |
479 | + refActionChildData = proxy.$refs.refActionChild.getFieldsValueFunc(); | |
438 | 480 | } catch (e) { |
439 | 481 | return e; |
440 | 482 | } |
... | ... | @@ -447,9 +489,9 @@ |
447 | 489 | refTriggerChildDataFunc(); |
448 | 490 | refConditionChildDataFunc(); |
449 | 491 | refActionChildDataFunc(); |
450 | - lastRefTriggerChildDataArray.value.push(refTriggerChildData.value as never); | |
451 | - lastRefConditionChildDataArray.value.push(refConditionChildData.value as never); | |
452 | - lastRefActionChildDataArray.value.push(refActionChildData.value as never); | |
492 | + lastRefTriggerChildDataArray.value.push(refTriggerChildData as never); | |
493 | + lastRefConditionChildDataArray.value.push(refConditionChildData as never); | |
494 | + lastRefActionChildDataArray.value.push(refActionChildData as never); | |
453 | 495 | triggersObj = { |
454 | 496 | triggers: lastRefTriggerChildDataArray.value, |
455 | 497 | }; |
... | ... | @@ -459,15 +501,14 @@ |
459 | 501 | actionsObj = { |
460 | 502 | doActions: lastRefActionChildDataArray.value, |
461 | 503 | }; |
462 | - | |
463 | 504 | Object.assign(getAllFormData, triggersObj, conditionsObj, actionsObj); |
464 | 505 | } else { |
465 | 506 | refTriggerChildDataFunc(); |
466 | 507 | refConditionChildDataFunc(); |
467 | 508 | refActionChildDataFunc(); |
468 | - pushEditArray.push(refTriggerChildData.value as never); | |
469 | - pushEditConditionArray.push(refConditionChildData.value as never); | |
470 | - pushEditActionArray.push(refActionChildData.value as never); | |
509 | + pushEditArray.push(refTriggerChildData as never); | |
510 | + pushEditConditionArray.push(refConditionChildData as never); | |
511 | + pushEditActionArray.push(refActionChildData as never); | |
471 | 512 | pushEditArray.forEach((f) => { |
472 | 513 | editTriggerPushData.value.push(f as never); |
473 | 514 | }); |
... | ... | @@ -490,12 +531,12 @@ |
490 | 531 | ); |
491 | 532 | |
492 | 533 | const filterThreeArrayTrigger = editTriggerPushData.value.filter( |
493 | - (f) => f?.deviceId == '' | |
534 | + (f) => f?.entityId == '' | |
494 | 535 | ); |
495 | 536 | const filterThreeArrayCondition = editConditionPushData.value.filter( |
496 | - (f) => f?.deviceId == '' | |
537 | + (f) => f?.entityId == '' | |
497 | 538 | ); |
498 | - const filterThreeArrayAction = editActionPushData.value.filter((f) => f?.deviceId == ''); | |
539 | + const filterThreeArrayAction = editActionPushData.value.filter((f) => f?.entityId == ''); | |
499 | 540 | const filterFourArrayTrigger = filterThreeArrayTrigger.filter( |
500 | 541 | (f) => f?.triggerType !== '' |
501 | 542 | ); |
... | ... | @@ -530,10 +571,17 @@ |
530 | 571 | |
531 | 572 | const handleSubmit = async () => { |
532 | 573 | if (!unref(isUpdate)) { |
574 | + let kongObj = true; | |
533 | 575 | getDefaultValue(); |
534 | 576 | getValuesFormData = await validateFields(); |
535 | 577 | if (!getValuesFormData) return; |
536 | 578 | Object.assign(getAllFormData, getValuesFormData); |
579 | + lastRefActionChildDataArray.value.forEach((f) => { | |
580 | + if (Object.keys(f).length == 0) { | |
581 | + kongObj = false; | |
582 | + } | |
583 | + }); | |
584 | + if (!kongObj) return createMessage.error('请填写执行动作'); | |
537 | 585 | await screenLinkPageAddApi(getAllFormData); |
538 | 586 | createMessage.success('场景联动新增成功'); |
539 | 587 | closeDrawer(); |
... | ... | @@ -564,14 +612,21 @@ |
564 | 612 | if (!unref(isUpdate)) { |
565 | 613 | unref(addTriggerPushData).push(addTriggerData as never); |
566 | 614 | refTriggerChildDataFunc(); |
567 | - lastRefTriggerChildData.value = refTriggerChildData.value; | |
568 | - filterNewTriggerArr.push(lastRefTriggerChildData.value as never); | |
615 | + // refTriggerChildData; | |
616 | + filterNewTriggerArr.push(refTriggerChildData as never); | |
569 | 617 | (lastRefTriggerChildDataArray.value as never[]) = filterNewTriggerArr.filter( |
570 | 618 | (v) => Object.keys(v).length !== 0 |
571 | 619 | ); |
620 | + try { | |
621 | + setTimeout(() => { | |
622 | + proxy.$refs.refTriggerChild.updateFieldDeviceId(optionsItemArray.value); | |
623 | + }, 150); | |
624 | + } catch (e) { | |
625 | + return e; | |
626 | + } | |
572 | 627 | } else { |
573 | 628 | refTriggerChildDataFunc(); |
574 | - pushEditArray.push(refTriggerChildData.value as never); | |
629 | + pushEditArray.push(refTriggerChildData as never); | |
575 | 630 | unref(editTriggerPushData).push(addTriggerData as never); |
576 | 631 | } |
577 | 632 | }; |
... | ... | @@ -579,7 +634,7 @@ |
579 | 634 | if (!unref(isUpdate)) { |
580 | 635 | try { |
581 | 636 | unref(addTriggerPushData).splice(0, 1); |
582 | - lastRefTriggerChildDataArray.value.pop(); | |
637 | + lastRefTriggerChildDataArray.value.splice(0, 1); | |
583 | 638 | } catch (e) { |
584 | 639 | return e; |
585 | 640 | } |
... | ... | @@ -604,14 +659,20 @@ |
604 | 659 | if (!unref(isUpdate)) { |
605 | 660 | unref(addConditionPushData).push(addConditionData as never); |
606 | 661 | refConditionChildDataFunc(); |
607 | - lastRefConditionChildData.value = refConditionChildData.value; | |
608 | - filterNewConditionArr.push(lastRefConditionChildData.value as never); | |
662 | + filterNewConditionArr.push(refConditionChildData as never); | |
609 | 663 | (lastRefConditionChildDataArray.value as never[]) = filterNewConditionArr.filter( |
610 | 664 | (v) => Object.keys(v).length !== 0 |
611 | 665 | ); |
666 | + try { | |
667 | + setTimeout(() => { | |
668 | + proxy.$refs.refConditionChild.updateFieldDeviceId(optionsItemArray.value); | |
669 | + }, 150); | |
670 | + } catch (e) { | |
671 | + return e; | |
672 | + } | |
612 | 673 | } else { |
613 | 674 | refConditionChildDataFunc(); |
614 | - pushEditConditionArray.push(refConditionChildData.value as never); | |
675 | + pushEditConditionArray.push(refConditionChildData as never); | |
615 | 676 | unref(editConditionPushData).push(addConditionData as never); |
616 | 677 | } |
617 | 678 | }; |
... | ... | @@ -644,14 +705,20 @@ |
644 | 705 | if (!unref(isUpdate)) { |
645 | 706 | unref(addActionPushData).push(addActionData as never); |
646 | 707 | refActionChildDataFunc(); |
647 | - lastRefActionChildData.value = refActionChildData.value; | |
648 | - filterNewActionArr.push(lastRefActionChildData.value as never); | |
708 | + filterNewActionArr.push(refActionChildData as never); | |
649 | 709 | (lastRefActionChildDataArray.value as never[]) = filterNewActionArr.filter( |
650 | 710 | (v) => Object.keys(v).length !== 0 |
651 | 711 | ); |
712 | + try { | |
713 | + setTimeout(() => { | |
714 | + proxy.$refs.refActionChild.updateFieldDeviceId(optionsItemArray.value); | |
715 | + }, 150); | |
716 | + } catch (e) { | |
717 | + return e; | |
718 | + } | |
652 | 719 | } else { |
653 | 720 | refActionChildDataFunc(); |
654 | - pushEditActionArray.push(refActionChildData.value as never); | |
721 | + pushEditActionArray.push(refActionChildData as never); | |
655 | 722 | unref(editActionPushData).push(addActionData as never); |
656 | 723 | } |
657 | 724 | }; |
... | ... | @@ -674,6 +741,7 @@ |
674 | 741 | }; |
675 | 742 | |
676 | 743 | return { |
744 | + updateDeviceIdFunc, | |
677 | 745 | handleClose, |
678 | 746 | defaultAddTrigger, |
679 | 747 | defaultAddCondition, | ... | ... |