徐振升 4 years ago
parent
commit
2b29e59709
  1. 3
      src/app/key-unit/basicinfo/basicinfo.component.html
  2. 111
      src/app/key-unit/basicinfo/basicinfo.component.ts

3
src/app/key-unit/basicinfo/basicinfo.component.html

@ -108,7 +108,8 @@
<div class="uploadimg" (click)="lookmaster()"> <div class="uploadimg" (click)="lookmaster()">
<span>单位照片:</span> <span>单位照片:</span>
<div class="uploadingimg"> <div class="uploadingimg">
<img [src]="imgsrc" alt="" style="width: 299px; height: 170px;" > <img *ngIf="imgsrc" [src]="imgsrc" alt="" style="width: 299px; height: 170px;">
<img *ngIf="!imgsrc" [src]="noImgSrc" alt="" style="width: 299px; height: 170px;">
</div> </div>
<mat-spinner *ngIf="isspinner" diameter= 50></mat-spinner> <mat-spinner *ngIf="isspinner" diameter= 50></mat-spinner>
</div> </div>

111
src/app/key-unit/basicinfo/basicinfo.component.ts

@ -5,21 +5,12 @@ import { HttpClient,HttpHeaders, HttpEventType } from '@angular/common/http';
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { FormControl } from '@angular/forms'; import { FormControl } from '@angular/forms';
import { MatSnackBar ,MatSnackBarConfig} from '@angular/material/snack-bar'; import { MatSnackBar ,MatSnackBarConfig} from '@angular/material/snack-bar';
import format from 'date-fns/format';
import { TreeService } from '../../http-interceptors/tree.service' import { TreeService } from '../../http-interceptors/tree.service'
import { FileUploader, FileItem } from 'ng2-file-upload'
// import { House } from '../../interface'
import { AddHouseInfo } from './addhouseinfo.component' import { AddHouseInfo } from './addhouseinfo.component'
import { DomSanitizer } from '@angular/platform-browser'
import { Injectable } from "@angular/core"
import { filter } from 'rxjs/operators';
import { async } from '@angular/core/testing';
import { MatTableDataSource } from '@angular/material/table'; import { MatTableDataSource } from '@angular/material/table';
import { isNgTemplate } from '@angular/compiler';
import * as _ from 'lodash'; import * as _ from 'lodash';
// import Swiper from 'swiper';
import { LookMaster } from './lookmaster.component' import { LookMaster } from './lookmaster.component'
import { Router,ActivatedRoute } from '@angular/router' import { ActivatedRoute } from '@angular/router'
import { TabbarAndScoreService } from 'src/app/http-interceptors/tabbar-and-score.service'; import { TabbarAndScoreService } from 'src/app/http-interceptors/tabbar-and-score.service';
declare var AMap: any; declare var AMap: any;
@ -49,16 +40,6 @@ export class BasicinfoComponent implements OnInit {
] ]
} }
uploader:FileUploader = new FileUploader({ //初始化上传事件 ng2-upload
url: `/api/Objects/PlanPlatform/${sessionStorage.getItem('companyId')}`,
method: "POST",
itemAlias: "uploadedfile",
autoUpload: false,
removeAfterUpload:true //上传之后是否在队列中移除,如果不移除就会出现无法上传第二次的情况
});
private _transformer = (node, level: number) => { //初始化tree private _transformer = (node, level: number) => { //初始化tree
return { return {
@ -79,22 +60,22 @@ export class BasicinfoComponent implements OnInit {
isorganizationbox = false//控制辖区中队框的显示隐藏 isorganizationbox = false//控制辖区中队框的显示隐藏
selectedorganization: any//所选的辖区中队 selectedorganization: any//所选的辖区中队
selectedorganizationid:any //所选的辖区中队的id selectedorganizationid:any //所选的辖区中队的id
highhouse = false//控制高层表单的显示 highhouse = false//控制高层表单的显示
houses: any = [] //存储当前单位的建筑信息
defaultbuildingTypes :any //存储当前建筑的默认类型的id defaultbuildingTypes :any //存储当前建筑的默认类型的id
buildingTypesname:any//存储当前建筑的默认类型name buildingTypesname:any//存储当前建筑的默认类型name
buildingCustomData:any //存储当前建筑的自定义信息 buildingCustomData:any //存储当前建筑的自定义信息
allunittype: any //所有单位类型
allorganizing:any = [] //所有组织机构
constructor(private elementRef: ElementRef,public renderer2: Renderer2,private tabbarService: TabbarAndScoreService,private router:Router,private route:ActivatedRoute,private http: HttpClient, private tree: TreeService, private sanitizer: DomSanitizer, public dialog: MatDialog,public snackBar: MatSnackBar) { } constructor(private elementRef: ElementRef,public renderer2: Renderer2,private tabbarService: TabbarAndScoreService,private route:ActivatedRoute,private http: HttpClient, private tree: TreeService, public dialog: MatDialog,public snackBar: MatSnackBar) { }
unitId : any //当前单位id unitId : any //当前单位id
ngOnInit(): void { ngOnInit(): void {
this.getallunittype() this.getallunittype()//获得所有单位类型
this.getorganization() this.getorganization()//获得所有组织机构 + 获得当前单位的基本信息
// this.getunitinfo() this.getunitallbuilding()//获得当前单位所有建筑
this.getunitallbuilding()
this.unitId = this.route.snapshot.queryParams.id this.unitId = this.route.snapshot.queryParams.id
sessionStorage.setItem("companyId",this.route.snapshot.queryParams.id); sessionStorage.setItem("companyId",this.route.snapshot.queryParams.id);
} }
@ -107,7 +88,6 @@ export class BasicinfoComponent implements OnInit {
isGisTopBoxTwo:boolean = false//点击位置按钮 isGisTopBoxTwo:boolean = false//点击位置按钮
oldPositionMarker:any //旧位置marker实例 oldPositionMarker:any //旧位置marker实例
newPositionMarker:any //新位置marker实例 newPositionMarker:any //新位置marker实例
newPositionMarkerContent:any = newPositionMarkerContent:any =
'<div class="custom-content-marker">' + '<div class="custom-content-marker">' +
' <img src="/assets/images/newposition.png">' + ' <img src="/assets/images/newposition.png">' +
@ -179,13 +159,9 @@ export class BasicinfoComponent implements OnInit {
this.map.setCity('上海市'); this.map.setCity('上海市');
} }
} }
markerPosition2 markerPosition2
//点击位置按钮 //点击位置按钮
setPosition(){ setPosition(){
this.isGisTopBox = false this.isGisTopBox = false
this.isGisTopBoxTwo = true this.isGisTopBoxTwo = true
if(this.isMapLabel){//如果已经标注单位坐标 if(this.isMapLabel){//如果已经标注单位坐标
@ -304,12 +280,14 @@ export class BasicinfoComponent implements OnInit {
} }
//获得所有单位类型 //获得所有单位类型
allunittype: any //所有单位类型
getallunittype() { getallunittype() {
this.http.get("/api/BuildingTypes/Simple").subscribe(data => { this.http.get("/api/BuildingTypes/Simple").subscribe(data => {
this.allunittype = data this.allunittype = data
}) })
} }
//获得所有组织机构 //获得所有组织机构
allorganizing:any = [] //所有组织机构
getorganization() { getorganization() {
this.http.get('/api/Organizations').subscribe( this.http.get('/api/Organizations').subscribe(
(data: any) => { (data: any) => {
@ -323,15 +301,12 @@ export class BasicinfoComponent implements OnInit {
}else{//未标注 }else{//未标注
_this.isMapLabel = false _this.isMapLabel = false
} }
this.labelGis() this.labelGis()
}) })
} }
) )
} }
//获得当前单位的基本信息 //获得当前单位的基本信息
CompanyId
async getunitinfo(){ async getunitinfo(){
let result = await new Promise((resolve, reject) => { let result = await new Promise((resolve, reject) => {
this.http.get(`/api/Companies/${this.unitId}`).subscribe((data:any)=>{ this.http.get(`/api/Companies/${this.unitId}`).subscribe((data:any)=>{
@ -368,7 +343,6 @@ export class BasicinfoComponent implements OnInit {
this.selectedorganization = str.substr(1) this.selectedorganization = str.substr(1)
} }
} }
this.unitinfo = data this.unitinfo = data
resolve(this.unitinfo) resolve(this.unitinfo)
this.selectedorganizationid = data.organizationId this.selectedorganizationid = data.organizationId
@ -383,6 +357,7 @@ export class BasicinfoComponent implements OnInit {
}) })
} }
//石油化工 装置信息 勾选框 //石油化工 装置信息 勾选框
checkboxchange(item,e){ checkboxchange(item,e){
if(item.buildingBasicGroups){ if(item.buildingBasicGroups){
@ -395,13 +370,13 @@ export class BasicinfoComponent implements OnInit {
} }
unitallbuilding:any = []//用于存储当前单位所有的建筑 unitallbuilding:any = []//用于存储当前单位所有的建筑
buildinginfoId:any = []//用于存储当前单位所有具体建筑的id
presentbuildinfoId:any // 用于存储当前单位第一个建筑的id
bigfor:any//循环(储罐信息+罐区信息)大组 bigfor:any//循环(储罐信息+罐区信息)大组
npdata:any = [] npdata:any = []
newnpdata:any //用于存储石油化工 储罐信息/罐区情况的 datasource newnpdata:any //用于存储石油化工 储罐信息/罐区情况的 datasource
basicCategoryId:any //当前单位所有建筑中位于第一个的建筑id
deviceinfodata:any=[];//用于存储石油化工装置信息的数组 deviceinfodata:any=[];//用于存储石油化工装置信息的数组
zhuangzhiinfodatasource:any = [] //用于存储石油化工装置信息表格的数据来源 zhuangzhiinfodatasource:any = [] //用于存储石油化工装置信息表格的数据来源
newzhuangzhiinfodatasource:any= []//存储石油化工装置信息表格的 datasource形式 newzhuangzhiinfodatasource:any= []//存储石油化工装置信息表格的 datasource形式
@ -575,7 +550,11 @@ export class BasicinfoComponent implements OnInit {
item.buildingCustomData.customProperties.pop() item.buildingCustomData.customProperties.pop()
} }
//得到建筑信息数据并进行处理 //得到建筑信息数据并进行处理
allBuildings:any allBuildings:any //当前单位所有的建筑
houses: any = [] //存储当前单位的建筑信息
basicCategoryId:any //当前单位所有建筑中位于第一个的建筑类型id
presentbuildinfoId:any //用于存储当前单位第一个建筑的具体id
buildinginfoId:any = []//用于存储当前单位所有具体建筑的id
getunitallbuilding(){ getunitallbuilding(){
this.houses = [] this.houses = []
this.unitId = this.route.snapshot.queryParams.id this.unitId = this.route.snapshot.queryParams.id
@ -584,9 +563,9 @@ export class BasicinfoComponent implements OnInit {
companyId:this.unitId companyId:this.unitId
} }
}).subscribe(async (data:any)=>{ // 获得当前单位所有的建筑 }).subscribe(async (data:any)=>{ // 获得当前单位所有的建筑
console.log('所有建筑',data)
this.allBuildings = data this.allBuildings = data
// console.log(data) if(data.length != 0){//如果存在建筑
if(data.length != 0){
this.basicCategoryId = data[0].buildingTypes[0].id this.basicCategoryId = data[0].buildingTypes[0].id
this.presentbuildinfoId = data[0].id // 用于存储当前单位第一个建筑的id this.presentbuildinfoId = data[0].id // 用于存储当前单位第一个建筑的id
for (let i = 0, length = data.length; i < length; i++) {//循环所有建筑 for (let i = 0, length = data.length; i < length; i++) {//循环所有建筑
@ -601,17 +580,19 @@ export class BasicinfoComponent implements OnInit {
buildingType:n.buildingTypes[0].id buildingType:n.buildingTypes[0].id
} }
}).subscribe((data)=>{ }).subscribe((data)=>{
//获得当前建筑自定义信息并且添加到item自定义属性上 //获得当前建筑自定义信息并且添加到建筑属性对象中
let _data = data let _data = data
console.log('当前建筑信息'+index,data)
this.http.get("/api/BuildingCustomData",{params:{ this.http.get("/api/BuildingCustomData",{params:{
buildingId:n.id buildingId:n.id
}}).subscribe((data:any)=>{ }}).subscribe((data:any)=>{
console.log('当前建筑自定义信息'+index,data)
_data[0].buildingCustomData = data _data[0].buildingCustomData = data
if(data && data.customProperties.length != 0){ if(data && data.customProperties.length != 0){
_data[0].isCustomData = true _data[0].isCustomData = true
}else{ }else{
_data[0].isCustomData = false _data[0].isCustomData = false
_data[0].buildingCustomData ={ _data[0].buildingCustomData = {
id: "", id: "",
customProperties: [ customProperties: [
{ {
@ -623,7 +604,7 @@ export class BasicinfoComponent implements OnInit {
} }
} }
}) })
//为每个建筑添加自定义属性 //为每个建筑添加建筑名称等自定义属性 用于显示使用
data[0].buildingtypeId = n.buildingTypes[0].id data[0].buildingtypeId = n.buildingTypes[0].id
data[0].name = n.name data[0].name = n.name
data[0].username = n.name data[0].username = n.name
@ -714,7 +695,6 @@ export class BasicinfoComponent implements OnInit {
this.houses.push(result) // 并且把他添加到 tab 总体数组中 this.houses.push(result) // 并且把他添加到 tab 总体数组中
} }
} }
// console.log(666,this.houses)
}) })
} }
@ -1052,7 +1032,8 @@ export class BasicinfoComponent implements OnInit {
hasChild = (_: number, node: any) => node.expandable; hasChild = (_: number, node: any) => node.expandable;
imgsrc = "../../../assets/images/upload.jpg" //没有上传图片时显示的图片,当上传后就会被替换,即保存时需要传的图片地址参数 imgsrc = "" //没有上传图片时显示的图片,当上传后就会被替换,即保存时需要传的图片地址参数
noImgSrc = '../../../assets/images/upload.jpg'
// imgsrc = "" // imgsrc = ""
imgUrl = ""//返回来的图片地址后缀 imgUrl = ""//返回来的图片地址后缀
file: any; //上传的文件 file: any; //上传的文件
@ -1102,7 +1083,6 @@ export class BasicinfoComponent implements OnInit {
let shardSize = 5 * 1024 * 1024 //5MB一个分片 let shardSize = 5 * 1024 * 1024 //5MB一个分片
if (file && fileSize <= shardSize) { //上传文件<=5MB时 if (file && fileSize <= shardSize) { //上传文件<=5MB时
// this.upload()
let formData = new FormData() let formData = new FormData()
formData.append("file",file) formData.append("file",file)
this.http.post(`/api/Objects/PlanPlatform/${sessionStorage.getItem('companyId')}`,formData).subscribe((data:any)=>{ this.http.post(`/api/Objects/PlanPlatform/${sessionStorage.getItem('companyId')}`,formData).subscribe((data:any)=>{
@ -1125,38 +1105,6 @@ export class BasicinfoComponent implements OnInit {
} }
} }
//小于5MB不需要分块上传
upload(){
this.uploader.queue[0].upload();//开始上传
this.uploader.queue[0].onSuccess = (response, status, headers) => {
// 上传文件成功
if (status == 201) {
// 上传文件后获取服务器返回的数据
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('上传成功','确定',config);
this.isspinner = false
let tempRes = JSON.parse(response);
this.imgUrl = tempRes.objectName
this.imgsrc = `/api/Objects/PlanPlatform/${this.imgUrl}?x-oss-process=image/resize,m_fill,h_170,w_299`
}else {
// 上传文件后获取服务器返回的数据错误
}
};
this.uploader.queue[0].onError = (response, status, headers) => {
if (status == 401) {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('上传失败','确定',config);
}
};
}
//开始分块上传 //开始分块上传
async subsectionUploading () { async subsectionUploading () {
let file = this.file || null //获取上传的文件 let file = this.file || null //获取上传的文件
@ -1194,7 +1142,6 @@ export class BasicinfoComponent implements OnInit {
this.imgsrc = `/api/Objects/PlanPlatform/${this.objectName}?x-oss-process=image/resize,m_fill,h_170,w_299` this.imgsrc = `/api/Objects/PlanPlatform/${this.objectName}?x-oss-process=image/resize,m_fill,h_170,w_299`
this.isspinner = false this.isspinner = false
this.PartNumberETag = [] this.PartNumberETag = []
this.uploader.clearQueue(); //清空input控件文件
}) })
} }
//删除具体建筑 //删除具体建筑

Loading…
Cancel
Save