|
|
|
@ -125,8 +125,8 @@ export class EntryPlanLookComponent implements OnInit {
|
|
|
|
|
}); |
|
|
|
|
dialogRef.afterClosed().subscribe(); |
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
let fetchUrl = e.attachmentUrls[0] |
|
|
|
|
//console.log(fetchUrl)
|
|
|
|
|
if (fetchUrl) { |
|
|
|
|
let suffix = fetchUrl.split('.')[fetchUrl.split('.').length - 1].toLowerCase() |
|
|
|
|
if (suffix == 'docx' || suffix == 'doc') { |
|
|
|
@ -219,8 +219,17 @@ export class EntryPlanLookComponent implements OnInit {
|
|
|
|
|
headers |
|
|
|
|
}; |
|
|
|
|
this.http.put(`/api/PlanComponents/${e.id}?resetAudit=${resetAudit}`, body, options).subscribe(data => { |
|
|
|
|
this.getAllPlanComponents() |
|
|
|
|
this.lookPlan(e) |
|
|
|
|
/* this.getAllPlanComponents() |
|
|
|
|
this.lookPlan(e) */ |
|
|
|
|
const dialogRef = this.dialog.open(editUpload, { |
|
|
|
|
width: "300px", |
|
|
|
|
height: "150px", |
|
|
|
|
data: { id:e.id, companyId: this.companyId, unitType: this.unitdata.unittype, unitName: this.unitdata.unitname }, |
|
|
|
|
disableClose: true |
|
|
|
|
}); |
|
|
|
|
dialogRef.afterClosed().subscribe(data => { |
|
|
|
|
this.getAllPlanComponents() |
|
|
|
|
}) |
|
|
|
|
}/* ,err => { |
|
|
|
|
this.snackBar.open(err,'确定',config); |
|
|
|
|
} */) |
|
|
|
@ -288,8 +297,15 @@ export class EntryPlanLookComponent implements OnInit {
|
|
|
|
|
headers |
|
|
|
|
}; |
|
|
|
|
this.http.put(`/api/PlanComponents/${e.id}?resetAudit=${resetAudit}`, body, options).subscribe(data => { |
|
|
|
|
this.getAllPlanComponents() |
|
|
|
|
this.lookPlan(e) |
|
|
|
|
const dialogRef = this.dialog.open(editUpload, { |
|
|
|
|
width: "300px", |
|
|
|
|
height: "150px", |
|
|
|
|
data: { id:e.id, companyId: this.companyId, unitType: this.unitdata.unittype, unitName: this.unitdata.unitname }, |
|
|
|
|
disableClose: true |
|
|
|
|
}); |
|
|
|
|
dialogRef.afterClosed().subscribe(data => { |
|
|
|
|
this.getAllPlanComponents() |
|
|
|
|
}) |
|
|
|
|
}/* ,err => { |
|
|
|
|
this.snackBar.open(err,'确定',config); |
|
|
|
|
} */) |
|
|
|
@ -350,8 +366,17 @@ export class EntryPlanLookComponent implements OnInit {
|
|
|
|
|
headers |
|
|
|
|
}; |
|
|
|
|
this.http.put(`/api/PlanComponents/${e.id}?resetAudit=${resetAudit}`, body, options).subscribe(data => { |
|
|
|
|
this.getAllPlanComponents() |
|
|
|
|
this.lookPlan(e) |
|
|
|
|
|
|
|
|
|
const dialogRef = this.dialog.open(editUpload, { |
|
|
|
|
width: "300px", |
|
|
|
|
height: "150px", |
|
|
|
|
data: { id:e.id, companyId: this.companyId, unitType: this.unitdata.unittype, unitName: this.unitdata.unitname }, |
|
|
|
|
disableClose: true |
|
|
|
|
}); |
|
|
|
|
dialogRef.afterClosed().subscribe(data => { |
|
|
|
|
this.getAllPlanComponents() |
|
|
|
|
}) |
|
|
|
|
//this.lookPlan(e)
|
|
|
|
|
}/* ,err => { |
|
|
|
|
this.snackBar.open(err,'确定',config); |
|
|
|
|
} */) |
|
|
|
@ -1082,9 +1107,6 @@ export class AddPlanone {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//导入word文件
|
|
|
|
|
fileInput(e) { |
|
|
|
|
this.file2 = e.target.files[0] |
|
|
|
@ -1422,8 +1444,6 @@ export class AddPlanone {
|
|
|
|
|
this.snackBar.open('请填写正确网址格式,需以http://或者https://开头的正确网址', '确定', config); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
@ -1649,4 +1669,186 @@ export class ChangeUrl{
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//编辑上传文件
|
|
|
|
|
@Component({ |
|
|
|
|
selector: 'editUpload', |
|
|
|
|
templateUrl: './upLoad.html', |
|
|
|
|
styleUrls: ['./entry-plan-look.component.scss'] |
|
|
|
|
}) |
|
|
|
|
export class editUpload{ |
|
|
|
|
constructor(private http: HttpClient, public dialogRef: MatDialogRef<editUpload>, @Inject(MAT_DIALOG_DATA) public data, public snackBar: MatSnackBar) { } |
|
|
|
|
planName: any//预案名称
|
|
|
|
|
ngOnInit(): void { |
|
|
|
|
console.log(this.data) |
|
|
|
|
} |
|
|
|
|
onNoClick(): void { |
|
|
|
|
this.dialogRef.close(); |
|
|
|
|
} |
|
|
|
|
//上传文件↓
|
|
|
|
|
file: any; //上传的文件
|
|
|
|
|
fileName: any; //上传文件name
|
|
|
|
|
uploadisLoading: boolean = false; //进度条loading加载
|
|
|
|
|
uploadProgress: number = 0; //进度条进度
|
|
|
|
|
objectName: any; //上传对象名
|
|
|
|
|
uploadId: any; //上传分块上传事件编号
|
|
|
|
|
lastyuanData //之前的预案数据
|
|
|
|
|
|
|
|
|
|
//上传文件input
|
|
|
|
|
filechange(e) { |
|
|
|
|
this.file = e.target.files[0] || null //上传的文件
|
|
|
|
|
} |
|
|
|
|
//上传文件
|
|
|
|
|
startUploading() { |
|
|
|
|
console.log(this.file) |
|
|
|
|
let file = this.file || null //获取上传的文件
|
|
|
|
|
let fileSize = file.size || null //上传文件的总大小
|
|
|
|
|
let shardSize = 5 * 1024 * 1024 //5MB一个分片
|
|
|
|
|
// console.log(this.psw)
|
|
|
|
|
if(this.file!=undefined){ |
|
|
|
|
if (file && fileSize <= shardSize) { //上传文件<=5MB时
|
|
|
|
|
let formData = new FormData() |
|
|
|
|
formData.append("file", file) |
|
|
|
|
this.http.post(`/api/Objects/PlanPlatform/${this.data.companyId}/2D`, formData).subscribe((data: any) => { |
|
|
|
|
this.objectName = data.objectName |
|
|
|
|
let headers = new HttpHeaders({ |
|
|
|
|
'Content-Type': 'text/json' |
|
|
|
|
}); |
|
|
|
|
let options = { |
|
|
|
|
headers |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.uploadover = true |
|
|
|
|
let level = sessionStorage.getItem("level") |
|
|
|
|
// console.log(level)
|
|
|
|
|
let PlanLevel |
|
|
|
|
if (level == '0') { |
|
|
|
|
PlanLevel = 1 |
|
|
|
|
} |
|
|
|
|
if (level == '1') { |
|
|
|
|
PlanLevel = 2 |
|
|
|
|
} |
|
|
|
|
if (level == '2') { |
|
|
|
|
PlanLevel = 4 |
|
|
|
|
} |
|
|
|
|
if (level == '3') { |
|
|
|
|
PlanLevel = 8 |
|
|
|
|
} |
|
|
|
|
let uploadUrl = "/api/PlanComponents" |
|
|
|
|
this.http.get(`/api/PlanComponents/${this.data.id}`).subscribe(yuandata => { |
|
|
|
|
console.log(yuandata) |
|
|
|
|
this.lastyuanData=yuandata |
|
|
|
|
this.lastyuanData.attachmentUrls[0]=this.objectName |
|
|
|
|
this.http.put(`/api/PlanComponents/${this.data.id}`, this.lastyuanData,options).subscribe(data => { |
|
|
|
|
this.dialogRef.close(data); |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
} else if (file && fileSize > shardSize) { //上传文件>5MB时,分块上传
|
|
|
|
|
let data = { filename: file.name } |
|
|
|
|
//this.uploadisLoading = tru
|
|
|
|
|
this.subsectionUploading() |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else{ |
|
|
|
|
const config = new MatSnackBarConfig(); |
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
config.duration = 3000 |
|
|
|
|
this.snackBar.open('请选择文件!', '确定', config); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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循环
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
uploadover: any = false //上传完成之后提示
|
|
|
|
|
//完成分块上传
|
|
|
|
|
endUploading() { |
|
|
|
|
let data = this.PartNumberETag |
|
|
|
|
let paramsData = { uploadId: this.uploadId } |
|
|
|
|
this.http.post(`/api/CompleteMultipartUpload/PlanPlatform/${this.objectName}`, data, { params: paramsData }).subscribe(data => { |
|
|
|
|
const config = new MatSnackBarConfig(); |
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
config.duration = 3000 |
|
|
|
|
this.snackBar.open('上传成功!', '确定', config); |
|
|
|
|
this.uploadProgress = 0; |
|
|
|
|
this.uploadisLoading = false |
|
|
|
|
this.PartNumberETag = [] //清空保存返回的信息
|
|
|
|
|
this.uploadover = true |
|
|
|
|
let level = sessionStorage.getItem("level") |
|
|
|
|
let headers = new HttpHeaders({ |
|
|
|
|
'Content-Type': 'text/json' |
|
|
|
|
}); |
|
|
|
|
let options = { |
|
|
|
|
headers |
|
|
|
|
}; |
|
|
|
|
// console.log(level)
|
|
|
|
|
let PlanLevel |
|
|
|
|
if (level == '0') { |
|
|
|
|
PlanLevel = 1 |
|
|
|
|
} |
|
|
|
|
if (level == '1') { |
|
|
|
|
PlanLevel = 2 |
|
|
|
|
} |
|
|
|
|
if (level == '2') { |
|
|
|
|
PlanLevel = 4 |
|
|
|
|
} |
|
|
|
|
if (level == '3') { |
|
|
|
|
PlanLevel = 8 |
|
|
|
|
} |
|
|
|
|
let uploadUrl = "/api/PlanComponents" |
|
|
|
|
|
|
|
|
|
if (this.uploadover) {//如果上次成功了才创建
|
|
|
|
|
this.http.get(`/api/PlanComponents/${this.data.id}`).subscribe(yuandata => { |
|
|
|
|
console.log(yuandata) |
|
|
|
|
this.lastyuanData=yuandata |
|
|
|
|
this.lastyuanData.attachmentUrls[0]=this.objectName |
|
|
|
|
this.http.put(`/api/PlanComponents/${this.data.id}`, this.lastyuanData,options).subscribe(data => { |
|
|
|
|
this.dialogRef.close(data); |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
console.log("上传出错!") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|