tree 에 loginRes 객체 주입 > 내 부서 열어주기 위한 전처리.
This commit is contained in:
parent
fa214fc01d
commit
9d0f6bdd8a
|
@ -5,6 +5,7 @@
|
||||||
<div class="oraganization-tab-tree" >
|
<div class="oraganization-tab-tree" >
|
||||||
<ucap-organization-tree
|
<ucap-organization-tree
|
||||||
[oraganizationList]="departmentInfoList$ | async"
|
[oraganizationList]="departmentInfoList$ | async"
|
||||||
|
[loginRes]="loginRes"
|
||||||
(selected)="onSelectedOrganization($event)"
|
(selected)="onSelectedOrganization($event)"
|
||||||
></ucap-organization-tree>
|
></ucap-organization-tree>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -35,6 +35,7 @@ import {
|
||||||
SelectGroupDialogData,
|
SelectGroupDialogData,
|
||||||
SelectGroupDialogResult
|
SelectGroupDialogResult
|
||||||
} from '../../dialogs/group/select-group.dialog.component';
|
} from '../../dialogs/group/select-group.dialog.component';
|
||||||
|
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-layout-chat-left-sidenav-organization',
|
selector: 'app-layout-chat-left-sidenav-organization',
|
||||||
|
@ -71,6 +72,7 @@ export class OrganizationComponent implements OnInit, OnDestroy {
|
||||||
selectedDepartmentName: string;
|
selectedDepartmentName: string;
|
||||||
|
|
||||||
loginInfo: LoginInfo;
|
loginInfo: LoginInfo;
|
||||||
|
loginRes: LoginResponse;
|
||||||
sessionVerinfo: VersionInfo2Response;
|
sessionVerinfo: VersionInfo2Response;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -137,6 +139,7 @@ export class OrganizationComponent implements OnInit, OnDestroy {
|
||||||
return loginRes;
|
return loginRes;
|
||||||
}),
|
}),
|
||||||
map(loginRes => {
|
map(loginRes => {
|
||||||
|
this.loginRes = loginRes;
|
||||||
this.selectedDepartmentName = loginRes.userInfo.deptName;
|
this.selectedDepartmentName = loginRes.userInfo.deptName;
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
|
@ -8,12 +8,14 @@ import {
|
||||||
EventEmitter,
|
EventEmitter,
|
||||||
AfterViewInit
|
AfterViewInit
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { DeptInfo } from '@ucap-webmessenger/protocol-query';
|
|
||||||
import { MatTreeNestedDataSource, MatTree } from '@angular/material';
|
import { MatTreeNestedDataSource, MatTree } from '@angular/material';
|
||||||
import { NestedTreeControl } from '@angular/cdk/tree';
|
import { NestedTreeControl } from '@angular/cdk/tree';
|
||||||
import { BehaviorSubject } from 'rxjs';
|
import { BehaviorSubject } from 'rxjs';
|
||||||
import { NGXLogger } from 'ngx-logger';
|
import { NGXLogger } from 'ngx-logger';
|
||||||
|
|
||||||
|
import { DeptInfo } from '@ucap-webmessenger/protocol-query';
|
||||||
|
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
|
||||||
|
|
||||||
export class OraganizationNode {
|
export class OraganizationNode {
|
||||||
private childNodeBehaviorSubject: BehaviorSubject<OraganizationNode[]>;
|
private childNodeBehaviorSubject: BehaviorSubject<OraganizationNode[]>;
|
||||||
private childNodeList: OraganizationNode[];
|
private childNodeList: OraganizationNode[];
|
||||||
|
@ -50,11 +52,14 @@ export class TreeComponent implements OnInit, AfterViewInit {
|
||||||
@Output()
|
@Output()
|
||||||
selected = new EventEmitter<DeptInfo>();
|
selected = new EventEmitter<DeptInfo>();
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
loginRes: LoginResponse;
|
||||||
@Input()
|
@Input()
|
||||||
set oraganizationList(deptInfo: DeptInfo[]) {
|
set oraganizationList(deptInfo: DeptInfo[]) {
|
||||||
const nodeMap = new Map<number, OraganizationNode>();
|
const nodeMap = new Map<number, OraganizationNode>();
|
||||||
const rootNodeList: OraganizationNode[] = [];
|
const rootNodeList: OraganizationNode[] = [];
|
||||||
const remainChildNodeList: OraganizationNode[] = [];
|
const remainChildNodeList: OraganizationNode[] = [];
|
||||||
|
let myNode: OraganizationNode;
|
||||||
|
|
||||||
deptInfo.forEach(value => {
|
deptInfo.forEach(value => {
|
||||||
const node = new OraganizationNode(value);
|
const node = new OraganizationNode(value);
|
||||||
|
@ -64,6 +69,10 @@ export class TreeComponent implements OnInit, AfterViewInit {
|
||||||
}
|
}
|
||||||
nodeMap.set(value.seq, node);
|
nodeMap.set(value.seq, node);
|
||||||
|
|
||||||
|
if (value.seq === this.loginRes.departmentCode) {
|
||||||
|
myNode = node;
|
||||||
|
}
|
||||||
|
|
||||||
if (0 === value.parentSeq) {
|
if (0 === value.parentSeq) {
|
||||||
rootNodeList.push(node);
|
rootNodeList.push(node);
|
||||||
return;
|
return;
|
||||||
|
@ -83,7 +92,20 @@ export class TreeComponent implements OnInit, AfterViewInit {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.dataSource.data = rootNodeList;
|
this.dataSource.data = rootNodeList;
|
||||||
this.treeControl.expand(this.dataSource.data[0]);
|
// console.log('myNode', myNode);
|
||||||
|
// console.log('this.dataSource.data', this.dataSource.data[0]);
|
||||||
|
// this.treeControl.expandDescendants(this.dataSource.data[2]);
|
||||||
|
// console.log('this.dataSource', this.dataSource);
|
||||||
|
// console.log('this.dataSource.data', this.dataSource.data);
|
||||||
|
// console.log('this.treeControl', this.treeControl);
|
||||||
|
// console.log('this.treeControl.dataNodes', this.treeControl.dataNodes);
|
||||||
|
|
||||||
|
// const myNode = this.treeControl.dataNodes.filter(
|
||||||
|
// node => node.deptInfo.seq === this.loginRes.departmentCode
|
||||||
|
// );
|
||||||
|
// if (!!myNode && myNode.length > 0) {
|
||||||
|
// this.treeControl.expand(myNode[0]);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ViewChild('orgranizationTree', { static: true })
|
@ViewChild('orgranizationTree', { static: true })
|
||||||
|
|
Loading…
Reference in New Issue
Block a user