|
@@ -60,7 +60,7 @@ interface depart {
|
|
|
NzModalModule,
|
|
|
NzRadioModule,
|
|
|
NzSelectModule,
|
|
|
- NzSpinModule
|
|
|
+ NzSpinModule,
|
|
|
],
|
|
|
standalone: true,
|
|
|
})
|
|
@@ -86,7 +86,7 @@ export class PageRoleComponent implements OnInit {
|
|
|
loading = false;
|
|
|
pageSize: number = 10;
|
|
|
pageIndex: number = 1;
|
|
|
- profileLength:number = 0
|
|
|
+ profileLength: number = 0;
|
|
|
|
|
|
isVisible: boolean = false;
|
|
|
activatedNode: NzTreeNode | any; //当前选择节点
|
|
@@ -116,8 +116,18 @@ export class PageRoleComponent implements OnInit {
|
|
|
};
|
|
|
userType: Array<string> = ['工作联系人', '评审专家', '高校联系人', '教师'];
|
|
|
parents: Array<any> = []; //所有一级列表
|
|
|
- nzExpandedKeys:any = [] //默认展开节点数
|
|
|
- modalValue:string = ''
|
|
|
+ nzExpandedKeys: any = []; //默认展开节点数
|
|
|
+ modalValue: string = '';
|
|
|
+ childrenList: Array<string> = [];
|
|
|
+
|
|
|
+ profileVisible: boolean = false; //用户部门变更
|
|
|
+ profileAccount: Parse.Object | undefined; //变更部门用户
|
|
|
+ profileEdit: any = {
|
|
|
+ //变更部门用户json
|
|
|
+ department: {},
|
|
|
+ companyType: '',
|
|
|
+ identity: '',
|
|
|
+ };
|
|
|
constructor(
|
|
|
private route: Router,
|
|
|
private activeRoute: ActivatedRoute,
|
|
@@ -138,15 +148,17 @@ export class PageRoleComponent implements OnInit {
|
|
|
}
|
|
|
ngOnInit(): void {
|
|
|
this.activeRoute.paramMap.subscribe(async (params) => {
|
|
|
- let nodes:Array<any> = await this.getDepart();
|
|
|
- this.parents = [...nodes]
|
|
|
- Promise.all(nodes.map(async (item,index)=>{
|
|
|
- nodes[index].children = await this.getDepart(item.key);
|
|
|
- // nodes[index]['isExpanded'] = true
|
|
|
- this.nzExpandedKeys.push(nodes[index]?.key)
|
|
|
- })).then(()=>{
|
|
|
- this.nodes = nodes
|
|
|
- })
|
|
|
+ let nodes: Array<any> = await this.getDepart();
|
|
|
+ this.parents = [...nodes];
|
|
|
+ Promise.all(
|
|
|
+ nodes.map(async (item, index) => {
|
|
|
+ nodes[index].children = await this.getDepart(item.key);
|
|
|
+ // nodes[index]['isExpanded'] = true
|
|
|
+ this.nzExpandedKeys.push(nodes[index]?.key);
|
|
|
+ })
|
|
|
+ ).then(() => {
|
|
|
+ this.nodes = nodes;
|
|
|
+ });
|
|
|
});
|
|
|
}
|
|
|
async getDepart(
|
|
@@ -161,7 +173,7 @@ export class PageRoleComponent implements OnInit {
|
|
|
}
|
|
|
searchValue && query.contains('name', searchValue);
|
|
|
query.notEqualTo('isDeleted', true);
|
|
|
- query.select('code', 'name', 'branch', 'parent', 'type','hasChildren');
|
|
|
+ query.select('code', 'name', 'branch', 'parent', 'type', 'hasChildren');
|
|
|
query.descending('createdAt');
|
|
|
query.limit(2000);
|
|
|
if (this.activeDepart) query.notEqualTo('objectId', this.activeDepart?.id);
|
|
@@ -174,7 +186,7 @@ export class PageRoleComponent implements OnInit {
|
|
|
branch: item.get('branch'),
|
|
|
parent: item.get('parent')?.id, //上级
|
|
|
isLeaf: !item.get('hasChildren'), //是否是最下级
|
|
|
- type: item.get('type')
|
|
|
+ type: item.get('type'),
|
|
|
});
|
|
|
});
|
|
|
return nodes;
|
|
@@ -188,23 +200,27 @@ export class PageRoleComponent implements OnInit {
|
|
|
this.nodes = await this.getDepart('', e, e ? true : false);
|
|
|
}
|
|
|
//搜索失去焦点
|
|
|
- onblur(type:string){
|
|
|
+ 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
|
|
|
+ if (type == 'account' || type == 'profileEdit') {
|
|
|
+ this.modalValue = this.account.department?.title;
|
|
|
+ this.modalValue = this.account.profileEdit?.title;
|
|
|
+ } else if (type == 'editObject') {
|
|
|
+ this.modalValue = this.editObject.parent?.title;
|
|
|
}
|
|
|
}
|
|
|
- reset(type:string){
|
|
|
- this.modalValue = ''
|
|
|
+ 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 = {}
|
|
|
+ this.parentMap = [];
|
|
|
+ if (type == 'account' || type == 'profileEdit') {
|
|
|
+ this.account.department = {};
|
|
|
+ this.account.identity = '';
|
|
|
+
|
|
|
+ this.account.profileEdit = {};
|
|
|
+ this.account.profileEdit = '';
|
|
|
+ } else if (type == 'editObject') {
|
|
|
+ this.editObject.parent = {};
|
|
|
}
|
|
|
}
|
|
|
//展开/合并
|
|
@@ -223,7 +239,10 @@ export class PageRoleComponent implements OnInit {
|
|
|
console.log(this.nodes);
|
|
|
} else {
|
|
|
// if (node.origin.isParent) {
|
|
|
+ this.loading = true;
|
|
|
+ this.pageIndex = 1;
|
|
|
this.currentDepart = node.origin;
|
|
|
+ this.childrenList = await this.tbookSer.getChild(this.currentDepart.key);
|
|
|
this.getProfile();
|
|
|
// }
|
|
|
}
|
|
@@ -231,9 +250,9 @@ export class PageRoleComponent implements OnInit {
|
|
|
async getProfile() {
|
|
|
this.profiles = [];
|
|
|
this.loading = true;
|
|
|
- let childrens = [this.currentDepart.key]
|
|
|
- if(!this.checkedShowFilter){
|
|
|
- childrens = await this.tbookSer.getChild(this.currentDepart.key)
|
|
|
+ let childrens = [this.currentDepart.key];
|
|
|
+ if (!this.checkedShowFilter) {
|
|
|
+ childrens = this.childrenList;
|
|
|
}
|
|
|
let queryParams = {
|
|
|
where: {
|
|
@@ -259,13 +278,13 @@ export class PageRoleComponent implements OnInit {
|
|
|
query.include('user');
|
|
|
query.notEqualTo('identity', '国家级管理员');
|
|
|
query.notEqualTo('isDeleted', true);
|
|
|
- this.profileLength = await query.count()
|
|
|
- query.limit(this.pageSize)
|
|
|
- query.skip((this.pageIndex - 1) * this.pageSize)
|
|
|
+ this.profileLength = await query.count();
|
|
|
+ query.limit(this.pageSize);
|
|
|
+ query.skip((this.pageIndex - 1) * this.pageSize);
|
|
|
let r = await query.find();
|
|
|
this.profiles = r;
|
|
|
this.loading = false;
|
|
|
- this.resetChange()
|
|
|
+ this.resetChange();
|
|
|
}
|
|
|
//分页切换
|
|
|
pageIndexChange(e: any) {
|
|
@@ -273,9 +292,9 @@ export class PageRoleComponent implements OnInit {
|
|
|
this.pageIndex = e;
|
|
|
this.getProfile();
|
|
|
}
|
|
|
- onChecked(){
|
|
|
+ onChecked() {
|
|
|
this.pageIndex = 1;
|
|
|
- this.getProfile()
|
|
|
+ this.getProfile();
|
|
|
}
|
|
|
//搜索触发
|
|
|
onSearch(event: NzFormatEmitEvent) {
|
|
@@ -342,7 +361,7 @@ export class PageRoleComponent implements OnInit {
|
|
|
//添加成员
|
|
|
addMember() {
|
|
|
this.radio = '';
|
|
|
- this.modalValue = ''
|
|
|
+ this.modalValue = '';
|
|
|
this.parentList = this.nodes;
|
|
|
this.account = {
|
|
|
name: '',
|
|
@@ -366,10 +385,10 @@ export class PageRoleComponent implements OnInit {
|
|
|
branch: '',
|
|
|
};
|
|
|
this.radio = '';
|
|
|
- this.modalValue = ''
|
|
|
+ this.modalValue = '';
|
|
|
if (type == 'edit') {
|
|
|
let query = new Parse.Query('Department');
|
|
|
- query.include('parent','parent.parent')
|
|
|
+ query.include('parent', 'parent.parent');
|
|
|
let r = await query.get(this.activatedNode?.key);
|
|
|
this.activeDepart = r;
|
|
|
this.editObject = {
|
|
@@ -382,24 +401,32 @@ export class PageRoleComponent implements OnInit {
|
|
|
},
|
|
|
branch: this.activeDepart.get('branch'),
|
|
|
};
|
|
|
+ this.modalValue = this.activeDepart.get('parent')?.get('name');
|
|
|
+
|
|
|
this.parentMap = await this.tbookSer.formatNode(
|
|
|
this.activeDepart.get('parent')?.id
|
|
|
);
|
|
|
if (r?.get('parent')?.get('parent')?.id) {
|
|
|
- this.parentList = await this.getDepart(r.get('parent')?.get('parent').id);
|
|
|
- }else{
|
|
|
- this.parentList = this.parents
|
|
|
+ this.parentList = await this.getDepart(
|
|
|
+ r.get('parent')?.get('parent').id
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ this.parentList = this.parents;
|
|
|
}
|
|
|
- this.radio = this.activeDepart.get('parent')?.id
|
|
|
+ this.radio = this.activeDepart.get('parent')?.id;
|
|
|
} else if (type == 'add' && this.activatedNode) {
|
|
|
this.editObject.parent = {
|
|
|
title: this.activatedNode.origin.title,
|
|
|
id: this.activatedNode.origin.key,
|
|
|
};
|
|
|
- this.radio = this.activatedNode.origin.key
|
|
|
+ this.radio = this.activatedNode.origin.key;
|
|
|
+ this.modalValue = this.activatedNode.origin.title;
|
|
|
+
|
|
|
this.editObject.branch =
|
|
|
this.activatedNode.origin.branch || this.activatedNode.origin.title;
|
|
|
- this.parentMap = await this.tbookSer.formatNode(this.activatedNode.origin.key);
|
|
|
+ this.parentMap = await this.tbookSer.formatNode(
|
|
|
+ this.activatedNode.origin.key
|
|
|
+ );
|
|
|
if (this.activatedNode?.origin.branch) {
|
|
|
this.parentList = await this.getDepart(
|
|
|
this.activatedNode?.origin.branch
|
|
@@ -425,10 +452,13 @@ export class PageRoleComponent implements OnInit {
|
|
|
async onCheckedDepart(type: string, e: any, checked?: boolean) {
|
|
|
console.log(e);
|
|
|
this.radio = e.key;
|
|
|
- if (type == 'account') this.account.identity = '';
|
|
|
+ if (type == 'account' || type == 'profileEdit') {
|
|
|
+ this.account.identity = '';
|
|
|
+ this.profileEdit.identity = '';
|
|
|
+ }
|
|
|
this.parentMap = await this.tbookSer.formatNode(e.key);
|
|
|
if (checked || e.isLeaf) {
|
|
|
- this.pushValue(type,e)
|
|
|
+ this.pushValue(type, e);
|
|
|
return;
|
|
|
}
|
|
|
if (e.isLeaf) {
|
|
@@ -437,16 +467,29 @@ export class PageRoleComponent implements OnInit {
|
|
|
this.parentList = await this.getDepart(e?.key);
|
|
|
}
|
|
|
//赋值
|
|
|
- pushValue(type:string, e: any){
|
|
|
- this.modalValue = e.title
|
|
|
+ pushValue(type: string, e: any) {
|
|
|
+ this.modalValue = e.title;
|
|
|
+ this.radio = e.key;
|
|
|
if (type == 'account' && e.parent) {
|
|
|
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 if (type == 'profileEdit' && e.parent) {
|
|
|
+ this.profileEdit.department = { title: e.title, id: e.key };
|
|
|
+ this.profileEdit.companyType = e.branch || e.title;
|
|
|
+ this.userType = this.parents.some((item) => e.parent == item.key)
|
|
|
+ ? !e.type
|
|
|
+ ? ['工作联系人']
|
|
|
+ : ['评审专家', '工作联系人', '教师']
|
|
|
+ : e.type == '单位'
|
|
|
+ ? ['评审专家', '高校联系人', '教师']
|
|
|
+ : ['评审专家', '教师'];
|
|
|
} else {
|
|
|
this.editObject.parent = {
|
|
|
title: e.title,
|
|
@@ -455,6 +498,7 @@ export class PageRoleComponent implements OnInit {
|
|
|
this.editObject.branch = e.branch || e.title;
|
|
|
}
|
|
|
}
|
|
|
+ //保存编辑&新增部门
|
|
|
async handleOk(): Promise<void> {
|
|
|
if (!this.editObject?.name || !this.editObject.parent?.id) {
|
|
|
this.message.error('请填写完整信息');
|
|
@@ -483,24 +527,24 @@ export class PageRoleComponent implements OnInit {
|
|
|
});
|
|
|
this.activeDepart?.set('branch', this.editObject.branch);
|
|
|
}
|
|
|
- let type
|
|
|
- let filters = ['出版单位','教育部直属高校']
|
|
|
- if(filters.includes(this.editObject.parent?.title)){
|
|
|
- type = '单位'
|
|
|
+ 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){
|
|
|
+ if (!type && this.activeDepart?.id) {
|
|
|
//判断添加的是部门还是单位
|
|
|
- let leng = await this.tbookSer.formatNode(this.activeDepart.id)
|
|
|
- if(leng.length > 2){
|
|
|
+ let leng = await this.tbookSer.formatNode(this.activeDepart.id);
|
|
|
+ if (leng.length > 2) {
|
|
|
console.log(leng.length);
|
|
|
- if(filters.includes(leng[0].title)){
|
|
|
+ if (filters.includes(leng[0].title)) {
|
|
|
this.activeDepart?.set('type', '部门');
|
|
|
- }else{
|
|
|
- this.activeDepart?.set('type',leng.length > 3 ? '部门' : '单位');
|
|
|
+ } else {
|
|
|
+ this.activeDepart?.set('type', leng.length > 3 ? '部门' : '单位');
|
|
|
}
|
|
|
- leng.slice()
|
|
|
+ leng.slice();
|
|
|
await this.activeDepart?.save();
|
|
|
}
|
|
|
}
|
|
@@ -514,7 +558,7 @@ export class PageRoleComponent implements OnInit {
|
|
|
async updateChildren() {
|
|
|
let query = new Parse.Query('Department');
|
|
|
query.equalTo('objectId', this.editObject.parent?.id);
|
|
|
- query.select('hasChildren')
|
|
|
+ query.select('hasChildren');
|
|
|
let r = await query.first();
|
|
|
if (r?.id && !r.get('hasChildren')) {
|
|
|
r?.set('hasChildren', true);
|
|
@@ -522,6 +566,44 @@ export class PageRoleComponent implements OnInit {
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
+ //变更用户部门
|
|
|
+ async showProfile(data: Parse.Object) {
|
|
|
+ let query = new Parse.Query('Department');
|
|
|
+ query.include('parent', 'parent.parent');
|
|
|
+ let r = await query.get(data?.get('user')?.get('department')?.id);
|
|
|
+ this.parentMap = await this.tbookSer.formatNode(
|
|
|
+ data?.get('user')?.get('department')?.id
|
|
|
+ );
|
|
|
+ if (r?.get('parent')?.id) {
|
|
|
+ this.parentList = await this.getDepart(r.get('parent').id);
|
|
|
+ } else {
|
|
|
+ this.parentList = this.parents;
|
|
|
+ }
|
|
|
+ this.radio = data?.get('user')?.get('department')?.id;
|
|
|
+ this.profileAccount = data;
|
|
|
+ this.profileEdit = {
|
|
|
+ //变更部门用户json
|
|
|
+ department: {
|
|
|
+ key: r?.id,
|
|
|
+ title: r?.get('title'),
|
|
|
+ },
|
|
|
+ companyType: data?.get('companyType'),
|
|
|
+ identity: data?.get('identity'),
|
|
|
+ };
|
|
|
+ let parms = {
|
|
|
+ title: r?.get('name'),
|
|
|
+ key: r?.id,
|
|
|
+ type: r?.get('type'),
|
|
|
+ parent: r?.get('parent')?.id,
|
|
|
+ branch: r?.get('branch'),
|
|
|
+ };
|
|
|
+ console.log(parms);
|
|
|
+
|
|
|
+ this.pushValue('profileEdit', parms);
|
|
|
+
|
|
|
+ this.modalValue = r?.get('name');
|
|
|
+ this.profileVisible = true;
|
|
|
+ }
|
|
|
handleCancel(): void {
|
|
|
console.log('Button cancel clicked!');
|
|
|
this.isVisible = false;
|
|
@@ -529,7 +611,23 @@ export class PageRoleComponent implements OnInit {
|
|
|
this.parentMap = [];
|
|
|
|
|
|
this.accountIsVisible = false;
|
|
|
- this.account = null;
|
|
|
+ this.account = {
|
|
|
+ name: '',
|
|
|
+ phone: '',
|
|
|
+ email: '',
|
|
|
+ password: '',
|
|
|
+ identity: '',
|
|
|
+ department: {},
|
|
|
+ companyType: '',
|
|
|
+ };
|
|
|
+ this.profileVisible = false;
|
|
|
+ this.profileAccount = undefined;
|
|
|
+ this.profileEdit = {
|
|
|
+ //变更部门用户json
|
|
|
+ department: {},
|
|
|
+ companyType: '',
|
|
|
+ identity: '',
|
|
|
+ };
|
|
|
}
|
|
|
|
|
|
/* 组织 */
|
|
@@ -541,25 +639,25 @@ export class PageRoleComponent implements OnInit {
|
|
|
}
|
|
|
|
|
|
randomPassword() {
|
|
|
- this.account.password = this.tbookSer.randomPassword()
|
|
|
+ this.account.password = this.tbookSer.randomPassword();
|
|
|
console.log(this.account.password);
|
|
|
}
|
|
|
/* 添加账号 */
|
|
|
- isLoadingOne:boolean = false
|
|
|
- async accountComplete(){
|
|
|
- if(this.isLoadingOne) return
|
|
|
- this.isLoadingOne = true
|
|
|
+ isLoadingOne: boolean = false;
|
|
|
+ async accountComplete() {
|
|
|
+ if (this.isLoadingOne) return;
|
|
|
+ this.isLoadingOne = true;
|
|
|
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{
|
|
|
+ try {
|
|
|
let obj = Parse.Object.extend('_User');
|
|
|
- let user = new obj()
|
|
|
+ let user = new obj();
|
|
|
user?.set('username', this.account?.email || this.account?.phone);
|
|
|
user?.set('name', this.account?.name);
|
|
|
user?.set('phone', this.account?.phone);
|
|
@@ -571,57 +669,103 @@ export class PageRoleComponent implements OnInit {
|
|
|
className: 'Department',
|
|
|
objectId: this.account.department?.id,
|
|
|
});
|
|
|
- let u = await user.save()
|
|
|
+ let u = await user.save();
|
|
|
let p = Parse.Object.extend('Profile');
|
|
|
- let profile = new p()
|
|
|
+ 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.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: '',
|
|
|
- nzOnOk: () =>{
|
|
|
- this.currentDepart && this.getProfile()
|
|
|
+ nzOnOk: () => {
|
|
|
+ this.currentDepart && this.getProfile();
|
|
|
},
|
|
|
});
|
|
|
+ } catch (err: any) {
|
|
|
+ console.warn('添加用户错误', err);
|
|
|
+ this.isLoadingOne = false;
|
|
|
+ this.message.error(
|
|
|
+ err?.Error || '错误:请检查用户邮箱或手机号是否已存在'
|
|
|
+ );
|
|
|
+ return;
|
|
|
}
|
|
|
- catch(err:any){
|
|
|
- console.warn('添加用户错误',err);
|
|
|
- this.isLoadingOne = false
|
|
|
- this.message.error(err?.Error || '错误:请检查用户邮箱或手机号是否已存在');
|
|
|
+ }
|
|
|
+
|
|
|
+ //保存更新部门
|
|
|
+ async updateProfile() {
|
|
|
+ if (this.isLoadingOne) return;
|
|
|
+ this.isLoadingOne = true;
|
|
|
+ if (
|
|
|
+ !this.profileEdit?.department.id ||
|
|
|
+ !this.profileEdit?.department?.title ||
|
|
|
+ !this.profileEdit?.identity ||
|
|
|
+ !this.profileEdit.companyType
|
|
|
+ ) {
|
|
|
+ this.message.warning('填写信息不完整');
|
|
|
+ this.isLoadingOne = false;
|
|
|
return;
|
|
|
}
|
|
|
+ try {
|
|
|
+ this.profileAccount?.set('identity', this.profileEdit?.identity);
|
|
|
+ this.profileAccount?.set('companyType', this.profileEdit?.companyType);
|
|
|
+ await this.profileAccount?.save();
|
|
|
+ this.profileAccount?.get('user')?.set('department', {
|
|
|
+ __type: 'Pointer',
|
|
|
+ className: 'Department',
|
|
|
+ objectId: this.profileEdit?.department.id,
|
|
|
+ });
|
|
|
+ await this.profileAccount?.get('user')?.save();
|
|
|
+ this.pageIndex = 1;
|
|
|
+ this.getProfile();
|
|
|
+ this.isLoadingOne = false;
|
|
|
+ this.handleCancel()
|
|
|
+ } catch (err) {
|
|
|
+ console.log(err);
|
|
|
+ this.message.error('修改出错,请稍后重试');
|
|
|
+ this.isLoadingOne = false;
|
|
|
+ }
|
|
|
}
|
|
|
- async authVrifly():Promise< boolean | undefined>{
|
|
|
+
|
|
|
+ async authVrifly(): Promise<boolean | undefined> {
|
|
|
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(!this.account?.name|| !this.account.department?.id || !this.account.password
|
|
|
- || !this.account.phone || !this.account?.email){
|
|
|
+ if (
|
|
|
+ !this.account?.name ||
|
|
|
+ !this.account.department?.id ||
|
|
|
+ !this.account.password ||
|
|
|
+ !this.account.phone ||
|
|
|
+ !this.account?.email
|
|
|
+ ) {
|
|
|
this.message.warning('请填写必填项');
|
|
|
- return
|
|
|
+ return;
|
|
|
}
|
|
|
- if(!this.account.identity){
|
|
|
- this.message.error("请选择人员类型");
|
|
|
+ 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("请填写正确手机号");
|
|
|
+ let a = /^(?:(?:\+|00)86)?1[3-9]\d{9}$/;
|
|
|
+ if (this.account.phone && !String(this.account.phone).match(a)) {
|
|
|
+ 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){
|
|
@@ -629,32 +773,78 @@ export class PageRoleComponent implements OnInit {
|
|
|
// return;
|
|
|
// }
|
|
|
console.log(this.account.password);
|
|
|
- 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;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
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.success("移除成功");
|
|
|
- this.getProfile();
|
|
|
+ // async removeBranch(data: Parse.Object) {
|
|
|
+ // if (data?.get('user')?.id) {
|
|
|
+ // data?.get('user')?.set('department', null);
|
|
|
+ // await data?.get('user')?.save();
|
|
|
+ // this.message.success('移除成功');
|
|
|
+ // 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'),
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ //删除用户
|
|
|
+ async deleteSelected(data?: Parse.Object) {
|
|
|
+ let filters = [];
|
|
|
+ if (data?.id) {
|
|
|
+ filters = [data?.id];
|
|
|
+ } else {
|
|
|
+ filters = Array.from(this.setOfCheckedId);
|
|
|
}
|
|
|
- }
|
|
|
- removeBranchAll(){
|
|
|
+ console.log(filters);
|
|
|
+
|
|
|
+ let v = await this.tbookSer.getEduProcessProf(filters);
|
|
|
this.modal.confirm({
|
|
|
- nzTitle: '批量移除',
|
|
|
- nzContent: `请谨慎操作`,
|
|
|
+ nzTitle: `确认${data?.id ? '批量删除' : '删除该用户'}吗?`,
|
|
|
+ nzContent: `${
|
|
|
+ v
|
|
|
+ ? '该用户已经被设置为【流程名称】的工作联系人,删除后,你需要重新设置该流程的工作联系人'
|
|
|
+ : '该用户已经提交至申报流程中的教材不会被删除'
|
|
|
+ }`,
|
|
|
nzOkText: '确认',
|
|
|
nzOkType: 'primary',
|
|
|
nzOkDanger: true,
|
|
@@ -662,27 +852,25 @@ export class PageRoleComponent implements OnInit {
|
|
|
let selectedList = this.profiles.filter((item: any) =>
|
|
|
this.setOfCheckedId.has(item?.id)
|
|
|
);
|
|
|
- let romovePromiseList = selectedList.map((item: any) => {
|
|
|
+ let deletePromiseList = selectedList.map((item: any) => {
|
|
|
return new Promise(async (resolve) => {
|
|
|
- item?.get('user')?.set('department',null)
|
|
|
- await item?.get('user')?.save()
|
|
|
- resolve(true)
|
|
|
+ await item.get('user')?.destroy();
|
|
|
+ await item.destroy();
|
|
|
+ resolve(true);
|
|
|
});
|
|
|
});
|
|
|
try {
|
|
|
- await Promise.all(romovePromiseList);
|
|
|
- this.message.error("移除成功");
|
|
|
+ await Promise.all(deletePromiseList);
|
|
|
this.getProfile();
|
|
|
- this.resetChange()
|
|
|
+ this.resetChange();
|
|
|
} catch (err) {}
|
|
|
},
|
|
|
nzCancelText: '取消',
|
|
|
nzOnCancel: () => console.log('Cancel'),
|
|
|
});
|
|
|
}
|
|
|
- resetChange(){
|
|
|
+ resetChange() {
|
|
|
this.setOfCheckedId = new Set<string>();
|
|
|
this.checkedAll = false;
|
|
|
}
|
|
|
-
|
|
|
}
|