From 5cbebd285d012c588dfda700ac4b48e745803cc5 Mon Sep 17 00:00:00 2001 From: hayu <1604366271@qq.com> Date: Thu, 22 Jan 2026 18:08:08 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=80=E6=96=99=E6=89=AB=E7=A0=81=E7=A1=AE?= =?UTF-8?q?=E8=AE=A4=E6=8C=89=E9=92=AE=E5=8E=BB=E9=99=A4=E4=B8=89=E7=A7=92?= =?UTF-8?q?=E7=AD=89=E5=BE=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/PopupConfirm/waitFree.vue | 108 +++++++++++++++++++++++ src/pages/back/backCode.vue | 69 ++++----------- src/pages/back/backCodeQrScan.vue | 21 ++++- 3 files changed, 146 insertions(+), 52 deletions(-) create mode 100644 src/components/PopupConfirm/waitFree.vue diff --git a/src/components/PopupConfirm/waitFree.vue b/src/components/PopupConfirm/waitFree.vue new file mode 100644 index 0000000..e1496d6 --- /dev/null +++ b/src/components/PopupConfirm/waitFree.vue @@ -0,0 +1,108 @@ + + + + + + {{ title }} + {{ content }} + + + {{ leftBtn }} + + {{ rightBtn }} + + + + + + + + + + \ No newline at end of file diff --git a/src/pages/back/backCode.vue b/src/pages/back/backCode.vue index f73aa28..d01dd4f 100644 --- a/src/pages/back/backCode.vue +++ b/src/pages/back/backCode.vue @@ -8,15 +8,6 @@ fixed @clickLeft="leftClick" > - - @@ -90,9 +81,6 @@ 编码识别 - 转至数量 @@ -100,39 +88,6 @@ - 规格型号: @@ -234,9 +189,6 @@ - @@ -257,7 +209,7 @@ import { baseURL } from '@/utils/http' import eselect from '@/components/tree-select/eselect.vue' import { decryptWithSM4, encryptWithSM4, hashWithSM3AndSalt } from '@/utils/sm' import PreviewImg from '@/components/PreviewImg/index.vue' -import PopupConfirm from '@/components/PopupConfirm' +import PopupConfirm from '@/components/PopupConfirm/waitFree' const taskInfo = ref({}) const maId = ref('') //编码 @@ -286,6 +238,9 @@ const remark = ref('') const isRadioCheck = ref(true) const popupConfirm = ref() +// 添加提交状态锁 +const isSubmitting = ref(false) + const leftClick = () => { // 返回 uni.navigateBack({ @@ -716,14 +671,23 @@ const onCodeIdentify = () => { } //提交 const submitCode = async () => { + // 防止重复提交:如果正在提交中,直接返回 + if (isSubmitting.value) { + return + } + console.log(taskInfo.value) if (selectCodeList.value.length == 0) { uni.showToast({ title: '请添加退料设备!', icon: 'none' }) } else if (apDetection.value == '不合格' && bmFileInfos.value.length == 0) { uni.showToast({ title: '请上传附件!', icon: 'none' }) } else { - const { data: confirm } = await popupConfirm.value.openPopup() + const { data: confirm } = await popupConfirm.value.openPopupWaitFree() if (!confirm) return + + // 设置提交锁为true + isSubmitting.value = true + let obj = { // maId: maId.value, // maCode: maCode.value, @@ -779,6 +743,11 @@ const submitCode = async () => { console.log(error) uni.hideLoading() }) + .finally(() => { + // 无论成功失败,都释放提交锁 + isSubmitting.value = false + uni.hideLoading() // 确保loading被关闭 + }) } } diff --git a/src/pages/back/backCodeQrScan.vue b/src/pages/back/backCodeQrScan.vue index a15381b..f9b32ac 100644 --- a/src/pages/back/backCodeQrScan.vue +++ b/src/pages/back/backCodeQrScan.vue @@ -130,7 +130,7 @@ import ScanQrCode from '@/pages/devicesSearch/ScanQrCode.vue' import eselect from '@/components/tree-select/eselect.vue' import { decryptWithSM4, encryptWithSM4, hashWithSM3AndSalt } from '@/utils/sm' import PreviewImg from '@/components/PreviewImg/index.vue' -import PopupConfirm from '@/components/PopupConfirm' +import PopupConfirm from '@/components/PopupConfirm/waitFree' const taskInfo = ref({}) const apDetection = ref('完好') //外观判定 @@ -144,6 +144,9 @@ const isRadioCheck = ref(true) const popupConfirm = ref() const codeInfo = ref({}) +// 添加提交状态锁 +const isSubmitting = ref(false) + const leftClick = () => { // 返回 uni.navigateBack({ @@ -239,14 +242,23 @@ const getMaInfoScan = () => { //提交 const submitCode = async () => { + // 防止重复提交:如果正在提交中,直接返回 + if (isSubmitting.value) { + return + } + console.log(taskInfo.value) if (!codeInfo.value.maCode) { uni.showToast({ title: '请添加退料设备!', icon: 'none' }) } else if (apDetection.value == '不合格' && bmFileInfos.value.length == 0) { uni.showToast({ title: '请上传附件!', icon: 'none' }) } else { - const { data: confirm } = await popupConfirm.value.openPopup() + const { data: confirm } = await popupConfirm.value.openPopupWaitFree() if (!confirm) return + + // 设置提交锁为true + isSubmitting.value = true + let obj = { // maId: codeInfo.value.maId.value, // maCode: codeInfo.value.maCode.value, @@ -293,6 +305,11 @@ const submitCode = async () => { console.log(error) uni.hideLoading() }) + .finally(() => { + // 无论成功失败,都释放提交锁 + isSubmitting.value = false + uni.hideLoading() // 确保loading被关闭 + }) } }