zhanbo.xu

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

...@@ -428,6 +428,8 @@ export default { ...@@ -428,6 +428,8 @@ export default {
428 pollInterval: 5000, // 轮询间隔(5秒) 428 pollInterval: 5000, // 轮询间隔(5秒)
429 isPolling: false, // 轮询状态标识 429 isPolling: false, // 轮询状态标识
430 currentTaskId: null, 430 currentTaskId: null,
431 + maxPollCount: 0,
432 + pollCount: 0,
431 }; 433 };
432 }, 434 },
433 created() { 435 created() {
...@@ -548,7 +550,7 @@ export default { ...@@ -548,7 +550,7 @@ export default {
548 debugger; 550 debugger;
549 let jsonData = JSON.parse(reader.result); 551 let jsonData = JSON.parse(reader.result);
550 if (jsonData.code == "10103") { 552 if (jsonData.code == "10103") {
551 - this.startPolling(); 553 + this.startPolling(50);
552 return; 554 return;
553 } 555 }
554 this.alertWarningMsg(jsonData.message); 556 this.alertWarningMsg(jsonData.message);
...@@ -606,7 +608,7 @@ export default { ...@@ -606,7 +608,7 @@ export default {
606 this.handleFailure(); 608 this.handleFailure();
607 this.alertWarningMsg(result.data.errorMessage); 609 this.alertWarningMsg(result.data.errorMessage);
608 } else { 610 } else {
609 - this.startPolling(); // 启动轮询 611 + this.startPolling(0); // 启动轮询
610 } 612 }
611 } else { 613 } else {
612 this.stopPolling(); 614 this.stopPolling();
...@@ -619,11 +621,29 @@ export default { ...@@ -619,11 +621,29 @@ export default {
619 } 621 }
620 }, 622 },
621 // 启动轮询 623 // 启动轮询
622 - startPolling() { 624 + startPolling(maxPollCount) {
625 + // if (this.isPolling) return;
626 +
627 + // this.isPolling = true;
628 + // this.pollTimer = setInterval(() => {
629 + // this.pollStatus();
630 + // }, this.pollInterval);
623 if (this.isPolling) return; 631 if (this.isPolling) return;
624 632
625 this.isPolling = true; 633 this.isPolling = true;
634 + this.pollCount = 0; // 初始化轮询计数器
635 + this.maxPollCount = maxPollCount; // 设置最大轮询次数
636 +
626 this.pollTimer = setInterval(() => { 637 this.pollTimer = setInterval(() => {
638 + this.pollCount++; // 每次轮询增加计数
639 +
640 + // 检查是否达到最大轮询次数
641 + if (this.pollCount > this.maxPollCount && this.maxPollCount !== 0) {
642 + this.stopPolling();
643 + this.alertWarningMsg("导出失败!");
644 + return;
645 + }
646 +
627 this.pollStatus(); 647 this.pollStatus();
628 }, this.pollInterval); 648 }, this.pollInterval);
629 }, 649 },
...@@ -679,7 +699,7 @@ export default { ...@@ -679,7 +699,7 @@ export default {
679 if (+res.code === 200) { 699 if (+res.code === 200) {
680 console.log(res); 700 console.log(res);
681 this.currentTaskId = res.data; 701 this.currentTaskId = res.data;
682 - this.startPolling(); 702 + this.startPolling(0);
683 } 703 }
684 }); 704 });
685 // this.fileDownload 705 // this.fileDownload
......