diff --git a/src/app/ui/basicinfo/basicinfo.component.html b/src/app/ui/basicinfo/basicinfo.component.html index 704e004..f54c90c 100644 --- a/src/app/ui/basicinfo/basicinfo.component.html +++ b/src/app/ui/basicinfo/basicinfo.component.html @@ -64,10 +64,10 @@ -
+
* 辖区中队: - +
+ @@ -93,12 +98,12 @@
  • {{node.name}}
  • -
    +
    -
    +
    * 单位地址: - + { + console.log(data) + this.allorganizing = data this.dataSource.data = this.tree.toTree(data); } ) } //获得当前单位的基本信息 getunitinfo(){ - this.http.get("/api/CompanyAccount/Company").subscribe((data:any)=>{ - 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 - } - }) + this.getorganization() + setTimeout(() => { + this.http.get("/api/CompanyAccount/Company").subscribe((data:any)=>{ + let node + this.allorganizing.forEach(item => { + if(item.id == data.organizationId){ + node = item + } + }); + + 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 + } + }) + }, 500); + } //获得建筑自定义信息 getbuildingCustomData(){ @@ -741,10 +778,32 @@ export class BasicinfoComponent implements OnInit { //点击辖区中队树,将选择的辖区中队添加到变量 add(node) { - this.selectedorganization = node.name + console.log(node) this.selectedorganizationid = node.id this.isorganizationbox = false - } + + 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) + } +} //关闭辖区中队隐藏框 closeorganizationbox() { @@ -768,9 +827,29 @@ export class BasicinfoComponent implements OnInit { //change选择文件 filechange(e) { this.file = e.target.files[0] || null //上传的文件 - if(this.file){ - this.startUploading() + var reader = new FileReader(); + reader.readAsDataURL(this.file); + var image:any = new Image(); + reader.onload = function(){ + image.src = reader.result } + setTimeout(() => { + if(image.width>=4096 || image.height>=5000 ){ + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('请选择分辨率小于4096*5000的图片','确定',config); + }else{ + if(this.file){ + this.startUploading() + } + } + + }, 100); + + // if(this.file){ + // this.startUploading() + // } } //查看单位大图 lookmaster(){ @@ -813,6 +892,10 @@ export class BasicinfoComponent implements OnInit { }) } } + + + + //小于5MB不需要分块上传 upload(){ this.uploader.queue[0].upload();//开始上传