|
@@ -10,7 +10,7 @@ import { NzSpaceModule } from 'ng-zorro-antd/space';
|
|
|
import { NzPageHeaderModule } from 'ng-zorro-antd/page-header';
|
|
|
import { NzBreadCrumbModule } from 'ng-zorro-antd/breadcrumb';
|
|
|
import { CommonCompModule } from '../../../services/common.modules';
|
|
|
-import { NzModalModule } from 'ng-zorro-antd/modal';
|
|
|
+import { NzModalModule, NzModalService } from 'ng-zorro-antd/modal';
|
|
|
import {
|
|
|
NzFormatEmitEvent,
|
|
|
NzTreeModule,
|
|
@@ -28,7 +28,7 @@ interface nodes {
|
|
|
title: string;
|
|
|
key: string;
|
|
|
isLeaf?: boolean;
|
|
|
- isParent?: boolean;
|
|
|
+ branch?: string;
|
|
|
children?: Array<any>;
|
|
|
}
|
|
|
interface depart {
|
|
@@ -69,7 +69,7 @@ export class PageRoleComponent implements OnInit {
|
|
|
queryParams: any | undefined;
|
|
|
fieldsArray: Array<any> | undefined;
|
|
|
searchValue: string = ''; //搜索内容
|
|
|
- searchValueNode:string = ''
|
|
|
+ searchValueNode: string = '';
|
|
|
nodes: Array<nodes | any> = [];
|
|
|
currentDepart: nodes | any = null;
|
|
|
|
|
@@ -93,13 +93,26 @@ export class PageRoleComponent implements OnInit {
|
|
|
};
|
|
|
parentMap: Array<any> = [];
|
|
|
parentList: Array<any> = [];
|
|
|
- radio:string = ''
|
|
|
+ radio: string = '';
|
|
|
+
|
|
|
+ /* 添加账号 */
|
|
|
+ accountIsVisible: boolean = false;
|
|
|
+ account: any = {
|
|
|
+ name: '',
|
|
|
+ phone: '',
|
|
|
+ email: '',
|
|
|
+ password: '',
|
|
|
+ identity: '',
|
|
|
+ department: '',
|
|
|
+ companyType: '',
|
|
|
+ };
|
|
|
|
|
|
constructor(
|
|
|
private route: Router,
|
|
|
private activeRoute: ActivatedRoute,
|
|
|
private nzContextMenuService: NzContextMenuService,
|
|
|
- private message: NzMessageService,
|
|
|
+ private modal: NzModalService,
|
|
|
+ private message: NzMessageService
|
|
|
) {
|
|
|
this.user = Parse.User.current();
|
|
|
this.className = this.Department.className;
|
|
@@ -127,47 +140,62 @@ export class PageRoleComponent implements OnInit {
|
|
|
async getDepart(
|
|
|
parent?: string,
|
|
|
searchValue?: string,
|
|
|
- filter?:boolean
|
|
|
+ filter?: boolean
|
|
|
): Promise<Array<nodes>> {
|
|
|
let nodes: any = [];
|
|
|
let query = new Parse.Query('Department');
|
|
|
- if(!filter){
|
|
|
+ if (!filter) {
|
|
|
query.equalTo('parent', parent ? parent : undefined);
|
|
|
}
|
|
|
searchValue && query.contains('name', searchValue);
|
|
|
query.notEqualTo('isDeleted', true);
|
|
|
- query.select('code', 'name', 'branch', 'parent','type');
|
|
|
+ query.select('code', 'name', 'branch', 'parent', 'type');
|
|
|
query.descending('createdAt');
|
|
|
query.limit(2000);
|
|
|
+ if (this.activeDepart) query.notEqualTo('objectId', this.activeDepart?.id);
|
|
|
let res = await query.find();
|
|
|
res.forEach((item) => {
|
|
|
nodes.push({
|
|
|
title: item.get('name'),
|
|
|
key: item.id,
|
|
|
children: [],
|
|
|
- isParent: item.get('type') =='单位' ? true : false, //是否是最下级
|
|
|
- isLeaf: item.get('type') =='单位' ? true : false,
|
|
|
+ branch: item.get('branch'),
|
|
|
+ isLeaf: item.get('type') == '单位' ? true : false, //是否是最下级
|
|
|
});
|
|
|
});
|
|
|
return nodes;
|
|
|
}
|
|
|
//搜索
|
|
|
- async onSearchNodes(e:string){
|
|
|
- this.nodes = await this.getDepart('',e, e ? true : false);
|
|
|
+ async onSearchNodes(e: string, modal?: boolean) {
|
|
|
+ if (modal) {
|
|
|
+ this.parentList = await this.getDepart('', e, true);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.nodes = await this.getDepart('', e, e ? true : false);
|
|
|
}
|
|
|
//添加成员
|
|
|
addMember() {
|
|
|
- this.message.warning('权限灰度中')
|
|
|
+ // this.message.warning('权限灰度中')
|
|
|
+ this.account = {
|
|
|
+ name: '',
|
|
|
+ phone: '',
|
|
|
+ email: '',
|
|
|
+ password: '',
|
|
|
+ identity: '',
|
|
|
+ department: '',
|
|
|
+ companyType: '',
|
|
|
+ };
|
|
|
+ this.accountIsVisible = true;
|
|
|
}
|
|
|
//展开/合并
|
|
|
async nzEvent(event: NzFormatEmitEvent): Promise<void> {
|
|
|
console.log(event);
|
|
|
let node: any = event.node;
|
|
|
if (event.eventName === 'expand') {
|
|
|
- if (node.origin.isParent) {
|
|
|
- node.addChildren([]);
|
|
|
- return;
|
|
|
- }
|
|
|
+ // if (node.origin.isParent) {
|
|
|
+ // node.addChildren([]);
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
if (node?._children.length <= 0) {
|
|
|
let data = await this.getDepart(node.key);
|
|
|
node.addChildren(data);
|
|
@@ -175,8 +203,8 @@ export class PageRoleComponent implements OnInit {
|
|
|
console.log(this.nodes);
|
|
|
} else {
|
|
|
// if (node.origin.isParent) {
|
|
|
- this.currentDepart = node.origin;
|
|
|
- this.getProfile();
|
|
|
+ this.currentDepart = node.origin;
|
|
|
+ this.getProfile();
|
|
|
// }
|
|
|
}
|
|
|
}
|
|
@@ -184,25 +212,29 @@ export class PageRoleComponent implements OnInit {
|
|
|
this.profiles = [];
|
|
|
this.loading = true;
|
|
|
let queryParams = {
|
|
|
- where : {
|
|
|
- "$or": [{
|
|
|
- "user": {
|
|
|
- "$inQuery": {
|
|
|
- "where": {
|
|
|
- "$or": [{
|
|
|
- "department": { "$eq": this.currentDepart.key}
|
|
|
- },
|
|
|
- ]
|
|
|
+ where: {
|
|
|
+ $or: [
|
|
|
+ {
|
|
|
+ user: {
|
|
|
+ $inQuery: {
|
|
|
+ where: {
|
|
|
+ $or: [
|
|
|
+ {
|
|
|
+ department: { $eq: this.currentDepart.key },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ className: '_User',
|
|
|
},
|
|
|
- "className": "_User"
|
|
|
- }
|
|
|
- }
|
|
|
- }]
|
|
|
- }
|
|
|
- }
|
|
|
- let query = Parse.Query.fromJSON('Profile',queryParams);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ };
|
|
|
+ let query = Parse.Query.fromJSON('Profile', queryParams);
|
|
|
query.include('user');
|
|
|
query.notEqualTo('identity', '国家级管理员');
|
|
|
+ query.notEqualTo('isDeleted', true);
|
|
|
let r = await query.find();
|
|
|
let profiles: any[] = [];
|
|
|
r.forEach((item) => {
|
|
@@ -227,8 +259,31 @@ export class PageRoleComponent implements OnInit {
|
|
|
this.nzContextMenuService.create($event, menu);
|
|
|
}
|
|
|
//删除部门
|
|
|
- onDelDepart() {
|
|
|
- this.message.warning('权限灰度中')
|
|
|
+ async onDelDepart() {
|
|
|
+ this.modal.confirm({
|
|
|
+ nzTitle: '删除',
|
|
|
+ nzContent:'删除后数据不可恢复,请谨慎操作',
|
|
|
+ nzOkText: '确认',
|
|
|
+ nzOkType: 'primary',
|
|
|
+ nzOkDanger: true,
|
|
|
+ nzOnOk: async () => {
|
|
|
+ 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()
|
|
|
+ }
|
|
|
+ this.message.success('删除成功')
|
|
|
+ this.nodes = await this.getDepart();
|
|
|
+ resolve(true)
|
|
|
+ }
|
|
|
+ }).catch(() => console.log('Oops errors!'))
|
|
|
+ },
|
|
|
+ nzCancelText: '取消',
|
|
|
+ nzOnCancel: () => console.log('Cancel'),
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
onAllChecked(checked: boolean): void {
|
|
@@ -251,56 +306,93 @@ export class PageRoleComponent implements OnInit {
|
|
|
//新建打开弹窗
|
|
|
async showModalDepart(type: string) {
|
|
|
this.parentList = this.nodes;
|
|
|
+ this.editObject = {
|
|
|
+ name: '',
|
|
|
+ code: '',
|
|
|
+ desc: '',
|
|
|
+ parent: '',
|
|
|
+ branch: '',
|
|
|
+ };
|
|
|
if (type == 'edit') {
|
|
|
let query = new Parse.Query('Department');
|
|
|
let r = await query.get(this.activatedNode?.key);
|
|
|
this.activeDepart = r;
|
|
|
- this.parentMap = this.formatNode(this.activatedNode);
|
|
|
- if(this.activatedNode?.parentNode?.origin.key){
|
|
|
- this.parentList = await this.getDepart(this.activatedNode.parentNode.origin.key);
|
|
|
+ this.editObject = {
|
|
|
+ name: this.activeDepart.get('name'),
|
|
|
+ code: this.activeDepart.get('code'),
|
|
|
+ desc: this.activeDepart.get('desc'),
|
|
|
+ parent: {
|
|
|
+ title: this.activeDepart.get('parent')?.get('name'),
|
|
|
+ id: this.activeDepart.get('parent')?.id,
|
|
|
+ },
|
|
|
+ branch: this.activeDepart.get('branch'),
|
|
|
+ };
|
|
|
+ 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){
|
|
|
+ console.log(this.activatedNode);
|
|
|
+ this.editObject.parent = {
|
|
|
+ title: this.activatedNode.origin.title,
|
|
|
+ id: this.activatedNode.origin.key,
|
|
|
+ };
|
|
|
+ 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(
|
|
|
+ this.activatedNode.parentNode.origin.key
|
|
|
+ );
|
|
|
}
|
|
|
}
|
|
|
+ console.log(this.parentMap);
|
|
|
this.editType = type;
|
|
|
this.isVisible = true;
|
|
|
}
|
|
|
//格式化链
|
|
|
- formatNode(node: NzTreeNode): Array<any> {
|
|
|
- let arr = [];
|
|
|
- if (node.parentNode?.origin.title) {
|
|
|
- arr.push({
|
|
|
- title: node.parentNode?.origin.title,
|
|
|
- key: node.parentNode?.origin.key,
|
|
|
- });
|
|
|
- arr.unshift(...this.formatNode(node.parentNode));
|
|
|
+ async formatNode(id: string): Promise<Array<any>> {
|
|
|
+ let query = new Parse.Query('Department');
|
|
|
+ query.select('name', 'parent');
|
|
|
+ let r = await query.get(id);
|
|
|
+ let arr = [
|
|
|
+ {
|
|
|
+ title: r.get('name'),
|
|
|
+ key: r.id,
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ if (r?.get('parent')) {
|
|
|
+ arr.unshift(...(await this.formatNode(r?.get('parent').id)));
|
|
|
}
|
|
|
return arr;
|
|
|
}
|
|
|
- async onPre(data?:any,index?:number){
|
|
|
- if(!data){
|
|
|
+ async onPre(data?: any, index?: number) {
|
|
|
+ if (!data) {
|
|
|
this.parentList = await this.getDepart();
|
|
|
- this.parentMap = []
|
|
|
- return
|
|
|
+ this.parentMap = [];
|
|
|
+ return;
|
|
|
}
|
|
|
- if(index == this.parentMap.length-1) return
|
|
|
- this.parentMap.splice(index || 0+1)
|
|
|
+ if (index == this.parentMap.length - 1) return;
|
|
|
+ this.parentMap.splice(index || 0 + 1);
|
|
|
this.parentList = await this.getDepart(data?.key);
|
|
|
}
|
|
|
//选择所属类别下级列表
|
|
|
async onCheckedDepart(e: any, checked?: boolean) {
|
|
|
- this.radio = e.key
|
|
|
+ this.radio = e.key;
|
|
|
console.log(this.radio);
|
|
|
+ this.parentMap = await this.formatNode(e.key);
|
|
|
if (checked) {
|
|
|
- this.editObject = {
|
|
|
- name: e.title,
|
|
|
- code: '',
|
|
|
- desc: '',
|
|
|
- parent: e,
|
|
|
- branch: '',
|
|
|
+ // this.editObject.name = e.title
|
|
|
+ this.editObject.parent = {
|
|
|
+ title: e.title,
|
|
|
+ id: e.key,
|
|
|
};
|
|
|
+ this.editObject.branch = e.branch || e.title;
|
|
|
return;
|
|
|
}
|
|
|
- if(e.isLeaf){
|
|
|
- return
|
|
|
+ if (e.isLeaf) {
|
|
|
+ return;
|
|
|
}
|
|
|
this.parentMap.push({
|
|
|
title: e.title,
|
|
@@ -308,9 +400,39 @@ export class PageRoleComponent implements OnInit {
|
|
|
});
|
|
|
this.parentList = await this.getDepart(e?.key);
|
|
|
}
|
|
|
- handleOk(): void {
|
|
|
- this.message.warning('权限灰度中')
|
|
|
+ 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)
|
|
|
+ }
|
|
|
+ await this.activeDepart?.save()
|
|
|
this.isVisible = false;
|
|
|
+ this.message.success(this.editType == 'edit' ? '保存' : '添加' + '成功')
|
|
|
+ this.activeDepart = undefined
|
|
|
+ this.nodes = await this.getDepart();
|
|
|
}
|
|
|
|
|
|
handleCancel(): void {
|
|
@@ -318,16 +440,16 @@ export class PageRoleComponent implements OnInit {
|
|
|
this.isVisible = false;
|
|
|
this.activatedNode = undefined;
|
|
|
this.parentMap = [];
|
|
|
+
|
|
|
+ this.accountIsVisible = false;
|
|
|
+ this.account = null;
|
|
|
}
|
|
|
|
|
|
/* 组织 */
|
|
|
- showModalOrganize(){
|
|
|
- this.message.warning('权限灰度中')
|
|
|
+ showModalOrganize() {
|
|
|
+ this.message.warning('权限灰度中');
|
|
|
}
|
|
|
- goDateil(id:string){
|
|
|
- this.route.navigate([
|
|
|
- '/nav-admin/manage/user/edit',
|
|
|
- { id:id },
|
|
|
- ])
|
|
|
+ goDateil(id: string) {
|
|
|
+ this.route.navigate(['/nav-admin/manage/user/edit', { id: id }]);
|
|
|
}
|
|
|
}
|