Quellcode durchsuchen

[Mod 0000] 修改三道沟均压联动的交互逻辑

houzekong vor 1 Tag
Ursprung
Commit
3d8bf56a9b

+ 88 - 30
src/views/vent/monitorManager/balancePressMonitor/components/balancePressHomeBD.vue

@@ -89,7 +89,7 @@
         :visible="showModules"
       />
     </div>
-    <PasswordModal :modal-is-show="modalVisible" modal-title="提交" @handle-ok="handleResolve" @handle-cancel="handleReject" />
+    <PasswordModal z-index="2000" :modal-is-show="modalVisible" modal-title="提交" @handle-ok="handleResolve" @handle-cancel="handleReject" />
     <UpdatePassword @register="updatePwdRegister" @submit="handleChangePassword" />
     <!-- <BasicModal title="风门状态监测" :mask="false" :bodyStyle="{ height: '50px' }" style="top: 20px" :show-ok-btn="false" @register="warnRegister2">
       {{ warnModalText2 }}
@@ -283,21 +283,32 @@
   }
 
   let resolver: any = null;
+  let rejecter: any = null;
   function handleResolve(password) {
-    if (resolver) resolver(password);
+    if (resolver) {
+      resolver(password);
+    } else {
+      modalVisible.value = false;
+    }
     resolver = null;
+    rejecter = null;
   }
   function handleReject() {
-    modalVisible.value = false;
+    if (rejecter) {
+      rejecter();
+    } else {
+      modalVisible.value = false;
+    }
     resolver = null;
+    rejecter = null;
   }
 
   // const [warnRegister1, warnModal1] = useModal();
   // const [warnRegister2, warnModal2] = useModal();
   // const [warnRegister3, warnModal3] = useModal();
-  const warnModal1 = ref();
-  const warnModal2 = ref();
-  const warnModal3 = ref();
+  let warnModal1: { destroy: () => void } | null = null;
+  let warnModal2: { destroy: () => void } | null = null;
+  let warnModal3: { destroy: () => void } | null = null;
   // const warnModalText1 = ref('');
   // const warnModalText2 = ref('');
   // const warnModalText3 = ref('');
