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.
256 lines
7.8 KiB
256 lines
7.8 KiB
import { Component, OnInit, ViewChild, Inject } from '@angular/core'; |
|
import { HttpClient } from '@angular/common/http' |
|
import { MatTreeFlatDataSource, MatTreeFlattener } from '@angular/material/tree'; |
|
import { MatPaginator } from '@angular/material/paginator'; |
|
import { FlatTreeControl } from '@angular/cdk/tree'; |
|
import { FormControl } from '@angular/forms'; |
|
import { Router,ActivatedRoute } from '@angular/router' |
|
import { PageEvent } from '@angular/material/paginator'; |
|
import { MatDialogRef, MatDialog, MAT_DIALOG_DATA } from '@angular/material/dialog'; |
|
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar'; |
|
import { TreeService } from '../../http-interceptors/tree.service' |
|
import { ConstantPool } from '@angular/compiler'; |
|
@Component({ |
|
selector: 'app-entry-plan', |
|
templateUrl: './entry-plan.component.html', |
|
styleUrls: ['./entry-plan.component.scss'] |
|
}) |
|
export class EntryPlanComponent implements OnInit { |
|
|
|
constructor(private http:HttpClient,private router:Router,private route:ActivatedRoute,private tree: TreeService,public dialog: MatDialog,public snackBar: MatSnackBar) { } |
|
|
|
private _transformer = (node, level: number) => { //初始化tree |
|
return { |
|
expandable: !!node.children && node.children.length > 0, |
|
name: node.name, |
|
level: level, |
|
id: node.id, |
|
parentId: node.parentId, |
|
children: node.children |
|
}; |
|
} |
|
treeControl = new FlatTreeControl<any>(node => node.level, node => node.expandable); |
|
treeFlattener = new MatTreeFlattener(this._transformer, node => node.level, node => node.expandable, node => node.children); |
|
dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener); |
|
myControl = new FormControl(); |
|
hasChild = (_: number, node: any) => node.expandable; |
|
//分页 |
|
@ViewChild(MatPaginator, {static: true}) |
|
pageEvent: PageEvent; |
|
paginator: MatPaginator; |
|
length:any; //共多少条数据 |
|
pageSize:any; //每页条数 |
|
pageSizeOptions: number[] = [10] //设置每页条数 |
|
PageNumber:any; //第几页 |
|
|
|
|
|
|
|
displayedColumns: string[] = ['unitname', 'jurisdictionsquadron', 'unittype','plantype', 'passstate','projectlevel','operation']; |
|
allorganizations:any //所有组织机构 |
|
allunittype:any //所有单位类型 |
|
tabledataSource:any //表格数据 |
|
|
|
organizationName:any //当前单位组织机构名称 |
|
preparelevels:any |
|
integrity(width){ |
|
let style:any = {} |
|
style.width = width*10 +'%'; |
|
if(width < 4){ |
|
style.background = "#FF4500"; |
|
} |
|
if(width >= 4 && width <7){ |
|
style.background = "#FF8C00"; |
|
} |
|
if(width >= 7){ |
|
style.background = "#32cd32"; |
|
} |
|
return style |
|
} |
|
integrityDetails(width,zong){ |
|
let style:any = {} |
|
style.width = (width/zong)*100 +'%'; |
|
return style |
|
} |
|
ngOnInit(): void { |
|
this.getunitdata(); |
|
this.getOrganizations(); |
|
this.getUnittype(); |
|
this.getAllPlanInfo(); |
|
let level = sessionStorage.getItem("level"); |
|
if(level == "0"){//如果是总队 |
|
this.preparelevels = [ |
|
{name:"总队",value:"1"}, |
|
{name:"支队",value:"2"}, |
|
{name:"大队",value:"4"}, |
|
{name:"中队",value:"8"} |
|
] |
|
} |
|
if(level == "1"){//如果是支队 |
|
this.preparelevels = [ |
|
{name:"支队",value:"2"}, |
|
{name:"大队",value:"4"}, |
|
{name:"中队",value:"8"} |
|
] |
|
} |
|
if(level == "2"){//如果是大队 |
|
this.preparelevels = [ |
|
{name:"大队",value:"4"}, |
|
{name:"中队",value:"8"} |
|
] |
|
} |
|
if(level == "3"){//如果是中队 |
|
this.preparelevels = [ |
|
{name:"中队",value:"8"} |
|
] |
|
} |
|
} |
|
|
|
|
|
|
|
//得到当前单位信息 |
|
getunitdata(){ |
|
this.http.get("/api/Account/Profiles").subscribe( |
|
(data:any)=>{ |
|
this.organizationName = data.organizationName |
|
} |
|
) |
|
} |
|
treedata:any //组织机构树型数据 |
|
newArr:any = [] |
|
newallorganizations:any //用于存储在原始数据基础上的每个机构增加children字段 |
|
//得到当前单位所在组织机构的tree型数据 |
|
getpresentOrganization(){ |
|
this.newallorganizations = this.allorganizations |
|
|
|
this.newallorganizations.forEach(item => { |
|
item.children = [] |
|
this.newallorganizations.forEach(element => { |
|
if(element.parentId == item.id){ |
|
item.children.push(element) |
|
} |
|
}); |
|
}); |
|
this.http.get("/api/Account/Profiles").subscribe( |
|
(data:any)=>{ |
|
this.organizationName = data.organizationName |
|
if(this.organizationName){ |
|
this.newallorganizations.forEach(item => { |
|
if(item.name == this.organizationName){ |
|
this.dataSource.data = [item] |
|
} |
|
}); |
|
}else{ |
|
this.dataSource.data = this.tree.toTree(this.treedata); |
|
} |
|
} |
|
) |
|
|
|
|
|
} |
|
//获得所有组织机构 |
|
getOrganizations(){ |
|
this.http.get('/api/Organizations').subscribe( |
|
(data:any)=>{ |
|
this.allorganizations = data |
|
this.treedata = this.tree.toTree(data); |
|
this.getpresentOrganization(); |
|
} |
|
) |
|
} |
|
//获得所有单位类型 |
|
getUnittype(){ |
|
this.http.get('/api/BuildingTypes/Simple').subscribe( |
|
data=>{ |
|
this.allunittype = data |
|
} |
|
) |
|
} |
|
|
|
//分页事件 |
|
chagePage(e){ |
|
this.PageNumber = e.pageIndex+1 |
|
this.getAllPlanInfo(); |
|
} |
|
//辖区中队div是否显示 |
|
isorganizationbox:boolean = false |
|
//点击辖区中队树,将选择的辖区中队添加到变量 |
|
add(node) { |
|
this.isorganizationbox = false |
|
this.js = node.name |
|
this.jsId = node.id |
|
} |
|
//打开辖区中队隐藏框 |
|
openorganizationbox() { |
|
this.isorganizationbox = true |
|
} |
|
//关闭出现的组织机构div |
|
closediv(){ |
|
this.isorganizationbox = false |
|
} |
|
|
|
allPlanInfo:any //存储所有预案信息 |
|
//获得所有预案信息 |
|
getAllPlanInfo(){ |
|
let paramsdata:any = { |
|
CompanyName: this.companyName || '', |
|
OrganizationId: this.jsId || '', |
|
HasChildrenOrganization:this.jscheck || '', |
|
BuildingTypeId: this.unittype || '', |
|
PlanType: this.reservePlanType || '', |
|
AuditStatus: this.toExamine || '', |
|
PlanLevel: this.preparelevel || '', |
|
HasChildrenPlanLevel: this.plcheck || '', |
|
PageNumber: this.PageNumber || '1', |
|
PageSize: this.pageSizeOptions[0], |
|
Sort: '' |
|
} |
|
this.http.get("/api/Plans",{params:paramsdata}).subscribe((data:any)=>{ |
|
|
|
this.length = data.totalCount |
|
this.allPlanInfo = data |
|
|
|
this.tabledataSource = data.items |
|
}) |
|
} |
|
|
|
|
|
//查看预案按钮跳转 |
|
routerTo(element){ |
|
// console.log(element) |
|
sessionStorage.setItem("companyName",element.company.name) |
|
window.open(`/planManagement/entryPlandetail?unitId=${element.company.id}&unitTypeId=${element.company.buildingTypes.length == 0 ? null :element.company.buildingTypes[0].id}&operation=true&pagetype=entryplan&unitName=${element.company.name}&orName=${element.company.organizationName}&unitType=${element.company.buildingTypes.length == 0 ? null :element.company.buildingTypes[0].name}&unitAdd=${element.company.address}`); |
|
} |
|
//查询 |
|
onSubmit (value) { |
|
this.PageNumber = 1 |
|
this.pageEvent.pageIndex = 0 |
|
this.getAllPlanInfo(); |
|
} |
|
|
|
companyName:any //单位名称 |
|
js:any //所选组织机构 |
|
jsId:any //所选组织机构的id |
|
jscheck:boolean //所选组织机构勾选框 |
|
unittype:any //单位类型 |
|
reservePlanType:any //预案类型 |
|
toExamine:any //审核状态 |
|
preparelevel:any //编制级别 |
|
plcheck:boolean //编制级别勾选框 |
|
//重置 |
|
reset(){ |
|
this.companyName = '' |
|
this.js = '' |
|
this.jsId = '' |
|
this.jscheck = false |
|
this.unittype = '' |
|
this.reservePlanType = '' |
|
this.toExamine = '' |
|
this.preparelevel = '' |
|
this.plcheck = false |
|
//重新获取初始化列表 |
|
// console.log(this.pageEvent) |
|
this.pageEvent.pageIndex = 0 |
|
this.PageNumber = 1 |
|
this.getAllPlanInfo(); |
|
} |
|
}
|
|
|