diff --git a/src/app/plan-management/entry-plan-look/entry-plan-look.component.html b/src/app/plan-management/entry-plan-look/entry-plan-look.component.html
index 691b75a..51e3107 100644
--- a/src/app/plan-management/entry-plan-look/entry-plan-look.component.html
+++ b/src/app/plan-management/entry-plan-look/entry-plan-look.component.html
@@ -99,7 +99,7 @@
改名
转在线导入
编辑
+ [ngClass]="{'grey': !(element.auditStatus!='16' && element.auditStatus != '1' )}">编辑
查看
下载
diff --git a/src/app/plan-management/entry-plan-look/entry-plan-look.component.scss b/src/app/plan-management/entry-plan-look/entry-plan-look.component.scss
index 8af8f8b..4a90054 100644
--- a/src/app/plan-management/entry-plan-look/entry-plan-look.component.scss
+++ b/src/app/plan-management/entry-plan-look/entry-plan-look.component.scss
@@ -209,4 +209,12 @@
top: 40%;
left: 40%;
}
+}
+
+//修改上传文件
+.upload{
+ width: 100%;
+ height: 100%;
+ display: flex;
+ flex-direction: column;
}
\ No newline at end of file
diff --git a/src/app/plan-management/entry-plan-look/entry-plan-look.component.ts b/src/app/plan-management/entry-plan-look/entry-plan-look.component.ts
index 2f957dc..5e26420 100644
--- a/src/app/plan-management/entry-plan-look/entry-plan-look.component.ts
+++ b/src/app/plan-management/entry-plan-look/entry-plan-look.component.ts
@@ -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{
})
}
-}
\ No newline at end of file
+}
+
+//编辑上传文件
+@Component({
+ selector: 'editUpload',
+ templateUrl: './upLoad.html',
+ styleUrls: ['./entry-plan-look.component.scss']
+})
+export class editUpload{
+ constructor(private http: HttpClient, public dialogRef: MatDialogRef, @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("上传出错!")
+ }
+
+ })
+ }
+}
diff --git a/src/app/plan-management/entry-plan-look/upLoad.html b/src/app/plan-management/entry-plan-look/upLoad.html
new file mode 100644
index 0000000..a4a531a
--- /dev/null
+++ b/src/app/plan-management/entry-plan-look/upLoad.html
@@ -0,0 +1,10 @@
+
\ No newline at end of file
diff --git a/src/app/plan-management/plan-management.module.ts b/src/app/plan-management/plan-management.module.ts
index b91230d..61d886e 100644
--- a/src/app/plan-management/plan-management.module.ts
+++ b/src/app/plan-management/plan-management.module.ts
@@ -75,12 +75,13 @@ import { disaster } from './create-plan-online-five/create-plan-online-five.comp
import { updataHl } from './create-plan-online-five/create-plan-online-five.component'
import {ChangeUrl} from './entry-plan-look/entry-plan-look.component'
import {adddwsurveys} from './create-plan-online-five/create-plan-online-five.component'
+import { editUpload } from './entry-plan-look/entry-plan-look.component'
@NgModule({
declarations: [EntryPlanComponent, PassPlanComponent, OpenPlanComponent, EntryPlanLookComponent, AddPlanone, PlanType, AuditSatus, PlanLevel, DownloadFile, AuditResult, ChangeName,
WebLookComponent, OnetwoEntryPlanComponent, newunitComponent, MeetPlanComponent, newunitMeet, TypePlanComponent, newunitType, PsViewer, onetwoAuditResult, meetAuditResult,
typeAuditResult, MaintainUpComponent, GkPsViewer, GkhtmlPsViewer, UnitInfo, ReinforcePlanComponent, state, ImgDetails, CreatePlanOnlineFiveComponent, CreatePlanOnlineThreeComponent,
- OpenPlanToolDialog,yinYong,newTitle,disaster,updataHl,ChangeUrl,adddwsurveys],
+ OpenPlanToolDialog,yinYong,newTitle,disaster,updataHl,ChangeUrl,adddwsurveys,editUpload],
imports: [
CommonModule,
PlanManagementRoutingModule,