|
@@ -3,52 +3,184 @@ import { ActivatedRoute, RouterOutlet } from '@angular/router';
|
|
import { CompTableListComponent } from '../../../app/comp-table/comp-table-list/comp-table-list.component';
|
|
import { CompTableListComponent } from '../../../app/comp-table/comp-table-list/comp-table-list.component';
|
|
import _Role from '../../../schemas/_Role';
|
|
import _Role from '../../../schemas/_Role';
|
|
// import { TranslateService } from '@ngx-translate/core';
|
|
// import { TranslateService } from '@ngx-translate/core';
|
|
-import * as Parse from "parse";
|
|
|
|
|
|
+import * as Parse from 'parse';
|
|
import { CommonModule } from '@angular/common';
|
|
import { CommonModule } from '@angular/common';
|
|
import { Department } from '../../../schemas/Department';
|
|
import { Department } from '../../../schemas/Department';
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+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 {
|
|
|
|
+ NzFormatEmitEvent,
|
|
|
|
+ NzTreeModule,
|
|
|
|
+ NzTreeNode,
|
|
|
|
+} from 'ng-zorro-antd/tree';
|
|
|
|
+import { NzContextMenuService, NzDropdownMenuComponent } from 'ng-zorro-antd/dropdown';
|
|
|
|
+import { NzCheckboxModule } from 'ng-zorro-antd/checkbox';
|
|
|
|
+import { NzEmptyModule } from 'ng-zorro-antd/empty';
|
|
|
|
+interface nodes {
|
|
|
|
+ title: string;
|
|
|
|
+ key: string;
|
|
|
|
+ isLeaf?: boolean;
|
|
|
|
+ isParent?: boolean;
|
|
|
|
+ children?: Array<any>;
|
|
|
|
+}
|
|
@Component({
|
|
@Component({
|
|
selector: 'app-page-role',
|
|
selector: 'app-page-role',
|
|
templateUrl: './page-role.component.html',
|
|
templateUrl: './page-role.component.html',
|
|
styleUrls: ['./page-role.component.scss'],
|
|
styleUrls: ['./page-role.component.scss'],
|
|
- imports: [CommonModule,RouterOutlet,CompTableListComponent],
|
|
|
|
|
|
+ imports: [
|
|
|
|
+ CommonModule,
|
|
|
|
+ CommonCompModule,
|
|
|
|
+ RouterOutlet,
|
|
|
|
+ CompTableListComponent,
|
|
|
|
+ NzSpaceModule,
|
|
|
|
+ NzPageHeaderModule,
|
|
|
|
+ NzBreadCrumbModule,
|
|
|
|
+ NzTreeModule,
|
|
|
|
+ NzCheckboxModule,
|
|
|
|
+ NzEmptyModule,
|
|
|
|
+ ],
|
|
standalone: true,
|
|
standalone: true,
|
|
})
|
|
})
|
|
-export class PageRoleComponent implements OnInit {
|
|
|
|
- @ViewChild(CompTableListComponent) list:CompTableListComponent|undefined
|
|
|
|
|
|
+export class PageRoleComponent implements OnInit {
|
|
|
|
+ @ViewChild(CompTableListComponent) list: CompTableListComponent | undefined;
|
|
|
|
|
|
// _Role = _Role
|
|
// _Role = _Role
|
|
- Department = Department
|
|
|
|
- user:Parse.User|undefined
|
|
|
|
- className:string|undefined
|
|
|
|
- queryParams:any|undefined
|
|
|
|
- fieldsArray:Array<any>|undefined
|
|
|
|
|
|
+ Department = Department;
|
|
|
|
+ user: Parse.User | undefined;
|
|
|
|
+ className: string | undefined;
|
|
|
|
+ queryParams: any | undefined;
|
|
|
|
+ fieldsArray: Array<any> | undefined;
|
|
|
|
+ searchValue: string = ''; //搜索内容
|
|
|
|
+ nodes: Array<nodes | any> = [];
|
|
|
|
+ currentDepart: nodes | any = null;
|
|
|
|
+
|
|
|
|
+ profiles: Array<any> = [];
|
|
|
|
+ checkedShowFilter: boolean = false;
|
|
|
|
+
|
|
|
|
+ checkedAll: boolean = false; //全选
|
|
|
|
+ indeterminate = false;
|
|
|
|
+ loading = false;
|
|
|
|
|
|
constructor(
|
|
constructor(
|
|
private route: ActivatedRoute,
|
|
private route: ActivatedRoute,
|
|
private activeRoute: ActivatedRoute,
|
|
private activeRoute: ActivatedRoute,
|
|
- // private translate:TranslateService,
|
|
|
|
|
|
+ private nzContextMenuService: NzContextMenuService,
|
|
) {
|
|
) {
|
|
this.user = Parse.User.current();
|
|
this.user = Parse.User.current();
|
|
- this.className = this.Department.className
|
|
|
|
- this.fieldsArray = this.Department.fieldsArray
|
|
|
|
- this.queryParams = {where:{
|
|
|
|
- // user:this.user?.toPointer(),
|
|
|
|
- isDeleted:{$ne:true},
|
|
|
|
- }}
|
|
|
|
|
|
+ this.className = this.Department.className;
|
|
|
|
+ this.fieldsArray = this.Department.fieldsArray;
|
|
|
|
+ this.queryParams = {
|
|
|
|
+ where: {
|
|
|
|
+ // user:this.user?.toPointer(),
|
|
|
|
+ isDeleted: { $ne: true },
|
|
|
|
+ },
|
|
|
|
+ };
|
|
}
|
|
}
|
|
|
|
|
|
ngOnInit(): void {
|
|
ngOnInit(): void {
|
|
this.activeRoute.paramMap.subscribe(async (params) => {
|
|
this.activeRoute.paramMap.subscribe(async (params) => {
|
|
- let isDeleted = params.get('isDeleted')
|
|
|
|
- if(isDeleted){
|
|
|
|
- this.queryParams.where['isDeleted'] = {$eq:true}
|
|
|
|
- }else{
|
|
|
|
- this.queryParams.where['isDeleted'] = {$ne:true}
|
|
|
|
- }
|
|
|
|
- this.list?.ngOnInit()
|
|
|
|
|
|
+ // let isDeleted = params.get('isDeleted');
|
|
|
|
+ // if (isDeleted) {
|
|
|
|
+ // this.queryParams.where['isDeleted'] = { $eq: true };
|
|
|
|
+ // } else {
|
|
|
|
+ // this.queryParams.where['isDeleted'] = { $ne: true };
|
|
|
|
+ // }
|
|
|
|
+ // this.list?.ngOnInit();
|
|
|
|
+ this.nodes = await this.getDepart();
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
+ async getDepart(
|
|
|
|
+ parent?: string,
|
|
|
|
+ searchValue?: string
|
|
|
|
+ ): Promise<Array<nodes>> {
|
|
|
|
+ let nodes: any = [];
|
|
|
|
+ let query = new Parse.Query('Department');
|
|
|
|
+ query.equalTo('parent', parent ? parent : undefined);
|
|
|
|
+ searchValue && query.contains('name', searchValue);
|
|
|
|
+ query.notEqualTo('isDeleted', true);
|
|
|
|
+ query.select('code', 'name', 'branch', 'parent');
|
|
|
|
+ query.descending('createdAt');
|
|
|
|
+ query.limit(2000);
|
|
|
|
+ let res = await query.find();
|
|
|
|
+ res.forEach((item) => {
|
|
|
|
+ nodes.push({
|
|
|
|
+ title: item.get('name'),
|
|
|
|
+ key: item.id,
|
|
|
|
+ children: [],
|
|
|
|
+ isParent: parent ? true : false, //是否为下级单位
|
|
|
|
+ isLeaf: false,
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ return nodes;
|
|
|
|
+ }
|
|
|
|
+ onAdd() {}
|
|
|
|
+ activatedNode?: NzTreeNode;
|
|
|
|
+ //展开/合并
|
|
|
|
+ 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?._children.length <= 0) {
|
|
|
|
+ let data = await this.getDepart(node.key);
|
|
|
|
+ node.addChildren(data);
|
|
|
|
+ }
|
|
|
|
+ console.log(this.nodes);
|
|
|
|
+ } else {
|
|
|
|
+ if (node.origin.isParent) {
|
|
|
|
+ this.currentDepart = node.origin;
|
|
|
|
+ this.getProfile();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ async getProfile() {
|
|
|
|
+ this.profiles = []
|
|
|
|
+ this.loading = true;
|
|
|
|
+ let query = new Parse.Query('Profile');
|
|
|
|
+ query.include('user');
|
|
|
|
+ query.notEqualTo('identity', '国家级管理员')
|
|
|
|
+ let r = await query.find();
|
|
|
|
+ let profiles: any[] = []
|
|
|
|
+ r.forEach(item=>{
|
|
|
|
+ let _item = item.toJSON()
|
|
|
|
+ _item['checked'] = false
|
|
|
|
+ profiles.push(_item);
|
|
|
|
+ })
|
|
|
|
+ this.profiles = profiles
|
|
|
|
+ this.loading = false;
|
|
|
|
+ }
|
|
|
|
+ //搜索触发
|
|
|
|
+ onSearch(event: NzFormatEmitEvent) {
|
|
|
|
+ console.log(event);
|
|
|
|
+ }
|
|
|
|
+ contextMenu($event: MouseEvent, menu: NzDropdownMenuComponent, node?:any): void {
|
|
|
|
+ console.log(node);
|
|
|
|
+ this.nzContextMenuService.create($event, menu);
|
|
|
|
+ }
|
|
|
|
+ goEditOKRTree(){
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ onAllChecked(checked: boolean): void {
|
|
|
|
+ console.log(checked);
|
|
|
|
+ this.profiles = this.profiles.map((item) => {
|
|
|
|
+ item.checked = checked;
|
|
|
|
+ return item;
|
|
|
|
+ });
|
|
|
|
+ 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
|
|
|
|
+ }
|
|
}
|
|
}
|