From 22ce3a4c8453b54c2bfe6d582b734195f899f195 Mon Sep 17 00:00:00 2001
From: hcong <1050828145@qq.com>
Date: 星期二, 10 十二月 2024 14:59:50 +0800
Subject: [PATCH] 1. 新增socket生命周期管理、心跳机制、重连机制 2. 新增socket消息校验、解析、生成 3. 新增socket消息类型枚举类src\enum\socketMessage 3. 新增消息管理类src\socket\MessageManager 4. 新增观察者模式消息的发布订阅机制src\socket\eventBus 5. 修改后台任务页面注册后台任务状态消息并修改状态的逻辑

---
 src/composables/formConfirm.js |   43 +++++++++++++++++++++++++++----------------
 1 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/src/composables/formConfirm.js b/src/composables/formConfirm.js
index 3b4d80c..e1eafd1 100644
--- a/src/composables/formConfirm.js
+++ b/src/composables/formConfirm.js
@@ -1,4 +1,4 @@
-import { onActivated, onDeactivated, ref, watch } from 'vue';
+import { defineProps, onActivated, onDeactivated, reactive, ref, watch } from 'vue';
 import { useCloned } from '@vueuse/core';
 import { useMessageBoxTip, useMessageBox } from './messageBox';
 
@@ -6,19 +6,24 @@
 export function useFormConfirm({
   defaultForm = undefined,
   submit = {
-    do: () => {},
+    do: () => {}
   },
   cancel = {
-    do: () => {},
+    do: () => {}
   },
   reset = {
-    do: () => {},
+    do: () => {}
   },
 }) {
   if (!submit.title) submit.title = '鎻愪氦';
   if (!submit.msg) submit.msg = '纭鏄惁鎻愪氦锛�';
   if (!cancel.title) cancel.title = '鍙栨秷';
   if (!cancel.msg) cancel.msg = '鏄惁鏀惧純宸茬紪杈戠殑鍐呭锛�';
+
+  // const formProps = defineProps({
+  //   // 鏄惁鍦ㄦ彁浜ゆ垚鍔熷悗娓呯┖琛ㄥ崟
+  //   clearAftSubmit: Boolean
+  // });
 
   //琛ㄥ崟鍐呭
   const formObj = ref(defaultForm ? defaultForm : {});
@@ -64,40 +69,46 @@
 
   // 閲嶇疆琛ㄥ崟
   const _reset = function () {
+    formRef.value.clearValidate();
     edit.value = false;
     isReset = true;
     formObj.value = useCloned(formObjClone.cloned, {
-      manual: true,
+      manual: true
     }).cloned.value;
-    formRef.value.clearValidate();
   };
 
   // 娓呯┖琛ㄥ崟
   const clear = function () {
-    edit.value = false;
     isReset = true;
     formRef.value.resetFields();
+    edit.value = false;
   };
 
   // 鎻愪氦鎴愬姛鍚�
   const submited = function () {
+    // if (formProps.clearAftSubmit) clear();
     edit.value = false;
     formObjClone = useCloned(formObj, { manual: true });
   };
 
   // 鎻愪氦琛ㄥ崟
-  const onSubmit = function () {
-    formRef.value.validate((valid) => {
+  const onSubmit = function (messageBox = true) {
+    formRef.value.validate(async (valid) => {
       if (valid) {
+        if (messageBox) {
         useMessageBoxTip({
           confirmMsg: submit.msg,
           confirmTitle: submit.title,
           onConfirm: async () => {
-            await submit.do();
+            const res = await submit.do();
             submited();
-            return;
-          },
+            return res;
+          }
         });
+        } else {
+          await submit.do();
+          submited();
+        }
       }
     });
   };
@@ -110,9 +121,9 @@
         confirmMsg: cancel.msg,
         confirmTitle: cancel.title,
         onConfirm: () => {
-          clear();
+          // clear();
           return cancel.do();
-        },
+        }
       });
     } else {
       cancel.do();
@@ -130,7 +141,7 @@
           onConfirm: () => {
             _reset();
             return reset.do();
-          },
+          }
         });
       } else {
         _reset();
@@ -141,5 +152,5 @@
     }
   };
 
-  return { formObj, formRef, edit, onSubmit, onCancel, onReset };
+  return { formObj, formRef, edit, onSubmit, onCancel, onReset, clear };
 }

--
Gitblit v1.9.3