Compare commits
2 Commits
9824c709b6
...
cf14f675d2
Author | SHA1 | Date |
---|---|---|
邵佳豪 | cf14f675d2 | 3 months ago |
邵佳豪 | bb308c063d | 3 months ago |
8 changed files with 136 additions and 5 deletions
@ -0,0 +1,4 @@
|
||||
<div class="box"> |
||||
<nz-tree #nzTreeComponent [nzSelectedKeys]="defaultSelectedKeys" [nzData]="nodes" |
||||
[nzExpandedKeys]="defaultExpandedKeys"></nz-tree> |
||||
</div> |
@ -0,0 +1,4 @@
|
||||
.box { |
||||
max-height: 500px; |
||||
overflow-y: auto; |
||||
} |
@ -0,0 +1,25 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing'; |
||||
|
||||
import { ChangeOrComponent } from './change-or.component'; |
||||
|
||||
describe('ChangeOrComponent', () => { |
||||
let component: ChangeOrComponent; |
||||
let fixture: ComponentFixture<ChangeOrComponent>; |
||||
|
||||
beforeEach(async () => { |
||||
await TestBed.configureTestingModule({ |
||||
declarations: [ ChangeOrComponent ] |
||||
}) |
||||
.compileComponents(); |
||||
}); |
||||
|
||||
beforeEach(() => { |
||||
fixture = TestBed.createComponent(ChangeOrComponent); |
||||
component = fixture.componentInstance; |
||||
fixture.detectChanges(); |
||||
}); |
||||
|
||||
it('should create', () => { |
||||
expect(component).toBeTruthy(); |
||||
}); |
||||
}); |
@ -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 = { |
||||
ContainsChildren: true, |
||||
pageSize: 9999, |
||||
}; |
||||
this.http |
||||
.get('/api/Organizations', { |
||||
params: params, |
||||
}) |
||||
.subscribe((data: any) => { |
||||
data.items.forEach((element) => { |
||||
element.key = element.id; |
||||
element.title = element.name; |
||||
}); |
||||
this.allOrList = data.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