Showing
1 changed file
with
15 additions
and
24 deletions
| ... | @@ -428,7 +428,6 @@ export default { | ... | @@ -428,7 +428,6 @@ 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 | pollCount: 0, |
| 433 | }; | 432 | }; |
| 434 | }, | 433 | }, |
| ... | @@ -516,7 +515,7 @@ export default { | ... | @@ -516,7 +515,7 @@ export default { |
| 516 | }; | 515 | }; |
| 517 | }, | 516 | }, |
| 518 | 517 | ||
| 519 | - downLoadZip() { | 518 | + downLoadZip(retryCount = 0) { |
| 520 | const baseUrl = process.env.VUE_APP_BASE_API; | 519 | const baseUrl = process.env.VUE_APP_BASE_API; |
| 521 | console.log(this.currentTaskId); | 520 | console.log(this.currentTaskId); |
| 522 | axios({ | 521 | axios({ |
| ... | @@ -550,7 +549,17 @@ export default { | ... | @@ -550,7 +549,17 @@ export default { |
| 550 | debugger; | 549 | debugger; |
| 551 | let jsonData = JSON.parse(reader.result); | 550 | let jsonData = JSON.parse(reader.result); |
| 552 | if (jsonData.code == "10103") { | 551 | if (jsonData.code == "10103") { |
| 553 | - this.startPolling(50); | 552 | + // 检查重试次数 |
| 553 | + if (retryCount < 50) { | ||
| 554 | + // 延迟后重试 | ||
| 555 | + setTimeout(() => { | ||
| 556 | + this.downLoadZip(retryCount + 1); | ||
| 557 | + }, 5000); // 5秒后重试 | ||
| 558 | + } else { | ||
| 559 | + this.alertWarningMsg("导出失败"); | ||
| 560 | + this.exportLoading = false; | ||
| 561 | + } | ||
| 562 | + | ||
| 554 | return; | 563 | return; |
| 555 | } | 564 | } |
| 556 | this.alertWarningMsg(jsonData.message); | 565 | this.alertWarningMsg(jsonData.message); |
| ... | @@ -608,7 +617,7 @@ export default { | ... | @@ -608,7 +617,7 @@ export default { |
| 608 | this.handleFailure(); | 617 | this.handleFailure(); |
| 609 | this.alertWarningMsg(result.data.errorMessage); | 618 | this.alertWarningMsg(result.data.errorMessage); |
| 610 | } else { | 619 | } else { |
| 611 | - this.startPolling(0); // 启动轮询 | 620 | + this.startPolling(); // 启动轮询 |
| 612 | } | 621 | } |
| 613 | } else { | 622 | } else { |
| 614 | this.stopPolling(); | 623 | this.stopPolling(); |
| ... | @@ -621,29 +630,11 @@ export default { | ... | @@ -621,29 +630,11 @@ export default { |
| 621 | } | 630 | } |
| 622 | }, | 631 | }, |
| 623 | // 启动轮询 | 632 | // 启动轮询 |
| 624 | - startPolling(maxPollCount) { | 633 | + startPolling() { |
| 625 | - // if (this.isPolling) return; | ||
| 626 | - | ||
| 627 | - // this.isPolling = true; | ||
| 628 | - // this.pollTimer = setInterval(() => { | ||
| 629 | - // this.pollStatus(); | ||
| 630 | - // }, this.pollInterval); | ||
| 631 | if (this.isPolling) return; | 634 | if (this.isPolling) return; |
| 632 | 635 | ||
| 633 | this.isPolling = true; | 636 | this.isPolling = true; |
| 634 | - this.pollCount = 0; // 初始化轮询计数器 | ||
| 635 | - this.maxPollCount = maxPollCount; // 设置最大轮询次数 | ||
| 636 | - | ||
| 637 | 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 | - | ||
| 647 | this.pollStatus(); | 638 | this.pollStatus(); |
| 648 | }, this.pollInterval); | 639 | }, this.pollInterval); |
| 649 | }, | 640 | }, |
| ... | @@ -699,7 +690,7 @@ export default { | ... | @@ -699,7 +690,7 @@ export default { |
| 699 | if (+res.code === 200) { | 690 | if (+res.code === 200) { |
| 700 | console.log(res); | 691 | console.log(res); |
| 701 | this.currentTaskId = res.data; | 692 | this.currentTaskId = res.data; |
| 702 | - this.startPolling(0); | 693 | + this.startPolling(); |
| 703 | } | 694 | } |
| 704 | }); | 695 | }); |
| 705 | // this.fileDownload | 696 | // this.fileDownload | ... | ... |
-
Please register or login to post a comment