Browse Source

update 创建用户相关

warrior 7 months ago
parent
commit
a9f67991a2

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

@@ -161,7 +161,7 @@ export class CompManageComponent implements OnInit {
         path: '/nav-review/profile',
       },
     ],
-    "个人":[
+    "教师":[
       {
         name: '个人空间',
         id: '1',

+ 26 - 14
projects/textbook/src/modules/nav-admin/page-role/page-role.component.html

@@ -282,13 +282,19 @@
             上级部门 <span style="color: #e8353e">*</span>
           </div>
           <div class="value">
-            <input
-              nz-input
-              placeholder="可击下方选择所属上级"
-              [ngModel]="editObject.parent?.title"
-              (ngModelChange)="onSearchNodes($event, true)"
-              type="text"
-            />
+            <nz-input-group nzSearch [nzAddOnAfter]="suffixIconclear">
+              <input
+                nz-input
+                placeholder="可击下方选择所属上级"
+                [(ngModel)]="editObject.parent?.title"
+                (ngModelChange)="onSearchNodes($event, true)"
+                (blur)="onblur('editObject')"
+                type="text"
+              />
+            </nz-input-group>
+            <ng-template #suffixIconclear>
+              <button nz-button nzType="primary" nzSearch (click)="reset('editObject')">清空</button>
+            </ng-template>
           </div>
         </div>
         <div class="select">
@@ -350,13 +356,19 @@
             选择所属部门 <span style="color: #e8353e">*</span>
           </div>
           <div class="value">
-            <input
-              nz-input
-              placeholder="请选择所属部门"
-              [ngModel]="account.department?.title"
-              (ngModelChange)="onSearchNodes($event, true)"
-              type="text"
-            />
+            <nz-input-group nzSearch [nzAddOnAfter]="suffixIconclear">
+              <input
+                nz-input
+                placeholder="请选择所属部门"
+                [(ngModel)]="modalValue"
+                (ngModelChange)="onSearchNodes($event, true)"
+                type="text"
+                (blur)="onblur('account')"
+              />
+            </nz-input-group>
+            <ng-template #suffixIconclear>
+              <button nz-button nzType="primary" nzSearch (click)="reset('account')">清空</button>
+            </ng-template>
           </div>
         </div>
         <div class="select">

+ 26 - 6
projects/textbook/src/modules/nav-admin/page-role/page-role.component.ts

@@ -114,10 +114,10 @@ export class PageRoleComponent implements OnInit {
     department: {},
     companyType: '',
   };
-  userType: Array<string> = ['工作联系人', '评审专家', '高校联系人', '个人'];
+  userType: Array<string> = ['工作联系人', '评审专家', '高校联系人', '教师'];
   parents: Array<any> = []; //所有一级列表
   nzExpandedKeys:any = [] //默认展开节点数
-
+  modalValue:string = ''
   constructor(
     private route: Router,
     private activeRoute: ActivatedRoute,
@@ -187,6 +187,26 @@ export class PageRoleComponent implements OnInit {
     }
     this.nodes = await this.getDepart('', e, e ? true : false);
   }
+  //搜索失去焦点
+  onblur(type:string){
+    console.log(type);
+    if(type == 'account'){
+      this.modalValue = this.account.department?.title
+    }else if(type == 'editObject'){
+      this.modalValue = this.editObject.parent?.title
+    }
+  }
+  reset(type:string){
+    this.modalValue = ''
+    this.parentList = this.nodes;
+    this.parentMap = []
+    if(type == 'account'){
+      this.account.department = {}
+      this.account.identity = ''
+    }else if(type == 'editObject'){
+      this.editObject.parent = {}
+    }
+  }
   //展开/合并
   async nzEvent(event: NzFormatEmitEvent): Promise<void> {
     console.log(event);
@@ -408,10 +428,10 @@ export class PageRoleComponent 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 ? ['工作联系人'] : ['评审专家', '工作联系人', '教师']
+        : e.type == '单位'
+        ? ['评审专家', '高校联系人', '教师']
+        : ['评审专家', '教师'];
       } else {
         this.editObject.parent = {
           title: e.title,

+ 11 - 10
projects/textbook/src/modules/nav-admin/page-user/page-user.component.ts

@@ -42,7 +42,7 @@ export class PageUserComponent implements OnInit {
         { value: '工作联系人', text: '工作联系人' },
         { value: '高校联系人', text: '高校联系人' },
         { value: '评审专家', text: '评审专家' },
-        { value: '个人', text: '个人' },
+        { value: '教师', text: '教师' },
       ],
     },
     companyType: {
@@ -69,7 +69,7 @@ export class PageUserComponent implements OnInit {
   loading = false;
   searchValue: string = ''; //搜索内容
   setOfCheckedId = new Set<string>();
-  userType: Array<string> = ['工作联系人', '评审专家', '高校联系人', '个人'];
+  userType: Array<string> = ['工作联系人', '评审专家', '高校联系人', '教师'];
   parentMap: Array<any> = [];
   parentList: Array<any> = [];
   radio: string = '';
@@ -101,7 +101,7 @@ export class PageUserComponent implements OnInit {
   ) {
     this.user = Parse.User.current();
     if (this.tbookSer.profile.identity != '国家级管理员') {
-      this.userType = ['评审专家', '高校联系人', '个人'];
+      this.userType = ['评审专家', '高校联系人', '教师'];
     }
   }
 
@@ -144,11 +144,12 @@ export class PageUserComponent implements OnInit {
       },
     };
     if (this.tbookSer.profile.identity != '国家级管理员') {
+      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'
       ] = {
-        $eq: this.tbookSer.profile.user.department?.objectId,
+        $in: [childrens],
       };
     }
     let query = Parse.Query.fromJSON('Profile', queryParams);
@@ -162,9 +163,9 @@ export class PageUserComponent implements OnInit {
     query.notEqualTo('identity', '国家级管理员');
     query.descending('createdAt');
     if (this.tbookSer.profile.identity == '工作联系人') {
-      query.containedIn('identity', ['个人', '评审专家', '高校联系人']);
+      query.containedIn('identity', ['教师', '评审专家', '高校联系人']);
     } else if (this.tbookSer.profile.identity == '高校联系人') {
-      query.containedIn('identity', ['个人', '评审专家']);
+      query.containedIn('identity', ['教师', '评审专家']);
     }
     this.profileLength = await query.count();
     query.limit(this.pageSize);
@@ -402,10 +403,10 @@ 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 ? ['工作联系人'] : ['评审专家', '工作联系人', '教师']
+        : e.type == '单位'
+        ? ['评审专家', '高校联系人', '教师']
+        : ['评审专家', '教师'];
       return;
     }
     if (e.isLeaf) {

+ 2 - 2
projects/textbook/src/modules/nav-admin/page-user/user-create/user-create.component.ts

@@ -76,7 +76,7 @@ export class UserCreateComponent implements OnInit {
   provinces: Array<string> = provinces.options; //省份
 
   unitTypes: Array<any> = [];
-  userType: Array<string> = ['工作联系人', '评审专家', '高校联系人', '个人'];
+  userType: Array<string> = ['工作联系人', '评审专家', '高校联系人', '教师'];
   identityFile: string = ''; //单位联系人认证文件
   department?: Parse.Object; //所属单位
   parentMap: Array<any> = [];
@@ -95,7 +95,7 @@ export class UserCreateComponent implements OnInit {
 
   async ngOnInit() {
     if (this.tbookSer.profile.identity != '国家级管理员') {
-      this.userType = ['个人'];
+      this.userType = ['教师'];
       this.getUnitTypes(this.tbookSer.profile.companyType);
       return;
     }

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

@@ -83,13 +83,13 @@ export class UserEditComponent implements OnInit {
           department: this.user.get('department'),
         };
       }
-      let arr = ['个人', '评审专家', '高校联系人'];
+      let arr = ['教师', '评审专家', '高校联系人'];
       if (
         this.tbookSer.profile.identity == '国家级管理员' ||
         (this.tbookSer.profile.identity == '工作联系人' &&
           arr.includes(this.profile.identity)) ||
         (this.tbookSer.profile.identity == '高校联系人' &&
-          this.profile.identity == '个人')
+          this.profile.identity == '教师')
       ) {
         this.edit = true;
       }

+ 28 - 16
projects/textbook/src/modules/nav-province-contact/page-role/page-role.component.html

@@ -270,13 +270,19 @@
             上级部门 <span style="color: #e8353e">*</span>
           </div>
           <div class="value">
-            <input
-              nz-input
-              placeholder="可击下方选择所属上级"
-              [ngModel]="editObject.parent?.title"
-              (ngModelChange)="onSearchNodes($event, true)"
-              type="text"
-            />
+            <nz-input-group nzSearch [nzAddOnAfter]="suffixIconclear">
+              <input
+                nz-input
+                placeholder="可输入搜索{{editObject.parent?.title || nodes[0]?.title}}下级所属部门"
+                [(ngModel)]="modalValue"
+                (ngModelChange)="onSearchNodes($event, true,editObject.parent?.id)"
+                (blur)="onblur('editObject')"
+                type="text"
+              />
+            </nz-input-group>
+            <ng-template #suffixIconclear>
+               <button nz-button nzType="primary" nzSearch (click)="reset('editObject')">清空</button>
+            </ng-template>
           </div>
         </div>
         <div class="select">
@@ -285,7 +291,7 @@
             @for (data of parentMap; track data.title) {
             <span style="margin: 0 10px">/</span>
             @if ($index !=0 && data?.verify) {
-            <a (click)="onPre(data, $index)">{{ data.title }}</a>
+            <a (click)="onPre('editObject',data, $index)">{{ data.title }}</a>
             }@else {
             <a style="color: #86909c">{{ data.title }}</a>
             } }
@@ -341,13 +347,19 @@
             选择所属部门 <span style="color: #e8353e">*</span>
           </div>
           <div class="value">
-            <input
-              nz-input
-              placeholder="请选择所属部门"
-              [ngModel]="account.department?.title"
-              (ngModelChange)="onSearchNodes($event, true)"
-              type="text"
-            />
+            <nz-input-group nzSearch [nzAddOnAfter]="suffixIconclear">
+              <input
+                nz-input
+                placeholder="可输入搜索{{account.department?.title || nodes[0]?.title}}下级所属部门"
+                [(ngModel)]="modalValue"
+                (ngModelChange)="onSearchNodes($event, true, account.department?.id)"
+                type="text"
+                (blur)="onblur('account')"
+              />
+            </nz-input-group>
+            <ng-template #suffixIconclear>
+               <button nz-button nzType="primary" nzSearch (click)="reset('account')">清空</button>
+            </ng-template>
           </div>
         </div>
         <div class="select">
@@ -356,7 +368,7 @@
             @for (data of parentMap; track data.title) {
             <span style="margin: 0 10px">/</span>
             @if ($index !=0 && data?.verify) {
-            <a (click)="onPre(data, $index)">{{ data.title }}</a>
+            <a (click)="onPre('account', data, $index)">{{ data.title }}</a>
             }@else {
             <a style="color: #86909c">{{ data.title }}</a>
             } }

+ 65 - 37
projects/textbook/src/modules/nav-province-contact/page-role/page-role.component.ts

@@ -113,7 +113,7 @@ export class PageRoleComponent implements OnInit {
     department: {},
     companyType: '',
   };
-  userType: Array<string> = ['个人'];
+  userType: Array<string> = ['教师'];
   parents: Array<any> = []; //所有一级列表
 
   constructor(
@@ -172,23 +172,20 @@ export class PageRoleComponent implements OnInit {
   }
   async getDepart(
     parent?: string,
-    searchValue?: string,
-    filter?: boolean
+    searchValue?: string
   ): Promise<Array<nodes>> {
+    console.log(searchValue);
     let nodes: any = [];
     let query = new Parse.Query('Department');
-    if (!filter) {
-      query.equalTo('parent', parent ? parent : undefined);
-    }
+    query.equalTo('parent', parent ? parent : this.tbookSer.profile.user.department?.objectId);
     searchValue && query.contains('name', searchValue);
     query.notEqualTo('isDeleted', true);
     query.select('code', 'name', 'branch', 'parent', 'type', 'hasChildren');
     query.descending('createdAt');
     query.equalTo('branch', this.tbookSer.profile.companyType);
-    console.log(searchValue);
-    if (searchValue && searchValue != undefined) {
-      query.equalTo('parent', this.tbookSer.profile.user.department?.objectId);
-    }
+    // if (searchValue && searchValue != undefined) {
+    //   query.equalTo('parent', this.tbookSer.profile.user.department?.objectId);
+    // }
     query.limit(100);
     if (this.activeDepart) query.notEqualTo('objectId', this.activeDepart?.id);
     let res = await query.find();
@@ -200,18 +197,38 @@ export class PageRoleComponent implements OnInit {
         branch: item.get('branch'),
         parent: item.get('parent')?.id, //上级
         isLeaf: !item.get('hasChildren') ? true : false, //是否是最下级
-        type: item.get('type'),
+        type: item.get('type')
       });
     });
     return nodes;
   }
   //搜索
-  async onSearchNodes(e: string, modal?: boolean) {
+  async onSearchNodes(e: string, modal?: boolean, id?:string) {
     if (modal) {
-      this.parentList = await this.getDepart('', e, true);
+      this.parentList = await this.getDepart(id, e);
       return;
     }
-    this.nodes = await this.getDepart('', e, e ? true : false);
+    this.nodes = await this.getDepart('', e);
+  }
+  //搜索失去焦点
+  onblur(type:string){
+    console.log(type);
+    if(type == 'account'){
+      this.modalValue = this.account.department?.title
+    }else if(type == 'editObject'){
+      this.modalValue = this.editObject.parent?.title
+    }
+  }
+  reset(type:string){
+    this.modalValue = ''
+    this.parentList = this.nodes;
+    this.parentMap = []
+    if(type == 'account'){
+      this.account.department = {}
+      this.account.identity = ''
+    }else if(type == 'editObject'){
+      this.editObject.parent = {}
+    }
   }
   //添加成员
   addMember() {
@@ -278,9 +295,9 @@ export class PageRoleComponent implements OnInit {
     let query = Parse.Query.fromJSON('Profile', queryParams);
     query.include('user');
     if(this.tbookSer.profile.identity == '工作联系人'){
-      query.containedIn('identity',['个人','高校联系人','评审专家'])
+      query.containedIn('identity',['教师','高校联系人','评审专家'])
     }else if(this.tbookSer.profile.identity == '高校联系人'){
-      query.containedIn('identity',['个人','评审专家'])
+      query.containedIn('identity',['教师','评审专家'])
     }
     query.notEqualTo('identity', '国家级管理员');
     query.notEqualTo('isDeleted', true);
@@ -339,7 +356,6 @@ export class PageRoleComponent implements OnInit {
               await r.save();
             }
             this.message.success('删除成功');
-            // this.nodes = await this.getDepart();
             this.ngOnInit();
             resolve(true);
           }
@@ -420,7 +436,7 @@ export class PageRoleComponent implements OnInit {
     this.isVisible = true;
     this.resetChange()
   }
-  async onPre(data?: any, index?: number) {
+  async onPre(type:string, data?: any, index?: number) {
     console.log(data);
     if (!data?.key || !data.hasChildren) {
       // this.parentList = await this.getDepart();
@@ -429,11 +445,13 @@ export class PageRoleComponent implements OnInit {
     }
     // if(index == this.parentMap.length-1) return
     this.parentMap.splice((index || 0) + 1);
-    this.parentList = await this.getDepart(data?.key);
+    this.radio = '';
+    this.pushValue(type,this.parentMap[this.parentMap.length - 1])
+    this.parentList = this.parentMap[this.parentMap.length - 1].key == this.tbookSer.profile.user.department?.objectId ? this.nodes : await this.getDepart(data?.parent);
   }
   //选择所属类别下级列表
   async onCheckedDepart(type: string, e: any, checked?: boolean) {
-    this.radio = e.key;
+    this.radio = '';
     console.log(e);
     if (type == 'account') this.account.identity = '';
     this.parentMap = await this.tbookSer.formatNode(e.key);
@@ -447,23 +465,8 @@ export class PageRoleComponent implements OnInit {
         }
       });
     }
-    if (checked) {
-      // this.editObject.name = e.title
-      if (type == 'account') {
-        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.id)
-          ? ['评审专家', '个人']
-          : e.type
-          ? ['评审专家', '高校联系人', '个人']
-          : ['评审专家', '个人'];
-      } else {
-        this.editObject.parent = {
-          title: e.title,
-          id: e.key,
-        };
-        this.editObject.branch = e.branch || e.title;
-      }
+    if (checked || e.isLeaf) {
+      this.pushValue(type,e)
       return;
     }
     if (e.isLeaf) {
@@ -471,6 +474,30 @@ export class PageRoleComponent implements OnInit {
     }
     this.parentList = await this.getDepart(e?.key);
   }
+  modalValue:string = ''
+  //赋值
+  pushValue(type:string, e: any){
+    console.log(e);
+    this.radio = e.key;
+    this.modalValue = e.title
+    if (type == 'account') {
+      this.account.department = { title: e.title, id: e.key };
+      this.account.companyType = e.branch || e.title;
+      if(this.tbookSer.profile.identity == '工作联系人'){
+        this.userType = this.parents.some((item) => e.parent == item.id)
+        ? ['评审专家', '教师','高校联系人']
+        : e.type == '单位'
+        ? ['评审专家', '高校联系人', '教师']
+        : ['评审专家', '教师'];
+      }
+    } else {
+      this.editObject.parent = {
+        title: e.title,
+        id: e.key,
+      };
+      this.editObject.branch = e.branch || e.title;
+    }
+  }
   async handleOk(): Promise<void> {
     if (!this.editObject?.name || !this.editObject.parent?.id) {
       this.message.error('请填写完整信息');
@@ -535,6 +562,7 @@ export class PageRoleComponent implements OnInit {
   }
   handleCancel(): void {
     console.log('Button cancel clicked!');
+    this.modalValue = ''
     this.isVisible = false;
     this.activatedNode = undefined;
     this.parentMap = [];

+ 1 - 1
projects/textbook/src/services/auth.service.ts

@@ -20,7 +20,7 @@ export class AuthServr {
     "工作联系人": '/nav-province-contact',
     "高校联系人": '/nav-province-school-contact',
     "评审专家": '/nav-review',
-    "个人": '/nav-author/manage/space',
+    "教师": '/nav-author/manage/space',
   };
   constructor(
     public router: Router,

+ 4 - 1
projects/textbook/src/services/textbook.ts

@@ -59,13 +59,16 @@ export class textbookServer {
   //格式化链
   async formatNode(id: string): Promise<Array<any>> {
     let query = new Parse.Query('Department');
-    query.select('name', 'parent', 'hasChildren');
+    query.select('name', 'parent', 'hasChildren','type','branch');
     let r = await query.get(id);
     let arr = [
       {
         title: r.get('name'),
         key: r.id,
         hasChildren: r.get('hasChildren'), //是否是最下级
+        type:r.get('type'),
+        branch: r?.get('branch'),
+        parent: r?.get('parent')?.id, //上级
       },
     ];
     if (r?.get('parent')) {