|
@@ -24,6 +24,7 @@ import { NzCheckboxModule } from 'ng-zorro-antd/checkbox';
|
|
|
import { NzEmptyModule } from 'ng-zorro-antd/empty';
|
|
|
import { NzRadioModule } from 'ng-zorro-antd/radio';
|
|
|
import { NzMessageService } from 'ng-zorro-antd/message';
|
|
|
+import { NzSelectModule } from 'ng-zorro-antd/select';
|
|
|
interface nodes {
|
|
|
title: string;
|
|
|
key: string;
|
|
@@ -56,6 +57,7 @@ interface depart {
|
|
|
NzEmptyModule,
|
|
|
NzModalModule,
|
|
|
NzRadioModule,
|
|
|
+ NzSelectModule,
|
|
|
],
|
|
|
standalone: true,
|
|
|
})
|
|
@@ -73,7 +75,7 @@ export class PageRoleComponent implements OnInit {
|
|
|
nodes: Array<nodes | any> = [];
|
|
|
currentDepart: nodes | any = null;
|
|
|
|
|
|
- profiles: Array<any> = [];
|
|
|
+ profiles: Array<Parse.Object> = [];
|
|
|
checkedShowFilter: boolean = false;
|
|
|
|
|
|
checkedAll: boolean = false; //全选
|
|
@@ -103,9 +105,10 @@ export class PageRoleComponent implements OnInit {
|
|
|
email: '',
|
|
|
password: '',
|
|
|
identity: '',
|
|
|
- department: '',
|
|
|
+ department: {},
|
|
|
companyType: '',
|
|
|
};
|
|
|
+ userType: Array<string> = ['工作联系人', '评审专家', '高校联系人', '个人'];
|
|
|
|
|
|
constructor(
|
|
|
private route: Router,
|
|
@@ -173,20 +176,6 @@ export class PageRoleComponent implements OnInit {
|
|
|
}
|
|
|
this.nodes = await this.getDepart('', e, e ? true : false);
|
|
|
}
|
|
|
- //添加成员
|
|
|
- addMember() {
|
|
|
- // this.message.warning('权限灰度中')
|
|
|
- this.account = {
|
|
|
- name: '',
|
|
|
- phone: '',
|
|
|
- email: '',
|
|
|
- password: '',
|
|
|
- identity: '',
|
|
|
- department: '',
|
|
|
- companyType: '',
|
|
|
- };
|
|
|
- this.accountIsVisible = true;
|
|
|
- }
|
|
|
//展开/合并
|
|
|
async nzEvent(event: NzFormatEmitEvent): Promise<void> {
|
|
|
console.log(event);
|
|
@@ -236,13 +225,13 @@ export class PageRoleComponent implements OnInit {
|
|
|
query.notEqualTo('identity', '国家级管理员');
|
|
|
query.notEqualTo('isDeleted', true);
|
|
|
let r = await query.find();
|
|
|
- let profiles: any[] = [];
|
|
|
- r.forEach((item) => {
|
|
|
- let _item = item.toJSON();
|
|
|
- _item['checked'] = false;
|
|
|
- profiles.push(_item);
|
|
|
- });
|
|
|
- this.profiles = profiles;
|
|
|
+ // let profiles: any[] = [];
|
|
|
+ // r.forEach((item) => {
|
|
|
+ // let _item = item.toJSON();
|
|
|
+ // _item['checked'] = false;
|
|
|
+ // profiles.push(_item);
|
|
|
+ // });
|
|
|
+ this.profiles = r;
|
|
|
this.loading = false;
|
|
|
}
|
|
|
//搜索触发
|
|
@@ -262,24 +251,24 @@ export class PageRoleComponent implements OnInit {
|
|
|
async onDelDepart() {
|
|
|
this.modal.confirm({
|
|
|
nzTitle: '删除',
|
|
|
- nzContent:'删除后数据不可恢复,请谨慎操作',
|
|
|
+ nzContent: '删除后数据不可恢复,请谨慎操作',
|
|
|
nzOkText: '确认',
|
|
|
nzOkType: 'primary',
|
|
|
nzOkDanger: true,
|
|
|
nzOnOk: async () => {
|
|
|
- new Promise(async(resolve, reject) => {
|
|
|
- if(this.activatedNode){
|
|
|
+ new Promise(async (resolve, reject) => {
|
|
|
+ if (this.activatedNode) {
|
|
|
let query = new Parse.Query('Department');
|
|
|
let r = await query.get(this.activatedNode?.key);
|
|
|
- if(r?.id){
|
|
|
- r.set('isDeleted',true)
|
|
|
- await r.save()
|
|
|
+ if (r?.id) {
|
|
|
+ r.set('isDeleted', true);
|
|
|
+ await r.save();
|
|
|
}
|
|
|
- this.message.success('删除成功')
|
|
|
+ this.message.success('删除成功');
|
|
|
this.nodes = await this.getDepart();
|
|
|
- resolve(true)
|
|
|
+ resolve(true);
|
|
|
}
|
|
|
- }).catch(() => console.log('Oops errors!'))
|
|
|
+ }).catch(() => console.log('Oops errors!'));
|
|
|
},
|
|
|
nzCancelText: '取消',
|
|
|
nzOnCancel: () => console.log('Cancel'),
|
|
@@ -287,21 +276,38 @@ export class PageRoleComponent implements OnInit {
|
|
|
}
|
|
|
|
|
|
onAllChecked(checked: boolean): void {
|
|
|
- console.log(checked);
|
|
|
- this.profiles = this.profiles.map((item) => {
|
|
|
- item.checked = checked;
|
|
|
- return item;
|
|
|
+ this.profiles.forEach((item) => {
|
|
|
+ if (checked) {
|
|
|
+ this.setOfCheckedId.add(item.id);
|
|
|
+ } else {
|
|
|
+ this.setOfCheckedId.delete(item.id);
|
|
|
+ }
|
|
|
});
|
|
|
this.checkedAll = checked;
|
|
|
}
|
|
|
onItemChecked(id: string, e: boolean) {
|
|
|
- let checkedAll = true;
|
|
|
- this.profiles = this.profiles.map((item) => {
|
|
|
- if (id == item.objectId) item.checked = e;
|
|
|
- if (!item.checked) checkedAll = false;
|
|
|
- return item;
|
|
|
- });
|
|
|
- this.checkedAll = checkedAll;
|
|
|
+ if (e) {
|
|
|
+ this.setOfCheckedId.add(id);
|
|
|
+ } else {
|
|
|
+ this.setOfCheckedId.delete(id);
|
|
|
+ }
|
|
|
+ this.checkedAll = this.profiles.every((item) =>
|
|
|
+ this.setOfCheckedId.has(item.id)
|
|
|
+ );
|
|
|
+ }
|
|
|
+ //添加成员
|
|
|
+ addMember() {
|
|
|
+ this.parentList = this.nodes;
|
|
|
+ this.account = {
|
|
|
+ name: '',
|
|
|
+ phone: '',
|
|
|
+ email: '',
|
|
|
+ password: '',
|
|
|
+ identity: '',
|
|
|
+ department: {},
|
|
|
+ companyType: '',
|
|
|
+ };
|
|
|
+ this.accountIsVisible = true;
|
|
|
}
|
|
|
//新建打开弹窗
|
|
|
async showModalDepart(type: string) {
|
|
@@ -327,19 +333,22 @@ export class PageRoleComponent implements OnInit {
|
|
|
},
|
|
|
branch: this.activeDepart.get('branch'),
|
|
|
};
|
|
|
- this.parentMap = await this.formatNode(this.activeDepart.get('parent')?.id);
|
|
|
+ this.parentMap = await this.formatNode(
|
|
|
+ this.activeDepart.get('parent')?.id
|
|
|
+ );
|
|
|
if (this.activatedNode?.parentNode?.origin?.parentNode?.origin.key) {
|
|
|
this.parentList = await this.getDepart(
|
|
|
this.activatedNode?.parentNode?.origin?.parentNode?.origin.key
|
|
|
);
|
|
|
}
|
|
|
- }else if(type == 'add' && this.activatedNode){
|
|
|
+ } else if (type == 'add' && this.activatedNode) {
|
|
|
console.log(this.activatedNode);
|
|
|
this.editObject.parent = {
|
|
|
- title: this.activatedNode.origin.title,
|
|
|
- id: this.activatedNode.origin.key,
|
|
|
+ title: this.activatedNode.origin.title,
|
|
|
+ id: this.activatedNode.origin.key,
|
|
|
};
|
|
|
- this.editObject.branch = this.activatedNode.origin.branch || this.activatedNode.origin.title
|
|
|
+ this.editObject.branch =
|
|
|
+ this.activatedNode.origin.branch || this.activatedNode.origin.title;
|
|
|
this.parentMap = await this.formatNode(this.activatedNode.origin.key);
|
|
|
if (this.activatedNode?.parentNode?.origin.key) {
|
|
|
this.parentList = await this.getDepart(
|
|
@@ -378,60 +387,65 @@ export class PageRoleComponent implements OnInit {
|
|
|
this.parentList = await this.getDepart(data?.key);
|
|
|
}
|
|
|
//选择所属类别下级列表
|
|
|
- async onCheckedDepart(e: any, checked?: boolean) {
|
|
|
+ async onCheckedDepart(type: string, e: any, checked?: boolean) {
|
|
|
this.radio = e.key;
|
|
|
console.log(this.radio);
|
|
|
this.parentMap = await this.formatNode(e.key);
|
|
|
if (checked) {
|
|
|
// this.editObject.name = e.title
|
|
|
- this.editObject.parent = {
|
|
|
- title: e.title,
|
|
|
- id: e.key,
|
|
|
- };
|
|
|
- this.editObject.branch = e.branch || e.title;
|
|
|
+ if (type == 'account') {
|
|
|
+ this.account.department = { title: e.title, id: e.key };
|
|
|
+ this.account.companyType = e.branch || e.title;
|
|
|
+ } else {
|
|
|
+ this.editObject.parent = {
|
|
|
+ title: e.title,
|
|
|
+ id: e.key,
|
|
|
+ };
|
|
|
+ this.editObject.branch = e.branch || e.title;
|
|
|
+ }
|
|
|
return;
|
|
|
}
|
|
|
if (e.isLeaf) {
|
|
|
return;
|
|
|
}
|
|
|
- this.parentMap.push({
|
|
|
- title: e.title,
|
|
|
- key: e.key,
|
|
|
- });
|
|
|
+ // this.parentMap.push({
|
|
|
+ // title: e.title,
|
|
|
+ // key: e.key,
|
|
|
+ // });
|
|
|
this.parentList = await this.getDepart(e?.key);
|
|
|
}
|
|
|
- async handleOk():Promise<void> {
|
|
|
- if(!this.editObject?.name || !this.editObject.parent?.id){
|
|
|
- this.message.error('请填写完整信息')
|
|
|
- return
|
|
|
+ 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',{
|
|
|
+ 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',{
|
|
|
+ });
|
|
|
+ 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)
|
|
|
+ });
|
|
|
+ this.activeDepart?.set('branch', this.editObject.branch);
|
|
|
}
|
|
|
- await this.activeDepart?.save()
|
|
|
+ await this.activeDepart?.save();
|
|
|
this.isVisible = false;
|
|
|
- this.message.success(this.editType == 'edit' ? '保存' : '添加' + '成功')
|
|
|
- this.activeDepart = undefined
|
|
|
+ this.message.success(this.editType == 'edit' ? '保存' : '添加' + '成功');
|
|
|
+ this.activeDepart = undefined;
|
|
|
this.nodes = await this.getDepart();
|
|
|
}
|
|
|
|
|
@@ -452,4 +466,116 @@ export class PageRoleComponent implements OnInit {
|
|
|
goDateil(id: string) {
|
|
|
this.route.navigate(['/nav-admin/manage/user/edit', { id: id }]);
|
|
|
}
|
|
|
+
|
|
|
+ randomPassword() {
|
|
|
+ let sCode =
|
|
|
+ 'A,B,C,E,F,G,H,J,K,L,M,N,P,Q,R,S,T,W,X,Y,Z,1,2,3,4,5,6,7,8,9,0,q,w,e,r,t,y,u,i,o,p,a,s,d,f,g,h,j,k,l,z,x,c,v,b,n,m';
|
|
|
+ let aCode = sCode.split(',');
|
|
|
+ let aLength = aCode.length; //获取到数组的长度
|
|
|
+ let str = []
|
|
|
+ for (let i = 0; i <= 16; i++) {
|
|
|
+ let j = Math.floor(Math.random() * aLength); //获取到随机的索引值
|
|
|
+ let txt = aCode[j]; //得到随机的一个内容
|
|
|
+ str.push(txt)
|
|
|
+ }
|
|
|
+ this.account.password = str.join('')
|
|
|
+ console.log(this.account.password);
|
|
|
+ }
|
|
|
+ /* 添加账号 */
|
|
|
+ async accountComplete(){
|
|
|
+ if(!this.account?.name.trim() || !this.account.department?.id || !this.account.password.trim()){
|
|
|
+ this.message.warning('请填写必填项');
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(!this.account.identity){
|
|
|
+ this.message.error("请选择人员类型");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let a = /^(?:(?:\+|00)86)?1[3-9]\d{9}$/
|
|
|
+ if(this.account.phone && !String(this.account.phone).match(a)){
|
|
|
+ this.message.error("请填写正确手机号");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ try{
|
|
|
+ let obj = Parse.Object.extend('_User');
|
|
|
+ let user = new obj()
|
|
|
+ user?.set('username', this.account?.email);
|
|
|
+ user?.set('name', this.account?.name);
|
|
|
+ user?.set('phone', this.account?.phone);
|
|
|
+ user?.set('email', this.account?.email);
|
|
|
+ user?.set('password', this.account.password);
|
|
|
+ user?.set('accountState', '已认证');
|
|
|
+ user?.set('department', {
|
|
|
+ __type: 'Pointer',
|
|
|
+ className: 'Department',
|
|
|
+ objectId: this.account.department?.id,
|
|
|
+ });
|
|
|
+ let u = await user.save()
|
|
|
+ let p = Parse.Object.extend('Profile');
|
|
|
+ let profile = new p()
|
|
|
+ profile?.set('user', u?.toPointer());
|
|
|
+ profile?.set('companyType', this.account.companyType);
|
|
|
+ profile?.set('email', this.account.email);
|
|
|
+ profile?.set('identity', this.account.identity);
|
|
|
+ let res = await profile?.save();
|
|
|
+ this.accountIsVisible = false;
|
|
|
+ this.account = null;
|
|
|
+ this.modal.success({
|
|
|
+ nzTitle: '添加成功',
|
|
|
+ nzContent: '',
|
|
|
+ nzOnOk: () =>{
|
|
|
+ this.currentDepart && this.getProfile()
|
|
|
+ },
|
|
|
+ });
|
|
|
+ }
|
|
|
+ catch(err:any){
|
|
|
+ console.warn('添加用户错误',err);
|
|
|
+ this.message.error(err?.Error || '错误:请检查用户邮箱是否已存在');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ setOfCheckedId = new Set<string>();
|
|
|
+ //移除部门
|
|
|
+ async removeBranch(data:Parse.Object){
|
|
|
+ if(data?.get('user')?.id){
|
|
|
+ data?.get('user')?.set('department',null)
|
|
|
+ await data?.get('user')?.save()
|
|
|
+ this.message.error("移除成功");
|
|
|
+ this.getProfile();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ removeBranchAll(){
|
|
|
+ this.modal.confirm({
|
|
|
+ nzTitle: '批量移除',
|
|
|
+ nzContent: `请谨慎操作`,
|
|
|
+ nzOkText: '确认',
|
|
|
+ nzOkType: 'primary',
|
|
|
+ nzOkDanger: true,
|
|
|
+ nzOnOk: async () => {
|
|
|
+ let selectedList = this.profiles.filter((item: any) =>
|
|
|
+ this.setOfCheckedId.has(item?.id)
|
|
|
+ );
|
|
|
+ let romovePromiseList = selectedList.map((item: any) => {
|
|
|
+ return new Promise(async (resolve) => {
|
|
|
+ item?.get('user')?.set('department',null)
|
|
|
+ await item?.get('user')?.save()
|
|
|
+ resolve(true)
|
|
|
+ });
|
|
|
+ });
|
|
|
+ try {
|
|
|
+ await Promise.all(romovePromiseList);
|
|
|
+ this.message.error("移除成功");
|
|
|
+ this.getProfile();
|
|
|
+ this.resetChange()
|
|
|
+ } catch (err) {}
|
|
|
+ },
|
|
|
+ nzCancelText: '取消',
|
|
|
+ nzOnCancel: () => console.log('Cancel'),
|
|
|
+ });
|
|
|
+ }
|
|
|
+ resetChange(){
|
|
|
+ this.setOfCheckedId = new Set<string>();
|
|
|
+ this.checkedAll = false;
|
|
|
+ }
|
|
|
+
|
|
|
}
|