From 9a61e46d96536f3299e57f7259ae1c9972256ec6 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期二, 30 九月 2025 09:42:09 +0800
Subject: [PATCH] 1. 隐藏未完成的账户匹配页面 2. 根据第三方新的接口文档修改接口url地址
---
src/composables/formConfirm.js | 78 ++++++++++++++++++++++++--------------
1 files changed, 49 insertions(+), 29 deletions(-)
diff --git a/src/composables/formConfirm.js b/src/composables/formConfirm.js
index 786cc6a..e1eafd1 100644
--- a/src/composables/formConfirm.js
+++ b/src/composables/formConfirm.js
@@ -1,14 +1,18 @@
-// 琛ㄥ崟鐨勭‘璁ゅ拰鍙栨秷
-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';
+// 琛ㄥ崟鐨勭‘璁ゅ拰鍙栨秷
export function useFormConfirm({
+ defaultForm = undefined,
submit = {
- do: () => {},
+ do: () => {}
},
cancel = {
- do: () => {},
+ do: () => {}
+ },
+ reset = {
+ do: () => {}
},
}) {
if (!submit.title) submit.title = '鎻愪氦';
@@ -16,8 +20,13 @@
if (!cancel.title) cancel.title = '鍙栨秷';
if (!cancel.msg) cancel.msg = '鏄惁鏀惧純宸茬紪杈戠殑鍐呭锛�';
+ // const formProps = defineProps({
+ // // 鏄惁鍦ㄦ彁浜ゆ垚鍔熷悗娓呯┖琛ㄥ崟
+ // clearAftSubmit: Boolean
+ // });
+
//琛ㄥ崟鍐呭
- const formObj = ref({});
+ const formObj = ref(defaultForm ? defaultForm : {});
let formObjClone = useCloned(formObj, { manual: true });
//琛ㄥ崟缁勪欢寮曠敤
const formRef = ref(null);
@@ -48,7 +57,7 @@
formObj,
(nv, ov) => {
if (!isReset && nv != ov) {
- formObjClone = useCloned(formObj, { manual: true });
+ formObjClone = useCloned(nv, { manual: true });
}
if (!isReset && nv === ov) {
edit.value = true;
@@ -59,41 +68,47 @@
);
// 閲嶇疆琛ㄥ崟
- const reset = function () {
+ 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();
+ }
}
});
};
@@ -106,9 +121,9 @@
confirmMsg: cancel.msg,
confirmTitle: cancel.title,
onConfirm: () => {
- clear();
+ // clear();
return cancel.do();
- },
+ }
});
} else {
cancel.do();
@@ -116,21 +131,26 @@
};
// 閲嶇疆琛ㄥ崟
- const onReset = function () {
+ const onReset = function (tips) {
if (edit.value) {
- // 寮瑰嚭纭妗�
- useMessageBox({
- confirmMsg: '鏄惁閲嶇疆琛ㄥ崟鍐呭锛�',
- confirmTitle: '閲嶇疆琛ㄥ崟',
- onConfirm: () => {
- reset();
- return cancel.do();
- },
- });
+ if (tips) {
+ // 寮瑰嚭纭妗�
+ useMessageBox({
+ confirmMsg: '鏄惁閲嶇疆琛ㄥ崟鍐呭锛�',
+ confirmTitle: '閲嶇疆琛ㄥ崟',
+ onConfirm: () => {
+ _reset();
+ return reset.do();
+ }
+ });
+ } else {
+ _reset();
+ reset.do();
+ }
} else {
- cancel.do();
+ reset.do();
}
};
- return { formObj, formRef, edit, onSubmit, onCancel, onReset };
+ return { formObj, formRef, edit, onSubmit, onCancel, onReset, clear };
}
--
Gitblit v1.9.3