From 9ae817dc41a6fa9a5fcb70823a4756a7167216ec Mon Sep 17 00:00:00 2001 From: wkc <978997012@qq.com> Date: Sun, 8 Feb 2026 14:00:18 +0800 Subject: [PATCH] =?UTF-8?q?feat(purchase-transaction):=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0startImportStatusPolling=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 实现轮询检查导入任务状态 - 设置最多150次轮询(5分钟超时) - 使用async/await处理异步请求 - 超时后自动停止轮询并提示用户 - 非PROCESSING状态时调用handleImportComplete处理结果 Co-Authored-By: Claude Sonnet 4.5 --- .../views/ccdiPurchaseTransaction/index.vue | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/ruoyi-ui/src/views/ccdiPurchaseTransaction/index.vue b/ruoyi-ui/src/views/ccdiPurchaseTransaction/index.vue index 0791e50..5afcc93 100644 --- a/ruoyi-ui/src/views/ccdiPurchaseTransaction/index.vue +++ b/ruoyi-ui/src/views/ccdiPurchaseTransaction/index.vue @@ -955,6 +955,34 @@ export default { this.$modal.msgError(response.msg); } }, + /** 开始轮询导入状态 */ + startImportStatusPolling(taskId) { + let pollCount = 0; + const maxPolls = 150; // 最多轮询150次(5分钟) + + this.importPollingTimer = setInterval(async () => { + try { + pollCount++; + + // 超时检查 + if (pollCount > maxPolls) { + clearInterval(this.importPollingTimer); + this.$modal.msgWarning('导入任务处理超时,请联系管理员'); + return; + } + + const response = await getImportStatus(taskId); + + if (response.data && response.data.status !== 'PROCESSING') { + clearInterval(this.importPollingTimer); + this.handleImportComplete(response.data); + } + } catch (error) { + clearInterval(this.importPollingTimer); + this.$modal.msgError('查询导入状态失败: ' + error.message); + } + }, 2000); // 每2秒轮询一次 + }, // 开始轮询导入状态 startImportPolling(taskId) { const message = this.$message({