|
@@ -189,7 +189,10 @@ export class PageRoleComponent implements OnInit {
|
|
|
type: item.get('type'),
|
|
|
});
|
|
|
});
|
|
|
- parent && nodes.sort((a:any,b:any)=> a.title.localeCompare(b.title, 'zh-Hans-CN'))
|
|
|
+ parent &&
|
|
|
+ nodes.sort((a: any, b: any) =>
|
|
|
+ a.title.localeCompare(b.title, 'zh-Hans-CN')
|
|
|
+ );
|
|
|
return nodes;
|
|
|
}
|
|
|
//搜索
|
|
@@ -276,7 +279,7 @@ export class PageRoleComponent implements OnInit {
|
|
|
},
|
|
|
};
|
|
|
let query = Parse.Query.fromJSON('Profile', queryParams);
|
|
|
- query.include('user');
|
|
|
+ query.include('user', 'user.department');
|
|
|
query.notEqualTo('identity', '国家级管理员');
|
|
|
query.notEqualTo('isDeleted', true);
|
|
|
this.profileLength = await query.count();
|
|
@@ -313,6 +316,7 @@ export class PageRoleComponent implements OnInit {
|
|
|
}
|
|
|
//删除部门
|
|
|
async onDelDepart() {
|
|
|
+ console.log(this.activatedNode);
|
|
|
this.modal.confirm({
|
|
|
nzTitle: '删除',
|
|
|
nzContent: '删除后数据不可恢复,请谨慎操作',
|
|
@@ -327,6 +331,23 @@ export class PageRoleComponent implements OnInit {
|
|
|
if (r?.id) {
|
|
|
r.set('isDeleted', true);
|
|
|
await r.save();
|
|
|
+ if (r?.get('parent')) {
|
|
|
+ let queryDat = new Parse.Query('Department');
|
|
|
+ queryDat.equalTo('parent', r?.get('parent'));
|
|
|
+ queryDat.notEqualTo('isDeleted', true);
|
|
|
+ let res = await queryDat.count();
|
|
|
+ if (res == 0) {
|
|
|
+ let queryDatPat = new Parse.Query('Department');
|
|
|
+ // queryDatPat.equalTo('id',r?.get('parent'));
|
|
|
+ queryDatPat.select('hasChildren');
|
|
|
+ let resParent = await queryDatPat.get(r?.get('parent'));
|
|
|
+ console.log(resParent);
|
|
|
+ if (resParent) {
|
|
|
+ resParent.set('hasChildren', false);
|
|
|
+ await resParent.save();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
this.message.success('删除成功');
|
|
|
this.nodes = await this.getDepart();
|
|
@@ -499,61 +520,69 @@ export class PageRoleComponent implements OnInit {
|
|
|
this.editObject.branch = e.branch || e.title;
|
|
|
}
|
|
|
}
|
|
|
+ isDisabled: boolean = false; //禁用
|
|
|
+ timer: any;
|
|
|
//保存编辑&新增部门
|
|
|
- async handleOk(): Promise<void> {
|
|
|
- if (!this.editObject?.name || !this.editObject.parent?.id) {
|
|
|
- this.message.error('请填写完整信息');
|
|
|
- return;
|
|
|
- }
|
|
|
- if (this.activeDepart?.id && this.editType == 'edit') {
|
|
|
- this.activeDepart.set('name', this.editObject?.name);
|
|
|
- this.activeDepart.set('code', this.editObject?.code);
|
|
|
- this.activeDepart.set('desc', this.editObject.desc);
|
|
|
- this.activeDepart.set('parent', {
|
|
|
- __type: 'Pointer',
|
|
|
- className: 'Department',
|
|
|
- objectId: this.editObject.parent?.id,
|
|
|
- });
|
|
|
- this.activeDepart.set('branch', this.editObject.branch);
|
|
|
- } else {
|
|
|
- let obj = Parse.Object.extend('Department');
|
|
|
- this.activeDepart = new obj();
|
|
|
- this.activeDepart?.set('name', this.editObject?.name);
|
|
|
- this.activeDepart?.set('code', this.editObject?.code);
|
|
|
- this.activeDepart?.set('desc', this.editObject.desc);
|
|
|
- this.activeDepart?.set('parent', {
|
|
|
- __type: 'Pointer',
|
|
|
- className: 'Department',
|
|
|
- objectId: this.editObject.parent?.id,
|
|
|
- });
|
|
|
- this.activeDepart?.set('branch', this.editObject.branch);
|
|
|
- }
|
|
|
- let type;
|
|
|
- let filters = ['出版单位', '教育部直属高校'];
|
|
|
- if (filters.includes(this.editObject.parent?.title)) {
|
|
|
- type = '单位';
|
|
|
- }
|
|
|
- this.activeDepart?.set('type', type);
|
|
|
- await this.activeDepart?.save();
|
|
|
- if (!type && this.activeDepart?.id) {
|
|
|
- //判断添加的是部门还是单位
|
|
|
- let leng = await this.tbookSer.formatNode(this.activeDepart.id);
|
|
|
- if (leng.length > 2) {
|
|
|
- console.log(leng.length);
|
|
|
- if (filters.includes(leng[0].title)) {
|
|
|
- this.activeDepart?.set('type', '部门');
|
|
|
- } else {
|
|
|
- this.activeDepart?.set('type', leng.length > 3 ? '部门' : '单位');
|
|
|
+ handleOk() {
|
|
|
+ if (this.isDisabled) return;
|
|
|
+ if (this.timer) clearTimeout(this.timer);
|
|
|
+ this.timer = setTimeout(async () => {
|
|
|
+ if (!this.editObject?.name || !this.editObject.parent?.id) {
|
|
|
+ this.message.error('请填写完整信息');
|
|
|
+ this.isDisabled = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (this.activeDepart?.id && this.editType == 'edit') {
|
|
|
+ this.activeDepart.set('name', this.editObject?.name);
|
|
|
+ this.activeDepart.set('code', this.editObject?.code);
|
|
|
+ this.activeDepart.set('desc', this.editObject.desc);
|
|
|
+ this.activeDepart.set('parent', {
|
|
|
+ __type: 'Pointer',
|
|
|
+ className: 'Department',
|
|
|
+ objectId: this.editObject.parent?.id,
|
|
|
+ });
|
|
|
+ this.activeDepart.set('branch', this.editObject.branch);
|
|
|
+ } else {
|
|
|
+ let obj = Parse.Object.extend('Department');
|
|
|
+ this.activeDepart = new obj();
|
|
|
+ this.activeDepart?.set('name', this.editObject?.name);
|
|
|
+ this.activeDepart?.set('code', this.editObject?.code);
|
|
|
+ this.activeDepart?.set('desc', this.editObject.desc);
|
|
|
+ this.activeDepart?.set('parent', {
|
|
|
+ __type: 'Pointer',
|
|
|
+ className: 'Department',
|
|
|
+ objectId: this.editObject.parent?.id,
|
|
|
+ });
|
|
|
+ this.activeDepart?.set('branch', this.editObject.branch);
|
|
|
+ }
|
|
|
+ let type;
|
|
|
+ let filters = ['出版单位', '教育部直属高校'];
|
|
|
+ if (filters.includes(this.editObject.parent?.title)) {
|
|
|
+ type = '单位';
|
|
|
+ }
|
|
|
+ this.activeDepart?.set('type', type);
|
|
|
+ await this.activeDepart?.save();
|
|
|
+ if (!type && this.activeDepart?.id) {
|
|
|
+ //判断添加的是部门还是单位
|
|
|
+ let leng = await this.tbookSer.formatNode(this.activeDepart.id);
|
|
|
+ if (leng.length > 2) {
|
|
|
+ console.log(leng.length);
|
|
|
+ if (filters.includes(leng[0].title)) {
|
|
|
+ this.activeDepart?.set('type', '部门');
|
|
|
+ } else {
|
|
|
+ this.activeDepart?.set('type', leng.length > 3 ? '部门' : '单位');
|
|
|
+ }
|
|
|
+ leng.slice();
|
|
|
+ await this.activeDepart?.save();
|
|
|
}
|
|
|
- leng.slice();
|
|
|
- await this.activeDepart?.save();
|
|
|
}
|
|
|
- }
|
|
|
- await this.updateChildren();
|
|
|
- this.isVisible = false;
|
|
|
- this.message.success(this.editType == 'edit' ? '保存' : '添加' + '成功');
|
|
|
- this.activeDepart = undefined;
|
|
|
- this.nodes = await this.getDepart();
|
|
|
+ await this.updateChildren();
|
|
|
+ this.isVisible = false;
|
|
|
+ this.message.success(this.editType == 'edit' ? '保存' : '添加' + '成功');
|
|
|
+ this.activeDepart = undefined;
|
|
|
+ this.nodes = await this.getDepart();
|
|
|
+ this.isDisabled = false;
|
|
|
+ }, 500);
|
|
|
}
|
|
|
//更新上级children字段
|
|
|
async updateChildren() {
|
|
@@ -569,7 +598,9 @@ export class PageRoleComponent implements OnInit {
|
|
|
}
|
|
|
//变更用户部门
|
|
|
async showProfile(data: Parse.Object) {
|
|
|
- let id = data?.get('user')?.get('department')?.id || data?.get('user')?.get('department')?.objectId
|
|
|
+ let id =
|
|
|
+ data?.get('user')?.get('department')?.id ||
|
|
|
+ data?.get('user')?.get('department')?.objectId;
|
|
|
let query = new Parse.Query('Department');
|
|
|
query.include('parent', 'parent.parent');
|
|
|
let r = await query.get(id);
|
|
@@ -719,8 +750,14 @@ export class PageRoleComponent implements OnInit {
|
|
|
}
|
|
|
try {
|
|
|
//如果更换用户之前是工作联系人,卸载对应流程工作联系人
|
|
|
- if(this.profileAccount?.id && this.profileAccount?.get('identity') == '工作联系人'){
|
|
|
- await this.tbookSer.updateProfileSubmitted(this.profileAccount?.id,'del')
|
|
|
+ if (
|
|
|
+ this.profileAccount?.id &&
|
|
|
+ this.profileAccount?.get('identity') == '工作联系人'
|
|
|
+ ) {
|
|
|
+ await this.tbookSer.updateProfileSubmitted(
|
|
|
+ this.profileAccount?.id,
|
|
|
+ 'del'
|
|
|
+ );
|
|
|
}
|
|
|
this.profileAccount?.set('identity', this.profileEdit?.identity);
|
|
|
this.profileAccount?.set('companyType', this.profileEdit?.companyType);
|
|
@@ -731,17 +768,25 @@ export class PageRoleComponent implements OnInit {
|
|
|
objectId: this.profileEdit?.department.id,
|
|
|
});
|
|
|
await this.profileAccount?.get('user')?.save();
|
|
|
- if(this.profileEdit?.identity == '工作联系人' && this.profileAccount?.id){
|
|
|
- let auth = await this.tbookSer.updateProfileSubmitted(this.profileAccount?.id,'save',this.profileEdit?.department.id,this.message)
|
|
|
- if(!auth){
|
|
|
+ if (
|
|
|
+ this.profileEdit?.identity == '工作联系人' &&
|
|
|
+ this.profileAccount?.id
|
|
|
+ ) {
|
|
|
+ let auth = await this.tbookSer.updateProfileSubmitted(
|
|
|
+ this.profileAccount?.id,
|
|
|
+ 'save',
|
|
|
+ this.profileEdit?.department.id,
|
|
|
+ this.message
|
|
|
+ );
|
|
|
+ if (!auth) {
|
|
|
this.isLoadingOne = false;
|
|
|
- return
|
|
|
+ return;
|
|
|
}
|
|
|
}
|
|
|
this.pageIndex = 1;
|
|
|
this.getProfile();
|
|
|
this.isLoadingOne = false;
|
|
|
- this.handleCancel()
|
|
|
+ this.handleCancel();
|
|
|
} catch (err) {
|
|
|
console.log(err);
|
|
|
this.message.error('修改出错,请稍后重试');
|
|
@@ -853,16 +898,23 @@ export class PageRoleComponent implements OnInit {
|
|
|
nzTitle: `确认${data?.id ? '删除该用户' : '批量删除'}吗?`,
|
|
|
nzContent: `${
|
|
|
v
|
|
|
- ? '该用户已经被设置为【'+ v + '】的工作联系人,删除后,你需要重新设置该流程的工作联系人'
|
|
|
+ ? '该用户已经被设置为【' +
|
|
|
+ v +
|
|
|
+ '】的工作联系人,删除后,你需要重新设置该流程的工作联系人'
|
|
|
: '该用户已经提交至申报流程中的教材不会被删除'
|
|
|
}`,
|
|
|
nzOkText: '确认',
|
|
|
nzOkType: 'primary',
|
|
|
nzOkDanger: true,
|
|
|
nzOnOk: async () => {
|
|
|
- let selectedList = this.profiles.filter((item: any) =>
|
|
|
- this.setOfCheckedId.has(item?.id)
|
|
|
- );
|
|
|
+ let selectedList: Array<any> = [];
|
|
|
+ if (!data?.id) {
|
|
|
+ selectedList = this.profiles.filter((item: any) =>
|
|
|
+ this.setOfCheckedId.has(item?.id)
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ selectedList = [data];
|
|
|
+ }
|
|
|
let deletePromiseList = selectedList.map((item: any) => {
|
|
|
return new Promise(async (resolve) => {
|
|
|
await item.get('user')?.destroy();
|