Browse Source

update 导出等待央视

cehn 7 months ago
parent
commit
f10098c858

+ 4 - 1
projects/textbook/src/app/textbook/textbook.component.html

@@ -604,5 +604,8 @@
     </div>
   </div>
 </div>
-
 }
+
+<div class="loading" [hidden]="!showLoading">
+  <nz-spin nzSimple [nzSize]="'large'"></nz-spin>
+</div>

+ 14 - 0
projects/textbook/src/app/textbook/textbook.component.scss

@@ -74,3 +74,17 @@
   font-size: 24px;
   margin-left: 8px;
 }
+
+.loading{
+  position: fixed;
+  z-index: 99;
+  top: 0;
+  left: 0;
+  width: 100vw;
+  text-align: center;
+  height: 100vh;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  background: rgb(0 0 0 / 30%);
+}

+ 22 - 10
projects/textbook/src/app/textbook/textbook.component.ts

@@ -150,6 +150,9 @@ export class TextbookComponent implements OnInit {
   searchValue: string = '';
   manage: boolean = false;
   calc:number = 120
+
+  showLoading:boolean = false //全局
+
   constructor(
     public tbookSer: textbookServer,
     private route: Router,
@@ -580,17 +583,26 @@ export class TextbookComponent implements OnInit {
   }
   //导出
   async exportProcess(data?: Parse.Object) {
-    let bookList: Array<string> = []
-    if(data?.id){
-      bookList = [data?.id]
-    }else{
-      bookList = Array.from(this.setOfCheckedId)
+    if(this.showLoading) return
+    this.showLoading = true
+    try{
+      let bookList: Array<string> = []
+      if(data?.id){
+        bookList = [data?.id]
+      }else{
+        bookList = Array.from(this.setOfCheckedId)
+      }
+      // let processId = await this.getEduProcess(
+      //   this.tbookSer.profile.user?.department?.objectId
+      // );
+      await this.tbookSer.tbookExportReport({ bookList: bookList })
+      this.showLoading = false
+    }
+    catch(err){
+      this.message.error('导出超时,请稍后重试')
+      console.log(err);
+      this.showLoading = false
     }
-    // let processId = await this.getEduProcess(
-    //   this.tbookSer.profile.user?.department?.objectId
-    // );
-    this.tbookSer.tbookExportReport({ bookList: bookList })
-
     // Parse.Cloud.run('tbookExportReport', { bookList: bookList }).then(
     //   (data) => {
     //     console.log(data);

+ 4 - 0
projects/textbook/src/modules/nav-province-contact/submitted/export-file/export-file.component.html

@@ -44,3 +44,7 @@
   <button nz-button nzType="default" (click)="close()" style="margin-right: 20px">取消</button>
   <button nz-button nzType="primary" (click)="next()" style="background: #3e49b3; border: 1px #3e49b3">下一步</button>
 </div> -->
+
+<div class="loading" [hidden]="!showLoading">
+  <nz-spin nzSimple [nzSize]="'large'"></nz-spin>
+</div>

+ 14 - 0
projects/textbook/src/modules/nav-province-contact/submitted/export-file/export-file.component.scss

@@ -53,4 +53,18 @@
   align-items: center;
   justify-content: flex-end;
   padding: 0 10px;
+}
+
+.loading{
+  position: fixed;
+  z-index: 99;
+  top: 0;
+  left: 0;
+  width: 100vw;
+  text-align: center;
+  height: 100vh;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  background: rgb(0 0 0 / 30%);
 }

+ 27 - 6
projects/textbook/src/modules/nav-province-contact/submitted/export-file/export-file.component.ts

@@ -1,15 +1,24 @@
-import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core';
+import {
+  Component,
+  ElementRef,
+  EventEmitter,
+  Input,
+  OnInit,
+  Output,
+  ViewChild,
+} from '@angular/core';
 import { Router, ActivatedRoute } from '@angular/router';
 import { CommonCompModule } from '../../../../services/common.modules';
 import { TextbookComponent } from '../../../../app/textbook/textbook.component';
 
 import Parse from 'parse';
 import { textbookServer } from '../../../../services/textbook';
+import { NzMessageService } from 'ng-zorro-antd/message';
 @Component({
   selector: 'app-export-file',
   templateUrl: './export-file.component.html',
   styleUrls: ['./export-file.component.scss'],
-  imports: [CommonCompModule,TextbookComponent],
+  imports: [CommonCompModule, TextbookComponent],
   standalone: true,
 })
 export class ExportFileComponent implements OnInit {
@@ -26,11 +35,14 @@ export class ExportFileComponent implements OnInit {
     status: ['400'],
     btns: {},
   };
+  showLoading: boolean = false; //全局
 
   constructor(
-    private router: Router, private activeRoute: ActivatedRoute,
+    private router: Router,
+    private activeRoute: ActivatedRoute,
     public tbookSer: textbookServer,
-    ) {}
+    private message: NzMessageService
+  ) {}
 
   ngOnInit() {
     this.activeRoute.paramMap.subscribe(async (params) => {
@@ -59,7 +71,16 @@ export class ExportFileComponent implements OnInit {
   next() {
     this.change.emit('next');
   }
-  onDownload() {
-    this.tbookSer.tbookExportReport({ processId: this.tbookId })
+  async onDownload() {
+    if (this.showLoading) return;
+    this.showLoading = true;
+    try {
+      await this.tbookSer.tbookExportReport({ processId: this.tbookId });
+      this.showLoading = false;
+    } catch (err) {
+      this.message.error('导出超时,请稍后重试');
+      console.log(err);
+      this.showLoading = false;
+    }
   }
 }

+ 3 - 1
projects/textbook/src/services/common.modules.ts

@@ -15,6 +15,7 @@ import { NzDatePickerModule } from 'ng-zorro-antd/date-picker';
 import { NzModalModule } from 'ng-zorro-antd/modal';
 import { NzSwitchModule } from 'ng-zorro-antd/switch';
 import { NzAvatarModule } from 'ng-zorro-antd/avatar';
+import { NzSpinModule } from 'ng-zorro-antd/spin';
 @NgModule({
   exports: [
     FormsModule,
@@ -32,7 +33,8 @@ import { NzAvatarModule } from 'ng-zorro-antd/avatar';
     NzDatePickerModule,
     NzModalModule,
     NzSwitchModule,
-    NzAvatarModule
+    NzAvatarModule,
+    NzSpinModule
   ]
 })
 export class CommonCompModule { }