From 9bbced4b7a925527f9b9cd801e5b59af0ecc38b5 Mon Sep 17 00:00:00 2001 From: donghaolin <17667510818@163.com> Date: Thu, 2 Jan 2025 13:11:27 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=99=E6=98=AF=E6=B1=87=E7=8E=87=E7=9A=84?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vue/gold-system/src/views/managerecharge/rate.vue | 28 + vue/gold-system/src/views/recharge/addRecharge.vue | 573 ++++++++++++++++----- 2 files changed, 468 insertions(+), 133 deletions(-) diff --git a/vue/gold-system/src/views/managerecharge/rate.vue b/vue/gold-system/src/views/managerecharge/rate.vue index 20020ae..b774fc1 100644 --- a/vue/gold-system/src/views/managerecharge/rate.vue +++ b/vue/gold-system/src/views/managerecharge/rate.vue @@ -101,6 +101,20 @@ const search = function () { const rateAdd = ref({}); const addRate = async function () { rateAdd.value.adminId = adminData.value.adminId; + if (rateAdd.value.startTime) { + const date = new Date(rateAdd.value.startTime); + date.setHours(0, 0, 0, 0); + rateAdd.value.startTime = `${date.getFullYear()}-${String( + date.getMonth() + 1 + ).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")} 00:00:00`; + } + if (rateAdd.value.endTime) { + const date = new Date(rateAdd.value.endTime); + date.setHours(23, 59, 59, 999); + rateAdd.value.endTime = `${date.getFullYear()}-${String( + date.getMonth() + 1 + ).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")} 23:59:59`; + } try { console.log("搜索参数", getObj.value); // 发送POST请求 @@ -171,6 +185,20 @@ const getEditData = async function (row) { } }; const editRate = async function () { + if (rateEdit.value.startTime) { + const date = new Date(rateEdit.value.startTime); + date.setHours(0, 0, 0, 0); + rateEdit.value.startTime = `${date.getFullYear()}-${String( + date.getMonth() + 1 + ).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")} 00:00:00`; + } + if (rateEdit.value.endTime) { + const date = new Date(rateEdit.value.endTime); + date.setHours(23, 59, 59, 999); + rateEdit.value.endTime = `${date.getFullYear()}-${String( + date.getMonth() + 1 + ).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")} 23:59:59`; + } try { console.log("搜索参数", rateEdit.value); // 发送POST请求 diff --git a/vue/gold-system/src/views/recharge/addRecharge.vue b/vue/gold-system/src/views/recharge/addRecharge.vue index b3736e8..a74e946 100644 --- a/vue/gold-system/src/views/recharge/addRecharge.vue +++ b/vue/gold-system/src/views/recharge/addRecharge.vue @@ -7,8 +7,8 @@ import { ElMessageBox } from "element-plus"; import API from "../../api/index.js"; import moment from "moment"; import { range, re } from "mathjs"; -import { _debounce } from '../../util/index.js'; -import * as xlsx from 'xlsx'; +import { _debounce } from "../../util/index.js"; +import * as xlsx from "xlsx"; // 这是添加上传图片的接口 const imageUrl = ref(""); @@ -251,6 +251,17 @@ function handleActivityChange(value) { getActivityById(value); console.log("看看", addRecharge.value); } +// 监听 paidGold 的变化 +watch( + () => addRecharge.value.paidGold, + (newValue) => { + // 当 paidGold 变化时,更新 freeGold 和 rechargeGold + addRecharge.value.freeGold = newValue % addRecharge.value.rechargeRatio; + console.log("剩余金币", addRecharge.value.freeGold); + addRecharge.value.rechargeGold = newValue * addRecharge.value.Rate; + console.log("充值金币", addRecharge.value.rechargeGold); + } +); //这是重置重置表单的方法 const deleteRecharge = function () { @@ -285,7 +296,10 @@ const getJwcodeList = async function () { console.log("请求成功", result); // 存储表格数据 jwcodeList.value = result.data; - jwcodeList.value = jwcodeList.value.map(item => ({ value: item, label: item })) + jwcodeList.value = jwcodeList.value.map((item) => ({ + value: item, + label: item, + })); console.log("精网号", jwcodeList.value); } catch (error) { console.log("请求失败", error); @@ -346,7 +360,9 @@ const batchInit = function () { // 提取添加滚动监听的逻辑到单独函数 const addScrollListener = () => { - const SELECTWRAP_DOM = document.querySelector(".el-select-dropdown .el-select-dropdown__wrap"); + 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; @@ -359,7 +375,9 @@ const vJwcodeLoadmore = { mounted(el, binding) { nextTick(() => { console.log("el===", el, "binding===", binding); - const SELECTWRAP_DOM = el.querySelector(".el-select-dropdown .el-select-dropdown__wrap"); + 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 () { @@ -371,12 +389,13 @@ const vJwcodeLoadmore = { * 如果元素滚动到底, 下面等式返回true, 没有则返回false: * ele.scrollHeight - ele.scrollTop === ele.clientHeight; */ - const condition = this.scrollHeight - this.scrollTop <= this.clientHeight; + const condition = + this.scrollHeight - this.scrollTop <= this.clientHeight; if (condition) binding.value(); }); } - }) - } + }); + }, }; // 下拉框打开时调用添加滚动监听函数 // const jwcodeSelectScrollerListener = () => { @@ -417,13 +436,15 @@ const addLines = async function () { const addLinesPromises = []; for (let j = 0; j < addLineObj.value; j++) { - addLinesPromises.push(new Promise((resolve) => { - batchData.value.unshift({ - line: ++i.value, - showInput: true, - }); - resolve(); - })); + addLinesPromises.push( + new Promise((resolve) => { + batchData.value.unshift({ + line: ++i.value, + showInput: true, + }); + resolve(); + }) + ); } await Promise.all(addLinesPromises); @@ -445,32 +466,32 @@ const excelList = ref([]); // 动态设置upload Ref const handleSetUploadRefMap = (el) => { if (el) { - uploadRefMap.value[`Upload_Ref`] = el + uploadRefMap.value[`Upload_Ref`] = el; } -} +}; // 文件上传自定义 const httpExcelRequest = async (op) => { // 获取除文件之外的参数,具体根据实际业务需求来 - console.log(op.data) + console.log(op.data); // 获取上传的excel 并解析数据 - let file = op.file + let file = op.file; let dataBinary = await readFile(file); - let workBook = xlsx.read(dataBinary, { type: "binary", cellDates: true }) - let workSheet = workBook.Sheets[workBook.SheetNames[0]] - const excelData = xlsx.utils.sheet_to_json(workSheet, { header: 1 }) - excelList.value = excelData - console.log(excelData) -} + let workBook = xlsx.read(dataBinary, { type: "binary", cellDates: true }); + let workSheet = workBook.Sheets[workBook.SheetNames[0]]; + const excelData = xlsx.utils.sheet_to_json(workSheet, { header: 1 }); + excelList.value = excelData; + console.log(excelData); +}; const readFile = (file) => { return new Promise((resolve) => { - let reader = new FileReader() - reader.readAsBinaryString(file) + let reader = new FileReader(); + reader.readAsBinaryString(file); reader.onload = (ev) => { - resolve(ev.target?.result) - } - }) -} + resolve(ev.target?.result); + }; + }); +}; //获取批量删除的数组 const handleSelectionChangebatch = function (val) { @@ -615,11 +636,13 @@ const changeRate = function (row) { row.rechargeGold = Math.ceil(Number(row.paidGold) * rate); } } - }; //监听改变凭证时的操作 const changeVoucher = function (row) { - if ((imageUrl.value != "" && rechargeVoucher.value != "") || (imageUrl.value != null && rechargeVoucher.value != null)) { + if ( + (imageUrl.value != "" && rechargeVoucher.value != "") || + (imageUrl.value != null && rechargeVoucher.value != null) + ) { console.log("row===", row); row.imageUrl = imageUrl.value; row.rechargeVoucher = rechargeVoucher.value; @@ -627,10 +650,9 @@ const changeVoucher = function (row) { imageUrl.value = ""; rechargeVoucher.value = ""; } -} +}; // 上传图片成功的回调函数 const handleBatchAvatarSuccess = (response, uploadFile) => { - imageUrl.value = URL.createObjectURL(uploadFile.raw); console.log("图片上传成功", response, uploadFile); rechargeVoucher.value = `http://192.168.8.93:10010/upload/${response.data}`; @@ -673,7 +695,10 @@ 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("添加失败"); @@ -703,7 +728,7 @@ const closeBatchSettingVisible = function () { // 批量设置初始化 const batchSettingInit = function () { openBatchSettingVisible(); -} +}; // 上传图片成功的回调函数 const batchSettingHandleAvatarSuccess = (response, uploadFile) => { batchSettingObj.value.imageUrl = URL.createObjectURL(uploadFile.raw); @@ -715,48 +740,81 @@ const batchSettingHandleAvatarSuccess = (response, uploadFile) => { const cancelBatchSetting = function () { batchSettingObj.value = {}; closeBatchSettingVisible(); -} +}; // 批量设置确认按钮 const batchSettingConfirm = function () { for (let i = 0; i < batchData.value.length; i++) { - if (batchSettingObj.value.jwcode != "" && batchSettingObj.value.jwcode != null) { + if ( + batchSettingObj.value.jwcode != "" && + batchSettingObj.value.jwcode != null + ) { batchData.value[i].jwcode = batchSettingObj.value.jwcode; } - if (batchSettingObj.value.activityId != "" && batchSettingObj.value.activityId != null) { + if ( + batchSettingObj.value.activityId != "" && + batchSettingObj.value.activityId != null + ) { batchData.value[i].activityId = batchSettingObj.value.activityId; } - if (batchSettingObj.value.paidGold != "" && batchSettingObj.value.paidGold != null) { + if ( + batchSettingObj.value.paidGold != "" && + batchSettingObj.value.paidGold != null + ) { batchData.value[i].paidGold = batchSettingObj.value.paidGold; } - if (batchSettingObj.value.freeGold != "" && batchSettingObj.value.freeGold != null) { + if ( + batchSettingObj.value.freeGold != "" && + batchSettingObj.value.freeGold != null + ) { batchData.value[i].freeGold = batchSettingObj.value.freeGold; } - if (batchSettingObj.value.rate != "" && batchSettingObj.value.rate != null) { + if ( + batchSettingObj.value.rate != "" && + batchSettingObj.value.rate != null + ) { batchData.value[i].rate = batchSettingObj.value.rate; } - if (batchSettingObj.value.rechargeGold != "" && batchSettingObj.value.rechargeGold != null) { + if ( + batchSettingObj.value.rechargeGold != "" && + batchSettingObj.value.rechargeGold != null + ) { batchData.value[i].rechargeGold = batchSettingObj.value.rechargeGold; } - if (batchSettingObj.value.payWay != "" && batchSettingObj.value.payWay != null) { + if ( + batchSettingObj.value.payWay != "" && + batchSettingObj.value.payWay != null + ) { batchData.value[i].payWay = batchSettingObj.value.payWay; } - if (batchSettingObj.value.rechargeTime != "" && batchSettingObj.value.rechargeTime != null) { + if ( + batchSettingObj.value.rechargeTime != "" && + batchSettingObj.value.rechargeTime != null + ) { batchData.value[i].rechargeTime = batchSettingObj.value.rechargeTime; } - if (batchSettingObj.value.imageUrl != "" && batchSettingObj.value.imageUrl != null) { + if ( + batchSettingObj.value.imageUrl != "" && + batchSettingObj.value.imageUrl != null + ) { batchData.value[i].imageUrl = batchSettingObj.value.imageUrl; } - if (batchSettingObj.value.rechargeVoucher != "" && batchSettingObj.value.rechargeVoucher != null) { - batchData.value[i].rechargeVoucher = batchSettingObj.value.rechargeVoucher; + if ( + batchSettingObj.value.rechargeVoucher != "" && + batchSettingObj.value.rechargeVoucher != null + ) { + batchData.value[i].rechargeVoucher = + batchSettingObj.value.rechargeVoucher; } - if (batchSettingObj.value.remark != "" && batchSettingObj.value.remark != null) { + if ( + batchSettingObj.value.remark != "" && + batchSettingObj.value.remark != null + ) { batchData.value[i].remark = batchSettingObj.value.remark; } } batchSettingObj.value = {}; closeBatchSettingVisible(); -} - +}; // 挂载 onMounted(async function () { @@ -770,14 +828,36 @@ onMounted(async function () { 批量充值 - + - 查询 + 查询 - - + + @@ -788,24 +868,66 @@ onMounted(async function () {

- - + + - - + + - + - - - - + + + + @@ -814,19 +936,41 @@ onMounted(async function () {

- + - + - 重置 + 重置 提交
- - + + 客户信息 @@ -849,10 +993,13 @@ onMounted(async function () { {{ user.buyJb + user.free6 + user.free12 + user.coreJb }} - (充值金币:{{ user.buyJb - }};免费金币:{{ + (充值金币:{{ user.buyJb }};免费金币:{{ user.free6 + user.free12 - }};任务金币:{{ user.coreJb }}) + }};任务金币:{{ user.coreJb }}) @@ -893,26 +1040,50 @@ onMounted(async function () { - + -
+
添加 - + - 添加 + 添加
- 批量设置 + 批量设置 - 批量删除 + 批量删除 - - + +