中化加油站项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

134 lines
4.4 KiB

import { Component, OnInit, ViewChild, ElementRef } 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';
import { NavChangeService } from 'src/app/service/navChange.service';
import { fromEvent } from 'rxjs';
import { debounceTime } from 'rxjs/operators';
import { OilStationListComponent } from './oil-station-list/oil-station-list.component';
import { UpdateLicenseListComponent } from './update-license-list/update-license-list.component';
import { FileLicenseListComponent } from './file-license-list/file-license-list.component';
@Component({
selector: 'app-plan-admin',
templateUrl: './plan-admin.component.html',
styleUrls: ['./plan-admin.component.scss']
})
export class PlanAdminComponent implements OnInit {
@ViewChild('nzTreeComponent', { static: false }) nzTreeComponent!: NzTreeComponent;
@ViewChild('child') oilStationListComponent!: OilStationListComponent;;
@ViewChild('child2') updateLicenseListComponent!: UpdateLicenseListComponent;;
@ViewChild('child3') fileLicenseListComponent!: FileLicenseListComponent;;
constructor(private element: ElementRef, private navChangeService: NavChangeService, private http: HttpClient, private toTree: TreeService, private fb: FormBuilder, private nzContextMenuService: NzContextMenuService, private router: Router) { }
ngOnInit(): void {
this.getAllOrganization()
}
//选择右侧tab页
selectedTab = 0
selectTab(index) {
this.selectedTab = index
if (this.selectedTab == 0) {
console.log('选择tab')
setTimeout(() => {
this.oilStationListComponent.list = []
this.oilStationListComponent.SkipCount = '0'
this.oilStationListComponent.onChildMethod()
}, 0);
}
if (this.selectedTab == 1) {
console.log('选择tab')
setTimeout(() => {
this.updateLicenseListComponent.list = []
this.updateLicenseListComponent.SkipCount = '0'
this.updateLicenseListComponent.onChildMethod()
}, 0);
}
}
//获取所有组织机构
nodes: any = []
nzExpandAll = false
nzSelectedKeys: any = []
orSpin: boolean = false
getAllOrganization() {
this.orSpin = true
let OrganizationUnitId = JSON.parse(sessionStorage.getItem('userdata')).organization.id
let params = {
OrganizationUnitId: OrganizationUnitId,
IsContainsChildren: "true"
}
this.http.get('/api/services/app/Organization/GetAll', {
params: params
}).subscribe((data: any) => {
data.result.items.forEach(element => {
if (element.id == OrganizationUnitId) {
element.parentId = null
}
});
data.result.items = data.result.items.filter((item, i) => {
return !item.isGasStation
})
for (let index = 0; index < data.result.items.length; index++) {
const element = data.result.items[index];
element.key = element.id
element.title = element.displayName
}
// console.log('组织机构', data.result.items)
this.orSpin = false
this.nodes = [...this.toTree.toTree(data.result.items)]
this.nzExpandedKeys = [OrganizationUnitId]
this.nzSelectedKeys = [OrganizationUnitId]
sessionStorage.setItem('planAdminOrid', OrganizationUnitId)
this.oilStationListComponent.onChildMethod()
})
}
nzExpandedKeys: any = []
activatedNode?: NzTreeNode;
//点击tree节点
activeNode(data: NzFormatEmitEvent): void {
this.activatedNode = data.node!;
sessionStorage.setItem('planAdminOrid', data.node.origin.id)
if (this.selectedTab == 0) {
console.log('选择tab')
setTimeout(() => {
this.oilStationListComponent.list = []
this.oilStationListComponent.SkipCount = '0'
this.oilStationListComponent.onChildMethod()
}, 0);
}
if (this.selectedTab == 1) {
console.log('选择tab')
setTimeout(() => {
this.updateLicenseListComponent.list = []
this.updateLicenseListComponent.SkipCount = '0'
this.updateLicenseListComponent.onChildMethod()
}, 0);
}
}
expand(e, node) {
e.stopPropagation()
node.isExpanded = !node.isExpanded
}
}