Browse Source

[完善]消防设施和实景图更新版本

master
邵佳豪 3 years ago
parent
commit
8c75906ecd
  1. 99
      src/app/ui/fire-fighting-device/fire-fighting-device.component.html
  2. 1
      src/app/ui/fire-fighting-device/fire-fighting-device.component.scss
  3. 10
      src/app/ui/fire-fighting-device/fire-fighting-device.component.ts
  4. 8
      src/app/ui/realistic-picture/realistic-picture.component.html
  5. 8
      src/app/ui/realistic-picture/realistic-picture.component.scss
  6. 347
      src/app/ui/realistic-picture/realistic-picture.component.ts
  7. 7
      src/styles.scss

99
src/app/ui/fire-fighting-device/fire-fighting-device.component.html

@ -1,101 +1,6 @@
<div class="content"> <div class="content" id="firefightingdevice">
<mat-tab-group (selectedIndexChange)="selectedChange($event)"> <mat-tab-group (selectedIndexChange)="selectedChange($event)">
<!-- <mat-tab label="单位消防设施">
<div class="contentBox">
<p style="width: 100%; margin: 30px auto; text-align: center;" *ngIf="!companyBuiltInGrouping.length">暂无数据,请完善单位基本信息</p>
<div style="width: 100%;margin-top: 25px;" *ngFor="let item of companyBuiltInGrouping;let key = index">
<h3 style="text-align: center;font-weight: 550;">{{item.name}}</h3>
<div style="margin-bottom: 10px;">
<mat-icon title="创建" (click)='addCompanyGrouping(item)'>add_circle_outline</mat-icon>
<mat-icon title="保存" style="margin-left: 25px;" (click)='editCompanyGrouping(item)'>description</mat-icon>
<mat-icon title="删除" style="margin-left: 25px;" (click)='deleteCompanyGrouping(item)'>delete</mat-icon>
</div>
<div>
<mat-accordion multi>
<mat-expansion-panel disabled>
<mat-expansion-panel-header>
<label class="firstContent"></label>
<label class="textContent">项目</label>
<label class="textContent">照片</label>
<label class="totalContent">总数</label>
<label class="lastTextContent">主要情况</label>
</mat-expansion-panel-header>
</mat-expansion-panel>
<mat-expansion-panel *ngFor="let items of item.facilityItems" disabled [expanded]=items.expanded>
<mat-expansion-panel-header>
<label class="firstContent">
<mat-checkbox (change)='checkedCompany($event,item,items)' [disabled]='items.isBuiltin'></mat-checkbox>
</label>
<label class="textContent">{{items.name}}</label>
<label class="textContent"><a href="javascript:void(0)" (click)='previewImg(items)'>查看图片</a></label>
<label class="totalContent">{{items.total ? items.total : '总数: 0'}}</label>
<label class="lastTextContent">
<textarea maxlength="999" [(ngModel)]="items.details" style="width: 80%;"></textarea>
</label>
<label><mat-icon (click)='SwitchBoard(items)' *ngIf="items.isBuiltin">keyboard_arrow_down</mat-icon></label>
</mat-expansion-panel-header>
<div class="overflowTable">
<div class="detailsTable">
<table>
<tr>
<th *ngFor="let header of items.header">{{header}}</th>
</tr>
<tr *ngFor="let body of items.body">
<td *ngFor="let header of items.header">{{body[header]? body[header] : '暂无数据'}}</td>
</tr>
</table>
</div>
<div *ngFor="let tableMsg of items.loopTable" class="detailsTable">
<p style="text-align: center; font-size: 16px; margin: 5px 0;">楼层/区域名称: {{tableMsg.name? tableMsg.name: '暂无名称'}}</p>
<table>
<tr>
<th *ngFor="let header of tableMsg.header">{{header}}</th>
</tr>
<tr *ngFor="let body of tableMsg.body">
<td *ngFor="let header of tableMsg.header">{{body[header]? body[header] : '暂无数据'}}</td>
</tr>
</table>
</div>
</div>
</mat-expansion-panel>
</mat-accordion>
</div>
</div>
<div style="width: 100%;margin-top: 25px;" *ngFor="let item of companyOptionalGrouping;let key = index">
<mat-accordion multi>
<mat-expansion-panel>
<mat-expansion-panel-header>
<h3 style="text-align: center;font-weight: 550;">{{item.name}}</h3>
<mat-icon title="保存" style="margin-left: 25px;" (click)='editCompanyOptional($event,item)'>description</mat-icon>
</mat-expansion-panel-header>
<div *ngFor="let items of item.propertyInfos" class="InputField">
<label>{{items.propertyName}}:</label>
<input type="text" *ngIf="items.propertyType!=1&&items.propertyType!=2&&items.propertyType!=4&&items.propertyType!=6"
[(ngModel)]="items.propertyValue" name="propertyValue">
<textarea maxlength="999" *ngIf="items.propertyType==1" [(ngModel)]="items.propertyValue" name="propertyValue"></textarea>
<input type="number" *ngIf="items.propertyType==2 ||items.propertyType==4" [(ngModel)]="items.propertyValue" name="propertyValue">
<mat-radio-group *ngIf="items.propertyType==6" [(ngModel)]="items.propertyValue" name="propertyValue">
<mat-radio-button style="margin-left: 5px;" [value]='radio.value' *ngFor="let radio of singleElection">{{radio.name}}</mat-radio-button>
</mat-radio-group>
</div>
</mat-expansion-panel>
</mat-accordion>
</div>
</div>
</mat-tab> -->
<mat-tab label="{{newItem.name}}" *ngFor="let newItem of allBuildingGrouping"> <mat-tab label="{{newItem.name}}" *ngFor="let newItem of allBuildingGrouping">
<div class="contentBox"> <div class="contentBox">
@ -121,7 +26,7 @@
</mat-expansion-panel> </mat-expansion-panel>
<mat-expansion-panel *ngFor="let items of item.facilityItems" disabled [expanded]=items.expanded> <mat-expansion-panel *ngFor="let items of item.facilityItems" disabled [expanded]=items.expanded>
<mat-expansion-panel-header> <mat-expansion-panel-header class="expansionheader">
<label class="firstContent"> <label class="firstContent">
<mat-checkbox (change)='checkedCompany($event,item,items)' [disabled]='items.isBuiltin'> <mat-checkbox (change)='checkedCompany($event,item,items)' [disabled]='items.isBuiltin'>
</mat-checkbox> </mat-checkbox>

