暂无数据
diff --git a/src/app/ui/realistic-picture/realistic-picture.component.scss b/src/app/ui/realistic-picture/realistic-picture.component.scss index 761c269..3e5dcc8 100644 --- a/src/app/ui/realistic-picture/realistic-picture.component.scss +++ b/src/app/ui/realistic-picture/realistic-picture.component.scss @@ -49,11 +49,13 @@ .material { cursor:pointer; - height: 30px; - line-height: 26px; + height: 35px; + line-height: 35px; font-size: 16px; - margin-top: 10px; padding-left: 15px; + .mat-icon { + vertical-align:super; + } span { max-width: 200px; display: inline-block; diff --git a/src/app/ui/realistic-picture/realistic-picture.component.ts b/src/app/ui/realistic-picture/realistic-picture.component.ts index cd26dc4..5711add 100644 --- a/src/app/ui/realistic-picture/realistic-picture.component.ts +++ b/src/app/ui/realistic-picture/realistic-picture.component.ts @@ -15,81 +15,132 @@ import Swiper from 'swiper'; }) export class RealisticPictureComponent implements OnInit { - uploader:FileUploader = new FileUploader({ //初始化上传文件 - url: `/api/Objects/PlanPlatform/${sessionStorage.getItem('companyId')}/RealImgs`, - method: "POST", + uploader: FileUploader = new FileUploader({ //初始化上传文件 + url: `/api/Objects/PlanPlatform/${sessionStorage.getItem('companyId')}/RealImgs`, + method: "POST", itemAlias: "uploadedfile", autoUpload: false, - removeAfterUpload:true, - }); + removeAfterUpload: true, + }); - constructor(private http:HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar) { } + constructor(private http: HttpClient, public dialog: MatDialog, public snackBar: MatSnackBar) { } ngOnInit(): void { this.companyId = sessionStorage.getItem('companyId') - this.http.get('/api/CompanyAccount/RealityImageGroups').subscribe((data:any)=>{ + this.http.get('/api/CompanyAccount/RealityImageGroups').subscribe((data: any) => { this.allRealPicture = data + this.allRealPicture.unshift({ + companyId: sessionStorage.getItem('companyId'), + id: '重点部位', + name: "重点部位", + realityImages: null + }, { + companyId: sessionStorage.getItem('companyId'), + id: '安全出口', + name: "安全出口", + realityImages: null + }) this.selectReal = data[0] this.getAllRealPicture() }) } - companyId:any; //单位编号 - allRealPicture:any=[]; //所有实景图文件 - selectReal:any; //选中的实景图文件 - selectRealIndex:number=0; //选中的实景图文件下标 - allImages:any=[]; //实景图文件对应所有的实景图 - isDownload:boolean = false; //是否批量下载 - downloadList:any = []; //选中需要下载的图片 + companyId: any; //单位编号 + allRealPicture: any = []; //所有实景图文件 + selectReal: any; //选中的实景图文件 + selectRealIndex: number = 0; //选中的实景图文件下标 + allImages: any = []; //实景图文件对应所有的实景图 + isDownload: boolean = false; //是否批量下载 + downloadList: any = []; //选中需要下载的图片 //分页 - @ViewChild(MatPaginator, {static: true}) + @ViewChild(MatPaginator, { static: true }) paginator: MatPaginator; - length:any; //共多少条数据 - pageSize:any = '12'; //每页条数 + length: any; //共多少条数据 + pageSize: any = '12'; //每页条数 pageSizeOptions: number[] = [12] //设置每页条数 - PageNumber:any; //第几页 + PageNumber: any; //第几页 //分页切换 - chagePage (e) { - this.PageNumber = e.pageIndex+1 + chagePage(e) { + this.PageNumber = e.pageIndex + 1 this.getAllRealPicture() } //获取所有实景图分组 - getAllGrouping () { - this.http.get('/api/CompanyAccount/RealityImageGroups').subscribe((data:any)=>{ + getAllGrouping() { + this.http.get('/api/CompanyAccount/RealityImageGroups').subscribe((data: any) => { this.allRealPicture = data this.selectReal = data[this.selectRealIndex] }) } //获取实景图分组对应实景图 - getAllRealPicture () { + getAllRealPicture() { if (this.selectReal) { - let data ={ - groupId: this.selectReal.id, - PageNumber: this.PageNumber || 1, - pageSize: this.pageSize, + + if (this.selectReal.id == '安全出口') { + let params = { + companyId: this.selectReal.companyId, + PageNumber: this.PageNumber || 1, + pageSize: this.pageSize, + } + this.http.get('/api/CompanyAccount/GetCompanySafetyExitImages', { params: params }).subscribe((data: any) => { + // console.log('当前单位安全出口', data) + this.allImages = data.items + this.length = data.totalCount + this.pageSize = this.pageSize + this.downloadList = [] + this.allImages.forEach(element => { //每张图片设置选中状态为false + element.newImageUrl = `${element.imageUrl}?x-oss-process=image/resize,m_fill,h_170,w_299` //处理图片URL地址 + element.nameStart = element.name + element.checked = false //图片是否选中布尔值 + }); + }) + } else { + let data + if (this.selectReal.id == '重点部位') { + data = { + groupId: this.selectReal.id, + // companyId: this.selectReal.companyId, + PageNumber: this.PageNumber || 1, + pageSize: this.pageSize, + } + } else { + data = { + groupId: this.selectReal.id, + PageNumber: this.PageNumber || 1, + pageSize: this.pageSize, + } + } + this.http.get('/api/CompanyAccount/RealityImages', { params: data }).subscribe((data: any) => { + this.allImages = data.items + this.length = data.totalCount + this.pageSize = data.pageSize + this.downloadList = [] + this.allImages.forEach(element => { //每张图片设置选中状态为false + // element.newImageUrl = `/api/Objects/PlanPlatform/${element.imageUrl}?x-oss-process=image/resize,m_fill,h_170,w_299` //处理图片URL地址 + if (this.selectReal.id == '重点部位') { + element.newImageUrl = `${element.imageUrl}?x-oss-process=image/resize,m_fill,h_170,w_299` + element.nameStart = element.name + } else { + element.newImageUrl = `/api/Objects/PlanPlatform/${element.imageUrl}?x-oss-process=image/resize,m_fill,h_170,w_299` //处理图片URL地址 + element.nameStart = element.name.substring(0, element.name.lastIndexOf(".")); //图片名称前缀 + } + element.checked = false //图片是否选中布尔值 + // element.nameStart = element.name.substring(0,element.name.lastIndexOf(".")); //图片名称前缀 + element.nameEnd = element.name.substring(element.name.lastIndexOf("."), element.name.length); //图片名称后缀 + }); + + }) } - this.http.get('/api/CompanyAccount/RealityImages',{params:data}).subscribe((data:any)=>{ - this.allImages = data.items - this.length = data.totalCount - this.pageSize = data.pageSize - this.downloadList = [] - this.allImages.forEach(element => { //每张图片设置选中状态为false - element.newImageUrl = `/api/Objects/PlanPlatform/${element.imageUrl}?x-oss-process=image/resize,m_fill,h_170,w_299` //处理图片URL地址 - element.checked = false //图片是否选中布尔值 - element.nameStart = element.name.substring(0,element.name.lastIndexOf(".")); //图片名称前缀 - element.nameEnd = element.name.substring(element.name.lastIndexOf("."),element.name.length); //图片名称后缀 - }); - }) + } } //切换左侧实景图文件 - changeReal (e,index) { + changeReal(e, index) { if (this.selectRealIndex != index) { this.selectReal = e this.selectRealIndex = index @@ -100,59 +151,81 @@ export class RealisticPictureComponent implements OnInit { } //选择批量下载 - download () { + download() { this.isDownload = !this.isDownload if (!this.isDownload) { //取消批量下载时数组清空 - this.allImages.forEach(element => {element.checked = false}); + this.allImages.forEach(element => { element.checked = false }); this.downloadList = [] } } - + // 预览图片---批量选择图片 - operation (e,index) { + operation(e, index) { if (this.isDownload) { //批量选择图片 e.checked = !e.checked - if (e.checked==true) {this.downloadList.push(e)} - else {this.downloadList.splice(this.downloadList.findIndex(item => item.id === e.id), 1)} + if (e.checked == true) { this.downloadList.push(e) } + else { this.downloadList.splice(this.downloadList.findIndex(item => item.id === e.id), 1) } } else { //预览图片 let data = { - allImages:this.allImages, - imgIndex: index} + selectReal: this.selectReal, + allImages: this.allImages, + imgIndex: index + } let dialogRef = this.dialog.open(previewImg, - {width: '1600px', - height:'900px',data}); - dialogRef.afterClosed().subscribe(); + { + width: '1600px', + height: '900px', data + }); + dialogRef.afterClosed().subscribe(); } } //新建实景图文件 - addReal () { + addReal() { let dialogRef = this.dialog.open(addRealPicture); - dialogRef.afterClosed().subscribe(data=>{ - if (data) {this.getAllGrouping()} - }); + dialogRef.afterClosed().subscribe(data => { + if (data) { this.getAllGrouping() } + }); } //编辑实景图文件 - editReal () { + editReal() { let data = this.selectReal if (this.selectReal) { - let dialogRef = this.dialog.open(editRealPicture, {data}); - dialogRef.afterClosed().subscribe(data=>{ - if (data) {this.getAllGrouping()} - }); + let dialogRef = this.dialog.open(editRealPicture, { data }); + dialogRef.afterClosed().subscribe(data => { + if (data) { this.getAllGrouping() } + }); } } //删除实景图文件 - delete () { + delete() { + if(this.selectReal.name == '重点部位' || this.selectReal.name == '安全出口' || this.selectReal.name == '外观'){ + const config = new MatSnackBarConfig(); + config.verticalPosition = 'top'; + config.duration = 3000 + this.snackBar.open('内置项不允许删除', '确定', config); + return + } if (this.selectReal) { let isDelete = confirm('您确定要删除吗') if (isDelete) { - this.http.delete(`/api/CompanyAccount/RealityImageGroups/${this.selectReal.id}`).subscribe(data=>{ - this.http.get('/api/CompanyAccount/RealityImageGroups').subscribe((data:any)=>{ + this.http.delete(`/api/CompanyAccount/RealityImageGroups/${this.selectReal.id}`).subscribe(data => { + this.http.get('/api/CompanyAccount/RealityImageGroups').subscribe((data: any) => { this.allRealPicture = data + this.allRealPicture.unshift({ + companyId: sessionStorage.getItem('companyId'), + id: '重点部位', + name: "重点部位", + realityImages: null + }, { + companyId: sessionStorage.getItem('companyId'), + id: '安全出口', + name: "安全出口", + realityImages: null + }) this.selectReal = data[this.selectRealIndex] this.allImages = [] this.getAllRealPicture() @@ -165,34 +238,34 @@ export class RealisticPictureComponent implements OnInit { //实景图修改 - preservationImg (e) { + preservationImg(e) { let data = { - id:e.id, - name:e.nameStart+e.nameEnd, - imageUrl:e.imageUrl, - realityImageGroupId:e.realityImageGroupId + id: e.id, + name: e.nameStart + e.nameEnd, + imageUrl: e.imageUrl, + realityImageGroupId: e.realityImageGroupId } - this.http.put(`/api/CompanyAccount/RealityImages/${e.id}`,data).subscribe(data=>{ + this.http.put(`/api/CompanyAccount/RealityImages/${e.id}`, data).subscribe(data => { this.getAllRealPicture() const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('图片修改成功','确定',config); + this.snackBar.open('图片修改成功', '确定', config); }) } //实景图删除 - deleteImg (e) { + deleteImg(e) { let isDelete = confirm('您确定要删除吗') if (isDelete) { - this.http.delete(`/api/CompanyAccount/RealityImages/${e.id}`).subscribe(data=>{ + this.http.delete(`/api/CompanyAccount/RealityImages/${e.id}`).subscribe(data => { this.getAllRealPicture() const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - this.snackBar.open('图片删除成功','确定',config); + this.snackBar.open('图片删除成功', '确定', config); }) - this.http.delete(`/api/Objects/PlanPlatform/${e.imageUrl}`).subscribe(data=>{}) + this.http.delete(`/api/Objects/PlanPlatform/${e.imageUrl}`).subscribe(data => { }) } } @@ -200,14 +273,14 @@ export class RealisticPictureComponent implements OnInit { - isLoading:boolean = false; //loading加载 + isLoading: boolean = false; //loading加载 //上传文件↓ - file:any; //上传的文件 - objectName:any; //上传对象名 - uploadId:any; //上传分块上传事件编号 + file: any; //上传的文件 + objectName: any; //上传对象名 + uploadId: any; //上传分块上传事件编号 //change选择文件 - uploadFile (e) { + uploadFile(e) { if (this.selectReal) { this.file = e.target.files[0] || null //上传的文件 let URL = window.URL.createObjectURL(this.file) @@ -215,46 +288,47 @@ export class RealisticPictureComponent implements OnInit { img.src = URL let that = this img.onload = function () { - if(img.width>=4096 || img.height>=5000 ){ + if (img.width >= 4096 || img.height >= 5000) { const config = new MatSnackBarConfig(); config.verticalPosition = 'top'; config.duration = 3000 - that.snackBar.open('请选择分辨率小于4096*5000的图片','确定',config); + that.snackBar.open('请选择分辨率小于4096*5000的图片', '确定', config); that.uploader.clearQueue(); //清空input控件文件 (