|
|
|
@ -19,7 +19,7 @@ declare var AMap: any;
|
|
|
|
|
export class FireForceComponent implements OnInit { |
|
|
|
|
|
|
|
|
|
constructor(private tree: TreeService,public snackBar: MatSnackBar,private http:HttpClient,private elementRef: ElementRef,public renderer2: Renderer2,public dialog: MatDialog) { } |
|
|
|
|
isMasklayer:boolean = false//遮罩层是否打开
|
|
|
|
|
|
|
|
|
|
isCheckedOfSearchDiv:boolean = true//列表过滤滑块
|
|
|
|
|
slideChange(e){ |
|
|
|
|
this.isCheckedOfSearchDiv = e.checked |
|
|
|
@ -146,7 +146,6 @@ export class FireForceComponent implements OnInit {
|
|
|
|
|
this.isGisTopBox = false |
|
|
|
|
if(this.selectedFireForceId != node.id){ |
|
|
|
|
this.clearData() |
|
|
|
|
|
|
|
|
|
this.selectedFireForce = node |
|
|
|
|
this.selectedFireForceId = node.id |
|
|
|
|
if(node.forceType != 0){//如果是其他消防力量
|
|
|
|
@ -158,6 +157,7 @@ export class FireForceComponent implements OnInit {
|
|
|
|
|
if(this.newPositionMarker){ |
|
|
|
|
this.map.remove(this.newPositionMarker); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(node.fireForceDetailId){ |
|
|
|
|
this.isPost = false//是否走post创建接口
|
|
|
|
|
let type |
|
|
|
@ -166,7 +166,9 @@ export class FireForceComponent implements OnInit {
|
|
|
|
|
}else{ |
|
|
|
|
type = 1 |
|
|
|
|
} |
|
|
|
|
this.isMasklayer = true |
|
|
|
|
this.http.get(`/api/FireForceDetail/${type}/${node.id}`).subscribe((data:any) => { |
|
|
|
|
this.isMasklayer = false |
|
|
|
|
this.FireForceDetailInfo = data |
|
|
|
|
if(data.location && data.location.x){//如果已经标注单位坐标
|
|
|
|
|
console.log('开始标注') |
|
|
|
@ -207,6 +209,14 @@ export class FireForceComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
this.map.setCity('上海市'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//寻找管辖单位
|
|
|
|
|
this.allFireForceList.forEach(item => { |
|
|
|
|
if(item.id == node.parentId){ |
|
|
|
|
this.superior.name = item.name |
|
|
|
|
this.superior.code = item.code |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//搜索
|
|
|
|
@ -270,7 +280,7 @@ export class FireForceComponent implements OnInit {
|
|
|
|
|
let isDelete = window.confirm(`确定要删除${item.name}吗`) |
|
|
|
|
if(isDelete){ |
|
|
|
|
this.http.delete(`/api/CustomFireForce/${item.id}`).subscribe(data => { |
|
|
|
|
const config = new MatSnackBarConfig(); |
|
|
|
|
let config = new MatSnackBarConfig(); |
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
config.duration = 3000 |
|
|
|
|
this.snackBar.open('删除成功','确定',config); |
|
|
|
@ -363,10 +373,6 @@ export class FireForceComponent implements OnInit {
|
|
|
|
|
clearData(){ |
|
|
|
|
this.deletedFile = []//清空相关资料已删除缓存
|
|
|
|
|
this.AttachmentArr = []//清空相关资料
|
|
|
|
|
this.superior = { |
|
|
|
|
name:'', |
|
|
|
|
code:'' |
|
|
|
|
} |
|
|
|
|
this.positionLngLat = {x:'',y:''} |
|
|
|
|
this.FireForceDetailInfo = { |
|
|
|
|
// id:'',//编号
|
|
|
|
@ -707,14 +713,19 @@ export class FireForceComponent implements OnInit {
|
|
|
|
|
AttachmentArr:any = []//上传附件地址集合
|
|
|
|
|
uploadId:any//分块上传id
|
|
|
|
|
objectName:any |
|
|
|
|
progressBarValue:any = 0//分块上传进度
|
|
|
|
|
isMasklayer:boolean = false//圆圈遮罩层是否打开
|
|
|
|
|
isMasklayerUploading:boolean = false//上传进度条遮罩层是否打开
|
|
|
|
|
isMasklayerDownload:boolean = false//下载进度条遮罩层是否打开
|
|
|
|
|
uploadAttachment(e){ |
|
|
|
|
console.log('选择的文件',e) |
|
|
|
|
this.file = e.target.files[0] || null //上传的文件
|
|
|
|
|
let file = e.target.files[0] || null //获取上传的文件
|
|
|
|
|
let fileSize = file.size || null //上传文件的总大小
|
|
|
|
|
let shardSize = 5 * 1024 * 1024 //5MB一个分片
|
|
|
|
|
this.isMasklayer = true |
|
|
|
|
|
|
|
|
|
if (file && fileSize<=shardSize) { //上传文件<=5MB时
|
|
|
|
|
this.isMasklayer = true |
|
|
|
|
console.log('file',this.file) |
|
|
|
|
let formData = new FormData() |
|
|
|
|
formData.append("file",file) |
|
|
|
@ -729,8 +740,13 @@ export class FireForceComponent implements OnInit {
|
|
|
|
|
this.AttachmentArr.push(obj) |
|
|
|
|
this.isMasklayer = false |
|
|
|
|
console.log('上传成功',data) |
|
|
|
|
let config = new MatSnackBarConfig(); |
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
config.duration = 3000 |
|
|
|
|
this.snackBar.open('上传成功','确定',config); |
|
|
|
|
}) |
|
|
|
|
} else if (file && fileSize>shardSize) { //上传文件>5MB时,分块上传
|
|
|
|
|
this.isMasklayerUploading = true |
|
|
|
|
let data = {filename: file.name} |
|
|
|
|
this.http.post(`/api/NewMultipartUpload/PlanPlatform/FireForce/${this.selectedFireForce.id}`,{},{params:data}).subscribe((data:any)=>{ //初始化分段上传
|
|
|
|
|
console.log('初始化分块上传成功',data) |
|
|
|
@ -741,14 +757,13 @@ export class FireForceComponent implements OnInit {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
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); //切割文件结束位置
|
|
|
|
@ -766,9 +781,10 @@ export class FireForceComponent implements OnInit {
|
|
|
|
|
}) |
|
|
|
|
}); |
|
|
|
|
this.PartNumberETag.push(result) |
|
|
|
|
// this.uploadProgress = Number((i/allSlice).toFixed(2))*100
|
|
|
|
|
// this.progressBarValue = Number((i/allSlice).toFixed(2))*100
|
|
|
|
|
this.progressBarValue = this.accMul(Number((i/allSlice).toFixed(2))*100,1,0) |
|
|
|
|
if (this.PartNumberETag.length === allSlice) { |
|
|
|
|
// this.uploadProgress = 100
|
|
|
|
|
this.progressBarValue = 100 |
|
|
|
|
this.endUploading()} |
|
|
|
|
}//for循环
|
|
|
|
|
|
|
|
|
@ -786,11 +802,90 @@ export class FireForceComponent implements OnInit {
|
|
|
|
|
fileLength:this.file.size |
|
|
|
|
} |
|
|
|
|
this.AttachmentArr.push(obj) |
|
|
|
|
console.log('完成分块上传',data) |
|
|
|
|
this.isMasklayer = false |
|
|
|
|
this.isMasklayerUploading = false//关闭进度条遮罩层
|
|
|
|
|
this.progressBarValue = 0//重置进度数
|
|
|
|
|
let config = new MatSnackBarConfig(); |
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
config.duration = 3000 |
|
|
|
|
this.snackBar.open('上传成功','确定',config); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//取消分块上传
|
|
|
|
|
cancelUploading() { |
|
|
|
|
this.http.delete(`/api/MultipartUpload/PlanPlatform/${this.objectName}?uploadId=${this.uploadId}`).subscribe(data=>{ |
|
|
|
|
this.progressBarValue = 0; |
|
|
|
|
this.isMasklayerUploading= false |
|
|
|
|
this.PartNumberETag =[] //清空保存返回的信息
|
|
|
|
|
const config = new MatSnackBarConfig(); |
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
config.duration = 3000 |
|
|
|
|
this.snackBar.open('取消上传成功','确定',config); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//下载
|
|
|
|
|
download (e) { |
|
|
|
|
this.isMasklayerDownload = true //开启下载进度条
|
|
|
|
|
let file = e //传递过来的文件元数据
|
|
|
|
|
let fileSize = file.fileLength //下载文件的总大小
|
|
|
|
|
let shardSize = 3 * 1024 * 1024 //文件大小是否大于10MB
|
|
|
|
|
if (file && fileSize<=shardSize) { //<=3MB时直接下载
|
|
|
|
|
this.progressBarValue = 60 |
|
|
|
|
this.http.get(`/api/Objects/PlanPlatform/${e.objectName}`,{responseType: 'blob'},).subscribe(data=>{ |
|
|
|
|
let url = window.URL.createObjectURL(new Blob([data])); //createObjectURL创建一个下载Blob的url地址
|
|
|
|
|
let link = document.createElement("a"); |
|
|
|
|
link.style.display = "none"; |
|
|
|
|
link.href = url; |
|
|
|
|
let fileName = e.fileName ? e.fileName : e.objectName.split('/')[e.objectName.split('/').length-1] |
|
|
|
|
link.setAttribute("download", fileName); |
|
|
|
|
document.body.appendChild(link); |
|
|
|
|
link.click(); |
|
|
|
|
this.isMasklayerDownload = false //关闭下载进度条
|
|
|
|
|
this.progressBarValue = 0 //初始化进度条
|
|
|
|
|
}) |
|
|
|
|
} else if (file && fileSize>shardSize) { //>3MB时分块下载
|
|
|
|
|
this.blockingDownload(e) //分段下载
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//分段下载并合并
|
|
|
|
|
async blockingDownload (e) { |
|
|
|
|
let file = e //传递过来的文件元数据
|
|
|
|
|
let fileSize = file.fileLength //下载文件的总大小
|
|
|
|
|
let shardSize = 3 * 1024 * 1024 //3MB一个分片
|
|
|
|
|
let allSlice = Math.ceil(fileSize / shardSize) //总文件/3MB===共分多少段
|
|
|
|
|
let allFile:any = [] //所有的file分段
|
|
|
|
|
|
|
|
|
|
for (let i=0;i<allSlice;i++) { |
|
|
|
|
let start = i * shardSize //每次下载文件开始位置
|
|
|
|
|
let end = Math.min(fileSize, start + shardSize-1); //每次下载文件结束为止
|
|
|
|
|
|
|
|
|
|
let result = await new Promise ((result,reject)=>{ |
|
|
|
|
this.http.get(`/api/Objects/PlanPlatform/${e.objectName}`,{headers:{'range':`bytes= ${start}-${end}`},responseType:'blob'}).subscribe(data=>{ |
|
|
|
|
result(data) })
|
|
|
|
|
}) |
|
|
|
|
allFile.push(result) |
|
|
|
|
// this.progressBarValue = Number((i/allSlice).toFixed(2))*100 //文件进度数
|
|
|
|
|
this.progressBarValue = this.accMul(Number((i/allSlice).toFixed(2))*100,1,0) |
|
|
|
|
if (allFile.length === allSlice) { //合并文件输出给浏览器
|
|
|
|
|
let url = window.URL.createObjectURL(new Blob(allFile)); //createObjectURL创建一个下载Blob的url地址
|
|
|
|
|
let link = document.createElement("a"); |
|
|
|
|
link.style.display = "none"; |
|
|
|
|
link.href = url; |
|
|
|
|
let fileName = e.fileName ? e.fileName : e.objectName.split('/')[e.objectName.split('/').length-1] |
|
|
|
|
link.setAttribute("download", fileName); |
|
|
|
|
document.body.appendChild(link); |
|
|
|
|
link.click(); |
|
|
|
|
this.isMasklayerDownload = false //关闭下载进度条
|
|
|
|
|
this.progressBarValue = 0 //初始化进度条
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} //for循环结束
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//删除图片
|
|
|
|
|
deletedFile:any = [] |
|
|
|
|
deleteFile(item,e){ |
|
|
|
@ -817,7 +912,7 @@ export class FireForceComponent implements OnInit {
|
|
|
|
|
clickFile(item){ |
|
|
|
|
console.log(item) |
|
|
|
|
let suffix = item.fileName.split('.')[item.fileName.split('.').length-1] |
|
|
|
|
if(suffix == 'png' || suffix == 'jpg'){ |
|
|
|
|
if(suffix == 'png' || suffix == 'jpg' || suffix == 'JPG'){ |
|
|
|
|
console.log('这是图片') |
|
|
|
|
let dom = document.getElementById(`viewerjs`) |
|
|
|
|
let pObjs = dom.childNodes; |
|
|
|
@ -842,6 +937,13 @@ export class FireForceComponent implements OnInit {
|
|
|
|
|
config.duration = 3000 |
|
|
|
|
this.snackBar.open('暂不支持查看','确定',config); |
|
|
|
|
} |
|
|
|
|
if(suffix == 'mp4'){ |
|
|
|
|
const dialogRef = this.dialog.open(ViewDetails, {//调用open方法打开对话框并且携带参数过去
|
|
|
|
|
data: {item:item,type:"video"}, |
|
|
|
|
id:'videodialog' |
|
|
|
|
}); |
|
|
|
|
dialogRef.afterClosed().subscribe(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -876,4 +978,28 @@ export class AddFireForce {
|
|
|
|
|
this.dialogRef.close(this.selectedFireForceTypeIndex) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//查看图片大图和视频
|
|
|
|
|
@Component({ |
|
|
|
|
selector: 'viewdetails', |
|
|
|
|
templateUrl: './viewdetails.html', |
|
|
|
|
styleUrls: ['./fire-force.component.scss'] |
|
|
|
|
}) |
|
|
|
|
export class ViewDetails { |
|
|
|
|
// myControl = new FormControl();
|
|
|
|
|
//注入MatDialogRef,可以用来关闭对话框
|
|
|
|
|
//要访问对话框组件中的数据,必须使用MAT_DIALOG_DATA注入令牌
|
|
|
|
|
constructor(private http: HttpClient,public dialogRef: MatDialogRef<ViewDetails>,@Inject(MAT_DIALOG_DATA) public data) {} |
|
|
|
|
Url:string |
|
|
|
|
onNoClick(): void { |
|
|
|
|
this.dialogRef.close(); |
|
|
|
|
} |
|
|
|
|
ngOnInit(): void { |
|
|
|
|
this.Url = '/api/Objects/PlanPlatform/' + this.data.item.objectName |
|
|
|
|
} |
|
|
|
|
closeDialog(){ |
|
|
|
|
this.dialogRef.close(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|