Browse Source

权限管理

cehn 7 tháng trước cách đây
mục cha
commit
482b8671cb
16 tập tin đã thay đổi với 374 bổ sung192 xóa
  1. 36 0
      projects/textbook/src/modules/nav-admin/auth.guard.ts
  2. 3 1
      projects/textbook/src/modules/nav-admin/modules.routes.ts
  3. 36 0
      projects/textbook/src/modules/nav-province-contact/auth.guard.ts
  4. 3 1
      projects/textbook/src/modules/nav-province-contact/modules.routes.ts
  5. 136 132
      projects/textbook/src/modules/nav-province-contact/page-process/process-list/process-list.component.html
  6. 12 0
      projects/textbook/src/modules/nav-province-contact/page-process/process-list/process-list.component.scss
  7. 4 0
      projects/textbook/src/modules/nav-province-contact/page-process/process-list/process-list.component.ts
  8. 10 0
      projects/textbook/src/modules/nav-province-contact/page-role/page-role.component.html
  9. 12 1
      projects/textbook/src/modules/nav-province-contact/page-role/page-role.component.scss
  10. 12 1
      projects/textbook/src/modules/nav-province-contact/page-role/page-role.component.ts
  11. 52 53
      projects/textbook/src/modules/nav-province-contact/page-textbook/page-textbook.component.html
  12. 12 0
      projects/textbook/src/modules/nav-province-contact/page-textbook/page-textbook.component.scss
  13. 4 1
      projects/textbook/src/modules/nav-province-contact/page-textbook/page-textbook.component.ts
  14. 36 0
      projects/textbook/src/modules/nav-province-school-contact/auth.guard.ts
  15. 3 1
      projects/textbook/src/modules/nav-province-school-contact/modules.routes.ts
  16. 3 1
      projects/textbook/src/services/common.modules.ts

+ 36 - 0
projects/textbook/src/modules/nav-admin/auth.guard.ts

@@ -0,0 +1,36 @@
+import { Injectable } from '@angular/core';
+import {
+  CanActivate,
+  ActivatedRouteSnapshot,
+  RouterStateSnapshot,
+} from '@angular/router';
+import { Observable } from 'rxjs';
+import { Router } from '@angular/router';
+import { textbookServer } from '../../services/textbook';
+@Injectable({
+  providedIn: 'root',
+})
+export class AuthGuard implements CanActivate {
+  LoginPage = '/user/login';
+
+  constructor(private tbookSer: textbookServer, private router: Router) {}
+
+  canActivate(
+    next: ActivatedRouteSnapshot,
+    state: RouterStateSnapshot
+  ): Observable<boolean> | Promise<boolean> | boolean {
+    // 当前路由url
+    // let url: string = state.url;
+    // console.log(url);
+    return this.checkLogin();
+  }
+  checkLogin(): boolean {
+    if (this.tbookSer.profile.identity == '国家级管理员') {
+      return true;
+    }
+    // 否则重定向到login页面
+    this.router.navigate([this.LoginPage]);
+    return false;
+  }
+}
+export { CanActivate };

+ 3 - 1
projects/textbook/src/modules/nav-admin/modules.routes.ts

@@ -1,5 +1,5 @@
 import { NgModule } from '@angular/core';
-import { RouterModule, Routes,RouteReuseStrategy } from '@angular/router';
+import { RouterModule, Routes,RouteReuseStrategy, mapToCanActivate } from '@angular/router';
 // import { CollectionEditComponent } from './collection/collection-edit/collection-edit.component';
 // import { CreateCollectionComponent } from './collection/create-collection/create-collection.component';
 // import { PageCollectionComponent } from './collection/page-collection/page-collection.component';
@@ -14,6 +14,7 @@ import { TextbookDetailsComponent } from '../common/textbook-details/textbook-de
 import { UserCreateComponent } from './page-user/user-create/user-create.component';
 import { ReuseService } from "../../services/route-reuse.service";
 import { LeaveGuard } from './user-edit/auth.guard';
