feat(purchase-transaction): 添加startImportStatusPolling方法
- 实现轮询检查导入任务状态 - 设置最多150次轮询(5分钟超时) - 使用async/await处理异步请求 - 超时后自动停止轮询并提示用户 - 非PROCESSING状态时调用handleImportComplete处理结果 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -955,6 +955,34 @@ export default {
|
|||||||
this.$modal.msgError(response.msg);
|
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) {
|
startImportPolling(taskId) {
|
||||||
const message = this.$message({
|
const message = this.$message({
|
||||||
|
|||||||
Reference in New Issue
Block a user