|
|
|
@ -8,6 +8,7 @@ import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
|
|
|
|
|
import { MatTreeFlatDataSource, MatTreeFlattener } from '@angular/material/tree'; |
|
|
|
|
import { NzTreeNode } from 'ng-zorro-antd/tree'; |
|
|
|
|
import { TreeService } from 'src/app/http-interceptors/tree.service'; |
|
|
|
|
import Viewer from 'viewerjs' |
|
|
|
|
declare var AMap: any; |
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
|
@ -18,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 |
|
|
|
@ -51,9 +52,42 @@ export class FireForceComponent implements OnInit {
|
|
|
|
|
} |
|
|
|
|
//获得所有消防力量
|
|
|
|
|
newdata:any |
|
|
|
|
allFireForceList:any= [] |
|
|
|
|
getAllFireForce(){ |
|
|
|
|
this.http.get('/api/CustomFireForce').subscribe((data:any) => { |
|
|
|
|
this.dataSource.data = this.tree.toTree(data) |
|
|
|
|
let MinIntegrity = 0 |
|
|
|
|
let MaxIntegrity = 1.1 |
|
|
|
|
if(this.searchForm.integrityNum == '0'){ |
|
|
|
|
MinIntegrity = 0 |
|
|
|
|
MaxIntegrity = 0.5 |
|
|
|
|
}else if(this.searchForm.integrityNum == '1'){ |
|
|
|
|
MinIntegrity = 0.5 |
|
|
|
|
MaxIntegrity = 0.6 |
|
|
|
|
}else if(this.searchForm.integrityNum == '2'){ |
|
|
|
|
MinIntegrity = 0.6 |
|
|
|
|
MaxIntegrity = 0.7 |
|
|
|
|
}else if(this.searchForm.integrityNum == '3'){ |
|
|
|
|
MinIntegrity = 0.7 |
|
|
|
|
MaxIntegrity = 0.8 |
|
|
|
|
}else if(this.searchForm.integrityNum == '4'){ |
|
|
|
|
MinIntegrity = 0.8 |
|
|
|
|
MaxIntegrity = 0.9 |
|
|
|
|
}else if(this.searchForm.integrityNum == '5'){ |
|
|
|
|
MinIntegrity = 0.9 |
|
|
|
|
MaxIntegrity = 1.1 |
|
|
|
|
}else if(this.searchForm.integrityNum == '-1'){ |
|
|
|
|
MinIntegrity = 0 |
|
|
|
|
MaxIntegrity = 1.1 |
|
|
|
|
} |
|
|
|
|
let params:any = { |
|
|
|
|
Keyword : this.searchForm.name ? this.searchForm.name : '', |
|
|
|
|
MinIntegrity : MinIntegrity, |
|
|
|
|
MaxIntegrity : MaxIntegrity |
|
|
|
|
} |
|
|
|
|
this.http.get('/api/CustomFireForce',{params:params}).subscribe((data:any) => { |
|
|
|
|
console.log('所有消防力量列表',data) |
|
|
|
|
this.allFireForceList = data |
|
|
|
|
this.dataSource.data = this.tree.toTree(data) |
|
|
|
|
this.treeControl.expand(this.treeControl.dataNodes[0]); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
upDateAllFireForce = ():void=>{ |
|
|
|
@ -91,7 +125,8 @@ export class FireForceComponent implements OnInit {
|
|
|
|
|
code:node.code, |
|
|
|
|
division:node.division, |
|
|
|
|
fireForceDetailId:node.fireForceDetailId, |
|
|
|
|
forceType:node.forceType |
|
|
|
|
forceType:node.forceType, |
|
|
|
|
fireForceDetailInfo:node.fireForceDetailInfo |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
treeControl = new FlatTreeControl<any>(node => node.level, node => node.expandable); |
|
|
|
@ -111,7 +146,7 @@ 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){//如果是其他消防力量
|
|
|
|
@ -147,6 +182,10 @@ export class FireForceComponent implements OnInit {
|
|
|
|
|
}else{ |
|
|
|
|
this.map.setCity('上海市'); |
|
|
|
|
} |
|
|
|
|
//相关资料
|
|
|
|
|
console.log('详情',data) |
|
|
|
|
data.relevantInfomationData ? this.AttachmentArr = JSON.parse(data.relevantInfomationData) : null |
|
|
|
|
|
|
|
|
|
if(node.forceType == 0 && node.level == 0){ |
|
|
|
|
this.ZongpersonCountData = JSON.parse(data.personCountData) |
|
|
|
|
this.ZongcontactData = JSON.parse(data.contactData) |
|
|
|
@ -162,20 +201,36 @@ export class FireForceComponent implements OnInit {
|
|
|
|
|
if(node.forceType != 0){ |
|
|
|
|
this.otherpersonCountData = JSON.parse(data.personCountData) |
|
|
|
|
this.othercontactData = JSON.parse(data.contactData) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}else{ |
|
|
|
|
|
|
|
|
|
this.map.setCity('上海市'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//搜索
|
|
|
|
|
isTreeView:boolean = true//决定显示树还是列表
|
|
|
|
|
searchList(){ |
|
|
|
|
console.log(this.searchForm) |
|
|
|
|
if(!this.searchForm.name && !this.searchForm.integrityNum){ |
|
|
|
|
this.isTreeView = true |
|
|
|
|
}else{ |
|
|
|
|
this.isTreeView = false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.getAllFireForce() |
|
|
|
|
} |
|
|
|
|
//重置搜索
|
|
|
|
|
reset(){ |
|
|
|
|
this.isTreeView = true |
|
|
|
|
this.selectedFireForceLevel = null |
|
|
|
|
this.searchForm = { |
|
|
|
|
name:'', |
|
|
|
|
integrityNum:'' |
|
|
|
|
} |
|
|
|
|
this.getAllFireForce() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//js乘法
|
|
|
|
|
accMul(arg1,arg2,fix) {
|
|
|
|
|
if(!parseInt(fix)==fix) |
|
|
|
@ -248,7 +303,8 @@ export class FireForceComponent implements OnInit {
|
|
|
|
|
}, |
|
|
|
|
personCountData:[],//人员数量自定义
|
|
|
|
|
contactData:[],//联系方式自定义
|
|
|
|
|
dutyForceData:[]//执勤力量自定义
|
|
|
|
|
dutyForceData:[],//执勤力量自定义
|
|
|
|
|
RelevantInfomationData:[]//相关资料
|
|
|
|
|
} |
|
|
|
|
//总队支队人员数量
|
|
|
|
|
ZongpersonCountData:any=[ |
|
|
|
@ -305,6 +361,8 @@ export class FireForceComponent implements OnInit {
|
|
|
|
|
] |
|
|
|
|
//清空表单数据
|
|
|
|
|
clearData(){ |
|
|
|
|
this.deletedFile = []//清空相关资料已删除缓存
|
|
|
|
|
this.AttachmentArr = []//清空相关资料
|
|
|
|
|
this.superior = { |
|
|
|
|
name:'', |
|
|
|
|
code:'' |
|
|
|
@ -325,7 +383,8 @@ export class FireForceComponent implements OnInit {
|
|
|
|
|
}, |
|
|
|
|
personCountData:[],//人员数量自定义
|
|
|
|
|
contactData:[],//联系方式自定义
|
|
|
|
|
dutyForceData:[]//执勤力量自定义
|
|
|
|
|
dutyForceData:[],//执勤力量自定义
|
|
|
|
|
RelevantInfomationData:[]//相关资料
|
|
|
|
|
} |
|
|
|
|
this.ZongpersonCountData = [ |
|
|
|
|
{PropertyName :'现役官兵人数',PropertyValue:''}, |
|
|
|
@ -412,10 +471,21 @@ export class FireForceComponent implements OnInit {
|
|
|
|
|
alert('名称必填') |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
console.log(777,this.atLastPositionLngLat) |
|
|
|
|
//删除一下数据库的文件
|
|
|
|
|
if(this.deletedFile.length != 0){ |
|
|
|
|
this.deletedFile.forEach(item => { |
|
|
|
|
// this.http.delete(`/api/Objects/PlanPlatform/${item.objectName}?x-oss-process=image/resize,m_fixed,h_100,w_100`).subscribe(data=>{
|
|
|
|
|
// console.log('删除缩略图成功')
|
|
|
|
|
// })
|
|
|
|
|
this.http.delete(`/api/Objects/PlanPlatform/${item.objectName}`).subscribe(data=>{ |
|
|
|
|
console.log('删除原文件成功') |
|
|
|
|
}) |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
this.FireForceDetailInfo.jurisdictionArea = Number(this.FireForceDetailInfo.jurisdictionArea) |
|
|
|
|
this.FireForceDetailInfo.RelevantInfomationData = JSON.stringify(this.AttachmentArr) |
|
|
|
|
//如果是总支大中
|
|
|
|
|
// console.log(8888, this.FireForceDetailInfo)
|
|
|
|
|
this.FireForceDetailInfo.location = {x:'',y:''} |
|
|
|
|
if(this.atLastPositionLngLat.x){ |
|
|
|
|
this.FireForceDetailInfo.location.x = this.atLastPositionLngLat.x |
|
|
|
@ -447,7 +517,6 @@ export class FireForceComponent implements OnInit {
|
|
|
|
|
config.duration = 3000 |
|
|
|
|
this.snackBar.open('保存成功','确定',config); |
|
|
|
|
this.upDateAllFireForce() |
|
|
|
|
console.log(123,data) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
//如果是其他消防力量
|
|
|
|
@ -468,6 +537,7 @@ export class FireForceComponent implements OnInit {
|
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
config.duration = 3000 |
|
|
|
|
this.snackBar.open('保存成功','确定',config); |
|
|
|
|
this.upDateAllFireForce() |
|
|
|
|
// console.log(123,data)
|
|
|
|
|
}) |
|
|
|
|
}else{ |
|
|
|
@ -564,18 +634,18 @@ export class FireForceComponent implements OnInit {
|
|
|
|
|
isGisTopBox:boolean = false //
|
|
|
|
|
searchTitle:any = ''//
|
|
|
|
|
|
|
|
|
|
positionLngLat:any = {}//临时坐标点
|
|
|
|
|
atLastPositionLngLat:any = {x:null,y:null}//最终坐标点
|
|
|
|
|
positionLngLat:any = {x:'',y:''}//临时坐标点
|
|
|
|
|
atLastPositionLngLat:any = {x:'',y:''}//最终坐标点
|
|
|
|
|
setPosition(){ |
|
|
|
|
if(!this.isGisTopBox){ |
|
|
|
|
this.isGisTopBox = true |
|
|
|
|
this.newPositionMarker ? this.map.remove(this.newPositionMarker) : null |
|
|
|
|
let center |
|
|
|
|
console.log() |
|
|
|
|
console.log(789,this.atLastPositionLngLat) |
|
|
|
|
if(this.newPositionMarker && this.atLastPositionLngLat.x){//如果已经标注单位坐标
|
|
|
|
|
console.log(1) |
|
|
|
|
center = [this.atLastPositionLngLat.x, this.atLastPositionLngLat.y] |
|
|
|
|
}else if(this.newPositionMarker && !this.atLastPositionLngLat.x && this.FireForceDetailInfo.location.x){ |
|
|
|
|
}else if(this.newPositionMarker && !this.atLastPositionLngLat.x && this.FireForceDetailInfo.location && this.FireForceDetailInfo.location.x){ |
|
|
|
|
console.log(2) |
|
|
|
|
center = [this.FireForceDetailInfo.location.x, this.FireForceDetailInfo.location.y] |
|
|
|
|
}else{ |
|
|
|
@ -628,6 +698,151 @@ export class FireForceComponent implements OnInit {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//上传附件
|
|
|
|
|
file:any; //上传的文件
|
|
|
|
|
AttachmentArr:any = []//上传附件地址集合
|
|
|
|
|
uploadId:any//分块上传id
|
|
|
|
|
objectName:any |
|
|
|
|
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时
|
|
|
|
|
console.log('file',this.file) |
|
|
|
|
let formData = new FormData() |
|
|
|
|
formData.append("file",file) |
|
|
|
|
//this.selectedFireForce.id 选择的组织机构的id
|
|
|
|
|
this.http.post(`/api/Objects/PlanPlatform/FireForce/${this.selectedFireForce.id}`,formData).subscribe((data:any)=>{ |
|
|
|
|
// this.objectName = data.objectName
|
|
|
|
|
let obj = { |
|
|
|
|
objectName:data.objectName, |
|
|
|
|
fileName:data.fileName, |
|
|
|
|
fileLength:data.fileLength |
|
|
|
|
} |
|
|
|
|
this.AttachmentArr.push(obj) |
|
|
|
|
this.isMasklayer = false |
|
|
|
|
console.log('上传成功',data) |
|
|
|
|
}) |
|
|
|
|
} else if (file && fileSize>shardSize) { //上传文件>5MB时,分块上传
|
|
|
|
|
let data = {filename: file.name} |
|
|
|
|
this.http.post(`/api/NewMultipartUpload/PlanPlatform/FireForce/${this.selectedFireForce.id}`,{},{params:data}).subscribe((data:any)=>{ //初始化分段上传
|
|
|
|
|
console.log('初始化分块上传成功',data) |
|
|
|
|
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) |
|
|
|
|
// this.uploadProgress = Number((i/allSlice).toFixed(2))*100
|
|
|
|
|
if (this.PartNumberETag.length === allSlice) { |
|
|
|
|
// this.uploadProgress = 100
|
|
|
|
|
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 =[] //清空保存返回的信息
|
|
|
|
|
let obj = { |
|
|
|
|
objectName:this.objectName, |
|
|
|
|
fileName:this.file.name, |
|
|
|
|
fileLength:this.file.size |
|
|
|
|
} |
|
|
|
|
this.AttachmentArr.push(obj) |
|
|
|
|
console.log('完成分块上传',data) |
|
|
|
|
this.isMasklayer = false |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//删除图片
|
|
|
|
|
deletedFile:any = [] |
|
|
|
|
deleteFile(item,e){ |
|
|
|
|
console.log(this.AttachmentArr) |
|
|
|
|
e.stopPropagation() |
|
|
|
|
let isTrue = window.confirm('确定要删除该文件吗?') |
|
|
|
|
if(isTrue){ |
|
|
|
|
let index |
|
|
|
|
this.AttachmentArr.forEach((element,key) => { |
|
|
|
|
if(element.objectName == item.objectName){ |
|
|
|
|
index = key |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
this.AttachmentArr.splice(index,1) |
|
|
|
|
this.deletedFile.push(item) |
|
|
|
|
let config = new MatSnackBarConfig(); |
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
config.duration = 3000 |
|
|
|
|
this.snackBar.open('删除成功','确定',config); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//点击文件
|
|
|
|
|
clickFile(item){ |
|
|
|
|
console.log(item) |
|
|
|
|
let suffix = item.fileName.split('.')[item.fileName.split('.').length-1] |
|
|
|
|
if(suffix == 'png' || suffix == 'jpg'){ |
|
|
|
|
console.log('这是图片') |
|
|
|
|
let dom = document.getElementById(`viewerjs`) |
|
|
|
|
let pObjs = dom.childNodes; |
|
|
|
|
let node = document.createElement("img") |
|
|
|
|
node.style.display = "none"; |
|
|
|
|
node.src = "/api/Objects/PlanPlatform/" + item.objectName; |
|
|
|
|
node.id = 'img' |
|
|
|
|
dom.appendChild(node) |
|
|
|
|
setTimeout(() => { |
|
|
|
|
let viewer = new Viewer(document.getElementById(`viewerjs`), { |
|
|
|
|
hidden:()=>{ |
|
|
|
|
dom.removeChild(pObjs[0]); |
|
|
|
|
viewer.destroy(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
node.click(); |
|
|
|
|
}, 0); |
|
|
|
|
} |
|
|
|
|
if(suffix == 'docx' || suffix == 'doc' || suffix == 'pdf'){ |
|
|
|
|
let config = new MatSnackBarConfig(); |
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
config.duration = 3000 |
|
|
|
|
this.snackBar.open('暂不支持查看','确定',config); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|