diff --git a/projects/ucap-webmessenger-ui-organization/src/lib/components/tree.component.ts b/projects/ucap-webmessenger-ui-organization/src/lib/components/tree.component.ts index 172237e7..b680792b 100644 --- a/projects/ucap-webmessenger-ui-organization/src/lib/components/tree.component.ts +++ b/projects/ucap-webmessenger-ui-organization/src/lib/components/tree.component.ts @@ -5,7 +5,8 @@ import { ChangeDetectorRef, ViewChild, Output, - EventEmitter + EventEmitter, + AfterViewInit } from '@angular/core'; import { DeptInfo } from '@ucap-webmessenger/protocol-query'; import { MatTreeNestedDataSource, MatTree } from '@angular/material'; @@ -45,7 +46,7 @@ export class OraganizationNode { templateUrl: './tree.component.html', styleUrls: ['./tree.component.scss'] }) -export class TreeComponent implements OnInit { +export class TreeComponent implements OnInit, AfterViewInit { @Output() selected = new EventEmitter(); @@ -82,6 +83,7 @@ export class TreeComponent implements OnInit { }); this.dataSource.data = rootNodeList; + this.treeControl.expand(this.dataSource.data[0]); } @ViewChild('orgranizationTree', { static: true }) @@ -104,6 +106,8 @@ export class TreeComponent implements OnInit { ngOnInit() {} + ngAfterViewInit(): void {} + getChildren = (node: OraganizationNode) => node.children; hasChildren = (index: number, node: OraganizationNode) =>