zhanbo.xu

feat: 优化导出配置10103的情况

......@@ -428,6 +428,8 @@ export default {
pollInterval: 5000, // 轮询间隔(5秒)
isPolling: false, // 轮询状态标识
currentTaskId: null,
maxPollCount: 0,
pollCount: 0,
};
},
created() {
......@@ -548,7 +550,7 @@ export default {
debugger;
let jsonData = JSON.parse(reader.result);
if (jsonData.code == "10103") {
this.startPolling();
this.startPolling(50);
return;
}
this.alertWarningMsg(jsonData.message);
......@@ -606,7 +608,7 @@ export default {
this.handleFailure();
this.alertWarningMsg(result.data.errorMessage);
} else {
this.startPolling(); // 启动轮询
this.startPolling(0); // 启动轮询
}
} else {
this.stopPolling();
......@@ -619,11 +621,29 @@ export default {
}
},
// 启动轮询
startPolling() {
startPolling(maxPollCount) {
// if (this.isPolling) return;
// this.isPolling = true;
// this.pollTimer = setInterval(() => {
// this.pollStatus();
// }, this.pollInterval);
if (this.isPolling) return;
this.isPolling = true;
this.pollCount = 0; // 初始化轮询计数器
this.maxPollCount = maxPollCount; // 设置最大轮询次数
this.pollTimer = setInterval(() => {
this.pollCount++; // 每次轮询增加计数
// 检查是否达到最大轮询次数
if (this.pollCount > this.maxPollCount && this.maxPollCount !== 0) {
this.stopPolling();
this.alertWarningMsg("导出失败!");
return;
}
this.pollStatus();
}, this.pollInterval);
},
......@@ -679,7 +699,7 @@ export default {
if (+res.code === 200) {
console.log(res);
this.currentTaskId = res.data;
this.startPolling();
this.startPolling(0);
}
});
// this.fileDownload
......