|
@@ -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 = [];
|