Sfoglia il codice sorgente

修复部分权限管理问题

cehn 7 mesi fa
parent
commit
1ccaf07d2e

+ 7 - 0
projects/textbook/src/app/app.routes.ts

@@ -3,6 +3,7 @@ import { AuthGuard } from '../services/auth.guard';
 import { CompUserComponent } from './comp-user/comp-user.component';
 import { ProfileComponent } from '../modules/user/profile/profile.component'
 import { CompManageComponent } from './comp-manage/comp-manage.component'
+import { TextbookDetailsComponent } from '../modules/common/textbook-details/textbook-details.component';
 export const routes: Routes = [
   { path: '', redirectTo:'user/login', pathMatch: "full",}, // 默认跳转到 ''
   // { path: '',loadComponent:()=>import('../modules/textbook/page-home/page-home.component').then(m=>m.PageHomeComponent) }, // 默认跳转到 ''
@@ -15,6 +16,12 @@ export const routes: Routes = [
     path: 'profile', // 用户登录/注册
     component: ProfileComponent,
   },
+  {
+    path: 'common', //教材详情
+    component: CompManageComponent,
+    canActivate: mapToCanActivate([AuthGuard]),
+    loadChildren: () =>import('../modules/common/modules.routes').then((mod) => mod.CommonRoutingModule),
+  },
   {
     path: 'nav-admin', //国家级管理员管理平台
     component: CompManageComponent,

+ 1 - 1
projects/textbook/src/app/textbook/textbook.component.ts

@@ -45,7 +45,7 @@ export class TextbookComponent implements OnInit {
   @Input('depart') depart: any; //指定申报单位
   @Input('recommend') recommend: any; //是否推荐
   @Input('uid') uid: string = ''; //个人空间
-  @Input('path') path: string = '/nav-admin/manage/textbook/details';
+  @Input('path') path: string = '/common/textbook/details';
   @Input('discard') discard: Boolean = false; //是否删除
   @Input('eduProcess') eduProcess?: Parse.Object; //流程id,verify存在时需要
 

+ 15 - 0
projects/textbook/src/modules/common/modules.routes.ts

@@ -0,0 +1,15 @@
+import { NgModule } from '@angular/core';
+import { RouterModule, Routes,RouteReuseStrategy, mapToCanActivate } from '@angular/router';
+import { TextbookDetailsComponent } from './textbook-details/textbook-details.component';
+const routes: Routes = [
+  {
+    path: 'textbook/details/:id', //流程申报
+    component: TextbookDetailsComponent,
+  },
+]
+
+@NgModule({
+  imports: [RouterModule.forChild(routes)],
+  exports: [RouterModule],
+})
+export class CommonRoutingModule {}

+ 3 - 3
projects/textbook/src/modules/nav-admin/page-process/process-create/process-create.component.ts

@@ -57,7 +57,7 @@ export class ProcessCreateComponent implements OnInit {
     name: ['', [Validators.required]],
     desc: ['',[Validators.maxLength(500)]],
     code: ['', [Validators.required]],
-    num: ['',],
+    num: [0,],
     branch: ['', [Validators.required]],
     startDate: [new Date('2024/07/20'), [Validators.required]],
     deadline: [new Date('2024/09/20'), [Validators.required]],
@@ -93,7 +93,7 @@ export class ProcessCreateComponent implements OnInit {
         this.validateForm.get('name')?.setValue(this.eduProcess?.get('name') || '')
         this.validateForm.get('desc')?.setValue(this.eduProcess?.get('desc') || '')
         this.validateForm.get('code')?.setValue(this.eduProcess?.get('code') || '')
-        this.validateForm.get('num')?.setValue(this.eduProcess?.get('num') || this.eduProcess?.get('num') == 0 ? this.eduProcess?.get('num') : '')
+        this.validateForm.get('num')?.setValue(this.eduProcess?.get('num') || this.eduProcess?.get('num') == 0 ? this.eduProcess?.get('num') : 0)
         this.validateForm.get('branch')?.setValue(this.eduProcess?.get('branch')?.id || '')
         this.validateForm.get('startDate')?.setValue(this.eduProcess?.get('startDate')
               ? this.eduProcess?.get('startDate')
@@ -203,7 +203,7 @@ export class ProcessCreateComponent implements OnInit {
     this.eduProcess?.set('name', params.name);
     this.eduProcess?.set('desc', params.desc);
     this.eduProcess?.set('code', params.code);
-    params.num && this.eduProcess?.set('num', params.num);
+    typeof(params.num) == 'number' && this.eduProcess?.set('num', params.num);
     this.eduProcess?.set('startDate', params.startDate);
     this.eduProcess?.set('deadline', params.deadline);
     if (!this.eduProcess?.get('profileSubmitted')) {

+ 109 - 63
projects/textbook/src/modules/nav-admin/page-user/page-user.component.ts

@@ -48,12 +48,15 @@ export class PageUserComponent implements OnInit {
     companyType: {
       listOfFilter: [
         { value: '教育部直属高校', text: '教育部直属高校' },
-        { value: '中央有关部门(单位)教育司(局)', text: '中央有关部门(单位)教育司(局)' },
+        {
+          value: '中央有关部门(单位)教育司(局)',
+          text: '中央有关部门(单位)教育司(局)',
+        },
         { value: '省级教育行政部门', text: '省级教育行政部门' },
         { value: '出版单位', text: '出版单位' },
       ],
     },
-  }
+  };
   // _User = _User;
   // ProfileList = Profile;
   // className: string | undefined;
@@ -107,9 +110,9 @@ export class PageUserComponent implements OnInit {
 
   ngOnInit(): void {
     this.activeRoute.queryParamMap.subscribe(async (queryParams) => {
-      console.log(queryParams)
-      let page = queryParams.get("page");
-      if(page){
+      console.log(queryParams);
+      let page = queryParams.get('page');
+      if (page) {
         this.pageIndex = Number(page);
         this.updateUrlPageIndex(Number(page));
       }
@@ -150,7 +153,9 @@ export class PageUserComponent implements OnInit {
       },
     };
     if (this.tbookSer.profile.identity != '国家级管理员') {
-      let childrens = await this.tbookSer.getChild(this.tbookSer.profile.user.department?.objectId)
+      let childrens = await this.tbookSer.getChild(
+        this.tbookSer.profile.user.department?.objectId
+      );
       this.tbookSer.profile.user.department;
       queryParams['where']['$or'][0]['user']['$inQuery']['where'][
         'department'
@@ -188,28 +193,31 @@ export class PageUserComponent implements OnInit {
     this.getProfile();
   }
   /** 更新页码queryParams */
-  updateUrlPageIndex(page:number){
+  updateUrlPageIndex(page: number) {
     let search = window.location.search;
-    if(!search){
-      search = `?page=${page}`
-    }else{
-      let pagestr = window.location.search?.replaceAll("?","").split("&").find(item=>item.indexOf("page=")>-1);
-      if(pagestr){
-        search = search.replaceAll(pagestr,`page=${page}`)
-      }else{
-        search = search + `?page=${page}`
+    if (!search) {
+      search = `?page=${page}`;
+    } else {
+      let pagestr = window.location.search
+        ?.replaceAll('?', '')
+        .split('&')
+        .find((item) => item.indexOf('page=') > -1);
+      if (pagestr) {
+        search = search.replaceAll(pagestr, `page=${page}`);
+      } else {
+        search = search + `?page=${page}`;
       }
     }
     let newHref = window.location.origin + window.location.pathname + search;
-    window.history.replaceState(null, "", newHref);
+    window.history.replaceState(null, '', newHref);
   }
   //筛选条件
-  onChangeFilter(data: any, type:string){
+  onChangeFilter(data: any, type: string) {
     console.log(data);
-    this.filters[type].value = data
-    this.profiles = []
-    this.pageIndex = 1
-    this.getProfile()
+    this.filters[type].value = data;
+    this.profiles = [];
+    this.pageIndex = 1;
+    this.getProfile();
   }
   createUser() {
     this.route.navigate(['/nav-admin/manage/user/create']);
@@ -261,18 +269,26 @@ export class PageUserComponent implements OnInit {
         if (r?.id) {
           switch (type) {
             case '通过认证':
-              if(!r?.get('department')?.id){
-                this.message.warning('该用户暂未绑定所属单位')
-                return
+              if (!r?.get('department')?.id) {
+                this.message.warning('该用户暂未绑定所属单位');
+                return;
               }
-              if(data?.get('identity') == '工作联系人'){
-                let auth = await this.tbookSer.updateProfileSubmitted(data?.id,'save',r?.get('department')?.id,this.message)
-                if(!auth) return
+              if (data?.get('identity') == '工作联系人') {
+                let auth = await this.tbookSer.updateProfileSubmitted(
+                  data?.id,
+                  'save',
+                  r?.get('department')?.id,
+                  this.message
+                );
+                if (!auth) return;
               }
               r?.set('accountState', '已认证');
-              Parse.Cloud.run('aliSmsSend',{
-                "mobileList": [data?.get('user')?.get('phone')],"templateCode":"SMS_468870790","params":{},"signName":"普通高等教育教材网"
-              })
+              Parse.Cloud.run('aliSmsSend', {
+                mobileList: [data?.get('user')?.get('phone')],
+                templateCode: 'SMS_468870790',
+                params: {},
+                signName: '普通高等教育教材网',
+              });
               await r?.save();
               break;
             case '禁用':
@@ -307,15 +323,15 @@ export class PageUserComponent implements OnInit {
         );
         let deletePromiseList = selectedList.map((item: any) => {
           return new Promise(async (resolve) => {
-            await item.get('user')?.destroy()
-            await item.destroy()
-            resolve(true)
+            await item.get('user')?.destroy();
+            await item.destroy();
+            resolve(true);
           });
         });
         try {
           await Promise.all(deletePromiseList);
           this.setOfCheckedId = new Set<string>();
-          this.checkedAll = false
+          this.checkedAll = false;
           this.getProfile();
         } catch (err) {}
       },
@@ -324,7 +340,21 @@ export class PageUserComponent implements OnInit {
     });
   }
   goDateil(id: string) {
-    this.route.navigate(['/nav-admin/manage/user/edit', { id: id }],{queryParams:{page:this.pageIndex}});
+    let url = '';
+    switch (this.tbookSer.profile.identity) {
+      case '国家级管理员':
+        url = '/nav-admin/manage/user/edit';
+        break;
+      case '工作联系人':
+        url = '/nav-province-contact/manage/user/edit';
+        break;
+      case '高校联系人':
+        url = '/nav-province-school-contact/manage/user/edit';
+        break;
+    }
+    this.route.navigate([url, { id: id }], {
+      queryParams: { page: this.pageIndex },
+    });
   }
 
   /* 添加用户 */
@@ -356,8 +386,12 @@ export class PageUserComponent implements OnInit {
       //     type: res.get('type'),
       //   },
       // ];
-      this.parentList = await this.getDepart(this.tbookSer.profile.user.department?.objectId);
-      this.parentMap = await this.formatNode(this.tbookSer.profile.user.department?.objectId);
+      this.parentList = await this.getDepart(
+        this.tbookSer.profile.user.department?.objectId
+      );
+      this.parentMap = await this.formatNode(
+        this.tbookSer.profile.user.department?.objectId
+      );
     } else {
       this.parentList = await this.getDepart();
     }
@@ -406,10 +440,11 @@ export class PageUserComponent implements OnInit {
       this.parentMap = [];
       return;
     }
-    if (index == this.parentMap.length - 1){
-      if(this.parentList.length == 0 ) this.parentList = await this.getDepart(data?.key);
+    if (index == this.parentMap.length - 1) {
+      if (this.parentList.length == 0)
+        this.parentList = await this.getDepart(data?.key);
       return;
-    } 
+    }
     this.parentMap.splice((index || 0) + 1);
     this.parentList = await this.getDepart(data?.key);
   }
@@ -434,7 +469,9 @@ export class PageUserComponent implements OnInit {
       this.account.department = { title: e.title, id: e.key };
       this.account.companyType = e.branch || e.title;
       this.userType = this.parents.some((item) => e.parent == item.key)
-        ? !e.type ? ['工作联系人'] : ['评审专家', '工作联系人', '教师']
+        ? !e.type
+          ? ['工作联系人']
+          : ['评审专家', '工作联系人', '教师']
         : e.type == '单位'
         ? ['评审专家', '高校联系人', '教师']
         : ['评审专家', '教师'];
@@ -471,18 +508,18 @@ export class PageUserComponent implements OnInit {
     console.log(this.account.password);
   }
   /* 添加账号 */
-  isLoadingOne:boolean = false
+  isLoadingOne: boolean = false;
   async accountComplete() {
-    if(this.isLoadingOne) return
-    this.isLoadingOne = true
+    if (this.isLoadingOne) return;
+    this.isLoadingOne = true;
     this.account.username = this.account?.username.trim();
     this.account.email = this.account?.email.trim();
     this.account.phone = this.account?.phone.trim();
     this.account.name = this.account?.name.trim();
     this.account.password = this.account?.password.trim();
-    if(!await this.authVrifly()){
-      this.isLoadingOne = false
-      return
+    if (!(await this.authVrifly())) {
+      this.isLoadingOne = false;
+      return;
     }
     try {
       let obj = Parse.Object.extend('_User');
@@ -509,12 +546,15 @@ export class PageUserComponent implements OnInit {
       profile?.set('email', this.account.email);
       profile?.set('identity', this.account.identity);
       let res = await profile?.save();
-      this.isLoadingOne = false
+      this.isLoadingOne = false;
       this.accountIsVisible = false;
       this.account = null;
-      Parse.Cloud.run('aliSmsSend',{
-        "mobileList": [this.account?.phone],"templateCode":"SMS_469060724","params":{},"signName":"普通高等教育教材网"
-      })
+      Parse.Cloud.run('aliSmsSend', {
+        mobileList: [this.account?.phone],
+        templateCode: 'SMS_469060724',
+        params: {},
+        signName: '普通高等教育教材网',
+      });
       this.modal.success({
         nzTitle: '添加成功',
         nzContent: '',
@@ -525,14 +565,14 @@ export class PageUserComponent implements OnInit {
       });
     } catch (err: any) {
       console.warn('添加用户错误', err);
-      this.isLoadingOne = false
+      this.isLoadingOne = false;
       this.message.error(
         err?.Error || '错误:请检查用户或邮箱及手机号是否已存在'
       );
       return;
     }
   }
-  async authVrifly():Promise< boolean | undefined>{
+  async authVrifly(): Promise<boolean | undefined> {
     this.account.password = this.account?.password.trim();
     this.account.email = this.account?.email.trim();
     this.account.phone = this.account?.phone.trim();
@@ -540,8 +580,9 @@ export class PageUserComponent implements OnInit {
     if (
       !this.account?.name ||
       !this.account.department?.id ||
-      !this.account.password||
-      !this.account.phone || !this.account?.email
+      !this.account.password ||
+      !this.account.phone ||
+      !this.account?.email
     ) {
       this.message.warning('请填写必填项');
       return;
@@ -555,23 +596,28 @@ export class PageUserComponent implements OnInit {
       this.message.error('请填写正确手机号');
       return;
     }
-    let m = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
-    if(!String(this.account.email).match(m)){
-      this.message.error("邮箱格式有误");
+    let m =
+      /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
+    if (!String(this.account.email).match(m)) {
+      this.message.error('邮箱格式有误');
       return;
     }
     // if (!this.account?.email&& !this.account?.phone) {
     //   this.message.error('邮箱或手机号必须填写一项');
     //   return;
     // }
-    if(!(this.account.password.length >= 6 && this.account.password.length <= 18)){
-      this.message.error('密码格式错误,请填写6-18位非空字符串(数字、大小写字母或英文符号)');
+    if (
+      !(this.account.password.length >= 6 && this.account.password.length <= 18)
+    ) {
+      this.message.error(
+        '密码格式错误,请填写6-18位非空字符串(数字、大小写字母或英文符号)'
+      );
       return;
     }
-    if(!await this.tbookSer.userFind(this.account.phone)){
+    if (!(await this.tbookSer.userFind(this.account.phone))) {
       this.message.error('手机号已存在');
-      return
+      return;
     }
-    return true
+    return true;
   }
 }

+ 1 - 1
projects/textbook/src/modules/nav-admin/user-edit/user-edit.component.ts

@@ -130,7 +130,7 @@ export class UserEditComponent implements OnInit {
         this.tbookSer.profile.identity == '工作联系人' &&
         arr.includes(this.profile.get('identity'))
       ) {
-        this.userType = ['教师', '评审专家', '工作联系人'];
+        this.userType = ['教师', '评审专家', '高校联系人'];
         this.edit = true;
       } else if (
         this.tbookSer.profile.identity == '高校联系人' &&

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

@@ -73,6 +73,8 @@ export class PageProcessComponent implements OnInit {
           let vrifly = await this.tbookSer.getEduProcess(
             res.get('department').id
           );
+          console.log(vrifly);
+          
           if (vrifly) {
             this.beforeFilterObj.btns = {
               reject: true, //退回教材

+ 16 - 2
projects/textbook/src/modules/nav-province-contact/page-role/page-role.component.ts

@@ -161,7 +161,9 @@ export class PageRoleComponent implements OnInit {
     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)
+    if(this.tbookSer.profile.identity == '工作联系人'){
+      queryEduProcess.equalTo('profileSubmitted',this.tbookSer?.profile?.objectId)
+    }
     queryEduProcess.select('objectId')
     this.eduProcess = await queryEduProcess.first();
     this.editLoading = false
@@ -692,7 +694,19 @@ export class PageRoleComponent implements OnInit {
     this.message.warning('权限灰度中');
   }
   goDateil(id: string) {
-    this.route.navigate(['/nav-admin/manage/user/edit', { id: id }]);
+    let url = '';
+    switch (this.tbookSer.profile.identity) {
+      case '国家级管理员':
+        url = '/nav-admin/manage/user/edit';
+        break;
+      case '工作联系人':
+        url = '/nav-province-contact/manage/user/edit';
+        break;
+      case '高校联系人':
+        url = '/nav-province-school-contact/manage/user/edit';
+        break;
+    }
+    this.route.navigate([url, { id: id }]);
   }
   randomPassword() {
     this.account.password = this.tbookSer.randomPassword();