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/audit/rechargeAudit.vue b/vue/gold-system/src/views/audit/rechargeAudit.vue index 5017093..cfb52d1 100644 --- a/vue/gold-system/src/views/audit/rechargeAudit.vue +++ b/vue/gold-system/src/views/audit/rechargeAudit.vue @@ -573,7 +573,7 @@ onMounted(async function () { label="充值方式" width="100px" /> - + diff --git a/vue/gold-system/src/views/consume/addConsume.vue b/vue/gold-system/src/views/consume/addConsume.vue index a74c252..0581439 100644 --- a/vue/gold-system/src/views/consume/addConsume.vue +++ b/vue/gold-system/src/views/consume/addConsume.vue @@ -241,7 +241,7 @@ function calculateCoins() { addConsume.value.freeCoin = Math.min(remainingGold, todayFree); remainingGold -= addConsume.value.freeCoin; - addConsume.value.rechargeCoin = remainingGold; // 剩余的都算作充值金币 + addConsume.value.rechargeCoin = remainingGold; // 剩余的都算作永久金币 // 恢复allGold的原始值 addConsume.value.allGold = originalAllGold; @@ -302,7 +302,7 @@ function calculateCoins() { /> - + (充值金币:{{ user.buyJb }};免费金币:{{ + >(永久金币:{{ user.buyJb }};免费金币:{{ user.free6 + user.free12 }};任务金币:{{ user.coreJb }}) diff --git a/vue/gold-system/src/views/consume/allConsume.vue b/vue/gold-system/src/views/consume/allConsume.vue index 040b0c5..01431ba 100644 --- a/vue/gold-system/src/views/consume/allConsume.vue +++ b/vue/gold-system/src/views/consume/allConsume.vue @@ -383,7 +383,7 @@ getGoods(); {{ scope.row.freeCoin * -1 }} - {{ scope.row.rechargeCoin * -1 }} 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 74ca9cf..9572c52 100644 --- a/vue/gold-system/src/views/recharge/addRecharge.vue +++ b/vue/gold-system/src/views/recharge/addRecharge.vue @@ -7,6 +7,9 @@ import { ElMessageBox } from "element-plus"; import API from "../../api/index.js"; import moment from "moment"; import { range, re } from "mathjs"; +import * as xlsx from 'xlsx'; +import _, { before } from 'lodash'; +import { th } from "element-plus/es/locales.mjs"; import * as xlsx from "xlsx"; import _ from "lodash"; @@ -103,7 +106,7 @@ const Ref = ref(null); const checkFreeGoldRadio = function (rule, value, callback) { if (value == "0" || value == null || value == "") { - callback(new Error("请输入充值金币")); + callback(new Error("请输入永久金币")); } else if (value < 0 || isNaN(value)) { callback(new Error("请输入正确的格式")); } else { @@ -292,6 +295,7 @@ const deleteRecharge = function () { // 批量充值 // jwcode列表 const jwcodeList = ref([]); +let jwcodeSet; // 获取jwcode列表 const getJwcodeList = async function () { try { @@ -305,16 +309,34 @@ const getJwcodeList = async function () { console.log("请求成功", result); // 存储表格数据 jwcodeList.value = result.data; - jwcodeList.value = jwcodeList.value.map((item) => ({ - value: item, - label: item, - })); console.log("精网号", jwcodeList.value); + // 将数组转换为set + jwcodeSet = new Set(jwcodeList.value); + console.log("精网号set", jwcodeSet); } catch (error) { console.log("请求失败", error); // 在这里可以处理错误逻辑,比如显示错误提示等 } }; + +// 校验精网号 +// 精网号错误对象 +const errorCount = ref(0); +// 校验规则 +const validateInput = function (row, index) { + console.log(jwcodeSet.has(row.jwcode), "has"); + if (!jwcodeSet.has(row.jwcode) && row.jwcode != '' && row.jwcode != null) { + row.isInputInvalid = true; + row.inputErrorMessage = '精网号不存在'; + errorCount.value++; + return; + } else { + row.isInputInvalid = false; + row.inputErrorMessage = ''; + errorCount.value--; + } +} + // 批量充值弹窗 const batchRechargeVisible = ref(false); const jwcodeSelectRef = ref(null); @@ -327,6 +349,11 @@ const batchData = ref([ { line: 1, showInput: true, + isInputInvalid: false, + inputErrorMessage: '', + freeGold: "0", + rechargeGold: "0", + paidGold: "0", }, ]); @@ -343,52 +370,6 @@ const batchInit = function () { openBatchRechargeVisible(); }; -// 提取添加滚动监听的逻辑到单独函数 -const addScrollListener = () => { - const SELECTWRAP_DOM = document.querySelector( - ".el-select-dropdown .el-select-dropdown__wrap" - ); - if (SELECTWRAP_DOM) { - SELECTWRAP_DOM.addEventListener("scroll", function () { - const condition = this.scrollHeight - this.scrollTop <= this.clientHeight; - if (condition) binding.value(); - }); - } -}; -// 局部注册指令 -const vJwcodeLoadmore = { - mounted(el, binding) { - nextTick(() => { - console.log("el===", el, "binding===", binding); - const SELECTWRAP_DOM = el.querySelector( - ".el-select-dropdown .el-select-dropdown__wrap" - ); - console.log("SELECTWRAP_DOM===", SELECTWRAP_DOM); - if (SELECTWRAP_DOM) { - SELECTWRAP_DOM.addEventListener("scroll", function () { - /** - * scrollHeight 获取元素内容高度(只读) - * scrollTop 获取或者设置元素的偏移值, - * 常用于:计算滚动条的位置, 当一个元素的容器没有产生垂直方向的滚动条, 那它的scrollTop的值默认为0. - * clientHeight 读取元素的可见高度(只读) - * 如果元素滚动到底, 下面等式返回true, 没有则返回false: - * ele.scrollHeight - ele.scrollTop === ele.clientHeight; - */ - const condition = - this.scrollHeight - this.scrollTop <= this.clientHeight; - if (condition) binding.value(); - }); - } - }); - }, -}; -// 下拉框打开时调用添加滚动监听函数 -// const jwcodeSelectScrollerListener = () => { -// console.log(jwcodeSelectRef.value, 'jwcodeSelectRef.value') -// if (jwcodeSelectRef.value) { -// directives.loadmore(jwcodeSelectRef.value, loadMore(rangeNumber.value)); -// } -// }; // 添加行数对象 const addLineObj = ref(0); //添加一行 @@ -396,33 +377,38 @@ const addLine = function () { batchData.value.unshift({ line: ++i.value, showInput: true, + isInputInvalid: false, + inputErrorMessage: '', + freeGold: "0", + rechargeGold: "0", + paidGold: "0", }); }; const loading = ref(true); // 添加多行 -// 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 () { loading.value = true; try { + loading.value = true; // 操作开始前,将loading设为true,显示加载动画 + console.log(loading.value, "loading.value") + + await new Promise(resolve => setTimeout(resolve, 100)); // 人为创建一个小延迟 + // 操作开始前,将loading设为true,显示加载动画 await nextTick(); // 等待视图更新,确保加载动画能及时显示出来 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", + }); + batchData.value.unshift({ + line: ++i.value, + showInput: true, }); } @@ -430,13 +416,49 @@ const addLines = async function () { await nextTick(); // 再次等待视图更新,确保数据添加操作引起的视图变化已完成 loading.value = false; // 将loading设为false,关闭加载动画 ElMessage.success("添加成功"); + console.log(batchData.value, "batchData.value"); } catch (error) { console.log("添加失败", error); ElMessage.error("添加失败"); - // 如果出现异常,也要确保关闭加载动画 + } 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数据 @@ -571,7 +593,7 @@ const changeActivity = function (row) { } } }; -//监听改变充值金币时的操作 +//监听改变永久金币时的操作 const changePaidGold = function (row) { console.log("row===", row); let ratio = 0; @@ -638,6 +660,74 @@ const handleBatchAvatarSuccess = (response, uploadFile) => { }; //批量充值确认按钮 const batchAdd = async function () { + try { + console.log("batchData===", batchData.value); + let msg = ''; + if (batchData.value.length == 0) { + ElMessage({ + type: "error", + message: "至少需要输入一条数据!", + }); + return; + } + if (errorCount.value > 0) { + console.log("errorCount.value", errorCount.value); + ElMessage({ + type: "error", + message: "请检查输入的精网号是否正确!", + }); + return; + } + for (let i = 0; i < batchData.value.length; i++) { + batchData.value[i].adminId = adminData.value.adminId; + batchData.value[i].area = adminData.value.area; + batchData.value[i].rechargeWay = "客服充值"; + if ( + batchData.value[i].jwcode == "" || + batchData.value[i].jwcode == null) { + msg += `精网号不能为空! `; + } + if ( + batchData.value[i].activityId == "" || + batchData.value[i].activityId == null) { + msg += `活动不能为空! `; + } + if ( + batchData.value[i].paidGold == "" || + batchData.value[i].paidGold == null) { + msg += `永久金币不能为空! `; + } + if ( + batchData.value[i].freeGold == "" || + batchData.value[i].freeGold == null) { + msg += `免费金币不能为空! `; + } + if ( + batchData.value[i].rechargeGold == "" || + batchData.value[i].rechargeGold == null) { + msg += `充值金额不能为空! `; + } + if ( + batchData.value[i].payWay == "" || + batchData.value[i].payWay == null) { + msg += `收款方式不能为空! `; + } + if ( + batchData.value[i].rechargeTime == "" || + batchData.value[i].rechargeTime == null) { + msg += `交款时间不能为空! `; + } + if (msg != '' && msg != null) { + console.log(batchData.value[i]); + ElMessage({ + dangerouslyUseHTMLString: true, + type: "error", + message: msg, + }); + return; + } + } + console.log("batchData::", batchData.value); console.log("batchData===", batchData.value); let msg = ""; if (batchData.value.length == 0) { @@ -690,27 +780,36 @@ const batchAdd = async function () { } console.log("batchData===", batchData.value); - const result = await API.post( - "http://192.168.8.93:10010/recharge/recharge/addmore", - { ...batchData.value } - ); + const result = await API.post( + "http://192.168.8.93:10010/recharge/recharge/addmore", + { ...batchData.value } + ); - if (result.code === 0) { - ElMessage.error("添加失败"); - return; - } + if (result.code === 0) { + ElMessage.error("添加失败"); + return; + } - ElMessage({ - type: "success", - message: "添加成功!", - }); + ElMessage({ + type: "success", + message: "添加成功!", + }); - closeBatchRechargeVisible(); -}; + closeBatchRechargeVisible(); + } catch (error) { + console.log("error===", error); + ElMessage.error("添加失败"); + return; + }; +} // 使用 _.throttle 并设置 trailing 为 false 实现严格节流,只执行一次 -const throttledBatchAdd = _.throttle(batchAdd, 5000, { trailing: false }); +const throttledBatchAdd = _.throttle(batchAdd, 2000, { trailing: false }); // 批量设置的对象 -const batchSettingObj = ref({}); +const batchSettingObj = ref({ + rechargeGold: "0", + paidGold: "0", + freeGold: "0", +}); // 批量充值弹窗 const batchSettingVisible = ref(false); // 打开批量充值弹窗 @@ -734,7 +833,11 @@ const batchSettingHandleAvatarSuccess = (response, uploadFile) => { }; // 批量设置取消按钮 const cancelBatchSetting = function () { - batchSettingObj.value = {}; + batchSettingObj.value = { + rechargeGold: "0", + paidGold: "0", + freeGold: "0", + }; closeBatchSettingVisible(); }; // 批量设置确认按钮 @@ -808,7 +911,11 @@ const batchSettingConfirm = function () { batchData.value[i].remark = batchSettingObj.value.remark; } } - batchSettingObj.value = {}; + batchSettingObj.value = { + rechargeGold: "0", + paidGold: "0", + freeGold: "0", + }; closeBatchSettingVisible(); }; @@ -856,7 +963,7 @@ onMounted(async function () { /> - + 个 免费金币 @@ -989,6 +1096,8 @@ onMounted(async function () { {{ user.buyJb + user.free6 + user.free12 + user.coreJb }} + (永久金币:{{ user.buyJb + }};免费金币:{{ 新增一行 --> 添加 - + 行 + 添加 添加 @@ -1072,6 +1182,8 @@ onMounted(async function () { > + - + + {{ + scope.row.inputErrorMessage }} + + @@ -1125,7 +1241,7 @@ onMounted(async function () { {{ scope.row.activityName }} - + + + {{ scope.row.freeGold }} + + \ No newline at end of file
个
免费金币
{{ + scope.row.inputErrorMessage }}