Browse Source

增加出版社预览教材权限

warrior 4 months ago
parent
commit
47fbffd11b

+ 1 - 1
projects/textbook/src/modules/nav-admin/components/collect-textbook/collect-textbook.component.html

@@ -284,7 +284,7 @@
 
 <nz-modal
   [(nzVisible)]="isVisible"
-  nzTitle="上传教材源文件"
+  nzTitle="教材源文件"
   (nzOnCancel)="isVisible = false"
   nzWidth="600px"
 >

+ 65 - 1
projects/textbook/src/modules/nav-province-contact/collect-file/collect-file.component.html

@@ -110,7 +110,9 @@
           <a nz-button nzType="link" (click)="onEditModal(data)">{{
             statusMap[data.id].btn
           }}</a>
-          }@else { - }
+          }@else { 
+            <a nz-button nzType="link" (click)="onCheckModal(data)">查看</a>
+          }
         </td>
       </tr>
       }
@@ -197,3 +199,65 @@
     </button>
   </div>
 </nz-modal>
+<!-- 查看预览 -->
+<nz-modal
+  [(nzVisible)]="isVisiblePreview"
+  nzTitle="查看文件"
+  (nzOnCancel)="handleCancel()"
+  nzWidth="600px"
+>
+  <ng-container *nzModalContent>
+    <div nz-row class="modal-content">
+      @if (currentTextbook?.get('type')=='全册') {
+      <nz-collapse [nzBordered]="false">
+        @for (panel of currentTextbook?.get('childrens'); track panel) { @if
+          (panel?.get('editionUnit') == tbookSer.profile.user?.department?.name) {
+        <nz-collapse-panel
+          #p
+          [nzHeader]="title"
+          [nzActive]="false"
+          nzExpandedIcon="caret-right"
+          style="
+            background: #f7f7f7;
+            border-radius: 4px;
+            margin-bottom: 24px;
+            border: 0px;
+          "
+        >
+          <ng-template #title>
+            <span class="panel-title">{{
+              "分册" + ($index + 1) + "-" + currentTextbook?.get("title")
+            }}</span>
+          </ng-template>
+          <div class="">
+            <app-upload-collect
+              #children
+              [eduTextbookVolume]="panel"
+              [review]="true"
+            ></app-upload-collect>
+          </div>
+          <ng-template #expandedIcon let-active>
+            {{ active }}
+            <span
+              nz-icon
+              nzType="caret-right"
+              class="ant-collapse-arrow"
+              [nzRotate]="p.nzActive ? 90 : -90"
+            ></span>
+          </ng-template>
+        </nz-collapse-panel>
+        } }
+      </nz-collapse>
+      } @else {
+      <app-upload-collect
+        #children
+        [eduTextbookVolume]="currentTextbook?.get('childrens')[0]"
+        [review]="true"
+      ></app-upload-collect>
+      }
+    </div>
+  </ng-container>
+  <div *nzModalFooter>
+    <button nz-button nzType="default" (click)="handleCancel()">关闭</button>
+  </div>
+</nz-modal>

+ 8 - 1
projects/textbook/src/modules/nav-province-contact/collect-file/collect-file.component.ts

@@ -80,7 +80,8 @@ export class CollectFileComponent implements OnInit {
   currentTextbook?: Parse.Object; //当前编辑教材
 
   statusMap: any = {}; //任务状态
-
+  isVisiblePreview:boolean = false
+  
   constructor(
     private msg: NzMessageService,
     public tbookSer: textbookServer,
@@ -273,6 +274,7 @@ export class CollectFileComponent implements OnInit {
   }
   handleCancel(): void {
     this.isVisible = false;
+    this.isVisiblePreview = false;
     this.currentTextbook = undefined;
   }
   btnLoading: boolean = false;
@@ -329,4 +331,9 @@ export class CollectFileComponent implements OnInit {
       return isVrifly;
     });
   }
+
+  onCheckModal(data:Parse.Object){
+    this.currentTextbook = data;
+    this.isVisiblePreview = true;
+  }
 }

+ 26 - 5
projects/textbook/src/modules/nav-province-contact/components/upload-collect/upload-collect.component.ts

@@ -5,6 +5,9 @@ import { CompUploadComponent } from '../../../../app/comp-upload/comp-upload.com
 import { NzRadioModule } from 'ng-zorro-antd/radio';
 import { CommonCompModule } from '../../../../services/common.modules';
 import { NzMessageService } from 'ng-zorro-antd/message';
+import { textbookServer } from '../../../../services/textbook';
+import { ProvierOssAli } from '../../../../app/comp-upload/provider-oss-aliyun';
+import { NzModalService } from 'ng-zorro-antd/modal';
 interface link {
   url: string;
   username?: string;
@@ -31,20 +34,28 @@ export class UploadCollectComponent implements OnInit {
   }; //链接、账号密码
 
   radioValue: string = '上传文件';
-  carrierShape:string = '' //类型
+  carrierShape: string = ''; //类型
+  ossProvider: { signatureUrl: any } | undefined;
 
-  constructor(private msg: NzMessageService) {}
+  constructor(
+    private modal: NzModalService,
+    public tbookSer: textbookServer,
+    private msg: NzMessageService
+  ) {
+    this.ossProvider = new ProvierOssAli();
+  }
 
   ngOnInit() {
     this.collectFiles = this.eduTextbookVolume?.get('collectFiles') || [];
-    this.collectDigitFiles = this.eduTextbookVolume?.get('collectDigitFiles') || [];
+    this.collectDigitFiles =
+      this.eduTextbookVolume?.get('collectDigitFiles') || [];
     this.collectLink = this.eduTextbookVolume?.get('collectLink') || {
       url: '',
       username: '',
       password: '',
     };
     this.radioValue = this.eduTextbookVolume?.get('collectCheck') || '上传文件';
-    this.carrierShape = this.eduTextbookVolume?.get('carrierShape')?.trim()
+    this.carrierShape = this.eduTextbookVolume?.get('carrierShape')?.trim();
   }
   upload(e: any, type: string) {
     console.log('上传材料发生改变');
@@ -100,7 +111,17 @@ export class UploadCollectComponent implements OnInit {
     return true;
   }
 
-  openUrl(url: string) {
+  async openUrl(url: string) {
+    if (
+      this.eduTextbookVolume?.get('editionUnit') ===
+      this.tbookSer.profile.user?.department?.name
+    ) {
+      url = await this.ossProvider?.signatureUrl(url);
+    }
     window.open(url);
+    this.modal.warning({
+      nzTitle: '提示',
+      nzContent: '教材文件临时链接已打开,有效期10分钟,请勿外泄。'
+    });
   }
 }