From 5212b98fc1564aeef2b53d591b840098cdaa58c8 Mon Sep 17 00:00:00 2001 From: DXC Date: Fri, 13 Mar 2026 11:11:34 +0800 Subject: [PATCH] fix: add debug trace and robust UI unlocking to finish stocktake action --- .../src/views/stock/stocktake/index.vue | 39 +++++++++++++++---- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/inventory-web/src/views/stock/stocktake/index.vue b/inventory-web/src/views/stock/stocktake/index.vue index a24e7ab..d8a00cc 100644 --- a/inventory-web/src/views/stock/stocktake/index.vue +++ b/inventory-web/src/views/stock/stocktake/index.vue @@ -849,38 +849,63 @@ const openFinishDialog = () => { } const finishStocktake = async () => { + // ====== 强制重置状态,防止锁死 ====== + console.log('--- [结束盘点] 1. 函数触发,当前状态: ---', { + printing: printing.value, + btnLoading: btnLoading.value, + sessionId: currentSessionId.value, + isSessionActive: isSessionActive.value + }) + printing.value = false + btnLoading.value = false + try { + console.log('--- [结束盘点] 2. 准备弹窗确认 ---') await ElMessageBox.confirm('确定要结束本次盘点吗?结束后将进入差异审核流程。', '结束确认', { type: 'warning', confirmButtonText: '确定结束', cancelButtonText: '取消' }) + console.log('--- [结束盘点] 3. 用户确认结束盘点 ---') printing.value = true + console.log('--- [结束盘点] 4. 开始调用 API, session_id:', currentSessionId.value) // 调用结束盘点 API const res: any = await api.finishStocktake() + console.log('--- [结束盘点] 5. API 返回:', res) // 结束会话 scannedMap.value.clear() isSessionActive.value = false showFinishDialog.value = false + console.log('--- [结束盘点] 6. 会话已清理 ---') + // 刷新服务器草稿计数 await checkServerDraft() + console.log('--- [结束盘点] 7. 草稿计数已刷新 ---') ElMessage.success('盘点已结束,请查看差异报告进行审核') + console.log('--- [结束盘点] 8. 成功提示已显示 ---') - // 自动打开差异审核对话框 - await openVarianceDialog() + // ====== 强行打开差异审核对话框 ====== + console.log('--- [结束盘点] 9. 准备打开差异面板 ---') + showVarianceDialog.value = true + console.log('--- [结束盘点] 10. showVarianceDialog 已设为 true ---') } catch (e: any) { - // ElMessageBox.cancel 是字符串 'cancel',需要正确判断 - if (e === 'cancel' || e === 'cancel' as any) { - return // 用户取消,不做任何提示 + console.error('--- [结束盘点] 捕获异常:', e) + // 判断用户取消 + if (e === 'cancel' || String(e).includes('cancel')) { + console.log('--- [结束盘点] 用户取消操作 ---') + return } // 其他错误需要提示用户 - console.error('结束盘点失败:', e) - ElMessage.error(e?.message || e?.data?.message || '结束盘点失败,请重试') + const errMsg = e?.message || e?.data?.message || String(e) || '结束盘点失败' + console.error('--- [结束盘点] 错误详情:', errMsg) + ElMessage.error(errMsg) } finally { printing.value = false + btnLoading.value = false + console.log('--- [结束盘点] 11. finally 块执行完成,loading 已重置 ---') } }