zhanbo.xu

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

......@@ -428,7 +428,6 @@ export default {
pollInterval: 5000, // 轮询间隔(5秒)
isPolling: false, // 轮询状态标识
currentTaskId: null,
maxPollCount: 0,
pollCount: 0,
};
},
......@@ -516,7 +515,7 @@ export default {
};
},
downLoadZip() {
downLoadZip(retryCount = 0) {
const baseUrl = process.env.VUE_APP_BASE_API;
console.log(this.currentTaskId);
axios({
......@@ -550,7 +549,17 @@ export default {
debugger;
let jsonData = JSON.parse(reader.result);
if (jsonData.code == "10103") {
this.startPolling(50);
// 检查重试次数
if (retryCount < 50) {
// 延迟后重试
setTimeout(() => {
this.downLoadZip(retryCount + 1);
}, 5000); // 5秒后重试
} else {
this.alertWarningMsg("导出失败");
this.exportLoading = false;
}
return;
}
this.alertWarningMsg(jsonData.message);
......@@ -608,7 +617,7 @@ export default {
this.handleFailure();
this.alertWarningMsg(result.data.errorMessage);
} else {
this.startPolling(0); // 启动轮询
this.startPolling(); // 启动轮询
}
} else {
this.stopPolling();
......@@ -621,29 +630,11 @@ export default {
}
},
// 启动轮询
startPolling(maxPollCount) {
// if (this.isPolling) return;
// this.isPolling = true;
// this.pollTimer = setInterval(() => {
// this.pollStatus();
// }, this.pollInterval);
startPolling() {
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);
},
......@@ -699,7 +690,7 @@ export default {
if (+res.code === 200) {
console.log(res);
this.currentTaskId = res.data;
this.startPolling(0);
this.startPolling();
}
});
// this.fileDownload
......