From ae4bcf250d374045156215b7e6a0b1e0804eaa21 Mon Sep 17 00:00:00 2001 From: hongxilin <17663930442@163.com> Date: Thu, 2 Jan 2025 13:14:45 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=89=B9=E9=87=8F=E5=85=85=E5=80=BC?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=8C=89=E9=92=AE=E9=98=B2=E6=AD=A2=E5=A4=9A?= =?UTF-8?q?=E6=AC=A1=E7=82=B9=E5=87=BB=E9=87=8D=E5=A4=8D=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vue/gold-system/src/util/index.js | 37 -------------------- vue/gold-system/src/views/consume/addConsume.vue | 1 + vue/gold-system/src/views/recharge/addRecharge.vue | 39 +++------------------- vue/gold-system/src/views/refund/addRefund.vue | 1 + 4 files changed, 6 insertions(+), 72 deletions(-) delete mode 100644 vue/gold-system/src/util/index.js diff --git a/vue/gold-system/src/util/index.js b/vue/gold-system/src/util/index.js deleted file mode 100644 index 17d9080..0000000 --- a/vue/gold-system/src/util/index.js +++ /dev/null @@ -1,37 +0,0 @@ -// 防抖 -function _debounce(fn, delay = 500) { - var timer = null; - return function () { - var _this = this; - var args = arguments; - if (timer) clearTimeout(timer); - timer = setTimeout(function () { - fn.apply(_this, args); - }, delay); - }; -} - -// 节流 -function _throttle(fn, delay = 1000) { - var lastTime, timer, delay; - return function () { - var _this = this; - var args = arguments; - var nowTime = Date.now(); - if (lastTime && nowTime - lastTime < delay) { - if (timer) clearTimeout(timer); - timer = setTimeout(function () { - lastTime = nowTime; - fn.apply(_this, args); - }, delay) - } else { - lastTime = nowTime; - fn.apply(_this, args); - } - } -} - -export { - _debounce, - _throttle, -} \ No newline at end of file diff --git a/vue/gold-system/src/views/consume/addConsume.vue b/vue/gold-system/src/views/consume/addConsume.vue index e3efd6a..a74c252 100644 --- a/vue/gold-system/src/views/consume/addConsume.vue +++ b/vue/gold-system/src/views/consume/addConsume.vue @@ -7,6 +7,7 @@ import axios from "axios"; import { ElMessageBox } from "element-plus"; import API from "../../api/index.js"; import moment from "moment"; +import _ from 'lodash'; //这是获取用户信息的接口 const adminData = ref({}); diff --git a/vue/gold-system/src/views/recharge/addRecharge.vue b/vue/gold-system/src/views/recharge/addRecharge.vue index b3736e8..d71e15a 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 _ from 'lodash'; // 这是添加上传图片的接口 const imageUrl = ref(""); @@ -270,8 +270,6 @@ const deleteRecharge = function () { // 批量充值 // jwcode列表 const jwcodeList = ref([]); -// jwcode下拉框懒加载变量 -const rangeNumber = ref(10); // 获取jwcode列表 const getJwcodeList = async function () { try { @@ -292,30 +290,6 @@ const getJwcodeList = async function () { // 在这里可以处理错误逻辑,比如显示错误提示等 } }; -// 滚动到底部加载更多数据 -const loadMore = (n) => { - return () => { - rangeNumber.value += 5; - }; -}; -// 筛选方法 -const filterMethod = _debounce(function (filterVal) { - if (filterVal) { - const filterArr = jwcodeList.value.fliter((item) => - item.toLowerCase().includes(filterVal.toLowerCase()) - ); - options.value = filterArr; - } else { - options.value = jwcodeList.value; - } -}, 500); -// 下拉框出现时调用过滤方法 -const visibleChange = function (flag) { - if (flag) { - filterMethod(); - } -}; - // 批量充值弹窗 const batchRechargeVisible = ref(false); const jwcodeSelectRef = ref(null); @@ -687,7 +661,8 @@ const batchAdd = async function () { closeBatchRechargeVisible(); }; - +// 使用 _.throttle 并设置 trailing 为 false 实现严格节流,只执行一次 +const throttledBatchAdd = _.throttle(batchAdd, 5000, { trailing: false }); // 批量设置的对象 const batchSettingObj = ref({}); // 批量充值弹窗 @@ -925,12 +900,6 @@ onMounted(async function () { {{ scope.row.jwcode }} -->