@@ -318,21 +329,45 @@
       const datestr = dayjs(date).format('YYYY-MM-DD HH:mm:ss');
       switch (type) {
         case 'o2':
-          if (warnModal1.value) break;
-          warnModal1.value = Modal.confirm({
+          // 如果已经存在报警模态框,则不需要处理
+          if (warnModal1) break;
+          warnModal1 = Modal.confirm({
             title: data.msgTitle,
             content: h('div', { style: { color: '#fff' } }, [h('p', datestr), h('p', info)]),
             centered: true,
             okText: '下发调节指令',
             mask: true,
             class: 'balancePress',
-            async onOk() {
-              await autoControl(avgPressureLogId);
-              warnModal1.value = null;
+            onOk() {
+              // 点击确定按钮后,执行调节指令。调节指令需要确认密码,所以需要先弹出密码框
+              return new Promise((resolve, reject) => {
+                modalVisible.value = true;
+                // 弹出密码框后,输入密码并验证成功则关闭密码弹窗和报警弹窗,失败则关闭密码弹窗但不关闭报警弹窗
+                resolver = (password) => {
+                  autoControl({ password, id: avePressSetting.value.id }, { avgPressLogId: avgPressureLogId })
+                    .then(() => {
+                      modalVisible.value = false;
+                      resolve(true);
+                      warnModal1?.destroy();
+                      warnModal1 = null;
+                    })
+                    .catch(() => {
+                      modalVisible.value = false;
+                      reject();
+                    });
+                };
+                // 弹出密码框取消操作则关闭密码弹窗但不关闭报警弹窗
+                rejecter = () => {
+                  modalVisible.value = false;
+                  reject();
+                };
+              });
             },
-            async onCancel() {
-              await cancelControl(avgPressureLogId);
-              warnModal1.value = null;
+            onCancel() {
+              return cancelControl({}, { avgPressLogId: avgPressureLogId }).finally(() => {
+                warnModal1?.destroy();
+                warnModal1 = null;
+              });
             },
           });
           // warnModalText1.value = info;
@@ -342,49 +377,72 @@
         case 'pressure':
           // warnModalText1.value = info;
           // warnModal1.openModal();
-          if (warnModal1.value) break;
-          warnModal1.value = Modal.confirm({
+          if (warnModal1) break;
+          warnModal1 = Modal.confirm({
             title: data.msgTitle,
             content: h('div', { style: { color: '#fff' } }, [h('p', datestr), h('p', info)]),
             centered: true,
             okText: '下发调节指令',
             mask: true,
             class: 'balancePress',
-            async onOk() {
-              await autoControl(avgPressureLogId);
-              warnModal1.value = null;
+            onOk() {
+              // 点击确定按钮后,执行调节指令。调节指令需要确认密码,所以需要先弹出密码框
+              return new Promise((resolve, reject) => {
+                modalVisible.value = true;
+                // 弹出密码框后,输入密码并验证成功则关闭密码弹窗和报警弹窗,失败则关闭密码弹窗但不关闭报警弹窗
+                resolver = (password) => {
+                  autoControl({ password, id: avePressSetting.value.id }, { avgPressLogId: avgPressureLogId })
+                    .then(() => {
+                      modalVisible.value = false;
+                      resolve(true);
+                      warnModal1?.destroy();
+                      warnModal1 = null;
+                    })
+                    .catch(() => {
+                      modalVisible.value = false;
+                      reject();
+                    });
+                };
+                // 弹出密码框取消操作则关闭密码弹窗但不关闭报警弹窗
+                rejecter = () => {
+                  modalVisible.value = false;
+                  reject();
+                };
+              });
             },
-            async onCancel() {
-              await cancelControl(avgPressureLogId);
-              warnModal1.value = null;
+            onCancel() {
+              return cancelControl({}, { avgPressLogId: avgPressureLogId }).finally(() => {
+                warnModal1?.destroy();
+                warnModal1 = null;
+              });
             },
           });
 
           break;
         case 'gate':
-          if (warnModal2.value) break;
-          warnModal2.value = Modal.warn({
+          if (warnModal2) break;
+          warnModal2 = Modal.warning({
             title: data.msgTitle,
             content: info,
-            showOkBtn: false,
             mask: true,
             class: 'balancePress',
             onOk: () => {
-              warnModal2.value = null;
+              warnModal2?.destroy();
+              warnModal2 = null;
             },
           });
           break;
         case 'fansys':
-          if (warnModal3.value) break;
-          warnModal3.value = Modal.warn({
+          if (warnModal3) break;
+          warnModal3 = Modal.warning({
             title: data.msgTitle,
             content: info,
-            showOkBtn: false,
             mask: true,
             class: 'balancePress',
             style: 'top: 700px',
             onOk: () => {
-              warnModal3.value = null;
+              warnModal3?.destroy();
+              warnModal3 = null;
             },
           });
 

+ 22 - 7
src/views/vent/monitorManager/balancePressMonitor/hooks/useControl.ts

@@ -106,23 +106,38 @@ export function usePressControl() {
       });
   }
 
-  function autoControl(avgPressLogId) {
-    return controlWindow({ avgPressId: avePressSetting.value.id, avgPressLogId })
+  function autoControl({ password, id }, { avgPressLogId }) {
+    return validPassword({
+      id,
+      password,
+    })
       .then(() => {
-        message.success('预警已处理');
+        return controlWindow({ avgPressId: avePressSetting.value.id, avgPressLogId })
+          .then(() => {
+            message.success('预警已处理');
+          })
+          .catch((e) => {
+            message.error('下发失败');
+            throw e;
+          });
       })
-      .catch(() => {
-        message.error('下发失败');
+      .catch((e) => {
+        message.error(e);
+        throw e;
+      })
+      .finally(() => {
+        getAvePress();
       });
   }
 
-  function cancelControl(avgPressLogId) {
+  function cancelControl(___, { avgPressLogId }) {
     return cancelcontrolWindow({ avgPressId: avePressSetting.value.id, avgPressLogId })
       .then(() => {
         message.success('已取消');
       })
-      .catch(() => {
+      .catch((e) => {
         message.error('下发失败');
+        throw e;
       });
   }