From a795fd4c7e12eb222ca92f37164107fc855c3ffb Mon Sep 17 00:00:00 2001
From: hongxilin <17663930442@163.com>
Date: Mon, 6 Jan 2025 10:22:54 +0800
Subject: [PATCH] =?UTF-8?q?=E6=89=B9=E9=87=8F=E5=85=85=E5=80=BC=E8=BE=93?=
=?UTF-8?q?=E5=85=A5=E7=B2=BE=E7=BD=91=E5=8F=B7=E7=9A=84=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
vue/gold-system/src/router/index.js | 2 +-
vue/gold-system/src/views/login.vue | 2 +-
vue/gold-system/src/views/recharge/addRecharge.vue | 92 +++++++----
vue/gold-system/src/views/z.vue | 181 ++++++++++++---------
4 files changed, 160 insertions(+), 117 deletions(-)
diff --git a/vue/gold-system/src/router/index.js b/vue/gold-system/src/router/index.js
index e951857..0c8fc72 100644
--- a/vue/gold-system/src/router/index.js
+++ b/vue/gold-system/src/router/index.js
@@ -4,7 +4,7 @@ const router=createRouter({
history:createWebHashHistory(),
routes:[
{path:'/login', name:"login", component:()=>import("../views/login.vue")},
- {path:'/',redirect:"/workspace"},
+ {path:'/',redirect:"/login"},
{path:'/test',component:()=>import("../views/z.vue")},
{
meta:{requireAuth:true},
diff --git a/vue/gold-system/src/views/login.vue b/vue/gold-system/src/views/login.vue
index bc409fd..73cf936 100644
--- a/vue/gold-system/src/views/login.vue
+++ b/vue/gold-system/src/views/login.vue
@@ -21,7 +21,7 @@ const login = async function () {
);
if (result.data.code == 200) {
localStorage.setItem("token", result.data.msg);
- router.push("/");
+ router.push("/workspace");
ElMessage.success("登录成功");
console.log("请求成功", result);
} else {
diff --git a/vue/gold-system/src/views/recharge/addRecharge.vue b/vue/gold-system/src/views/recharge/addRecharge.vue
index eefe256..e45a225 100644
--- a/vue/gold-system/src/views/recharge/addRecharge.vue
+++ b/vue/gold-system/src/views/recharge/addRecharge.vue
@@ -373,48 +373,68 @@ const addLine = function () {
};
const loading = ref(false);
// 添加多行
-// const addLines = async function () {
-// try {
-// for (let j = 0; j < addLineObj.value; j++) {
-// batchData.value.unshift({
-// line: ++i.value,
-// showInput: true,
-// });
-// }
-// ElMessage.success("添加成功");
-// } catch (error) {
-// console.log("添加失败", error);
-// ElMessage.error("添加失败");
-// }
-// }
-
-// 添加多行点击按钮
const addLines = async function () {
try {
- // loading.value = true; // 操作开始前,将loading设为true,显示加载动画
- // console.log(loading.value, "loading.value");
+ loading.value = true; // 操作开始前,将loading设为true,显示加载动画
+ console.log(loading.value, "loading.value")
- const newItems = Array.from({ length: addLineObj.value }, (_, index) => reactive({
- line: ++i.value,
- showInput: true,
- isInputInvalid: false,
- inputErrorMessage: '',
- freeGold: "0",
- rechargeGold: "0",
- paidGold: "0",
- }));
- batchData.value = [...newItems, ...batchData.value];
+ await new Promise(resolve => setTimeout(resolve, 100)); // 人为创建一个小延迟
+ for (let j = 0; j < addLineObj.value; j++) {
+ batchData.value.unshift({
+ line: ++i.value,
+ showInput: true,
+ isInputInvalid: false,
+ inputErrorMessage: '',
+ freeGold: "0",
+ rechargeGold: "0",
+ paidGold: "0",
+ });
+ }
ElMessage.success("添加成功");
- // loading.value = false; // 将loading设为false,关闭加载动画
+ console.log(batchData.value, "batchData.value");
} catch (error) {
console.log("添加失败", error);
ElMessage.error("添加失败");
- // 如果出现异常,也要确保关闭加载动画
- // loading.value = false;
+ } finally {
+ loading.value = false;
+ console.log(loading.value, "loading.value")
}
-};
+}
+// 添加多行点击按钮
+// const addLines = async function () {
+// try {
+
+// loading.value = true; // 操作开始前,将loading设为true,显示加载动画
+// console.log(loading.value, "loading.value")
+
+// await new Promise(resolve => setTimeout(resolve, 100)); // 人为创建一个小延迟
+
+// const newItems = Array.from({ length: addLineObj.value }, (_, index) => reactive({
+// line: ++i.value,
+// showInput: true,
+// isInputInvalid: false,
+// inputErrorMessage: '',
+// freeGold: "0",
+// rechargeGold: "0",
+// paidGold: "0",
+// }));
+// batchData.value = [...newItems, ...batchData.value];
+// ElMessage.success("添加成功");
+// console.log(batchData.value, "batchData.value");
+
+// loading.value = false;
+// console.log(loading.value, "loading.value")
+// } catch (error) {
+// console.log("添加失败", error);
+// ElMessage.error("添加失败");
+// // 如果出现异常,也要确保关闭加载动画
+// loading.value = false;
+// }
+// };
+// 使用 _.throttle 并设置 trailing 为 false 实现严格节流,只执行一次
+const throttledAddLines = _.throttle(addLines, 500, { trailing: false });
// 导入excel按钮的ref
const uploadRefMap = ref({});
// 获取excel数据
@@ -967,7 +987,7 @@ onMounted(async function () {
添加