|
|
|
import { HttpClient } from '@angular/common/http';
|
|
|
|
import { Component, OnInit, AfterViewInit, ViewChild, ViewContainerRef } from '@angular/core';
|
|
|
|
import { TreeService } from 'src/app/service/tree.service';
|
|
|
|
import { NzFormatEmitEvent, NzTreeComponent, NzTreeNodeOptions } from 'ng-zorro-antd/tree';
|
|
|
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
|
|
|
import { NzModalService } from 'ng-zorro-antd/modal';
|
|
|
|
import { NzMessageService } from 'ng-zorro-antd/message';
|
|
|
|
import { AddhostComponent } from './addhost/addhost.component';
|
|
|
|
@Component({
|
|
|
|
selector: 'app-analysis-of-the-host',
|
|
|
|
templateUrl: './analysis-of-the-host.component.html',
|
|
|
|
styleUrls: ['./analysis-of-the-host.component.scss']
|
|
|
|
})
|
|
|
|
export class AnalysisOfTheHostComponent implements OnInit {
|
|
|
|
|
|
|
|
constructor(private fb: FormBuilder, private http: HttpClient, private toTree: TreeService, private modal: NzModalService, private message: NzMessageService, private viewContainerRef: ViewContainerRef) { }
|
|
|
|
ngOnInit(): void {
|
|
|
|
this.getAllOrganization()
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//获取所有组织机构
|
|
|
|
searchValue = '';
|
|
|
|
nzExpandAll = false;
|
|
|
|
totalCount: string
|
|
|
|
getAllOrganization() {
|
|
|
|
this.http.get('/api/services/app/Organization/GetAll').subscribe((data: any) => {
|
|
|
|
this.totalCount = data.result.totalCount
|
|
|
|
data.result.items.forEach(element => {
|
|
|
|
element.key = element.id
|
|
|
|
element.title = element.displayName
|
|
|
|
element.selectable = false
|
|
|
|
});
|
|
|
|
this.nodes = [...this.toTree.toTree(data.result.items)]
|
|
|
|
this.defaultExpandedKeys = [...this.defaultExpandedKeys]
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ViewChild('nzTreeComponent', { static: false }) nzTreeComponent!: NzTreeComponent;
|
|
|
|
|
|
|
|
defaultExpandedKeys = [];
|
|
|
|
|
|
|
|
nodes: any[] = []
|
|
|
|
nzSelectedKeys: any[] = []
|
|
|
|
selectedOilStation:any
|
|
|
|
nzClick(event: NzFormatEmitEvent): void {
|
|
|
|
console.log(event.node.origin);
|
|
|
|
if(event.node.origin.isGasStation){//如果点击的是加油站才生效
|
|
|
|
this.nzSelectedKeys[0] = event.node.origin.id
|
|
|
|
this.nzSelectedKeys = [...this.nzSelectedKeys]
|
|
|
|
this.selectedOilStation = event.node.origin
|
|
|
|
this.getHost()
|
|
|
|
}else{
|
|
|
|
this.message.info('只有加油站才可以增加主机');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//获得加油站的主机
|
|
|
|
getHost(){
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ngAfterViewInit(): void {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//新增分析主机
|
|
|
|
addHost() {
|
|
|
|
const modal = this.modal.create({
|
|
|
|
nzTitle: '新增加油站主机',
|
|
|
|
nzContent: AddhostComponent,
|
|
|
|
nzViewContainerRef: this.viewContainerRef,
|
|
|
|
nzWidth: 288,
|
|
|
|
nzComponentParams: {},
|
|
|
|
nzOnOk: async () => {
|
|
|
|
if (instance.validateForm.valid) {
|
|
|
|
await new Promise(resolve => {
|
|
|
|
console.log('表单信息', instance.validateForm)
|
|
|
|
|
|
|
|
let body = {
|
|
|
|
// name: instance.validateForm.value.name,
|
|
|
|
// DisplayName: instance.validateForm.value.name,
|
|
|
|
// grantedPermissions: arr
|
|
|
|
}
|
|
|
|
this.http.post('/api/services/app/Role/Create', body).subscribe(data => {
|
|
|
|
resolve(data)
|
|
|
|
this.message.create('success', '创建成功!');
|
|
|
|
// this.getAllRoles()
|
|
|
|
return true
|
|
|
|
})
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
this.message.create('warning', '请填写完整!');
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
const instance = modal.getContentComponent();
|
|
|
|
}
|
|
|
|
edit(data) {
|
|
|
|
|
|
|
|
}
|
|
|
|
delete(data) {
|
|
|
|
|
|
|
|
}
|
|
|
|
listOfData: any[] = [];
|
|
|
|
}
|