1
src/app/ui/fire-fighting-device/fire-fighting-device.component.scss

@ -38,7 +38,6 @@
color: black; color: black;
text-align: center; text-align: center;
white-space: pre-line; white-space: pre-line;
max-height: 48px;
overflow-y: auto; overflow-y: auto;
} }
.lastTextContent { //textarea多行文本 .lastTextContent { //textarea多行文本

10
src/app/ui/fire-fighting-device/fire-fighting-device.component.ts

@ -54,7 +54,6 @@ export class FireFightingDeviceComponent implements OnInit {
}); });
}) //http }) //http
} //if } //if
}) })
} }
@ -484,21 +483,19 @@ export class FireFightingDeviceComponent implements OnInit {
for (const key in object) { for (const key in object) {
if (Object.prototype.hasOwnProperty.call(object, key)) { if (Object.prototype.hasOwnProperty.call(object, key)) {
const element = object[key]; const element = object[key];
if (element.total || element.details) {
body.push({ body.push({
buildingId: item.buildingId, buildingId: item.buildingId,
groupName: groupName, groupName: groupName,
facilityName: element.name, facilityName: element.name,
count: element.total, count: element.total || '',
description: element.details description: element.details || ''
}) })
} }
} }
}
return body return body
} }
let header = {buildingId:e.id, groupId:item.id} let header = { buildingId: e.id, groupId: item.id }
let data = [] let data = []
item.facilityItems.forEach((element, index) => { item.facilityItems.forEach((element, index) => {
let msg = { let msg = {
@ -529,6 +526,7 @@ export class FireFightingDeviceComponent implements OnInit {
} else if (item.name == '自动消防设施') { } else if (item.name == '自动消防设施') {
putBody = returnBody(this.automaticFireProtectionFacility, '自动消防设施') putBody = returnBody(this.automaticFireProtectionFacility, '自动消防设施')
} }
console.log('putBody', putBody)
if (putBody.length != 0) { if (putBody.length != 0) {
this.http.put('/api/CompanyAccount/FacilityStatUpdate', putBody, { this.http.put('/api/CompanyAccount/FacilityStatUpdate', putBody, {
params: { params: {

8
src/app/ui/realistic-picture/realistic-picture.component.html

@ -8,7 +8,7 @@
<mat-icon title="删除" (click)='delete()'>delete</mat-icon> <mat-icon title="删除" (click)='delete()'>delete</mat-icon>
</div> </div>
</div> </div>
<div> <div style="box-sizing: border-box;padding-top: 20px;">
<div *ngFor="let item of allRealPicture,let key=index" class="material" <div *ngFor="let item of allRealPicture,let key=index" class="material"
[ngClass]="{'leftFile': selectRealIndex===key}" (click)="changeReal(item,key)"> [ngClass]="{'leftFile': selectRealIndex===key}" (click)="changeReal(item,key)">
<mat-icon class="btn">folder</mat-icon><span>{{item.name}}</span> <mat-icon class="btn">folder</mat-icon><span>{{item.name}}</span>
@ -23,7 +23,7 @@
<div class="topBox"> <div class="topBox">
<div> <div>
<span class="title" *ngIf="selectReal">{{selectReal.name}}</span> <span class="title" *ngIf="selectReal">{{selectReal.name}}</span>
<button mat-raised-button color="primary" class="uploadFileFixed" *ngIf="!isLoading"> <button mat-raised-button color="primary" class="uploadFileFixed" *ngIf="!isLoading && selectReal && selectReal.id != '重点部位' && selectReal.id != '安全出口'">
上传图片 上传图片
<input type="file" id="uploadFile" class="uploadFile" (change)='uploadFile($event)' ng2FileSelect [uploader]="uploader" accept="image/*"> <input type="file" id="uploadFile" class="uploadFile" (change)='uploadFile($event)' ng2FileSelect [uploader]="uploader" accept="image/*">
</button> </button>
@ -42,8 +42,8 @@
<div class="fixedImg"><img [src]="item.newImageUrl" (click)='operation(item,key)' [ngClass]="{'selectImg': item.checked}"></div> <div class="fixedImg"><img [src]="item.newImageUrl" (click)='operation(item,key)' [ngClass]="{'selectImg': item.checked}"></div>
<label style="margin-left: 5px;">图片名称:</label> <label style="margin-left: 5px;">图片名称:</label>
<input type="text" style="margin-left: 10px;" [(ngModel)]="item.nameStart" maxlength="20"> <input type="text" style="margin-left: 10px;" [(ngModel)]="item.nameStart" maxlength="20">
<a href="javascript:" style="margin-left: 5px;" (click)='preservationImg(item)'>保存</a> <a *ngIf="selectReal.id != '重点部位'&& selectReal.id != '安全出口'" href="javascript:" style="margin-left: 5px;" (click)='preservationImg(item)'>保存</a>
<a href="javascript:" style="margin-left: 5px;" (click)="deleteImg(item)">删除</a> <a *ngIf="selectReal.id != '重点部位'&& selectReal.id != '安全出口'" href="javascript:" style="margin-left: 5px;" (click)="deleteImg(item)">删除</a>
</div> </div>
<p style="width: 100px;margin: 30px auto;" *ngIf="!allImages.length">暂无数据</p> <p style="width: 100px;margin: 30px auto;" *ngIf="!allImages.length">暂无数据</p>

8
src/app/ui/realistic-picture/realistic-picture.component.scss

@ -49,11 +49,13 @@
.material { .material {
cursor:pointer; cursor:pointer;
height: 30px; height: 35px;
line-height: 26px; line-height: 35px;
font-size: 16px; font-size: 16px;
margin-top: 10px;
padding-left: 15px; padding-left: 15px;
.mat-icon {
vertical-align:super;
}
span { span {
max-width: 200px; max-width: 200px;
display: inline-block; display: inline-block;

347
src/app/ui/realistic-picture/realistic-picture.component.ts

@ -15,81 +15,132 @@ import Swiper from 'swiper';
}) })
export class RealisticPictureComponent implements OnInit { export class RealisticPictureComponent implements OnInit {
uploader:FileUploader = new FileUploader({ //初始化上传文件 uploader: FileUploader = new FileUploader({ //初始化上传文件
url: `/api/Objects/PlanPlatform/${sessionStorage.getItem('companyId')}/RealImgs`, url: `/api/Objects/PlanPlatform/${sessionStorage.getItem('companyId')}/RealImgs`,
method: "POST", method: "POST",
itemAlias: "uploadedfile", itemAlias: "uploadedfile",
autoUpload: false, 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 { ngOnInit(): void {
this.companyId = sessionStorage.getItem('companyId') 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 = 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.selectReal = data[0]
this.getAllRealPicture() this.getAllRealPicture()
}) })
} }
companyId:any; //单位编号 companyId: any; //单位编号
allRealPicture:any=[]; //所有实景图文件 allRealPicture: any = []; //所有实景图文件
selectReal:any; //选中的实景图文件 selectReal: any; //选中的实景图文件
selectRealIndex:number=0; //选中的实景图文件下标 selectRealIndex: number = 0; //选中的实景图文件下标
allImages:any=[]; //实景图文件对应所有的实景图 allImages: any = []; //实景图文件对应所有的实景图
isDownload:boolean = false; //是否批量下载 isDownload: boolean = false; //是否批量下载
downloadList:any = []; //选中需要下载的图片 downloadList: any = []; //选中需要下载的图片
//分页 //分页
@ViewChild(MatPaginator, {static: true}) @ViewChild(MatPaginator, { static: true })
paginator: MatPaginator; paginator: MatPaginator;
length:any; //共多少条数据 length: any; //共多少条数据
pageSize:any = '12'; //每页条数 pageSize: any = '12'; //每页条数
pageSizeOptions: number[] = [12] //设置每页条数 pageSizeOptions: number[] = [12] //设置每页条数
PageNumber:any; //第几页 PageNumber: any; //第几页
//分页切换 //分页切换
chagePage (e) { chagePage(e) {
this.PageNumber = e.pageIndex+1 this.PageNumber = e.pageIndex + 1
this.getAllRealPicture() this.getAllRealPicture()
} }
//获取所有实景图分组 //获取所有实景图分组
getAllGrouping () { getAllGrouping() {
this.http.get('/api/CompanyAccount/RealityImageGroups').subscribe((data:any)=>{ this.http.get('/api/CompanyAccount/RealityImageGroups').subscribe((data: any) => {
this.allRealPicture = data this.allRealPicture = data
this.selectReal = data[this.selectRealIndex] this.selectReal = data[this.selectRealIndex]
}) })
} }
//获取实景图分组对应实景图 //获取实景图分组对应实景图
getAllRealPicture () { getAllRealPicture() {
if (this.selectReal) { if (this.selectReal) {
let data ={
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, groupId: this.selectReal.id,
// companyId: this.selectReal.companyId,
PageNumber: this.PageNumber || 1, PageNumber: this.PageNumber || 1,
pageSize: this.pageSize, pageSize: this.pageSize,
} }
this.http.get('/api/CompanyAccount/RealityImages',{params:data}).subscribe((data:any)=>{ } 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.allImages = data.items
this.length = data.totalCount this.length = data.totalCount
this.pageSize = data.pageSize this.pageSize = data.pageSize
this.downloadList = [] this.downloadList = []
this.allImages.forEach(element => { //每张图片设置选中状态为false 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.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.checked = false //图片是否选中布尔值
element.nameStart = element.name.substring(0,element.name.lastIndexOf(".")); //图片名称前缀 // element.nameStart = element.name.substring(0,element.name.lastIndexOf(".")); //图片名称前缀
element.nameEnd = element.name.substring(element.name.lastIndexOf("."),element.name.length); //图片名称后缀 element.nameEnd = element.name.substring(element.name.lastIndexOf("."), element.name.length); //图片名称后缀
}); });
}) })
} }
}
} }
//切换左侧实景图文件 //切换左侧实景图文件
changeReal (e,index) { changeReal(e, index) {
if (this.selectRealIndex != index) { if (this.selectRealIndex != index) {
this.selectReal = e this.selectReal = e
this.selectRealIndex = index this.selectRealIndex = index
@ -100,59 +151,81 @@ export class RealisticPictureComponent implements OnInit {
} }
//选择批量下载 //选择批量下载
download () { download() {
this.isDownload = !this.isDownload this.isDownload = !this.isDownload
if (!this.isDownload) { //取消批量下载时数组清空 if (!this.isDownload) { //取消批量下载时数组清空
this.allImages.forEach(element => {element.checked = false}); this.allImages.forEach(element => { element.checked = false });
this.downloadList = [] this.downloadList = []
} }
} }
// 预览图片---批量选择图片 // 预览图片---批量选择图片
operation (e,index) { operation(e, index) {
if (this.isDownload) { //批量选择图片 if (this.isDownload) { //批量选择图片
e.checked = !e.checked e.checked = !e.checked
if (e.checked==true) {this.downloadList.push(e)} if (e.checked == true) { this.downloadList.push(e) }
else {this.downloadList.splice(this.downloadList.findIndex(item => item.id === e.id), 1)} else { this.downloadList.splice(this.downloadList.findIndex(item => item.id === e.id), 1) }
} else { //预览图片 } else { //预览图片
let data = { let data = {
allImages:this.allImages, selectReal: this.selectReal,
imgIndex: index} allImages: this.allImages,
imgIndex: index
}
let dialogRef = this.dialog.open(previewImg, let dialogRef = this.dialog.open(previewImg,
{width: '1600px', {
height:'900px',data}); width: '1600px',
height: '900px', data
});
dialogRef.afterClosed().subscribe(); dialogRef.afterClosed().subscribe();
} }
} }
//新建实景图文件 //新建实景图文件
addReal () { addReal() {
let dialogRef = this.dialog.open(addRealPicture); let dialogRef = this.dialog.open(addRealPicture);
dialogRef.afterClosed().subscribe(data=>{ dialogRef.afterClosed().subscribe(data => {
if (data) {this.getAllGrouping()} if (data) { this.getAllGrouping() }
}); });
} }
//编辑实景图文件 //编辑实景图文件
editReal () { editReal() {
let data = this.selectReal let data = this.selectReal
if (this.selectReal) { if (this.selectReal) {
let dialogRef = this.dialog.open(editRealPicture, {data}); let dialogRef = this.dialog.open(editRealPicture, { data });
dialogRef.afterClosed().subscribe(data=>{ dialogRef.afterClosed().subscribe(data => {
if (data) {this.getAllGrouping()} 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) { if (this.selectReal) {
let isDelete = confirm('您确定要删除吗') let isDelete = confirm('您确定要删除吗')
if (isDelete) { if (isDelete) {
this.http.delete(`/api/CompanyAccount/RealityImageGroups/${this.selectReal.id}`).subscribe(data=>{ this.http.delete(`/api/CompanyAccount/RealityImageGroups/${this.selectReal.id}`).subscribe(data => {
this.http.get('/api/CompanyAccount/RealityImageGroups').subscribe((data:any)=>{ this.http.get('/api/CompanyAccount/RealityImageGroups').subscribe((data: any) => {
this.allRealPicture = data 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.selectReal = data[this.selectRealIndex]
this.allImages = [] this.allImages = []
this.getAllRealPicture() this.getAllRealPicture()
@ -165,34 +238,34 @@ export class RealisticPictureComponent implements OnInit {
//实景图修改 //实景图修改
preservationImg (e) { preservationImg(e) {
let data = { let data = {
id:e.id, id: e.id,
name:e.nameStart+e.nameEnd, name: e.nameStart + e.nameEnd,
imageUrl:e.imageUrl, imageUrl: e.imageUrl,
realityImageGroupId:e.realityImageGroupId 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() this.getAllRealPicture()
const config = new MatSnackBarConfig(); const config = new MatSnackBarConfig();
config.verticalPosition = 'top'; config.verticalPosition = 'top';
config.duration = 3000 config.duration = 3000
this.snackBar.open('图片修改成功','确定',config); this.snackBar.open('图片修改成功', '确定', config);
}) })
} }
//实景图删除 //实景图删除
deleteImg (e) { deleteImg(e) {
let isDelete = confirm('您确定要删除吗') let isDelete = confirm('您确定要删除吗')
if (isDelete) { if (isDelete) {
this.http.delete(`/api/CompanyAccount/RealityImages/${e.id}`).subscribe(data=>{ this.http.delete(`/api/CompanyAccount/RealityImages/${e.id}`).subscribe(data => {
this.getAllRealPicture() this.getAllRealPicture()
const config = new MatSnackBarConfig(); const config = new MatSnackBarConfig();
config.verticalPosition = 'top'; config.verticalPosition = 'top';
config.duration = 3000 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; //上传的文件 file: any; //上传的文件
objectName:any; //上传对象名 objectName: any; //上传对象名
uploadId:any; //上传分块上传事件编号 uploadId: any; //上传分块上传事件编号
//change选择文件 //change选择文件
uploadFile (e) { uploadFile(e) {
if (this.selectReal) { if (this.selectReal) {
this.file = e.target.files[0] || null //上传的文件 this.file = e.target.files[0] || null //上传的文件
let URL = window.URL.createObjectURL(this.file) let URL = window.URL.createObjectURL(this.file)
@ -215,46 +288,47 @@ export class RealisticPictureComponent implements OnInit {
img.src = URL img.src = URL
let that = this let that = this
img.onload = function () { img.onload = function () {
if(img.width>=4096 || img.height>=5000 ){ if (img.width >= 4096 || img.height >= 5000) {
const config = new MatSnackBarConfig(); const config = new MatSnackBarConfig();
config.verticalPosition = 'top'; config.verticalPosition = 'top';
config.duration = 3000 config.duration = 3000
that.snackBar.open('请选择分辨率小于4096*5000的图片','确定',config); that.snackBar.open('请选择分辨率小于4096*5000的图片', '确定', config);
that.uploader.clearQueue(); //清空input控件文件 that.uploader.clearQueue(); //清空input控件文件
(<HTMLInputElement>document.getElementById('uploadFile')).value = null //清空input框缓存 (<HTMLInputElement>document.getElementById('uploadFile')).value = null //清空input框缓存
}else{ that.startUploading() } } else { that.startUploading() }
} //onload } //onload
} else { } else {
const config = new MatSnackBarConfig(); const config = new MatSnackBarConfig();
config.verticalPosition = 'top'; config.verticalPosition = 'top';
config.duration = 3000 config.duration = 3000
this.snackBar.open('请选择或创建实景图文件夹','确定',config); this.snackBar.open('请选择或创建实景图文件夹', '确定', config);
this.uploader.clearQueue(); //清空input控件文件 this.uploader.clearQueue(); //清空input控件文件
(<HTMLInputElement>document.getElementById('uploadFile')).value = null //清空input框缓存 (<HTMLInputElement>document.getElementById('uploadFile')).value = null //清空input框缓存
} }
} }
//上传文件 //上传文件
startUploading () { startUploading() {
let file = this.file || null //获取上传的文件 let file = this.file || null //获取上传的文件
let fileSize = file.size || null //上传文件的总大小 let fileSize = file.size || null //上传文件的总大小
let shardSize = 5 * 1024 * 1024 //5MB一个分片 let shardSize = 5 * 1024 * 1024 //5MB一个分片
let maxdSize = 20 * 1024 * 1024 //限制20MB let maxdSize = 20 * 1024 * 1024 //限制20MB
if (file && fileSize<=shardSize) { //上传文件<=5MB时 if (file && fileSize <= shardSize) { //上传文件<=5MB时
this.uploader.queue[0].upload();//开始上传 this.uploader.queue[0].upload();//开始上传
this.uploader.queue[0].onSuccess = (response, status, headers) => { this.uploader.queue[0].onSuccess = (response, status, headers) => {
if (status == 201) { // 上传文件成功,上传文件后获取服务器返回的数据 if (status == 201) { // 上传文件成功,上传文件后获取服务器返回的数据
let tempRes = JSON.parse(response); let tempRes = JSON.parse(response);
this.objectName = tempRes.objectName this.objectName = tempRes.objectName
this.addRealImg() this.addRealImg()
}else { // 上传文件后获取服务器返回的数据错误 } else { // 上传文件后获取服务器返回的数据错误
let tempRes = JSON.parse(response); let tempRes = JSON.parse(response);
}}; }
} else if (file && fileSize>shardSize && fileSize<maxdSize) { //上传文件>5MB时, };
let data = {filename: file.name} } else if (file && fileSize > shardSize && fileSize < maxdSize) { //上传文件>5MB时,分块上传
let data = { filename: file.name }
this.isLoading = true this.isLoading = true
this.http.post(`/api/NewMultipartUpload/PlanPlatform/${this.companyId}/RealImgs`,{},{params:data}).subscribe((data:any)=>{ //初始化分段上传 this.http.post(`/api/NewMultipartUpload/PlanPlatform/${this.companyId}/RealImgs`, {}, { params: data }).subscribe((data: any) => { //初始化分段上传
this.objectName = data.objectName this.objectName = data.objectName
this.uploadId = data.uploadId this.uploadId = data.uploadId
this.subsectionUploading() this.subsectionUploading()
@ -263,62 +337,63 @@ export class RealisticPictureComponent implements OnInit {
} }
PartNumberETag:any=[]; //每次返回需要保存的信息 PartNumberETag: any = []; //每次返回需要保存的信息
//开始分段上传 //开始分段上传
async subsectionUploading () { async subsectionUploading() {
let file = this.file || null //获取上传的文件 let file = this.file || null //获取上传的文件
let fileSize = file.size || null //上传文件的总大小 let fileSize = file.size || null //上传文件的总大小
let shardSize = 5 * 1024 * 1024 //5MB一个分片 let shardSize = 5 * 1024 * 1024 //5MB一个分片
let allSlice = Math.ceil(fileSize / shardSize) //总文件/5MB===共分多少段 let allSlice = Math.ceil(fileSize / shardSize) //总文件/5MB===共分多少段
for (let i = 0;i < allSlice;i++) { //循环分段上传 for (let i = 0; i < allSlice; i++) { //循环分段上传
let start = i * shardSize //切割文件开始位置 let start = i * shardSize //切割文件开始位置
let end = Math.min(fileSize, start + shardSize); //切割文件结束位置 let end = Math.min(fileSize, start + shardSize); //切割文件结束位置
let formData = new FormData() let formData = new FormData()
formData.append("file",file.slice(start, end)) formData.append("file", file.slice(start, end))
//同步写法实现异步调用 //同步写法实现异步调用
let result = await new Promise((resolve, reject) => { let result = await new Promise((resolve, reject) => {
// await 需要后面返回一个 promise 对象 // await 需要后面返回一个 promise 对象
this.http.post(`/api/MultipartUpload/PlanPlatform/${this.objectName}?uploadId=${this.uploadId}&partNumber=${i+1}`,formData).subscribe((data:any)=>{ this.http.post(`/api/MultipartUpload/PlanPlatform/${this.objectName}?uploadId=${this.uploadId}&partNumber=${i + 1}`, formData).subscribe((data: any) => {
let msg = { let msg = {
"partNumber":data.partNumber || null, "partNumber": data.partNumber || null,
"eTag": data.eTag || null} "eTag": data.eTag || null
}
resolve(msg) // 调用 promise 内置方法处理成功 resolve(msg) // 调用 promise 内置方法处理成功
}) })
}); });
this.PartNumberETag.push(result) this.PartNumberETag.push(result)
if (this.PartNumberETag.length === allSlice) {this.endUploading()} if (this.PartNumberETag.length === allSlice) { this.endUploading() }
}//for循环 }//for循环
} }
//完成分块上传 //完成分块上传
endUploading () { endUploading() {
let data = this.PartNumberETag let data = this.PartNumberETag
let paramsData = {uploadId:this.uploadId} let paramsData = { uploadId: this.uploadId }
this.http.post(`/api/CompleteMultipartUpload/PlanPlatform/${this.objectName}`,data,{params:paramsData}).subscribe(data=>{ this.http.post(`/api/CompleteMultipartUpload/PlanPlatform/${this.objectName}`, data, { params: paramsData }).subscribe(data => {
this.addRealImg() //上传完成后,发送请求创建实景图 this.addRealImg() //上传完成后,发送请求创建实景图
this.isLoading = false this.isLoading = false
this.uploader.clearQueue(); //清空input控件文件 this.uploader.clearQueue(); //清空input控件文件
this.PartNumberETag =[] //清空保存返回的信息 this.PartNumberETag = [] //清空保存返回的信息
}) })
} }
//上传图片成功后获取url地址发送请求创建实景图 //上传图片成功后获取url地址发送请求创建实景图
addRealImg () { addRealImg() {
let data = { let data = {
name: this.file.name, name: this.file.name,
imageUrl:this.objectName, imageUrl: this.objectName,
realityImageGroupId: this.selectReal.id, realityImageGroupId: this.selectReal.id,
} }
this.http.post('/api/CompanyAccount/RealityImages',data).subscribe(data=>{ this.http.post('/api/CompanyAccount/RealityImages', data).subscribe(data => {
(<HTMLInputElement>document.getElementById('uploadFile')).value = null //清空input框缓存 (<HTMLInputElement>document.getElementById('uploadFile')).value = null //清空input框缓存
this.getAllRealPicture() this.getAllRealPicture()
const config = new MatSnackBarConfig(); const config = new MatSnackBarConfig();
config.verticalPosition = 'top'; config.verticalPosition = 'top';
config.duration = 3000 config.duration = 3000
this.snackBar.open('图片上传成功','确定',config); this.snackBar.open('图片上传成功', '确定', config);
}) })
} }
@ -326,33 +401,50 @@ export class RealisticPictureComponent implements OnInit {
//批量下载↓ //批量下载↓
//开始下载 //开始下载
async batchDownload () { async batchDownload() {
if (this.downloadList.length) { //开始批量循环下载 if (this.downloadList.length) { //开始批量循环下载
this.isLoading = true this.isLoading = true
for (let i=0;i<this.downloadList.length;i++) { for (let i = 0; i < this.downloadList.length; i++) {
let result = await new Promise ((result,reject)=>{ let result = await new Promise((result, reject) => {
this.http.get(`/api/Objects/PlanPlatform/${this.downloadList[i].imageUrl}`,{responseType: 'blob'},).subscribe(data=>{ // this.http.get(`/api/Objects/PlanPlatform/${this.downloadList[i].imageUrl}`,{responseType: 'blob'},).subscribe(data=>{
let url
if (this.selectReal.id == '重点部位') {
url = this.downloadList[i].imageUrl
} else {
url = `/api/Objects/PlanPlatform/${this.downloadList[i].imageUrl}`
}
this.http.get(url, { responseType: 'blob' },).subscribe((data: any) => {
let url = window.URL.createObjectURL(new Blob([data])); //createObjectURL创建一个下载Blob的url地址 let url = window.URL.createObjectURL(new Blob([data])); //createObjectURL创建一个下载Blob的url地址
let link = document.createElement("a"); let link = document.createElement("a");
link.style.display = "none"; link.style.display = "none";
link.href = url; link.href = url;
link.setAttribute("download", this.downloadList[i].name); // link.setAttribute("download", this.downloadList[i].name);
let imgName
if (this.selectReal.id == '重点部位') {
imgName = this.downloadList[i].name + '.' + data.type.split('/')[data.type.split('/').length - 1]
} else {
imgName = this.downloadList[i].name
}
link.setAttribute("download", imgName);
document.body.appendChild(link); document.body.appendChild(link);
link.click(); link.click();
result('success')}) result('success')
}) })
if(i == this.downloadList.length-1) { //判断是否下载完毕 })
if (i == this.downloadList.length - 1) { //判断是否下载完毕
this.isLoading = false this.isLoading = false
this.isDownload = false this.isDownload = false
this.allImages.forEach(element => {element.checked = false}); this.allImages.forEach(element => { element.checked = false });
this.downloadList = []} this.downloadList = []
}
} //for循环 } //for循环
} else { } else {
const config = new MatSnackBarConfig(); const config = new MatSnackBarConfig();
config.verticalPosition = 'top'; config.verticalPosition = 'top';
config.duration = 3000 config.duration = 3000
this.snackBar.open('请选择图片','确定',config);} this.snackBar.open('请选择图片', '确定', config);
}
} }
@ -371,14 +463,19 @@ export class RealisticPictureComponent implements OnInit {
}) })
export class previewImg { export class previewImg {
constructor(private http:HttpClient,public dialog: MatDialog,public dialogRef: MatDialogRef<previewImg>, constructor(private http: HttpClient, public dialog: MatDialog, public dialogRef: MatDialogRef<previewImg>,
@Inject(MAT_DIALOG_DATA) public data) { } @Inject(MAT_DIALOG_DATA) public data) { }
testSwiper: Swiper; testSwiper: Swiper;
ngOnInit(): void { ngOnInit(): void {
this.allImages = this.data.allImages this.allImages = this.data.allImages
this.allImages.forEach(element => { this.allImages.forEach(element => {
// element.previewImageUrl = `/api/Objects/PlanPlatform/${element.imageUrl}?x-oss-process=image/auto-orient,1` //处理图片URL地址
if (this.data.selectReal.id == '重点部位' || this.data.selectReal.id == '安全出口') {
element.previewImageUrl = `${element.imageUrl}` //处理图片URL地址
} else {
element.previewImageUrl = `/api/Objects/PlanPlatform/${element.imageUrl}?x-oss-process=image/auto-orient,1` //处理图片URL地址 element.previewImageUrl = `/api/Objects/PlanPlatform/${element.imageUrl}?x-oss-process=image/auto-orient,1` //处理图片URL地址
}
}); });
} }
@ -399,13 +496,13 @@ export class previewImg {
}); });
} }
allImages:any; //展示所有的图片 allImages: any; //展示所有的图片
rotationAngle:number=0; //旋转角度 rotationAngle: number = 0; //旋转角度
//旋转图片 //旋转图片
rotate () { rotate() {
this.rotationAngle = this.rotationAngle+90 this.rotationAngle = this.rotationAngle + 90
if (this.rotationAngle === 360) {this.rotationAngle = 0} if (this.rotationAngle === 360) { this.rotationAngle = 0 }
} }
} }
@ -420,25 +517,33 @@ export class previewImg {
}) })
export class addRealPicture { export class addRealPicture {
constructor(private http:HttpClient,public dialog: MatDialog,public dialogRef: MatDialogRef<addRealPicture>) { } constructor(private http: HttpClient, public dialog: MatDialog, public dialogRef: MatDialogRef<addRealPicture>, public snackBar: MatSnackBar) { }
ngOnInit(): void { ngOnInit(): void {
this.companyId = sessionStorage.getItem('companyId') this.companyId = sessionStorage.getItem('companyId')
} }
companyId:any; //单位编号 companyId: any; //单位编号
//提交表单 //提交表单
onSubmit (e) { onSubmit(e) {
let data={ let data = {
name:e.name, name: e.name,
companyId: this.companyId companyId: this.companyId
} }
this.http.post('/api/CompanyAccount/RealityImageGroups',data).subscribe(data=>{ if(e.name == '安全出口' || e.name == '重点部位' || e.name == '外观'){
let config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('不允许创建名为安全出口、重点部位、外观的文件夹', '确定', config);
}else{
this.http.post('/api/CompanyAccount/RealityImageGroups', data).subscribe(data => {
this.dialogRef.close(data); this.dialogRef.close(data);
}) })
} }
}
} }
@ -451,25 +556,33 @@ export class addRealPicture {
}) })
export class editRealPicture { export class editRealPicture {
constructor(private http:HttpClient,public dialog: MatDialog,public dialogRef: MatDialogRef<editRealPicture>, constructor(private http: HttpClient, public dialog: MatDialog, public dialogRef: MatDialogRef<editRealPicture>,
@Inject(MAT_DIALOG_DATA) public data) { } @Inject(MAT_DIALOG_DATA) public data, public snackBar: MatSnackBar) { }
ngOnInit(): void { ngOnInit(): void {
this.name = this.data.name this.name = this.data.name
} }
name:any //实景图分组名称 name: any //实景图分组名称
//提交表单 //提交表单
onSubmit (e) { onSubmit(e) {
let data = { let data = {
id:this.data.id, id: this.data.id,
name:e.name, name: e.name,
companyId:this.data.companyId companyId: this.data.companyId
} }
this.http.put(`/api/CompanyAccount/RealityImageGroups/${this.data.id}`,data).subscribe(data=>{ if(e.name == '安全出口' || e.name == '重点部位'){
let config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('文件名不允许为安全出口、重点部位、外观', '确定', config);
}else{
this.http.put(`/api/CompanyAccount/RealityImageGroups/${this.data.id}`, data).subscribe(data => {
this.dialogRef.close('success'); this.dialogRef.close('success');
}) })
} }
}
} }

7
src/styles.scss

@ -176,3 +176,10 @@ table td.mat-footer-cell:last-of-type {
background: #666; background: #666;
} }
} }
#firefightingdevice{
.expansionheader{
height: auto!important;
}
}
Loading…
Cancel
Save