Browse Source

[修复]修复基本信息有时报错问题

develop
邵佳豪 5 years ago
parent
commit
e6f4f6cb88
  1. 126
      src/app/ui/basicinfo/basicinfo.component.ts

126
src/app/ui/basicinfo/basicinfo.component.ts

@ -83,13 +83,13 @@ export class BasicinfoComponent implements OnInit {
buildingTypesname:any//存储当前建筑的默认类型name
buildingCustomData:any //存储当前建筑的自定义信息
allunittype: any //所有单位类型
allorganizing:any //所有组织机构
allorganizing:any = [] //所有组织机构
constructor(private http: HttpClient, private tree: TreeService, private sanitizer: DomSanitizer, public dialog: MatDialog,public snackBar: MatSnackBar) { }
ngOnInit(): void {
this.getallunittype()
// this.getorganization()
this.getunitinfo()
this.getorganization()
// this.getunitinfo()
this.getunitallbuilding()
}
@ -103,69 +103,59 @@ export class BasicinfoComponent implements OnInit {
getorganization() {
this.http.get('/api/Organizations').subscribe(
(data: any) => {
// console.log(data)
this.allorganizing = data
this.allorganizing = data;
this.dataSource.data = this.tree.toTree(data);
this.getunitinfo();
}
)
}
//获得当前单位的基本信息
getunitinfo(){
this.getorganization()
setTimeout(() => {
this.http.get("/api/CompanyAccount/Company").subscribe((data:any)=>{
// console.log(111,data.buildingTypes.length)
if(data.buildingTypes.length){
sessionStorage.setItem('buildingTypeId',data.buildingTypes[0].id)
}else{
sessionStorage.setItem('buildingTypeId',"")
this.http.get("/api/CompanyAccount/Company").subscribe((data:any)=>{
if(data.buildingTypes.length){
sessionStorage.setItem('buildingTypeId',data.buildingTypes[0].id)
}else{
sessionStorage.setItem('buildingTypeId',"")
}
let node
this.allorganizing.forEach(item => {
if(item.id == data.organizationId){
node = item
}
let node
this.allorganizing.forEach(item => {
if(item.id == data.organizationId){
node = item
}
});
if(node){
if(!node.parentId){
this.selectedorganization = node.name
}else{
let namearr = [node.name]
let targetId = node.parentId; // 临时变量
for(let i = 0; i < node.level ; i++){
this.allorganizing.forEach(item => {
if(item.id == targetId ){
namearr.push(item.name)
targetId = item.parentId; // 临时变量更新没有副作用
}
});
}
namearr.reverse()
let str = ''
namearr.forEach(item=>{
str += '/' + item
})
this.selectedorganization = str.substr(1)
});
if(node){
if(!node.parentId){
this.selectedorganization = node.name
}else{
let namearr = [node.name]
let targetId = node.parentId; // 临时变量
for(let i = 0; i < node.level ; i++){
this.allorganizing.forEach(item => {
if(item.id == targetId ){
namearr.push(item.name)
targetId = item.parentId; // 临时变量更新没有副作用
}
});
}
namearr.reverse()
let str = ''
namearr.forEach(item=>{
str += '/' + item
})
this.selectedorganization = str.substr(1)
}
this.unitinfo = data
// this.selectedorganization = data.organizationName
this.selectedorganizationid = data.organizationId
if(data.imageUrl){
this.imgsrc = data.imageUrl
}
if(data.buildingTypes[0]){
this.defaultbuildingTypes = data.buildingTypes[0].id
this.buildingTypesname = data.buildingTypes[0].name
}
})
}, 1000);
}
this.unitinfo = data
this.selectedorganizationid = data.organizationId
if(data.imageUrl){
this.imgsrc = data.imageUrl
}
if(data.buildingTypes[0]){
this.defaultbuildingTypes = data.buildingTypes[0].id
this.buildingTypesname = data.buildingTypes[0].name
}
})
}
//获得建筑自定义信息
getbuildingCustomData(){
@ -173,10 +163,8 @@ export class BasicinfoComponent implements OnInit {
this.buildingCustomData = data
})
}
//石油化工 装置信息 勾选框
checkboxchange(item,e){
// console.log(122,item)
if(item.buildingBasicGroups){
item.buildingBasicGroups.forEach(item=>{
if(item.name != "基本信息" && item.name != "装置信息"){
@ -190,12 +178,9 @@ export class BasicinfoComponent implements OnInit {
buildinginfoId:any = []//用于存储当前单位所有具体建筑的id
presentbuildinfoId:any // 用于存储当前单位第一个建筑的id
bigfor:any//循环(储罐信息+罐区信息)大组
npdata:any = []
newnpdata:any //用于存储石油化工 储罐信息/罐区情况的 datasource
basicCategoryId:any //当前单位所有建筑中位于第一个的建筑id
deviceinfodata:any=[];//用于存储石油化工装置信息的数组
zhuangzhiinfodatasource:any = [] //用于存储石油化工装置信息表格的数据来源
@ -224,7 +209,6 @@ export class BasicinfoComponent implements OnInit {
this.devicedataSourcebox[item.buildingId] = new MatTableDataSource<any>(item.newzhuangzhiinfodatasource)
}
//数据格式化函数 将原始数据映射转化为表格需要的datasource
formatHandle(list) {
const result = [{}]; // tag 是从1开始,因此预置索引为0的项
@ -347,10 +331,10 @@ export class BasicinfoComponent implements OnInit {
})
data[0].bigfor = bigfor
}
if(data[0].buildtype == "地铁类"){
data[0].tongyong = true
// data[0].ditie = true
}
// if(data[0].buildtype == "地铁类"){
// data[0].tongyong = true
// // data[0].ditie = true
// }
return data[0]
}
@ -480,7 +464,6 @@ export class BasicinfoComponent implements OnInit {
// })
// }
let bigtankgroups = noemptybigfordata.slice(2)
// console.log("bigtankgroups",bigtankgroups)
let proportion = 2; //按照比例切割
let num = 0;
let bigfor =[];
@ -497,7 +480,6 @@ export class BasicinfoComponent implements OnInit {
//bigfor决定当前储罐分组有几个
// console.log(bigfor)
bigfor.forEach((item,index)=>{
// if(item.length != 2){
// bigfor.splice(index,1)
@ -889,11 +871,7 @@ export class BasicinfoComponent implements OnInit {
}
}
}, 100);
// if(this.file){
// this.startUploading()
// }
}, 500);
}
//查看单位大图
lookmaster(){

Loading…
Cancel
Save