6 changed files with 114 additions and 2 deletions
@ -0,0 +1,4 @@
|
||||
<div class="box"> |
||||
<nz-tree #nzTreeComponent [nzSelectedKeys]="defaultSelectedKeys" [nzData]="nodes" |
||||
[nzExpandedKeys]="defaultExpandedKeys"></nz-tree> |
||||
</div> |
@ -0,0 +1,5 @@
|
||||
.box { |
||||
max-height: 500px; |
||||
overflow-y: auto; |
||||
} |
||||
|
@ -0,0 +1,55 @@
|
||||
import { Component, Input, OnInit, ViewChild } from "@angular/core"; |
||||
import { NzModalRef } from "ng-zorro-antd/modal"; |
||||
import { FormBuilder, FormGroup, Validators } from "@angular/forms"; |
||||
import { HttpClient } from "@angular/common/http"; |
||||
import { TreeService } from "src/app/service/tree.service"; |
||||
import { NzTreeComponent } from "ng-zorro-antd/tree"; |
||||
|
||||
@Component({ |
||||
selector: "app-change-or", |
||||
templateUrl: "./change-or.component.html", |
||||
styleUrls: ["./change-or.component.scss"], |
||||
}) |
||||
export class ChangeOrComponent implements OnInit { |
||||
@Input() data?: any; |
||||
@ViewChild("nzTreeComponent", { static: false }) |
||||
nzTreeComponent!: NzTreeComponent; |
||||
constructor( |
||||
private modal: NzModalRef, |
||||
private fb: FormBuilder, |
||||
private http: HttpClient, |
||||
private toTree: TreeService |
||||
) {} |
||||
|
||||
defaultExpandedKeys = []; |
||||
defaultSelectedKeys = []; |
||||
ngOnInit(): void { |
||||
this.getAllOrganization(); |
||||
// this.nzTreeComponent.getCheckedNodeList()
|
||||
} |
||||
|
||||
allOrList: any; |
||||
nodes: any; |
||||
getAllOrganization() { |
||||
let params = { |
||||
IsContainsChildren: "true", |
||||
}; |
||||
this.http |
||||
.get("/api/services/app/Organization/GetAll", { |
||||
params: params, |
||||
}) |
||||
.subscribe((data: any) => { |
||||
console.log(data); |
||||
data.result.items.forEach((element) => { |
||||
element.key = element.id; |
||||
element.title = element.displayName; |
||||
}); |
||||
this.allOrList = data.result.items.filter((v) => !v.isGasStation); |
||||
this.nodes = [...this.toTree.toTree(this.allOrList)]; |
||||
}); |
||||
} |
||||
|
||||
destroyModal(): void { |
||||
this.modal.destroy({ data: "this the result data" }); |
||||
} |
||||
} |
Loading…
Reference in new issue