中化加油站项目
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.

179 lines
5.9 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) {
setTimeout(() => {
this.oilStationListComponent.list = []
this.oilStationListComponent.SkipCount = '0'
this.oilStationListComponent.onChildMethod()
}, 0);
}
if (this.selectedTab == 1) {
setTimeout(() => {
this.updateLicenseListComponent.list = []
this.updateLicenseListComponent.SkipCount = '0'
this.updateLicenseListComponent.onChildMethod()
}, 0);
}
if (this.selectedTab == 2) {
setTimeout(() => {
this.fileLicenseListComponent.list = []
this.fileLicenseListComponent.SkipCount = '0'
this.fileLicenseListComponent.onChildMethod()
}, 0);
}
}
//获取所有组织机构
nodes: any = []
nzExpandAll = false
nzSelectedKeys: any = []
orSpin: boolean = false
organization: any
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 = data.result.items.filter((item, i) => {
return !item.isGasStation
})
this.organization = data.result.items
this.getStationsNum(data.result.items)
// data.result.items.forEach(element => {
// if (element.id == OrganizationUnitId) {
// element.parentId = null
// }
// });
// for (let index = 0; index < data.result.items.length; index++) {
// const element = data.result.items[index];
// element.key = element.id
// element.title = element.displayName
// }
// this.orSpin = false
// this.nodes = [...this.toTree.toTree(data.result.items)]
// this.nzExpandedKeys = [OrganizationUnitId]
// this.nzSelectedKeys = [OrganizationUnitId]
// sessionStorage.setItem('planAdminOrid', OrganizationUnitId)
// this.oilStationListComponent.onChildMethod()
})
}
//获得组织机构下有多少油站
stationsList
getStationsNum(e) {
let OrganizationUnitId = JSON.parse(sessionStorage.getItem('userdata')).organization.id
this.http.get('/api/services/app/GasStation/GetCountsByOrganizations?IsContainsChildren=true').subscribe((data: any) => {
this.stationsList = data.result
const arrs = e.map(item => {
const data = this.stationsList.find(i => item.id == i.organizationId)
return {
...item,
products: data ? data : false
}
})
for (let index = 0; index < arrs.length; index++) {
if (arrs[index].id == OrganizationUnitId) {
arrs[index].parentId = null
}
arrs[index].title = arrs[index].displayName
arrs[index].key = arrs[index].id
}
this.orSpin = false
this.nodes = [...this.toTree.toTree(arrs)]
3 years ago
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) {
setTimeout(() => {
this.oilStationListComponent.list = []
this.oilStationListComponent.SkipCount = '0'
this.oilStationListComponent.onChildMethod()
}, 0);
}
if (this.selectedTab == 1) {
setTimeout(() => {
this.updateLicenseListComponent.list = []
this.updateLicenseListComponent.SkipCount = '0'
this.updateLicenseListComponent.onChildMethod()
}, 0);
}
if (this.selectedTab == 2) {
setTimeout(() => {
this.fileLicenseListComponent.list = []
this.fileLicenseListComponent.SkipCount = '0'
this.fileLicenseListComponent.onChildMethod()
}, 0);
}
}
expand(e, node) {
e.stopPropagation()
node.isExpanded = !node.isExpanded
}
}