|
|
|
import { Component, OnInit, ViewChild } from '@angular/core';
|
|
|
|
import { HttpClient } from '@angular/common/http';
|
|
|
|
import { TreeService } from 'src/app/service/tree.service';
|
|
|
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
|
|
|
import { NzContextMenuService, NzDropdownMenuComponent } from 'ng-zorro-antd/dropdown';
|
|
|
|
import { NzFormatEmitEvent, NzTreeComponent, NzTreeNode } from 'ng-zorro-antd/tree';
|
|
|
|
import { Router } from '@angular/router';
|
|
|
|
@Component({
|
|
|
|
selector: 'app-plan-admin',
|
|
|
|
templateUrl: './plan-admin.component.html',
|
|
|
|
styleUrls: ['./plan-admin.component.scss']
|
|
|
|
})
|
|
|
|
export class PlanAdminComponent implements OnInit {
|
|
|
|
validateForm!: FormGroup;
|
|
|
|
@ViewChild('nzTreeComponent', { static: false }) nzTreeComponent!: NzTreeComponent;
|
|
|
|
constructor(private http: HttpClient, private toTree: TreeService, private fb: FormBuilder, private nzContextMenuService: NzContextMenuService, private router: Router) { }
|
|
|
|
list: any = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
|
|
|
|
ngOnInit(): void {
|
|
|
|
this.validateForm = this.fb.group({
|
|
|
|
name: [null],
|
|
|
|
linkman: [null],
|
|
|
|
phone: [null]
|
|
|
|
});
|
|
|
|
this.getAllOrganization()
|
|
|
|
}
|
|
|
|
submitForm(): void {
|
|
|
|
for (const i in this.validateForm.controls) {
|
|
|
|
this.validateForm.controls[i].markAsDirty();
|
|
|
|
this.validateForm.controls[i].updateValueAndValidity();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
resetForm(e: MouseEvent): void {
|
|
|
|
e.preventDefault();
|
|
|
|
this.validateForm.reset();
|
|
|
|
for (const key in this.validateForm.controls) {
|
|
|
|
this.validateForm.controls[key].markAsPristine();
|
|
|
|
this.validateForm.controls[key].updateValueAndValidity();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//获取所有组织机构
|
|
|
|
nodes: any = []
|
|
|
|
nzExpandAll = false
|
|
|
|
getAllOrganization() {
|
|
|
|
this.http.get('/api/services/app/Organization/GetAll').subscribe((data: any) => {
|
|
|
|
data.result.items.forEach(element => {
|
|
|
|
element.key = element.id
|
|
|
|
element.title = element.displayName
|
|
|
|
});
|
|
|
|
this.nodes = [...this.toTree.toTree(data.result.items)]
|
|
|
|
this.nzExpandAll = true
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
look() {
|
|
|
|
this.router.navigate(['/plan/petrolStation'])
|
|
|
|
}
|
|
|
|
nzExpandedKeys: any = []
|
|
|
|
activatedNode?: NzTreeNode;
|
|
|
|
//点击tree节点
|
|
|
|
activeNode(data: NzFormatEmitEvent): void {
|
|
|
|
this.activatedNode = data.node!;
|
|
|
|
// console.log(data)
|
|
|
|
}
|
|
|
|
|
|
|
|
expand(e, node) {
|
|
|
|
e.stopPropagation()
|
|
|
|
node.isExpanded = !node.isExpanded
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|