+import { AuthGuard } from './auth.guard';
 const routes: Routes = [
   {
     path: '',
@@ -22,6 +23,7 @@ const routes: Routes = [
   },
   {
     path: 'manage',
+    canActivate: mapToCanActivate([AuthGuard]),
     children:[
       {
         path: 'process', //流程申报

+ 36 - 0
projects/textbook/src/modules/nav-province-contact/auth.guard.ts

@@ -0,0 +1,36 @@
+import { Injectable } from '@angular/core';
+import {
+  CanActivate,
+  ActivatedRouteSnapshot,
+  RouterStateSnapshot,
+} from '@angular/router';
+import { Observable } from 'rxjs';
+import { Router } from '@angular/router';
+import { textbookServer } from '../../services/textbook';
+@Injectable({
+  providedIn: 'root',
+})
+export class AuthGuard implements CanActivate {
+  LoginPage = '/user/login';
+
+  constructor(private tbookSer: textbookServer, private router: Router) {}
+
+  canActivate(
+    next: ActivatedRouteSnapshot,
+    state: RouterStateSnapshot
+  ): Observable<boolean> | Promise<boolean> | boolean {
+    // 当前路由url
+    // let url: string = state.url;
+    // console.log(url);
+    return this.checkLogin();
+  }
+  checkLogin(): boolean {
+    if (this.tbookSer.profile.identity == '工作联系人') {
+      return true;
+    }
+    // 否则重定向到login页面
+    this.router.navigate([this.LoginPage]);
+    return false;
+  }
+}
+export { CanActivate };

+ 3 - 1
projects/textbook/src/modules/nav-province-contact/modules.routes.ts

@@ -1,5 +1,5 @@
 import { NgModule } from "@angular/core";
-import { RouterModule, Routes } from "@angular/router";
+import { mapToCanActivate, RouterModule, Routes } from "@angular/router";
 import { PageUserComponent } from "../nav-admin/page-user/page-user.component";
 import { UserEditComponent } from "../nav-admin/user-edit/user-edit.component";
 import { PageProcessComponent } from "./page-process/page-process.component";
@@ -7,6 +7,7 @@ import { ProcessListComponent } from "./page-process/process-list/process-list.c
 import { PageRoleComponent } from "./page-role/page-role.component";
 import { PageTextbookComponent } from "./page-textbook/page-textbook.component";
 import { SubmittedComponent } from "./submitted/submitted.component";
+import { AuthGuard } from "./auth.guard";
 // import { PageTextbookComponent } from "./page-textbook/page-textbook.component";
 const routes: Routes = [
   {
@@ -16,6 +17,7 @@ const routes: Routes = [
   },
   {
     path: 'manage',
+    canActivate: mapToCanActivate([AuthGuard]),
     children:[
       {
         path: 'process', //流程申报

+ 136 - 132
projects/textbook/src/modules/nav-province-contact/page-process/process-list/process-list.component.html

@@ -1,3 +1,4 @@
+@if (!editLoading && eduProcessList.length > 0) {
 <nz-page-header>
   <!--title-->
   <nz-page-header-title
@@ -15,19 +16,19 @@
   <div class="tool">
     <div class="tool-left">
       <!-- <div class="search">
-        <nz-input-group style="width: 210px" [nzPrefix]="prefixTemplateUser">
-          <input
-            type="text"
-            nz-input
-            placeholder="搜索"
-            [(ngModel)]="searchValue"
-            (ngModelChange)="onSearch($event)"
-          />
-        </nz-input-group>
-        <ng-template #prefixTemplateUser
-          ><span nz-icon nzType="search"></span
-        ></ng-template>
-      </div> -->
+          <nz-input-group style="width: 210px" [nzPrefix]="prefixTemplateUser">
+            <input
+              type="text"
+              nz-input
+              placeholder="搜索"
+              [(ngModel)]="searchValue"
+              (ngModelChange)="onSearch($event)"
+            />
+          </nz-input-group>
+          <ng-template #prefixTemplateUser
+            ><span nz-icon nzType="search"></span
+          ></ng-template>
+        </div> -->
       <div class="">
         <nz-input-group style="width: 210px" [nzPrefix]="prefixTemplateUser">
           <input
@@ -47,12 +48,12 @@
   </div>
   <div class="layout" #maxWidth>
     <!-- <div class="sider" #sider>
-      <ul nz-menu>
-        @for (item of nodes; track $index) {
-        <li nz-menu-item (click)="changeDepart(item)">{{ item.title }}</li>
-        }
-      </ul>
-    </div> -->
+        <ul nz-menu>
+          @for (item of nodes; track $index) {
+          <li nz-menu-item (click)="changeDepart(item)">{{ item.title }}</li>
+          }
+        </ul>
+      </div> -->
     <div class="breadcrumb">
       <nz-table
         #tableData
@@ -71,14 +72,14 @@
         <thead>
           <tr>
             <!-- <th
-              nzEllipsis
-              nzWidth="50px"
-              nzLeft
-              [nzChecked]="checkedAll"
-              [nzIndeterminate]="indeterminate"
-              nzLabel="Select all"
-              (nzCheckedChange)="onAllChecked($event)"
-            ></th> -->
+                nzEllipsis
+                nzWidth="50px"
+                nzLeft
+                [nzChecked]="checkedAll"
+                [nzIndeterminate]="indeterminate"
+                nzLabel="Select all"
+                (nzCheckedChange)="onAllChecked($event)"
+              ></th> -->
             <th nzEllipsis nzWidth="120px" nzLeft>流程名称</th>
             <!-- <th nzEllipsis nzWidth="120px">流程code</th> -->
             <th nzEllipsis nzWidth="120px">流程描述</th>
@@ -92,11 +93,11 @@
           @for (data of tableData.data; track data.id) {
           <tr>
             <!-- <td
-              nzEllipsis
-              nzLeft
-              [nzChecked]="setOfCheckedId.has(data.id)"
-              (nzCheckedChange)="onItemChecked(data.id, $event)"
-            ></td> -->
+                nzEllipsis
+                nzLeft
+                [nzChecked]="setOfCheckedId.has(data.id)"
+                (nzCheckedChange)="onItemChecked(data.id, $event)"
+              ></td> -->
             <td
               nzEllipsis
               (click)="
@@ -109,13 +110,17 @@
               {{ data?.get("name") || "-" }}
             </td>
             <!-- <td nzEllipsis>
-              {{ data?.get("code") || "-" }}
-            </td> -->
+                {{ data?.get("code") || "-" }}
+              </td> -->
             <td nzEllipsis>
               {{ data?.get("desc") || "-" }}
             </td>
             <td nzEllipsis>
-              {{ data?.get("num") || data?.get("num") == 0 ? data?.get("num") : "-" }}
+              {{
+                data?.get("num") || data?.get("num") == 0
+                  ? data?.get("num")
+                  : "-"
+              }}
             </td>
             <td nzEllipsis>
               {{
@@ -128,65 +133,65 @@
               >
             </td>
             <!-- <td nzEllipsis nzRight>
-              <button
-                nz-button
-                nz-dropdown
-                [nzDropdownMenu]="menu"
-                [nzPlacement]="'bottomLeft'"
-              >
-                <span nz-icon nzType="ellipsis" nzTheme="outline"></span>
-              </button>
-              <nz-dropdown-menu #menu="nzDropdownMenu">
-                <ul nz-menu>
-                  @if (statusMap[data.id].strat){
-                  <li nz-menu-item>
-                    <button
-                      nz-button
-                      nzType="link"
-                      style="color: #231c1f"
-                      (click)="onStatusChange(data, 'strat', true)"
-                    >
-                      <span
-                        nz-icon
-                        nzType="caret-right"
-                        nzTheme="outline"
-                      ></span
-                      >开始流程
-                    </button>
-                  </li>
-                  } @if (statusMap[data.id].stop){
-                  <li nz-menu-item>
-                    <button
-                      nz-button
-                      nzType="link"
-                      style="color: #231c1f"
-                      (click)="onStatusChange(data, 'stop', true)"
-                    >
-                      <span
-                        nz-icon
-                        nzType="pause-circle"
-                        nzTheme="outline"
-                      ></span
-                      >暂停流程
-                    </button>
-                  </li>
-                  } @if (statusMap[data.id].end){
-                  <li nz-menu-item>
-                    <button
-                      nz-button
-                      nzType="link"
-                      style="color: #231c1f"
-                      (click)="onStatusChange(data, 'end', true)"
-                    >
-                      <span nz-icon nzType="stop" nzTheme="outline"></span
-                      >结束流程
-                    </button>
-                  </li>
-                  } @if (statusMap[data.id].del){
-                  }
-                </ul>
-              </nz-dropdown-menu>
-            </td> -->
+                <button
+                  nz-button
+                  nz-dropdown
+                  [nzDropdownMenu]="menu"
+                  [nzPlacement]="'bottomLeft'"
+                >
+                  <span nz-icon nzType="ellipsis" nzTheme="outline"></span>
+                </button>
+                <nz-dropdown-menu #menu="nzDropdownMenu">
+                  <ul nz-menu>
+                    @if (statusMap[data.id].strat){
+                    <li nz-menu-item>
+                      <button
+                        nz-button
+                        nzType="link"
+                        style="color: #231c1f"
+                        (click)="onStatusChange(data, 'strat', true)"
+                      >
+                        <span
+                          nz-icon
+                          nzType="caret-right"
+                          nzTheme="outline"
+                        ></span
+                        >开始流程
+                      </button>
+                    </li>
+                    } @if (statusMap[data.id].stop){
+                    <li nz-menu-item>
+                      <button
+                        nz-button
+                        nzType="link"
+                        style="color: #231c1f"
+                        (click)="onStatusChange(data, 'stop', true)"
+                      >
+                        <span
+                          nz-icon
+                          nzType="pause-circle"
+                          nzTheme="outline"
+                        ></span
+                        >暂停流程
+                      </button>
+                    </li>
+                    } @if (statusMap[data.id].end){
+                    <li nz-menu-item>
+                      <button
+                        nz-button
+                        nzType="link"
+                        style="color: #231c1f"
+                        (click)="onStatusChange(data, 'end', true)"
+                      >
+                        <span nz-icon nzType="stop" nzTheme="outline"></span
+                        >结束流程
+                      </button>
+                    </li>
+                    } @if (statusMap[data.id].del){
+                    }
+                  </ul>
+                </nz-dropdown-menu>
+              </td> -->
           </tr>
           }
         </tbody>
@@ -198,44 +203,43 @@
   </div>
 </div>
 <!-- 全选操作:批量操作 -->
-<div class="batch-toolbar-modal" *ngIf="setOfCheckedId?.size">
-  <div class="batch-toolbar">
-    <div class="styles_counter__18S08">
-      <span>已选</span>
-      <span class="styles_num__178Wa">{{ setOfCheckedId.size }}</span>
-    </div>
-    <!-- <div class="batch-toolbar-actions">
-      <div class="ant-space ant-space-horizontal ant-space-align-center">
-        <div class="ant-space-item" style="margin-right: 16px">
-          <button nz-button nzType="text" (click)="statusSelected('del')">
-            <span nz-icon nzType="delete"></span>
-            删除
-          </button>
-        </div>
+<!-- <div class="batch-toolbar-modal" *ngIf="setOfCheckedId?.size">
+    <div class="batch-toolbar">
+      <div class="styles_counter__18S08">
+        <span>已选</span>
+        <span class="styles_num__178Wa">{{ setOfCheckedId.size }}</span>
+      </div>
+      <div class="styles_cancel__AARoT">
+        <button nz-button nzType="text" (click)="statusSelected('strat')">
+          <span nz-icon nzType="caret-right" nzTheme="outline"></span>
+          批量开始
+        </button>
+      </div>
+      <div class="styles_cancel__AARoT">
+        <button nz-button nzType="text" (click)="statusSelected('stop')">
+          <span nz-icon nzType="pause-circle" nzTheme="outline"></span>
+          批量暂停
+        </button>
+      </div>
+      <div class="styles_cancel__AARoT">
+        <button nz-button nzType="text" (click)="statusSelected('end')">
+          <span nz-icon nzType="stop" nzTheme="outline"></span>
+          批量结束
+        </button>
+      </div>
+      <div class="styles_cancel__AARoT">
+        <button nz-button nzType="text" (click)="onAllChecked(false)">
+          取消选中
+        </button>
       </div>
-    </div> -->
-    <div class="styles_cancel__AARoT">
-      <button nz-button nzType="text" (click)="statusSelected('strat')">
-        <span nz-icon nzType="caret-right" nzTheme="outline"></span>
-        批量开始
-      </button>
-    </div>
-    <div class="styles_cancel__AARoT">
-      <button nz-button nzType="text" (click)="statusSelected('stop')">
-        <span nz-icon nzType="pause-circle" nzTheme="outline"></span>
-        批量暂停
-      </button>
-    </div>
-    <div class="styles_cancel__AARoT">
-      <button nz-button nzType="text" (click)="statusSelected('end')">
-        <span nz-icon nzType="stop" nzTheme="outline"></span>
-        批量结束
-      </button>
-    </div>
-    <div class="styles_cancel__AARoT">
-      <button nz-button nzType="text" (click)="onAllChecked(false)">
-        取消选中
-      </button>
     </div>
+  </div> -->
+}
+@else if (editLoading) {
+  <div class="loading">
+    <nz-spin nzSimple [nzSize]="'large'"></nz-spin>
   </div>
-</div>
+}
+@else {
+  <nz-empty style="margin: 100px auto;" nzNotFoundContent="暂未绑定对应单位管理员,请联系工作人员"></nz-empty> 
+}

+ 12 - 0
projects/textbook/src/modules/nav-province-contact/page-process/process-list/process-list.component.scss

@@ -94,6 +94,18 @@
     }
   }
 }
+.loading{
+  position: fixed;
+  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%);
+}
 // 选中,批量操作区域
 .batch-toolbar-modal{
   position: fixed;

+ 4 - 0
projects/textbook/src/modules/nav-province-contact/page-process/process-list/process-list.component.ts

@@ -177,6 +177,8 @@ export class ProcessListComponent implements OnInit {
     }
     return;
   };
+  editLoading:boolean = true
+
   constructor(
     public tbookSer: textbookServer,
     private route: Router,
@@ -260,6 +262,7 @@ export class ProcessListComponent implements OnInit {
     query.notEqualTo('isDeleted', true);
     query.equalTo('department',this.tbookSer.profile.user.department?.objectId)
     query.descending('createdAt');
+    query.equalTo('profileSubmitted',this.tbookSer?.profile?.objectId)
     let r = await query.find();
     // let list: any[] = [];
     r.forEach((item) => {
@@ -269,6 +272,7 @@ export class ProcessListComponent implements OnInit {
       this.statusMap[item.id] = this.formatStatus(item);
     });
     this.eduProcessList = r;
+    this.editLoading = false
     this.loading = false;
   }
   //分页切换

+ 10 - 0
projects/textbook/src/modules/nav-province-contact/page-role/page-role.component.html

@@ -1,3 +1,4 @@
+@if (!editLoading && eduProcess?.id) {
 <nz-page-header>
   <nz-page-header-title
     >申报单位管理
@@ -688,3 +689,12 @@
     </div>
   </div>
 </div>
+}
+@else if (editLoading) {
+  <div class="page-loading">
+    <nz-spin nzSimple [nzSize]="'large'"></nz-spin>
+  </div>
+}
+@else {
+  <nz-empty style="margin: 100px auto;" nzNotFoundContent="暂未绑定对应单位管理员,请联系工作人员"></nz-empty> 
+}

+ 12 - 1
projects/textbook/src/modules/nav-province-contact/page-role/page-role.component.scss

@@ -162,7 +162,18 @@
   font-size: 24px;
   margin-left: 8px;
 }
-
+.page-loading{
+  position: fixed;
+  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%);
+}
 input:-webkit-autofill,
 input:-webkit-autofill:hover,
 input:-webkit-autofill:focus,

+ 12 - 1
projects/textbook/src/modules/nav-province-contact/page-role/page-role.component.ts

@@ -125,6 +125,9 @@ export class PageRoleComponent implements OnInit {
     companyType: '',
     identity: '',
   };
+  eduProcess?: Parse.Object;
+  editLoading:boolean = true
+
   constructor(
     public tbookSer: textbookServer,
     private route: Router,
@@ -152,9 +155,17 @@ export class PageRoleComponent implements OnInit {
   async refresh() {
     if (!this.tbookSer.profile.user.department?.objectId) {
       this.message.warning('权限不足');
-      history.back();
+      // history.back();
       return;
     }
+    let queryEduProcess = new Parse.Query('EduProcess');
+    queryEduProcess.notEqualTo('isDeleted', true);
+    queryEduProcess.equalTo('department', this.tbookSer.profile.user.department?.objectId)
+    queryEduProcess.equalTo('profileSubmitted',this.tbookSer?.profile?.objectId)
+    queryEduProcess.select('objectId')
+    this.eduProcess = await queryEduProcess.first();
+    this.editLoading = false
+
     let query = new Parse.Query('Department');
     query.equalTo('objectId', this.tbookSer.profile.user.department?.objectId);
     query.select('code', 'name', 'branch', 'parent', 'type', 'hasChildren');

+ 52 - 53
projects/textbook/src/modules/nav-province-contact/page-textbook/page-textbook.component.html

@@ -1,54 +1,53 @@
-<nz-page-header>
-  <nz-page-header-title
-    >全部教材
-    <br />
-    <div class="subtitle">
-      查看全部申报流程所提交的教材推荐表
-    </div>
-  </nz-page-header-title>
-  <nz-page-header-extra>
-    <nz-space>
-      <button
-        style="background: #3e49b3; border: 1px #3e49b3"
-        *nzSpaceItem
-        nz-button
-        nzType="primary"
-        (click)="submitted()"
-      >
-      提交推荐教材列表
-      </button>
-    </nz-space>
-  </nz-page-header-extra>
-</nz-page-header>
-<!-- <comp-table-list
-  #list
-  [schema]="EduTextbook"
-  *ngIf="className && fieldsArray"
-  [className]="className"
-  [fieldsArray]="fieldsArray"
-  [queryParams]="queryParams"
-></comp-table-list> -->
-<!-- <div class="conetent">
-  <app-textbook [depart]="this.tbookSer.profile.user.department?.objectId" [limit]="15" [filterObj]="filterObj"></app-textbook>
-</div> -->
-<div class="conetent">
-  <nz-tabset [(nzSelectedIndex)]="active">
-    <nz-tab nzTitle="待评审教材">
-      @if (!active && eduProcess) {
-        <app-textbook
-        [eduProcess]="eduProcess"
-        [filterObj]="beforeFilterObj"
-      ></app-textbook>
-      }
-    </nz-tab>
-    <nz-tab nzTitle="推荐教材">
-      @if (active && eduProcess) {
-        <app-textbook
-        [filterObj]="afterFilterObj"
-        [recommend]="true"
-        [eduProcess]="eduProcess"
+@if (!editLoading && eduProcess?.id) {
+  <nz-page-header>
+    <nz-page-header-title
+      >全部教材
+      <br />
+      <div class="subtitle">
+        查看全部申报流程所提交的教材推荐表
+      </div>
+    </nz-page-header-title>
+    <nz-page-header-extra>
+      <nz-space>
+        <button
+          style="background: #3e49b3; border: 1px #3e49b3"
+          *nzSpaceItem
+          nz-button
+          nzType="primary"
+          (click)="submitted()"
+        >
+        提交推荐教材列表
+        </button>
+      </nz-space>
+    </nz-page-header-extra>
+  </nz-page-header>
+  <div class="conetent">
+    <nz-tabset [(nzSelectedIndex)]="active">
+      <nz-tab nzTitle="待评审教材">
+        @if (!active) {
+          <app-textbook
+          [eduProcess]="eduProcess"
+          [filterObj]="beforeFilterObj"
         ></app-textbook>
-      }
-    </nz-tab>
-  </nz-tabset>
-</div>
+        }
+      </nz-tab>
+      <nz-tab nzTitle="推荐教材">
+        @if (active) {
+          <app-textbook
+          [filterObj]="afterFilterObj"
+          [recommend]="true"
+          [eduProcess]="eduProcess"
+          ></app-textbook>
+        }
+      </nz-tab>
+    </nz-tabset>
+  </div>
+}
+@else if (editLoading) {
+  <div class="loading">
+    <nz-spin nzSimple [nzSize]="'large'"></nz-spin>
+  </div>
+}
+@else {
+  <nz-empty style="margin: 100px auto;" nzNotFoundContent="暂未绑定对应单位管理员,请联系工作人员"></nz-empty> 
+}

+ 12 - 0
projects/textbook/src/modules/nav-province-contact/page-textbook/page-textbook.component.scss

@@ -27,3 +27,15 @@
 ::ng-deep .ant-tabs-tab-btn:active {
   color: #e97488;
 }
+.loading{
+  position: fixed;
+  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%);
+}

+ 4 - 1
projects/textbook/src/modules/nav-province-contact/page-textbook/page-textbook.component.ts

@@ -65,6 +65,7 @@ export class PageTextbookComponent implements OnInit {
     },
   };
   eduProcess?: Parse.Object;
+  editLoading:boolean = true
 
   constructor(
     public tbookSer: textbookServer,
@@ -94,11 +95,12 @@ export class PageTextbookComponent implements OnInit {
     );
     if (!parentMap[1]?.key) return;
     let query = new Parse.Query('EduProcess');
-    query.equalTo('department', parentMap[1]?.key);
+    // query.equalTo('department', parentMap[1]?.key);
     // query.lessThanOrEqualTo('startDate', new Date());
     // query.greaterThan('deadline', new Date());
     query.notEqualTo('isDeleted', true);
     // query.notEqualTo('status', '100');
+    query.equalTo('profileSubmitted',this.tbookSer?.profile?.objectId)
     let res = await query.first();
     let vrifly = await this.tbookSer.getEduProcess(parentMap[1]?.key);
     if (vrifly) {
@@ -112,6 +114,7 @@ export class PageTextbookComponent implements OnInit {
         export: true,
       };
     }
+    this.editLoading = false
     this.eduProcess = res;
   }
   toUrl(url: string, params?: object) {

+ 36 - 0
projects/textbook/src/modules/nav-province-school-contact/auth.guard.ts

@@ -0,0 +1,36 @@
+import { Injectable } from '@angular/core';
+import {
+  CanActivate,
+  ActivatedRouteSnapshot,
+  RouterStateSnapshot,
+} from '@angular/router';
+import { Observable } from 'rxjs';
+import { Router } from '@angular/router';
+import { textbookServer } from '../../services/textbook';
+@Injectable({
+  providedIn: 'root',
+})
+export class AuthGuard implements CanActivate {
+  LoginPage = '/user/login';
+
+  constructor(private tbookSer: textbookServer, private router: Router) {}
+
+  canActivate(
+    next: ActivatedRouteSnapshot,
+    state: RouterStateSnapshot
+  ): Observable<boolean> | Promise<boolean> | boolean {
+    // 当前路由url
+    // let url: string = state.url;
+    // console.log(url);
+    return this.checkLogin();
+  }
+  checkLogin(): boolean {
+    if (this.tbookSer.profile.identity == '高校联系人') {
+      return true;
+    }
+    // 否则重定向到login页面
+    this.router.navigate([this.LoginPage]);
+    return false;
+  }
+}
+export { CanActivate };

+ 3 - 1
projects/textbook/src/modules/nav-province-school-contact/modules.routes.ts

@@ -1,11 +1,12 @@
 import { NgModule } from "@angular/core";
-import { RouterModule, Routes } from "@angular/router";
+import { mapToCanActivate, RouterModule, Routes } from "@angular/router";
 import { PageUserComponent } from "../nav-admin/page-user/page-user.component";
 import { UserEditComponent } from "../nav-admin/user-edit/user-edit.component";
 import { RecycleComponent } from "../nav-author/recycle/recycle.component";
 import { SpaceComponent } from "../nav-author/space/space.component";
 import { PageRoleComponent } from "../nav-province-contact/page-role/page-role.component";
 import { PageTextbookComponent } from "./page-textbook/page-textbook.component";
+import { AuthGuard } from "./auth.guard";
 const routes: Routes = [
   {
     path: '',
@@ -14,6 +15,7 @@ const routes: Routes = [
   },
   {
     path: 'manage',
+    canActivate: mapToCanActivate([AuthGuard]),
     children:[
       {
         path: 'textbook', //全部教材

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

@@ -16,6 +16,7 @@ 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';
+import { NzEmptyModule } from 'ng-zorro-antd/empty';
 @NgModule({
   exports: [
     FormsModule,
@@ -34,7 +35,8 @@ import { NzSpinModule } from 'ng-zorro-antd/spin';
     NzModalModule,
     NzSwitchModule,
     NzAvatarModule,
-    NzSpinModule
+    NzSpinModule,
+    NzEmptyModule
   ]
 })
 export class CommonCompModule { }