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

141 lines
5.0 KiB

import { Component, OnInit, ViewChild } from '@angular/core';
import { NzFormatEmitEvent, NzTreeComponent, NzTreeNodeOptions } from 'ng-zorro-antd/tree';
import { FacilityInfoInSceneWindow } from 'src/app/babylon/view/facilityinfoinscene-window/facilityinfoinscene-window';
import { PlanComponent } from '../plan/plan.component';
import { FacilityInfoUIItem } from "../../babylon/view/facilityinfoinscene-window/facilityinfo-ui-item";
import { ConfigManager } from 'src/app/babylon/controller/config-manager';
import { FacilityType } from 'src/app/babylon/model/data/model-data/model-data-facility';
@Component({
selector: 'app-left-domain',
templateUrl: './left-domain.component.html',
styleUrls: ['./left-domain.component.scss']
})
export class LeftDomainComponent implements OnInit {
constructor() { }
ngOnInit(): void {
this.initComponent()
}
beforeFence: number; //当前选中功能栏
FacilityList: FacilityInfoUIItem[] = []; //统计设备 list
@ViewChild('nzTreeComponent', { static: false }) nzTreeComponent!: NzTreeComponent;
treeData: NzTreeNodeOptions[] = []; //tree data
//初始化组件
initComponent(type?: number) {
if (type != undefined && type != null) {
this.beforeFence = type
this.handleFacility()
} else {
this.beforeFence = PlanComponent.instance.selectFence
this.handleFacility()
}
}
//处理 设备data
handleFacility() {
let list: FacilityInfoUIItem[] = []
FacilityInfoInSceneWindow.instance.facilityInfoUIItemes.forEach(item=>{
if (this.beforeFence === 1) { //加油机
item.getType() === "JY_JYJ"? list.push(item) : null
} else if (this.beforeFence === 2) { //油罐设备
item.getType() === "JY_YG"? list.push(item) : null
} else if (this.beforeFence === 3) { //消防设施
(item.getType()).slice(0,3) === "XF_"? list.push(item) : null
}
})
this.FacilityList = list
if (this.beforeFence === 3) { //消防设施
this.handleTreeData(this.FacilityList)
}
}
//处理 treeData
handleTreeData(list: FacilityInfoUIItem[]) {
this.treeData = []
list.forEach(item=>{
let isFind = this.treeData.find(element=>{ return (item.getType()).includes(element.key) })
if (!isFind) { //不存在
if (item.getType().includes('XF_MHQ')) { //灭火器
let primaryNode = { title: '灭火器', key: 'XF_MHQ', selectable: false, expanded: true, children: [], }
let treeNode = { title: ConfigManager.getFacilityTypeName(item.getType()), key: item.getType(), selectable: false, }
primaryNode.children.push(treeNode)
this.treeData.push(primaryNode)
} else {
let primaryNode = { title: ConfigManager.getFacilityTypeName(item.getType()), key: item.getType(), selectable: false, }
this.treeData.push(primaryNode)
}
} else { //存在
if (item.getType().includes('XF_MHQ') && !isFind.children.find(elements=>{ return elements.key === item.getType() })) { //灭火器
let treeNode = { title: ConfigManager.getFacilityTypeName(item.getType()), key: item.getType(), selectable: false, }
isFind.children.push(treeNode)
}
}
})
//编辑模式
let isFind = this.treeData.find(item=>{ return item.key === 'XF_MHQ' })
if (!isFind) {
let primaryNode = { title: '灭火器', key: 'XF_MHQ', selectable: false, }
this.treeData.push(primaryNode)
}
for (let facility in FacilityType) {
if (facility.slice(0,3) === "XF_" && !facility.includes('XF_MHQ')) {
let isFind = this.treeData.find(item=>{ return item.key === facility })
if (!isFind) {
let primaryNode = { title: ConfigManager.getFacilityTypeName(FacilityType[facility]), key: facility, selectable: false, }
this.treeData.push(primaryNode)
}
}
}
//编辑模式
}
//获取设备 数量
getFacilityNum(type: string): number {
let num = 0
this.FacilityList.forEach(item=>{
item.getType().includes(type)? num = num + 1 : null
})
return num
}
//点击tree节点
nzClick(event: NzFormatEmitEvent) {
if (event.node.key != 'XF_MHQ') {
event.node.isSelected = !event.node.isSelected
if (event.node.isSelected) { //显示当前, 隐藏所有
FacilityInfoInSceneWindow.instance.showFacilityByType(null, false)
FacilityInfoInSceneWindow.instance.showFacilityByType(FacilityType[event.node.key], event.node.isSelected)
} else { //显示所有
this.treeData.forEach(item=>{
if (item.key != 'XF_MHQ') {
FacilityInfoInSceneWindow.instance.showFacilityByType(FacilityType[item.key], true)
} else {
item.children.forEach(element=>{ FacilityInfoInSceneWindow.instance.showFacilityByType(FacilityType[element.key], true) })
}
})
}
}
}
//编辑信息
editInfo() {
}
//导出Excel
deriveExcel() {
}
}
export class treeData {
static nodes: NzTreeNodeOptions[] = []
}