From 93966cafdabec6b5e49f12e05e2917795268c8f7 Mon Sep 17 00:00:00 2001 From: donghaolin <17667510818@163.com> Date: Mon, 13 Jan 2025 16:01:23 +0800 Subject: [PATCH] --- gold-system/src/views/recharge/addRecharge.vue | 108 ++++++++++++++++--------- 1 file changed, 71 insertions(+), 37 deletions(-) diff --git a/gold-system/src/views/recharge/addRecharge.vue b/gold-system/src/views/recharge/addRecharge.vue index cc5a7af..9a1deec 100644 --- a/gold-system/src/views/recharge/addRecharge.vue +++ b/gold-system/src/views/recharge/addRecharge.vue @@ -7,7 +7,7 @@ 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 * as xlsx from "xlsx"; import _ from "lodash"; // 这是添加上传图片的接口 @@ -256,7 +256,9 @@ function handleActivityChange(value) { // 监听 paidGold 的变化 const calculatedFree = computed(() => { if ( - Math.trunc(addRecharge.value.paidGold / addRecharge.value.rechargeRatio) < 1 + Math.trunc(addRecharge.value.paidGold / addRecharge.value.rechargeRatio) < + 1 || + addRecharge.value.rechargeRatio == 0 ) { return 0; } else { @@ -322,17 +324,17 @@ 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) { + if (!jwcodeSet.has(row.jwcode) && row.jwcode != "" && row.jwcode != null) { row.isInputInvalid = true; - row.inputErrorMessage = '精网号不存在'; + row.inputErrorMessage = "精网号不存在"; errorCount.value++; return; } else { row.isInputInvalid = false; - row.inputErrorMessage = ''; + row.inputErrorMessage = ""; errorCount.value--; } -} +}; // 批量充值弹窗 const batchRechargeVisible = ref(false); @@ -347,7 +349,7 @@ const batchData = ref([ line: 1, showInput: true, isInputInvalid: false, - inputErrorMessage: '', + inputErrorMessage: "", freeGold: "0", rechargeGold: "0", paidGold: "0", @@ -375,7 +377,7 @@ const addLine = function () { line: ++i.value, showInput: true, isInputInvalid: false, - inputErrorMessage: '', + inputErrorMessage: "", freeGold: "0", rechargeGold: "0", paidGold: "0", @@ -387,9 +389,9 @@ const addLines = async function () { loading.value = true; try { loading.value = true; // 操作开始前,将loading设为true,显示加载动画 - console.log(loading.value, "loading.value") + console.log(loading.value, "loading.value"); - await new Promise(resolve => setTimeout(resolve, 100)); // 人为创建一个小延迟 + await new Promise((resolve) => setTimeout(resolve, 100)); // 人为创建一个小延迟 // 操作开始前,将loading设为true,显示加载动画 await nextTick(); // 等待视图更新,确保加载动画能及时显示出来 @@ -398,7 +400,7 @@ const addLines = async function () { line: ++i.value, showInput: true, isInputInvalid: false, - inputErrorMessage: '', + inputErrorMessage: "", freeGold: "0", rechargeGold: "0", paidGold: "0", @@ -415,9 +417,9 @@ const addLines = async function () { ElMessage.error("添加失败"); } finally { loading.value = false; - console.log(loading.value, "loading.value") + console.log(loading.value, "loading.value"); } -} +}; // 添加多行点击按钮 // const addLines = async function () { // try { @@ -451,7 +453,7 @@ const addLines = async function () { // } // }; // 使用 _.throttle 并设置 trailing 为 false 实现严格节流,只执行一次 -const throttledAddLines = _.throttle(addLines, 500, { trailing: false }); +const throttledAddLines = _.throttle(addLines, 500, { trailing: false }); // 导入excel按钮的ref const uploadRefMap = ref({}); // 获取excel数据 @@ -655,7 +657,7 @@ const handleBatchAvatarSuccess = (response, uploadFile) => { const batchAdd = async function () { try { console.log("batchData===", batchData.value); - let msg = ''; + let msg = ""; if (batchData.value.length == 0) { ElMessage({ type: "error", @@ -677,40 +679,47 @@ const batchAdd = async function () { batchData.value[i].rechargeWay = "客服充值"; if ( batchData.value[i].jwcode == "" || - batchData.value[i].jwcode == null) { + batchData.value[i].jwcode == null + ) { msg += `精网号不能为空!
`; } if ( batchData.value[i].activityId == "" || - batchData.value[i].activityId == null) { + batchData.value[i].activityId == null + ) { msg += `活动不能为空!
`; } if ( batchData.value[i].paidGold == "" || - batchData.value[i].paidGold == null) { + batchData.value[i].paidGold == null + ) { msg += `永久金币不能为空!
`; } if ( batchData.value[i].freeGold == "" || - batchData.value[i].freeGold == null) { + batchData.value[i].freeGold == null + ) { msg += `免费金币不能为空!
`; } if ( batchData.value[i].rechargeGold == "" || - batchData.value[i].rechargeGold == null) { + batchData.value[i].rechargeGold == null + ) { msg += `充值金额不能为空!
`; } if ( batchData.value[i].payWay == "" || - batchData.value[i].payWay == null) { + batchData.value[i].payWay == null + ) { msg += `收款方式不能为空!
`; } if ( batchData.value[i].rechargeTime == "" || - batchData.value[i].rechargeTime == null) { + batchData.value[i].rechargeTime == null + ) { msg += `交款时间不能为空!
`; } - if (msg != '' && msg != null) { + if (msg != "" && msg != null) { console.log(batchData.value[i]); ElMessage({ dangerouslyUseHTMLString: true, @@ -720,8 +729,8 @@ const batchAdd = async function () { return; } } - - console.log("batchData===", batchData.value); + + console.log("batchData===", batchData.value); const result = await API.post( "http://192.168.8.93:10010/recharge/recharge/addmore", @@ -743,8 +752,8 @@ const batchAdd = async function () { console.log("error===", error); ElMessage.error("添加失败"); return; - }; -} + } +}; // 使用 _.throttle 并设置 trailing 为 false 实现严格节流,只执行一次 const throttledBatchAdd = _.throttle(batchAdd, 2000, { trailing: false }); // 批量设置的对象 @@ -1039,8 +1048,10 @@ onMounted(async function () { {{ user.buyJb + user.free6 + user.free12 + user.coreJb }} - (永久金币:{{ user.buyJb - }};免费金币:{{ + (永久金币:{{ user.buyJb }};免费金币:{{ user.free6 + user.free12 }};任务金币:{{ user.coreJb }}) @@ -1095,9 +1106,19 @@ onMounted(async function () {
添加 - + - 添加 + 添加