From 20f3394205e55398a4090d95f60c945dc18b1c0b Mon Sep 17 00:00:00 2001 From: liugongyu <290219706@qq.com> Date: Mon, 15 Sep 2025 16:52:34 +0800 Subject: [PATCH] 反正多次提交 --- components/common/tui-utils/tui-utils.js | 18 ++++++++++++++++++ pages/work/daily/inspection/add.vue | 28 ++++++++++++++++------------ pages/work/daily/inspection/record.vue | 7 ++++++- pages/work/daily/reporting.vue | 4 ++-- utils/utils.js | 20 ++++++++++++++++++++ 5 files changed, 62 insertions(+), 15 deletions(-) create mode 100644 utils/utils.js diff --git a/components/common/tui-utils/tui-utils.js b/components/common/tui-utils/tui-utils.js index 974bd3d..df07b5f 100644 --- a/components/common/tui-utils/tui-utils.js +++ b/components/common/tui-utils/tui-utils.js @@ -332,3 +332,21 @@ export default { debounce: utils.debounce, throttle: utils.throttle } +// 👇 新增:补充具名导出(关键步骤) +export const { + trim, + trimAll, + replaceAll, + formatNumber, + formatMoney, + formatDate, + rgbToHex, + hexToRGB, + unique, + distinctArray, + getDateTimeSlot, + getUrlParam, + getUUID, + debounce, + throttle // 单独导出 throttle 方法 +} = utils; \ No newline at end of file diff --git a/pages/work/daily/inspection/add.vue b/pages/work/daily/inspection/add.vue index d18be73..e7bf225 100644 --- a/pages/work/daily/inspection/add.vue +++ b/pages/work/daily/inspection/add.vue @@ -48,7 +48,9 @@ export default { }, // 提交记录 onSubmit() { - this.$refs.form.validate(this.formData, rules).then(res => { + // 关键:如果正在加载中(请求未完成),直接拦截后续点击 + if (this.isLoading) return; + this.$refs.form.validate(this.formData, rules).then(res => { if (!res.isPass) { uni.$tui.toast(res.errorMsg) return @@ -60,17 +62,19 @@ export default { this.isLoading = true apiInspectionAdd({data:{...this.formData}}).then(res => { uni.$tui.toast('提交成功') - const pages = getCurrentPages() - const beforePage = pages[pages.length - 2] - const id = this.id - setTimeout(() => { - uni.navigateBack({ - success () { - // 刷新页面数据 - beforePage.$vm.getInspectionInfo(id) - } - }) - }, 1500) + uni.navigateBack() + + // const pages = getCurrentPages() + // const beforePage = pages[pages.length - 2] + // const id = this.id + // setTimeout(() => { + // uni.navigateBack({ + // success () { + // // 刷新页面数据 + // beforePage.$vm.getInspectionInfo(id) + // } + // }) + // }, 1500) }).finally(() => { this.isLoading = false }) diff --git a/pages/work/daily/inspection/record.vue b/pages/work/daily/inspection/record.vue index 3ef6fc0..91c3400 100644 --- a/pages/work/daily/inspection/record.vue +++ b/pages/work/daily/inspection/record.vue @@ -1,6 +1,6 @@