From c620dc8b6d5c34697cb1d3996abd5c6448eb1f9d Mon Sep 17 00:00:00 2001 From: wkc <978997012@qq.com> Date: Sun, 8 Feb 2026 14:00:10 +0800 Subject: [PATCH] =?UTF-8?q?feat(purchase-transaction):=20=E9=87=8D?= =?UTF-8?q?=E6=9E=84handleFileSuccess=E6=96=B9=E6=B3=95=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E5=BC=82=E6=AD=A5=E5=AF=BC=E5=85=A5=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 增强响应数据验证,确保taskId存在 - 清理旧的轮询定时器,避免内存泄漏 - 保存导入任务初始状态到localStorage - 使用$notify通知替代弹窗提示 - 重置失败按钮和任务ID状态 - 调用startImportStatusPolling开始轮询 Co-Authored-By: Claude Sonnet 4.5 --- .../views/ccdiPurchaseTransaction/index.vue | 61 ++++++++++++++----- 1 file changed, 45 insertions(+), 16 deletions(-) diff --git a/ruoyi-ui/src/views/ccdiPurchaseTransaction/index.vue b/ruoyi-ui/src/views/ccdiPurchaseTransaction/index.vue index a210a4d..0791e50 100644 --- a/ruoyi-ui/src/views/ccdiPurchaseTransaction/index.vue +++ b/ruoyi-ui/src/views/ccdiPurchaseTransaction/index.vue @@ -905,25 +905,54 @@ export default { handleFileUploadProgress(event, file, fileList) { this.upload.isUploading = true; }, - // 文件上传成功处理 - 使用异步导入 + // 文件上传成功处理 handleFileSuccess(response, file, fileList) { - // 检查是否返回了taskId(异步导入) - if (response.code === 200 && response.data && response.data.taskId) { - const taskId = response.data.taskId; - this.upload.isUploading = false; - this.upload.open = false; - this.$refs.upload.clearFiles(); + this.upload.isUploading = false; + this.upload.open = false; - // 开始轮询导入状态 - this.startImportPolling(taskId); + if (response.code === 200) { + // 验证响应数据完整性 + if (!response.data || !response.data.taskId) { + this.$modal.msgError('导入任务创建失败:缺少任务ID'); + this.upload.isUploading = false; + this.upload.open = true; + return; + } + + const taskId = response.data.taskId; + + // 清除旧的轮询定时器 + if (this.importPollingTimer) { + clearInterval(this.importPollingTimer); + this.importPollingTimer = null; + } + + this.clearImportTaskFromStorage(); + + // 保存新任务的初始状态 + this.saveImportTaskToStorage({ + taskId: taskId, + status: 'PROCESSING', + timestamp: Date.now(), + hasFailures: false + }); + + // 重置状态 + this.showFailureButton = false; + this.currentTaskId = taskId; + + // 显示后台处理提示(不是弹窗,是通知) + this.$notify({ + title: '导入任务已提交', + message: '正在后台处理中,处理完成后将通知您', + type: 'info', + duration: 3000 + }); + + // 开始轮询检查状态 + this.startImportStatusPolling(taskId); } else { - // 同步导入结果(如果后端改为同步) - this.upload.isUploading = false; - this.upload.open = false; - this.getList(); - this.importResultContent = response.msg || response; - this.importResultVisible = true; - this.$refs.upload.clearFiles(); + this.$modal.msgError(response.msg); } }, // 开始轮询导入状态