|
|
@ -14,6 +14,7 @@ import { async } from '@angular/core/testing'; |
|
|
|
import { Viewer } from 'photo-sphere-viewer'; |
|
|
|
import { Viewer } from 'photo-sphere-viewer'; |
|
|
|
import { STEPPER_GLOBAL_OPTIONS } from '@angular/cdk/stepper'; |
|
|
|
import { STEPPER_GLOBAL_OPTIONS } from '@angular/cdk/stepper'; |
|
|
|
import Swiper from 'swiper'; |
|
|
|
import Swiper from 'swiper'; |
|
|
|
|
|
|
|
import { MaskLayerService } from 'src/app/mask-layer.service'; |
|
|
|
declare var CryptoJS |
|
|
|
declare var CryptoJS |
|
|
|
@Component({ |
|
|
|
@Component({ |
|
|
|
selector: 'app-entry-plan-look', |
|
|
|
selector: 'app-entry-plan-look', |
|
|
@ -21,7 +22,7 @@ declare var CryptoJS |
|
|
|
styleUrls: ['./entry-plan-look.component.scss'] |
|
|
|
styleUrls: ['./entry-plan-look.component.scss'] |
|
|
|
}) |
|
|
|
}) |
|
|
|
export class EntryPlanLookComponent implements OnInit { |
|
|
|
export class EntryPlanLookComponent implements OnInit { |
|
|
|
constructor(private http: HttpClient, private router: Router, private route: ActivatedRoute, private tree: TreeService, public dialog: MatDialog, public snackBar: MatSnackBar) { } |
|
|
|
constructor(private http: HttpClient, private router: Router, private route: ActivatedRoute, private tree: TreeService, public dialog: MatDialog, public snackBar: MatSnackBar,private maskLayerService: MaskLayerService) { } |
|
|
|
pageEvent: PageEvent; |
|
|
|
pageEvent: PageEvent; |
|
|
|
private _transformer = (node, level: number) => { //初始化tree
|
|
|
|
private _transformer = (node, level: number) => { //初始化tree
|
|
|
|
return { |
|
|
|
return { |
|
|
@ -172,6 +173,11 @@ export class EntryPlanLookComponent implements OnInit { |
|
|
|
let companyId = sessionStorage.getItem("companyId") |
|
|
|
let companyId = sessionStorage.getItem("companyId") |
|
|
|
window.open(`/keyUnit/editunitinfo?id=${companyId}&orName=${this.route.snapshot.queryParams.orName}&orId=${this.route.snapshot.queryParams.orId}`); |
|
|
|
window.open(`/keyUnit/editunitinfo?id=${companyId}&orName=${this.route.snapshot.queryParams.orName}&orId=${this.route.snapshot.queryParams.orId}`); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else if (e.planType == 4) { //其他预案 上传
|
|
|
|
|
|
|
|
this.selectPlan = e |
|
|
|
|
|
|
|
let Dom = document.getElementById('uploadFile') |
|
|
|
|
|
|
|
Dom.click() |
|
|
|
|
|
|
|
} |
|
|
|
else if (e.planType == 16) { |
|
|
|
else if (e.planType == 16) { |
|
|
|
this.lookPlan(e) |
|
|
|
this.lookPlan(e) |
|
|
|
let body = JSON.stringify(""); |
|
|
|
let body = JSON.stringify(""); |
|
|
@ -343,6 +349,95 @@ export class EntryPlanLookComponent implements OnInit { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
selectPlan: any; //选中的预案
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
file: any; //上传的文件
|
|
|
|
|
|
|
|
fileName: any; //上传文件name
|
|
|
|
|
|
|
|
objectName: any; //上传对象名
|
|
|
|
|
|
|
|
uploadId: any; //上传分块上传事件编号
|
|
|
|
|
|
|
|
//选择文件上传
|
|
|
|
|
|
|
|
filechange(e) { |
|
|
|
|
|
|
|
if (!this.selectPlan) { return } |
|
|
|
|
|
|
|
this.maskLayerService.sendMessage(true); |
|
|
|
|
|
|
|
this.file = e.target.files[0] |
|
|
|
|
|
|
|
let file = e.target.files[0] || null //上传的文件
|
|
|
|
|
|
|
|
let fileSize = file.size || null //上传文件的总大小
|
|
|
|
|
|
|
|
let shardSize = 5 * 1024 * 1024 //5MB一个分片
|
|
|
|
|
|
|
|
if (file && fileSize <= shardSize) { //上传文件<=5MB时
|
|
|
|
|
|
|
|
let formData = new FormData() |
|
|
|
|
|
|
|
formData.append("file", file) |
|
|
|
|
|
|
|
this.http.post(`/api/Objects/PlanPlatform/${this.companyId}/2D`, formData).subscribe((data: any) => { |
|
|
|
|
|
|
|
this.objectName = data.objectName |
|
|
|
|
|
|
|
this.selectPlan.attachmentUrls[0] = this.objectName |
|
|
|
|
|
|
|
this.http.put(`/api/PlanComponents/${this.selectPlan.id}`,this.selectPlan).subscribe(info=>{ |
|
|
|
|
|
|
|
const config = new MatSnackBarConfig(); |
|
|
|
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
|
|
|
config.duration = 3000 |
|
|
|
|
|
|
|
this.snackBar.open('上传成功!', '确定', config); |
|
|
|
|
|
|
|
this.maskLayerService.sendMessage(false); |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} else if (file && fileSize > shardSize) { //上传文件>5MB时,分块上传
|
|
|
|
|
|
|
|
let data = { filename: file.name } |
|
|
|
|
|
|
|
this.http.post(`/api/NewMultipartUpload/PlanPlatform/${this.companyId}/2D`, {}, { params: data }).subscribe((data: any) => { //初始化分段上传
|
|
|
|
|
|
|
|
this.objectName = data.objectName |
|
|
|
|
|
|
|
this.uploadId = data.uploadId |
|
|
|
|
|
|
|
this.subsectionUploading() |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PartNumberETag: any = []; //每次返回需要保存的信息
|
|
|
|
|
|
|
|
//开始分段上传
|
|
|
|
|
|
|
|
async subsectionUploading() { |
|
|
|
|
|
|
|
let file = this.file || null //获取上传的文件
|
|
|
|
|
|
|
|
let fileSize = file.size || null //上传文件的总大小
|
|
|
|
|
|
|
|
let shardSize = 5 * 1024 * 1024 //5MB一个分片
|
|
|
|
|
|
|
|
let allSlice = Math.ceil(fileSize / shardSize) //总文件/5MB===共分多少段 向上取整
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < allSlice; i++) { //循环分段上传
|
|
|
|
|
|
|
|
let start = i * shardSize //切割文件开始位置
|
|
|
|
|
|
|
|
let end = Math.min(fileSize, start + shardSize); //切割文件结束位置 (对比取小数)
|
|
|
|
|
|
|
|
let formData = new FormData() |
|
|
|
|
|
|
|
formData.append("file", file.slice(start, end)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//同步写法实现异步调用
|
|
|
|
|
|
|
|
let result = await new Promise((resolve, reject) => { |
|
|
|
|
|
|
|
// await 需要后面返回一个 promise 对象
|
|
|
|
|
|
|
|
this.http.post(`/api/MultipartUpload/PlanPlatform/${this.objectName}?uploadId=${this.uploadId}&partNumber=${i + 1}`, formData).subscribe((data: any) => { |
|
|
|
|
|
|
|
let msg = { |
|
|
|
|
|
|
|
"partNumber": data.partNumber || null, |
|
|
|
|
|
|
|
"eTag": data.eTag || null |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
resolve(msg) // 调用 promise 内置方法处理成功
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
this.PartNumberETag.push(result) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.PartNumberETag.length === allSlice) { |
|
|
|
|
|
|
|
this.endUploading() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}//for循环
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//完成分块上传
|
|
|
|
|
|
|
|
endUploading() { |
|
|
|
|
|
|
|
let data = this.PartNumberETag |
|
|
|
|
|
|
|
let paramsData = { uploadId: this.uploadId } |
|
|
|
|
|
|
|
this.http.post(`/api/CompleteMultipartUpload/PlanPlatform/${this.objectName}`, data, { params: paramsData }).subscribe(data => { |
|
|
|
|
|
|
|
this.PartNumberETag = [] //清空保存返回的信息
|
|
|
|
|
|
|
|
this.selectPlan.attachmentUrls[0] = this.objectName |
|
|
|
|
|
|
|
console.log(this.selectPlan) |
|
|
|
|
|
|
|
this.http.put(`/api/PlanComponents/${this.selectPlan.id}`,this.selectPlan).subscribe(info=>{ |
|
|
|
|
|
|
|
const config = new MatSnackBarConfig(); |
|
|
|
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
|
|
|
config.duration = 3000 |
|
|
|
|
|
|
|
this.snackBar.open('上传成功!', '确定', config); |
|
|
|
|
|
|
|
this.maskLayerService.sendMessage(false); |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//下载↓
|
|
|
|
//下载↓
|
|
|
|
selectDownloadFile: any; //选择下载的文件
|
|
|
|
selectDownloadFile: any; //选择下载的文件
|
|
|
|
download: any; //下载文件元数据
|
|
|
|
download: any; //下载文件元数据
|
|
|
|