Browse Source

[修改]一到五级预案录入功能实现

dev
chenjingyu 4 years ago
parent
commit
0e3d3b6476
  1. 61
      src/app/plan-management/meet-plan/meet-plan.component.html
  2. 3
      src/app/plan-management/meet-plan/meet-plan.component.scss
  3. 353
      src/app/plan-management/meet-plan/meet-plan.component.ts
  4. 30
      src/app/plan-management/meet-plan/newunit.html
  5. 2
      src/app/plan-management/meet-plan/newunit.scss
  6. 30
      src/app/plan-management/onetwo-entry-plan/newunit.html
  7. 2
      src/app/plan-management/onetwo-entry-plan/newunit.scss
  8. 32
      src/app/plan-management/onetwo-entry-plan/onetwo-entry-plan.component.html
  9. 3
      src/app/plan-management/onetwo-entry-plan/onetwo-entry-plan.component.scss
  10. 351
      src/app/plan-management/onetwo-entry-plan/onetwo-entry-plan.component.ts
  11. 22
      src/app/plan-management/type-plan/newunit.html
  12. 4
      src/app/plan-management/type-plan/newunit.scss
  13. 40
      src/app/plan-management/type-plan/type-plan.component.html
  14. 3
      src/app/plan-management/type-plan/type-plan.component.scss
  15. 341
      src/app/plan-management/type-plan/type-plan.component.ts

61
src/app/plan-management/meet-plan/meet-plan.component.html

@ -1,6 +1,6 @@
<div style="height: 100%;overflow-y: auto;">
<div class="header" >
<form >
<form (ngSubmit)="onSubmit(form.value)" #form="ngForm">
<div class="queryBox">
<div class="queryField">
@ -14,32 +14,37 @@
<div class="queryField">
<label style="margin-right: 10px;">预案级别:</label>
<mat-form-field>
<mat-select placeholder='请选择单位类型' name="unittype" [(ngModel)]="level">
<mat-option value="1"></mat-option>
<mat-option value="2"></mat-option>
<mat-select placeholder='请选择预案级别' name="level" [(ngModel)]="level">
<mat-option value="6">国家</mat-option>
<mat-option value="7"></mat-option>
</mat-select>
</mat-form-field>
</div>
<div class="queryField">
<label style="margin-right: 10px;">添加人:</label>
<mat-form-field class="example-full-width">
<input matInput placeholder="请输入添加人" name="companyName" autocomplete="off" [(ngModel)]="addname">
<input matInput placeholder="请输入添加人" name="addname" autocomplete="off" [(ngModel)]="addname">
</mat-form-field>
</div>
<div class="queryField">
<label style="margin-right: 10px;">添加时间:</label>
<mat-form-field class="example-full-width">
<input type="date" matInput name="companyName" autocomplete="off" [(ngModel)]="addtime">
<input type="date" matInput name="addtime" autocomplete="off" [(ngModel)]="addtime">
</mat-form-field>
🠊
<mat-form-field class="example-full-width">
<input type="date" matInput autocomplete="off" >
<input type="date" matInput name="endtime" autocomplete="off" [(ngModel)]="endtime">
</mat-form-field>
</div>
<div class="queryField">
<label style="margin-right: 10px;">预案类型:</label>
<mat-form-field class="example-full-width">
<input matInput placeholder="请输入预案类型" name="companyName" autocomplete="off" [(ngModel)]="unittype">
<mat-form-field>
<mat-select name="reservePlanType" [(ngModel)]="reservePlanType" placeholder='请选择预案类型' [multiple]="true">
<mat-option value="8">卡片预案</mat-option>
<mat-option value="1">二维预案</mat-option>
<mat-option value="2">三维预案</mat-option>
<mat-option value="4">其他预案</mat-option>
</mat-select>
</mat-form-field>
</div>
<div class="queryField">
@ -82,42 +87,44 @@
<div class="tablebox">
<table mat-table [dataSource]="tabledataSource" class="mat-elevation-z8">
<ng-container matColumnDef="unitname">
<th mat-header-cell *matHeaderCellDef>预案名称</th>
<td mat-cell *matCellDef="let element">{{element.unitname}}</td>
<th mat-header-cell *matHeaderCellDef style="width: 10%;">预案名称</th>
<td mat-cell *matCellDef="let element">{{element.name}}</td>
</ng-container>
<ng-container matColumnDef="level">
<th mat-header-cell *matHeaderCellDef>预案级别</th>
<td mat-cell *matCellDef="let element">{{url=='2'?'Ⅱ级':'Ⅰ级'}}</td>
<th mat-header-cell *matHeaderCellDef style="width: 10%;">预案级别</th>
<td mat-cell *matCellDef="let element">{{element.planCategory=='6'?'国家级':'市级'}}</td>
</ng-container>
<ng-container matColumnDef="addname">
<th mat-header-cell *matHeaderCellDef>添加人</th>
<td mat-cell *matCellDef="let element">{{element.addname}}</td>
<th mat-header-cell *matHeaderCellDef style="width: 10%;">添加人</th>
<td mat-cell *matCellDef="let element">{{element.creatorName}}</td>
</ng-container>
<ng-container matColumnDef="addtime">
<th mat-header-cell *matHeaderCellDef>添加时间</th>
<td mat-cell *matCellDef="let element">{{element.addtime}}</td>
<th mat-header-cell *matHeaderCellDef style="width: 10%;">添加时间</th>
<td mat-cell *matCellDef="let element">{{element.creationTime|date:'yyyy-MM-dd'}}</td>
</ng-container>
<ng-container matColumnDef="plantype">
<th mat-header-cell *matHeaderCellDef>预案类型</th>
<td mat-cell *matCellDef="let element">{{element.plantype}}</td>
<th mat-header-cell *matHeaderCellDef style="width: 10%;">预案类型</th>
<td mat-cell *matCellDef="let element">{{element.planType=='1'?'二维预案':element.planType=='2'?'三维预案':element.planType=='4'?'其他预案':'卡片预案'}}</td>
</ng-container>
<ng-container matColumnDef="passstate">
<th mat-header-cell *matHeaderCellDef>审核状态</th>
<td mat-cell *matCellDef="let element">{{element.passstate}}</td>
<th mat-header-cell *matHeaderCellDef style="width: 10%;">审核状态</th>
<td mat-cell *matCellDef="let element">{{element.auditStatus=='8'?'未提交审核':element.auditStatus=='1'?'审核中':element.auditStatus=='2'?'审核通过':'审核退回'}}</td>
</ng-container>
<ng-container matColumnDef="isopen">
<th mat-header-cell *matHeaderCellDef>是否公开</th>
<td mat-cell *matCellDef="let element">{{element.isopen}}</td>
<th mat-header-cell *matHeaderCellDef style="width: 10%;">是否公开</th>
<td mat-cell *matCellDef="let element">{{element.openRange}}</td>
</ng-container>
<ng-container matColumnDef="projectlevel">
<th mat-header-cell *matHeaderCellDef>编制级别</th>
<td mat-cell *matCellDef="let element">{{element.projectlevel}}</td>
<th mat-header-cell *matHeaderCellDef style="width: 10%;">编制级别</th>
<td mat-cell *matCellDef="let element">{{element.planLevel=='1'?'总队':element.planLevel=='2'?'支队':element.planLevel=='4'?'大队':'中队'}}</td>
</ng-container>
<ng-container matColumnDef="operation">
<th mat-header-cell *matHeaderCellDef>操作</th>
<td mat-cell *matCellDef="let element">
<th mat-header-cell *matHeaderCellDef style="width: 20%;">操作</th>
<td mat-cell *matCellDef="let element" style="white-space: nowrap;cursor: pointer;">
<span style="color: blue;">查看预案</span>
<span style="color: blue;margin-left: 4px;" (click)='readFile(element)'>下载</span>
<span style="color: red;margin-left: 4px" (click)='deletePlan(element.id)'> 删除</span>
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>

3
src/app/plan-management/meet-plan/meet-plan.component.scss

@ -114,5 +114,8 @@
.mat-column-jurisdictionsquadron{
width: 10%;
}
span:hover{
text-decoration:underline
}
}
}

353
src/app/plan-management/meet-plan/meet-plan.component.ts

@ -47,10 +47,9 @@ export class MeetPlanComponent implements OnInit {
{name:"中队",value:"8"}
]
}
this.url=window.location.href.substring(window.location.href.length-1,window.location.href.length)
this.getAlltabledate()
}
url
preparelevels:any
plcheck:boolean //编制级别勾选框
displayedColumns: string[] = ['unitname','level','addname','addtime', 'plantype', 'passstate','isopen','projectlevel','operation'];
@ -59,6 +58,8 @@ export class MeetPlanComponent implements OnInit {
level//预案级别
addname//添加人
addtime//添加时间
endtime
reservePlanType//预案类型
unittype//预案类型
unitstate//审核状态
projectlevel//编制级别
@ -71,21 +72,162 @@ export class MeetPlanComponent implements OnInit {
pageSizeOptions: number[] = [10] //设置每页条数
PageNumber:any; //第几页
//获得所有预案信息
getAllPlanInfo(){
//获取表格数据
getAlltabledate(){
let reservePlanType
this.reservePlanType ? reservePlanType = JSON.parse(JSON.stringify(this.reservePlanType)) : reservePlanType = ''
if(this.reservePlanType && this.reservePlanType.length != 0){
reservePlanType = eval(this.reservePlanType.join("|"))
}
let paramsdata:any = {
Name:this.unitname||'',
planCategories:this.level||[6,7],
PlanType:reservePlanType||'',
CreatorName:this.addname||'',
AuditStatus:this.unitstate|| '',
QueryStartTime:this.addtime||'',
QueryEndTime:this.endtime||'',
PlanLevel:this.projectlevel||'',
HasChildrenPlanLevel:this.plcheck||'',
PageNumber: this.PageNumber || '1',
PageSize: this.pageSizeOptions[0],
}
this.http.get("/api/Plans",{params:paramsdata}).subscribe((data:any)=>{
}
this.http.get("/api/PlanComponentsMajor",{params:paramsdata}).subscribe((data:any)=>{
this.length = data.totalCount
//this.allPlanInfo = data
this.tabledataSource = data.items
})
}
//查询
onSubmit (value) {
if(this.endtime!=undefined&&this.addtime>this.endtime){
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('开始时间不能大于结束时间!','确定',config);
}else{
this.PageNumber = 1
this.pageEvent.pageIndex = 0
this.getAlltabledate();
}
}
//删除预案
deletePlan(id){
let isTrue = confirm('您确定要删除吗')
if(isTrue){
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.http.delete(`/api/PlanComponentsMajor/${id}`).subscribe(data=>{
this.snackBar.open('删除成功!','确定',config);
this.getAlltabledate()
},err => {
this.snackBar.open(err,'确定',config);
})
}
}
//下载↓
selectDownloadFile:any; //选择下载的文件
download:any; //下载文件元数据
downloadisLoading:boolean = false; //进度条loading加载
downloadProgress:number=0; //进度条进度
downloadFileName:any
fileUrls:any //当前预案附件地址
fileDatas:any = []
selectedFileIndex : any = 0
selectedFileData : any
uploadFileLonging:any
//读取下载文件信息
readFile (element) {
this.uploadFileLonging = element
element.attachmentUrls.forEach(item=>{
this.http.get('/api/ObjectMetadata/PlanPlatform/'+item).subscribe((data:any)=>{
data.filePige = (data.fileLength / (1024*1024)).toFixed(2)
this.download = data
this.downloadFile()
})
})
}
//this.tabledataSource = new MatTableDataSource(data.items)
console.log(this.tabledataSource)
//初始化下载
downloadFile () {
this.downloadProgress = 0
let file = this.download
let fileSize = file.fileLength//下载文件的总大小
let shardSize = 10 * 1024 * 1024 //文件大小是否大于10MB
if (file && fileSize<=shardSize) { //<=10MB时直接下载
this.downloadisLoading = true
// this.setFileLoading()
this.http.get(`/api/Objects/PlanPlatform/${file.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 suffix = file.objectName.substring(file.objectName.lastIndexOf(".")+1,file.objectName.length) ;
link.setAttribute("download", file.fileName + "-" +this.uploadFileLonging.name + "." + suffix);
document.body.appendChild(link);
link.click();
this.downloadisLoading = false
// this.setFileLoading()
})
} else if (file && fileSize > shardSize) { //>10MB时分块下载
this.blockingDownload() //分段下载
this.downloadisLoading = true
// this.setFileLoading()
}
}
//分段下载并合并
async blockingDownload () {
let file = this.download
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/${file.objectName}`,{headers:{'range':`bytes= ${start}-${end}`},responseType:'blob'}).subscribe(data=>{
result(data) })
})
allFile.push(result)
this.downloadProgress = Number((i/allSlice).toFixed(2))*100
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 suffix = file.objectName.substring(file.objectName.lastIndexOf(".")+1,file.objectName.length) ;
link.setAttribute("download", file.fileName + "-" +this.uploadFileLonging.name + "." + suffix);
document.body.appendChild(link);
link.click();
// this.downloadProgress = 0
this.downloadisLoading = false
// this.setFileLoading()
}
} //for循环
}
//取消分块下载
cancelDowload () {
}
//重置
@ -94,17 +236,24 @@ export class MeetPlanComponent implements OnInit {
this.level=''
this.addname=''
this.addtime=''
this.unittype=''
this.endtime=''
this.reservePlanType=''
this.unitstate=''
this.projectlevel=''
this.plcheck=false
this.getAlltabledate()
}
//新增预案弹窗
addunit(){
const dialogRef = this.dialog.open(newunitMeet, {
width: '340px',
height:'430px'
height:'505px'
//data: paperDataInfo
});
dialogRef.afterClosed().subscribe(result => {
this.getAlltabledate()
}
);
}
}
@ -119,9 +268,189 @@ export class newunitMeet{
level//预案级别
addname//添加人
addtime//添加时间
unittype//预案类型
reservePlanType//预案类型
unitstate//审核状态
projectlevel//编制级别
//上传文件↓
file:any; //上传的文件
fileName:any; //上传文件name
uploadisLoading:boolean = false; //进度条loading加载
uploadProgress:number=0; //进度条进度
objectName:any; //上传对象名
uploadId:any; //上传分块上传事件编号
uploadover:any = false //上传完成之后提示
selectedPLanType:any//所选预案类型
selectedPLanName:any//所选预案名称
localup:boolean = false //本地上传
defaultisshow = '0' //默认显示上传input框
//上传
upload(){
document.getElementById('up').click()
}
//上传文件input
filechange(e){
this.file = e.target.files[0] || null //上传的文件
//console.log(this.file)
}
//上传文件
startUploading (planType) {
let file = this.file || 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)
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.http.post('/api/Objects/PlanPlatform/meetClass',formData).subscribe((data:any)=>{
this.objectName = data.objectName
//this.snackBar.open('上传成功!','确定',config);
let body:any = {
Name:this.unitname||'',
PlanCategory:Number(this.level)||'',
PlanType: Number(this.reservePlanType),
PlanLevel:1,
PlanMode:1,
attachmentUrls:[`${this.objectName}`]
}
this.http.post("/api/PlanComponentsMajor",body).subscribe((data:any)=>{
this.snackBar.open('创建成功!','确定',config);
//console.log(data)
this.dialogRef.close();
},err=>{
this.snackBar.open('创建失败!','确定',config);
})
},err=>{
this.snackBar.open('上传失败!','确定',config);
})
} else if (file && fileSize>shardSize) { //上传文件>5MB时,分块上传
let data = {filename: file.name}
this.uploadisLoading = true
this.http.post('/api/NewMultipartUpload/PlanPlatform/meetClass',{},{params:data}).subscribe((data:any)=>{ //初始化分段上传
this.objectName = data.objectName
this.uploadId = data.uploadId
this.subsectionUploading(planType)
})
}
}
PartNumberETag:any=[]; //每次返回需要保存的信息
//开始分段上传
async subsectionUploading (planType) {
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(planType)}
}//for循环
}
//完成分块上传
endUploading (planType) {
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 body:any = {
Name:this.unitname||'',
PlanCategory:Number(this.level)||'',
PlanType: Number(this.reservePlanType),
PlanLevel:1,
PlanMode:1,
attachmentUrls:[`${this.objectName}`]
}
this.http.post("/api/PlanComponentsMajor",body).subscribe((data:any)=>{
this.snackBar.open('创建成功!','确定',config);
this.dialogRef.close();
},err=>{
this.snackBar.open('创建失败!','确定',config);
})
})
}
//取消分块上传
cancel () {
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000;
this.http.delete(`/api/MultipartUpload/PlanPlatform/${this.objectName}?uploadId=${this.uploadId}`).subscribe(data=>{
this.uploadProgress = 0;
this.uploadisLoading= false;
(<HTMLInputElement>document.getElementById('up')).value = null
this.PartNumberETag =[] //清空保存返回的信息
this.snackBar.open('取消上传成功!','确定',config);
this.uploadover = false
this.file = null
})
}
//创建预案
newplan(){
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
if(this.unitname==undefined||this.unitname==''){
this.snackBar.open('请输入预案名称!','确定',config);
}
else if(this.reservePlanType==undefined||this.reservePlanType==''){
this.snackBar.open('请输入预案类型!','确定',config);
}
else if(this.level==undefined||this.level==''){
this.snackBar.open('请输入预案级别!','确定',config);
}
else if(this.file==undefined){
this.snackBar.open('请先上传文件!','确定',config);
}
else{
if(this.reservePlanType!='1'){
this.startUploading("非二维")
}
else{this.startUploading("二维")}
}
}
//取消
close(){
this.dialogRef.close();
}

30
src/app/plan-management/meet-plan/newunit.html

@ -4,7 +4,7 @@
* @Author: sueRimn
* @Date: 2020-12-24 16:26:16
* @LastEditors: sueRimn
* @LastEditTime: 2021-01-06 09:34:26
* @LastEditTime: 2021-01-11 13:56:29
-->
<div class="box">
<div class="top">
@ -13,30 +13,42 @@
<div class="queryField">
<label style="margin-right: 10px;">预案名称:</label>
<mat-form-field class="example-full-width">
<input matInput placeholder="请输入单位名称" name="companyName" autocomplete="off" [(ngModel)]="unitname">
<input matInput placeholder="请输入预案名称" name="companyName" autocomplete="off" [(ngModel)]="unitname" required>
</mat-form-field>
</div>
<div class="queryField">
<label style="margin-right: 10px;">预案类型:</label>
<mat-form-field class="example-full-width">
<input matInput placeholder="请输入预案类型" name="companyName" autocomplete="off" [(ngModel)]="unittype">
<mat-form-field>
<mat-select name="reservePlanType" [(ngModel)]="reservePlanType" autocomplete="off" placeholder='请选择预案类型' required>
<mat-option value='8'>卡片预案</mat-option>
<mat-option value='1'>二维预案</mat-option>
<mat-option value='2'>三维预案</mat-option>
<mat-option value='4'>其他预案</mat-option>
</mat-select>
</mat-form-field>
</div>
<div class="queryField">
<label style="margin-right: 10px;">预案级别:</label>
<mat-form-field>
<mat-select placeholder='请选择单位类型' name="unittype" [(ngModel)]="level">
<mat-option value="1">国家级</mat-option>
<mat-option value="2">市级</mat-option>
<mat-select placeholder='请选择单位类型' name="unittype" [(ngModel)]="level" required>
<mat-option value="6">国家级</mat-option>
<mat-option value="7">市级</mat-option>
</mat-select>
</mat-form-field>
</div>
<div class="queryField">
<label style="margin-right: 10px;">上传本地文件:</label>
<button mat-raised-button color="primary" ><img style="margin-bottom: 2px;" src="../../../assets/images/bendi.png"> 本地文件</button>
<button mat-raised-button color="primary" (click)='upload()'><img style="margin-bottom: 2px;" src="../../../assets/images/bendi.png"> 本地文件</button>
<input type="file" style="display: none;" id="up" (change)='filechange($event)' accept=".doc,.txt,.docx,.pdf">
<div *ngIf="file!=undefined"><label style="font-size: 10px;">{{file.name}}</label></div>
<div *ngIf="uploadisLoading">
<span style="font-size: 10px;">上传中...</span>
<mat-progress-bar mode="determinate" [value]="uploadProgress" class="progress" style="width: 250px;"></mat-progress-bar>
<button mat-raised-button (click)="cancel()" style="width: 80px;font-size: 10px;margin-top: 3px;">取消上传</button>
</div>
</div>
<div class="bottom">
<button mat-raised-button color="primary">确定</button>
<button mat-raised-button color="primary" (click)='newplan()'>确定</button>
<button mat-raised-button style="margin-left: 50px;" (click)="close()">取消</button>
</div>
</div>

2
src/app/plan-management/meet-plan/newunit.scss

@ -7,7 +7,7 @@
.queryField {
margin: 3px 5px;
input {
width: 50px;
width: 100%;
height: 18px;
line-height: 18px;
border-radius: 3px;}

30
src/app/plan-management/onetwo-entry-plan/newunit.html

@ -4,7 +4,7 @@
* @Author: sueRimn
* @Date: 2020-12-24 16:26:16
* @LastEditors: sueRimn
* @LastEditTime: 2020-12-28 11:47:01
* @LastEditTime: 2021-01-11 13:55:40
-->
<div class="box">
<div class="top">
@ -13,30 +13,34 @@
<div class="queryField">
<label style="margin-right: 10px;">预案名称:</label>
<mat-form-field class="example-full-width">
<input matInput placeholder="请输入单位名称" name="companyName" autocomplete="off" [(ngModel)]="unitname">
<input matInput placeholder="请输入单位名称" name="companyName" autocomplete="off" [(ngModel)]="unitname" required>
</mat-form-field>
</div>
<div class="queryField">
<label style="margin-right: 10px;">预案类型:</label>
<mat-form-field class="example-full-width">
<input matInput placeholder="请输入预案类型" name="companyName" autocomplete="off" [(ngModel)]="unittype">
</mat-form-field>
</div>
<div class="queryField">
<label style="margin-right: 10px;">预案级别:</label>
<mat-form-field>
<mat-select placeholder='请选择单位类型' name="unittype" [(ngModel)]="level">
<mat-option value="1">Ⅰ级</mat-option>
<mat-option value="2">Ⅱ级</mat-option>
<mat-select name="reservePlanType" [(ngModel)]="reservePlanType" autocomplete="off" placeholder='请选择预案类型' required>
<mat-option value='8'>卡片预案</mat-option>
<mat-option value='1'>二维预案</mat-option>
<mat-option value='2'>三维预案</mat-option>
<mat-option value='4'>其他预案</mat-option>
</mat-select>
</mat-form-field>
</div>
<div class="queryField">
<label style="margin-right: 10px;">上传本地文件:</label>
<button mat-raised-button color="primary" ><img style="margin-bottom: 2px;" src="../../../assets/images/bendi.png"> 本地文件</button>
<button mat-raised-button color="primary" (click)='upload()'><img style="margin-bottom: 2px;" src="../../../assets/images/bendi.png"> 本地文件</button>
<input type="file" style="display: none;" id="up" (change)='filechange($event)' accept=".doc,.txt,.docx,.pdf">
<div *ngIf="file!=undefined"><label style="font-size: 10px;">{{file.name}}</label></div>
<div *ngIf="uploadisLoading">
<span style="font-size: 10px;">上传中...</span>
<mat-progress-bar mode="determinate" [value]="uploadProgress" class="progress" style="width: 250px;"></mat-progress-bar>
<button mat-raised-button (click)="cancel()" style="width: 80px;font-size: 10px;margin-top: 3px;">取消上传</button>
</div>
</div>
<div class="bottom">
<button mat-raised-button color="primary">确定</button>
<button mat-raised-button color="primary" (click)='newplan()'>确定</button>
<button mat-raised-button style="margin-left: 50px;" (click)="close()">取消</button>
</div>
</div>

2
src/app/plan-management/onetwo-entry-plan/newunit.scss

@ -7,7 +7,7 @@
.queryField {
margin: 3px 5px;
input {
width: 50px;
width: 100%;
height: 18px;
line-height: 18px;
border-radius: 3px;}

32
src/app/plan-management/onetwo-entry-plan/onetwo-entry-plan.component.html

@ -4,7 +4,7 @@
* @Author: sueRimn
* @Date: 2020-12-24 14:15:10
* @LastEditors: sueRimn
* @LastEditTime: 2021-01-08 09:47:51
* @LastEditTime: 2021-01-09 10:37:36
-->
<div style="height: 100%;overflow-y: auto;">
<div class="header" >
@ -39,7 +39,7 @@
<div class="queryField">
<label style="margin-right: 10px;">预案类型:</label>
<mat-form-field>
<mat-select name="reservePlanType" [(ngModel)]="reservePlanType" placeholder='请选择预案类型'>
<mat-select name="reservePlanType" [(ngModel)]="reservePlanType" placeholder='请选择预案类型' [multiple]="true">
<mat-option value="8">卡片预案</mat-option>
<mat-option value="1">二维预案</mat-option>
<mat-option value="2">三维预案</mat-option>
@ -88,44 +88,44 @@
<div class="tablebox">
<table mat-table [dataSource]="tabledataSource" class="mat-elevation-z8">
<ng-container matColumnDef="unitname">
<th mat-header-cell *matHeaderCellDef>预案名称</th>
<th mat-header-cell *matHeaderCellDef style="width: 10%;">预案名称</th>
<td mat-cell *matCellDef="let element">{{element.name}}</td>
</ng-container>
<ng-container matColumnDef="level">
<th mat-header-cell *matHeaderCellDef>预案级别</th>
<th mat-header-cell *matHeaderCellDef style="width: 10%;">预案级别</th>
<td mat-cell *matCellDef="let element">{{url=='2'?'Ⅱ级':'Ⅰ级'}}</td>
</ng-container>
<ng-container matColumnDef="addname">
<th mat-header-cell *matHeaderCellDef>添加人</th>
<th mat-header-cell *matHeaderCellDef style="width: 10%;">添加人</th>
<td mat-cell *matCellDef="let element">{{element.creatorName}}</td>
</ng-container>
<ng-container matColumnDef="addtime">
<th mat-header-cell *matHeaderCellDef>添加时间</th>
<th mat-header-cell *matHeaderCellDef style="width: 10%;">添加时间</th>
<td mat-cell *matCellDef="let element">{{element.creationTime|date:'yyyy-MM-dd'}}</td>
</ng-container>
<ng-container matColumnDef="plantype">
<th mat-header-cell *matHeaderCellDef>预案类型</th>
<th mat-header-cell *matHeaderCellDef style="width: 10%;">预案类型</th>
<td mat-cell *matCellDef="let element">{{element.planType=='1'?'二维预案':element.planType=='2'?'三维预案':element.planType=='4'?'其他预案':'卡片预案'}}</td>
</ng-container>
<ng-container matColumnDef="passstate">
<th mat-header-cell *matHeaderCellDef>审核状态</th>
<th mat-header-cell *matHeaderCellDef style="width: 10%;">审核状态</th>
<td mat-cell *matCellDef="let element">{{element.auditStatus=='8'?'未提交审核':element.auditStatus=='1'?'审核中':element.auditStatus=='2'?'审核通过':'审核退回'}}</td>
</ng-container>
<ng-container matColumnDef="isopen">
<th mat-header-cell *matHeaderCellDef>是否公开</th>
<th mat-header-cell *matHeaderCellDef style="width: 10%;">是否公开</th>
<td mat-cell *matCellDef="let element">{{element.openRange}}</td>
</ng-container>
<ng-container matColumnDef="projectlevel">
<th mat-header-cell *matHeaderCellDef>编制级别</th>
<td mat-cell *matCellDef="let element">{{element.planLevel=='0'?'总队':element.planLevel=='1'?'支队':element.planLevel=='2'?'大队':'中队'}}</td>
<th mat-header-cell *matHeaderCellDef style="width: 10%;">编制级别</th>
<td mat-cell *matCellDef="let element">{{element.planLevel=='1'?'总队':element.planLevel=='2'?'支队':element.planLevel=='4'?'大队':'中队'}}</td>
</ng-container>
<ng-container matColumnDef="operation">
<th mat-header-cell *matHeaderCellDef>操作</th>
<td mat-cell *matCellDef="let element" style="white-space: nowrap;">
<span (click)='routerTo(element)' style="color: blue;">查看预案</span>
<span style="color: blue;"> 下载</span>
<span style="color: red;"> 删除</span>
<th mat-header-cell *matHeaderCellDef style="width: 20%;">操作</th>
<td mat-cell *matCellDef="let element" style="white-space: nowrap;cursor: pointer;">
<span style="color: blue;">查看预案</span>
<span style="color: blue;margin-left: 4px;" (click)='readFile(element)'>下载</span>
<span style="color: red;margin-left: 4px" (click)='deletePlan(element.id)'> 删除</span>
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>

3
src/app/plan-management/onetwo-entry-plan/onetwo-entry-plan.component.scss

@ -114,5 +114,8 @@
.mat-column-jurisdictionsquadron{
width: 10%;
}
span:hover{
text-decoration:underline
}
}
}

351
src/app/plan-management/onetwo-entry-plan/onetwo-entry-plan.component.ts

@ -4,7 +4,7 @@
* @Author: sueRimn
* @Date: 2020-12-24 14:15:10
* @LastEditors: sueRimn
* @LastEditTime: 2021-01-08 09:48:06
* @LastEditTime: 2021-01-11 14:04:49
*/
import { Component, OnInit, ViewChild, Inject } from '@angular/core';
import { HttpClient } from '@angular/common/http'
@ -84,29 +84,23 @@ export class OnetwoEntryPlanComponent implements OnInit {
pageSizeOptions: number[] = [10] //设置每页条数
PageNumber:any; //第几页
//获得所有预案信息
getAllPlanInfo(){
let paramsdata:any = {
HasChildrenPlanLevel: this.plcheck || '',
PageNumber: this.PageNumber || '1',
PageSize: this.pageSizeOptions[0],
}
this.http.get("/api/Plans",{params:paramsdata}).subscribe((data:any)=>{
this.length = data.totalCount
//this.allPlanInfo = data
//this.tabledataSource = new MatTableDataSource(data.items)
console.log(this.tabledataSource)
})
}
//获取表格数据
getAlltabledate(){
let reservePlanType
this.reservePlanType ? reservePlanType = JSON.parse(JSON.stringify(this.reservePlanType)) : reservePlanType = ''
if(this.reservePlanType && this.reservePlanType.length != 0){
reservePlanType = eval(this.reservePlanType.join("|"))
}
let paramsdata:any = {
PlanCategory:this.url=='2'?2:1,
PlanType:this.projectlevel||'',
Name:this.unitname||'',
planCategories:this.url=='2'?2:1,
PlanType:reservePlanType||'',
CreatorName:this.addname||'',
AuditStatus:this.unitstate|| '',
QueryStartTime:this.addtime||'',
QueryEndTime:this.endtime||'',
PlanLevel:this.projectlevel||'',
HasChildrenPlanLevel:this.plcheck||'',
PageNumber: this.PageNumber || '1',
PageSize: this.pageSizeOptions[0],
@ -114,7 +108,6 @@ export class OnetwoEntryPlanComponent implements OnInit {
this.http.get("/api/PlanComponentsMajor",{params:paramsdata}).subscribe((data:any)=>{
this.length = data.totalCount
this.tabledataSource = data.items
console.log(this.tabledataSource)
})
}
@ -124,29 +117,160 @@ export class OnetwoEntryPlanComponent implements OnInit {
this.level=''
this.addname=''
this.addtime=''
//this.unittype=''
this.endtime=''
this.reservePlanType=''
this.unitstate=''
this.projectlevel=''
this.plcheck=false
this.getAlltabledate()
}
//查询
onSubmit (value) {
//console.log(value)
if(this.endtime!=undefined&&this.addtime>this.endtime){
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('开始时间不能大于结束时间!','确定',config);
}else{
this.PageNumber = 1
this.pageEvent.pageIndex = 0
this.getAlltabledate();
}
}
//删除预案
deletePlan(id){
let isTrue = confirm('您确定要删除吗')
if(isTrue){
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.http.delete(`/api/PlanComponentsMajor/${id}`).subscribe(data=>{
this.snackBar.open('删除成功!','确定',config);
this.getAlltabledate()
},err => {
this.snackBar.open(err,'确定',config);
})
}
}
//新增预案弹窗
addunit(){
const dialogRef = this.dialog.open(newunitComponent, {
width: '340px',
height:'430px'
height:'440px'
//data: paperDataInfo
});
dialogRef.afterClosed().subscribe(result => {
this.getAlltabledate()
}
);
}
//下载↓
selectDownloadFile:any; //选择下载的文件
download:any; //下载文件元数据
downloadisLoading:boolean = false; //进度条loading加载
downloadProgress:number=0; //进度条进度
downloadFileName:any
fileUrls:any //当前预案附件地址
fileDatas:any = []
selectedFileIndex : any = 0
selectedFileData : any
uploadFileLonging:any
//读取下载文件信息
readFile (element) {
this.uploadFileLonging = element
element.attachmentUrls.forEach(item=>{
this.http.get('/api/ObjectMetadata/PlanPlatform/'+item).subscribe((data:any)=>{
data.filePige = (data.fileLength / (1024*1024)).toFixed(2)
//console.log(data)
this.download = data
this.downloadFile()
})
})
}
//初始化下载
downloadFile () {
this.downloadProgress = 0
let file = this.download
let fileSize = file.fileLength//下载文件的总大小
let shardSize = 10 * 1024 * 1024 //文件大小是否大于10MB
if (file && fileSize<=shardSize) { //<=10MB时直接下载
this.downloadisLoading = true
// this.setFileLoading()
this.http.get(`/api/Objects/PlanPlatform/${file.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 suffix = file.objectName.substring(file.objectName.lastIndexOf(".")+1,file.objectName.length) ;
link.setAttribute("download", file.fileName + "-" +this.uploadFileLonging.name + "." + suffix);
document.body.appendChild(link);
link.click();
this.downloadisLoading = false
// this.setFileLoading()
})
} else if (file && fileSize > shardSize) { //>10MB时分块下载
this.blockingDownload() //分段下载
this.downloadisLoading = true
// this.setFileLoading()
}
}
//分段下载并合并
async blockingDownload () {
let file = this.download
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/${file.objectName}`,{headers:{'range':`bytes= ${start}-${end}`},responseType:'blob'}).subscribe(data=>{
result(data) })
})
allFile.push(result)
this.downloadProgress = Number((i/allSlice).toFixed(2))*100
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 suffix = file.objectName.substring(file.objectName.lastIndexOf(".")+1,file.objectName.length) ;
link.setAttribute("download", file.fileName + "-" +this.uploadFileLonging.name + "." + suffix);
document.body.appendChild(link);
link.click();
// this.downloadProgress = 0
this.downloadisLoading = false
// this.setFileLoading()
}
} //for循环
}
//取消分块下载
cancelDowload () {
}
//查看预案按钮跳转
routerTo(element){
console.log(element)
sessionStorage.setItem("companyName",element.unitname)
window.open(`/planManagement/entryPlandetail?unitId=${element.company.id}&unitTypeId=${element.company.buildingTypes.length == 0 ? null :element.company.buildingTypes[0].id}&operation=true&pagetype=entryplan&unitName=${element.company.name}&orName=${element.company.organizationName}&unitType=${element.company.buildingTypes.length == 0 ? null :element.company.buildingTypes[0].name}&unitAdd=${element.company.address}`);
}
@ -160,13 +284,190 @@ export class OnetwoEntryPlanComponent implements OnInit {
})
export class newunitComponent{
constructor(private router:Router,private http: HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar,public dialogRef: MatDialogRef<newunitComponent>,@Inject(MAT_DIALOG_DATA) public data: any) {}
ngOnInit(): void {
this.url=window.location.href.substring(window.location.href.length-1,window.location.href.length)
}
url
unitname//预案名称
level//预案级别
addname//添加人
addtime//添加时间
unittype//预案类型
reservePlanType//预案类型
unitstate//审核状态
projectlevel//编制级别
//上传文件↓
file:any; //上传的文件
fileName:any; //上传文件name
uploadisLoading:boolean = false; //进度条loading加载
uploadProgress:number=0; //进度条进度
objectName:any; //上传对象名
uploadId:any; //上传分块上传事件编号
uploadover:any = false //上传完成之后提示
selectedPLanType:any//所选预案类型
selectedPLanName:any//所选预案名称
localup:boolean = false //本地上传
defaultisshow = '0' //默认显示上传input框
//上传
upload(){
document.getElementById('up').click()
}
//上传文件input
filechange(e){
this.file = e.target.files[0] || null //上传的文件
}
//上传文件
startUploading (planType) {
let file = this.file || 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)
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.http.post(this.url=='2'?`/api/Objects/PlanPlatform/twoClass`:'/api/Objects/PlanPlatform/oneClass',formData).subscribe((data:any)=>{
this.objectName = data.objectName
//this.snackBar.open('上传成功!','确定',config);
let body:any = {
Name:this.unitname||'',
PlanCategory:this.url=='2'?2:1,
PlanType: Number(this.reservePlanType),
PlanLevel:1,
PlanMode:1,
attachmentUrls:[`${this.objectName}`]
}
this.http.post("/api/PlanComponentsMajor",body).subscribe((data:any)=>{
this.snackBar.open('创建成功!','确定',config);
this.dialogRef.close();
},err=>{
this.snackBar.open('创建失败!','确定',config);
})
},err=>{
this.snackBar.open('上传失败!','确定',config);
})
} else if (file && fileSize>shardSize) { //上传文件>5MB时,分块上传
let data = {filename: file.name}
this.uploadisLoading = true
this.http.post(this.url=='2'?`/api/NewMultipartUpload/PlanPlatform/twoClass`:'/api/NewMultipartUpload/PlanPlatform/oneClass',{},{params:data}).subscribe((data:any)=>{ //初始化分段上传
this.objectName = data.objectName
this.uploadId = data.uploadId
this.subsectionUploading(planType)
})
}
}
PartNumberETag:any=[]; //每次返回需要保存的信息
//开始分段上传
async subsectionUploading (planType) {
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(planType)}
}//for循环
}
//完成分块上传
endUploading (planType) {
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 body:any = {
Name:this.unitname||'',
PlanCategory:this.url=='2'?2:1,
PlanType: Number(this.reservePlanType),
PlanLevel:1,
PlanMode:1,
attachmentUrls:[`${this.objectName}`]
}
this.http.post("/api/PlanComponentsMajor",body).subscribe((data:any)=>{
this.snackBar.open('创建成功!','确定',config);
this.dialogRef.close();
},err=>{
this.snackBar.open('创建失败!','确定',config);
})
})
}
//取消分块上传
cancel () {
this.http.delete(`/api/MultipartUpload/PlanPlatform/${this.objectName}?uploadId=${this.uploadId}`).subscribe(data=>{
this.uploadProgress = 0;
this.uploadisLoading= false;
(<HTMLInputElement>document.getElementById('up')).value = null
this.PartNumberETag =[] //清空保存返回的信息
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('取消上传成功!','确定',config);
this.uploadover = false
this.file = null
})
}
//创建预案
newplan(){
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
if(this.unitname==undefined||this.reservePlanType==undefined){
this.snackBar.open('请输入预案名称或类型!','确定',config);
}
else if(this.file==undefined){
this.snackBar.open('请先上传文件!','确定',config);
}
else{
if(this.reservePlanType!='1'){
this.startUploading("非二维")
}
else{this.startUploading("二维")}
}
}
//取消按钮
close(){
this.dialogRef.close();
}

22
src/app/plan-management/type-plan/newunit.html

@ -4,7 +4,7 @@
* @Author: sueRimn
* @Date: 2020-12-24 16:26:16
* @LastEditors: sueRimn
* @LastEditTime: 2021-01-06 15:16:50
* @LastEditTime: 2021-01-11 13:57:06
-->
<div class="box">
<div class="top">
@ -13,20 +13,24 @@
<div class="queryField">
<label style="margin-right: 10px;">预案名称:</label>
<mat-form-field class="example-full-width">
<input matInput placeholder="请输入单位名称" name="companyName" autocomplete="off" [(ngModel)]="unitname">
<input matInput placeholder="请输入单位名称" name="companyName" autocomplete="off" [(ngModel)]="unitname" required>
</mat-form-field>
</div>
<div class="queryField">
<label style="margin-right: 10px;">上传本地文件:</label>
<button mat-raised-button color="primary" (click)='upload()' ><img style="margin-bottom: 2px;margin-right: 2px;" src="../../../assets/images/bendi.png">本地文件</button>
<input type="file" id="up" style="display: none;" (change)='upchange($event)'>
<!-- <span class="fileinput-button mat-raised-button">
<img style="position: relative;top: 2px;right: 2px;" src="../../../assets/images/bendi.png"><span>本地文件</span>
<input type="file">
</span> -->
<button mat-raised-button color="primary" (click)='upload()'><img style="margin-bottom: 2px;" src="../../../assets/images/bendi.png"> 本地文件</button>
<input type="file" style="display: none;" id="up" (change)='filechange($event)' accept=".doc,.txt,.docx,.pdf">
<div *ngIf="file!=undefined"><label style="font-size: 10px;">{{file.name}}</label></div>
<div *ngIf="uploadisLoading">
<span style="font-size: 10px;">上传中...</span>
<mat-progress-bar mode="determinate" [value]="uploadProgress" class="progress" style="width: 250px;"></mat-progress-bar>
<button mat-raised-button (click)="cancel()" style="width: 80px;font-size: 10px;margin-top: 3px;">取消上传</button>
</div>
</div>
<div class="bottom">
<button mat-raised-button color="primary">确定</button>
<button mat-raised-button color="primary" (click)='newplan()'>确定</button>
<button mat-raised-button style="margin-left: 50px;" (click)="close()">取消</button>
</div>
</div>

4
src/app/plan-management/type-plan/newunit.scss

@ -7,7 +7,7 @@
.queryField {
margin: 3px 5px;
input {
width: 50px;
width: 100%;
height: 18px;
line-height: 18px;
border-radius: 3px;}
@ -26,7 +26,7 @@
}
}
.bottom{
margin: 30px 30px;
margin: 10% 30px;
button{
width: 80px;
height: 36px;

40
src/app/plan-management/type-plan/type-plan.component.html

@ -1,6 +1,6 @@
<div style="height: 100%;overflow-y: auto;">
<div class="header" >
<form >
<form (ngSubmit)="onSubmit(form.value)" #form="ngForm">
<div class="queryBox">
<div class="queryField">
@ -13,17 +13,17 @@
<div class="queryField">
<label style="margin-right: 10px;">添加人:</label>
<mat-form-field class="example-full-width">
<input matInput placeholder="请输入添加人" name="companyName" autocomplete="off" [(ngModel)]="addname">
<input matInput placeholder="请输入添加人" name="addname" autocomplete="off" [(ngModel)]="addname">
</mat-form-field>
</div>
<div class="queryField">
<label style="margin-right: 10px;">添加时间:</label>
<mat-form-field class="example-full-width">
<input type="date" matInput name="companyName" autocomplete="off" [(ngModel)]="addtime">
<input type="date" matInput name="addtime" autocomplete="off" [(ngModel)]="addtime">
</mat-form-field>
🠊
<mat-form-field class="example-full-width">
<input type="date" matInput autocomplete="off" >
<input type="date" matInput autocomplete="off" name="endtime" [(ngModel)]="endtime">
</mat-form-field>
</div>
@ -68,39 +68,41 @@
<div class="tablebox">
<table mat-table [dataSource]="tabledataSource" class="mat-elevation-z8">
<ng-container matColumnDef="unitname">
<th mat-header-cell *matHeaderCellDef>预案名称</th>
<td mat-cell *matCellDef="let element">{{element.unitname}}</td>
<th mat-header-cell *matHeaderCellDef style="width: 20%;">预案名称</th>
<td mat-cell *matCellDef="let element">{{element.name}}</td>
</ng-container>
<ng-container matColumnDef="addname">
<th mat-header-cell *matHeaderCellDef>添加人</th>
<td mat-cell *matCellDef="let element">{{element.addname}}</td>
<th mat-header-cell *matHeaderCellDef style="width: 10%;">添加人</th>
<td mat-cell *matCellDef="let element">{{element.creatorName}}</td>
</ng-container>
<ng-container matColumnDef="addtime">
<th mat-header-cell *matHeaderCellDef>添加时间</th>
<td mat-cell *matCellDef="let element">{{element.addtime}}</td>
<th mat-header-cell *matHeaderCellDef style="width: 10%;">添加时间</th>
<td mat-cell *matCellDef="let element">{{element.creationTime|date:'yyyy-MM-dd'}}</td>
</ng-container>
<ng-container matColumnDef="plantype">
<th mat-header-cell *matHeaderCellDef>预案类型</th>
<th mat-header-cell *matHeaderCellDef style="width: 10%;">预案类型</th>
<td mat-cell *matCellDef="let element">类型预案</td>
</ng-container>
<ng-container matColumnDef="passstate">
<th mat-header-cell *matHeaderCellDef>审核状态</th>
<td mat-cell *matCellDef="let element">{{element.passstate}}</td>
<th mat-header-cell *matHeaderCellDef style="width: 10%;">审核状态</th>
<td mat-cell *matCellDef="let element">{{element.auditStatus=='8'?'未提交审核':element.auditStatus=='1'?'审核中':element.auditStatus=='2'?'审核通过':'审核退回'}}</td>
</ng-container>
<ng-container matColumnDef="isopen">
<th mat-header-cell *matHeaderCellDef>是否公开</th>
<td mat-cell *matCellDef="let element">{{element.isopen}}</td>
<th mat-header-cell *matHeaderCellDef style="width: 10%;">是否公开</th>
<td mat-cell *matCellDef="let element">{{element.openRange}}</td>
</ng-container>
<ng-container matColumnDef="projectlevel">
<th mat-header-cell *matHeaderCellDef>编制级别</th>
<td mat-cell *matCellDef="let element">{{element.projectlevel}}</td>
<th mat-header-cell *matHeaderCellDef style="width: 10%;">编制级别</th>
<td mat-cell *matCellDef="let element">{{element.planLevel=='1'?'总队':element.planLevel=='2'?'支队':element.planLevel=='4'?'大队':'中队'}}</td>
</ng-container>
<ng-container matColumnDef="operation">
<th mat-header-cell *matHeaderCellDef>操作</th>
<td mat-cell *matCellDef="let element">
<th mat-header-cell *matHeaderCellDef style="width: 20%;">操作</th>
<td mat-cell *matCellDef="let element" style="white-space: nowrap;cursor: pointer;">
<span style="color: blue;">查看预案</span>
<span style="color: blue;margin-left: 4px;" (click)='readFile(element)'>下载</span>
<span style="color: red;margin-left: 4px" (click)='deletePlan(element.id)'> 删除</span>
</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>

3
src/app/plan-management/type-plan/type-plan.component.scss

@ -114,5 +114,8 @@
.mat-column-jurisdictionsquadron{
width: 10%;
}
span:hover{
text-decoration:underline
}
}
}

341
src/app/plan-management/type-plan/type-plan.component.ts

@ -4,7 +4,7 @@
* @Author: sueRimn
* @Date: 2021-01-06 09:47:43
* @LastEditors: sueRimn
* @LastEditTime: 2021-01-06 15:12:30
* @LastEditTime: 2021-01-11 14:01:30
*/
import { Component, OnInit, ViewChild, Inject } from '@angular/core';
import { HttpClient } from '@angular/common/http'
@ -55,6 +55,7 @@ export class TypePlanComponent implements OnInit {
{name:"中队",value:"8"}
]
}
this.getAlltabledate()
}
preparelevels:any
@ -65,6 +66,7 @@ export class TypePlanComponent implements OnInit {
level//预案级别
addname//添加人
addtime//添加时间
endtime
unittype//预案类型
unitstate//审核状态
projectlevel//编制级别
@ -77,23 +79,183 @@ export class TypePlanComponent implements OnInit {
pageSizeOptions: number[] = [10] //设置每页条数
PageNumber:any; //第几页
//获取表格数据
getAlltabledate(){
let paramsdata:any = {
Name:this.unitname||'',
planCategories:8,
CreatorName:this.addname||'',
AuditStatus:this.unitstate|| '',
QueryStartTime:this.addtime||'',
QueryEndTime:this.endtime||'',
PlanLevel:this.projectlevel||'',
HasChildrenPlanLevel:this.plcheck||'',
PageNumber: this.PageNumber || '1',
PageSize: this.pageSizeOptions[0],
}
this.http.get("/api/PlanComponentsMajor",{params:paramsdata}).subscribe((data:any)=>{
this.length = data.totalCount
this.tabledataSource = data.items
})
}
//重置
reset(){
this.unitname=''
this.level=''
this.addname=''
this.addtime=''
this.unittype=''
this.endtime=''
this.unitstate=''
this.projectlevel=''
this.plcheck=false
this.getAlltabledate()
}
//查询
onSubmit (value) {
if(this.endtime!=undefined&&this.addtime>this.endtime){
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('开始时间不能大于结束时间!','确定',config);
}else{
this.PageNumber = 1
this.pageEvent.pageIndex = 0
this.getAlltabledate();
}
}
//删除预案
deletePlan(id){
let isTrue = confirm('您确定要删除吗')
if(isTrue){
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.http.delete(`/api/PlanComponentsMajor/${id}`).subscribe(data=>{
this.snackBar.open('删除成功!','确定',config);
this.getAlltabledate()
},err => {
this.snackBar.open(err,'确定',config);
})
}
}
//新增预案弹窗
addunit(){
const dialogRef = this.dialog.open(newunitType, {
width: '340px',
height:'300px'
height:'370px'
//data: paperDataInfo
});
dialogRef.afterClosed().subscribe(result => {
this.getAlltabledate()
}
);
}
//下载↓
selectDownloadFile:any; //选择下载的文件
download:any; //下载文件元数据
downloadisLoading:boolean = false; //进度条loading加载
downloadProgress:number=0; //进度条进度
downloadFileName:any
fileUrls:any //当前预案附件地址
fileDatas:any = []
selectedFileIndex : any = 0
selectedFileData : any
uploadFileLonging:any
//读取下载文件信息
readFile (element) {
this.uploadFileLonging = element
element.attachmentUrls.forEach(item=>{
this.http.get('/api/ObjectMetadata/PlanPlatform/'+item).subscribe((data:any)=>{
data.filePige = (data.fileLength / (1024*1024)).toFixed(2)
//console.log(data)
this.download = data
this.downloadFile()
})
})
}
//初始化下载
downloadFile () {
this.downloadProgress = 0
let file = this.download
let fileSize = file.fileLength//下载文件的总大小
let shardSize = 10 * 1024 * 1024 //文件大小是否大于10MB
if (file && fileSize<=shardSize) { //<=10MB时直接下载
this.downloadisLoading = true
// this.setFileLoading()
this.http.get(`/api/Objects/PlanPlatform/${file.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 suffix = file.objectName.substring(file.objectName.lastIndexOf(".")+1,file.objectName.length) ;
link.setAttribute("download", file.fileName + "-" +this.uploadFileLonging.name + "." + suffix);
document.body.appendChild(link);
link.click();
this.downloadisLoading = false
// this.setFileLoading()
})
} else if (file && fileSize > shardSize) { //>10MB时分块下载
this.blockingDownload() //分段下载
this.downloadisLoading = true
// this.setFileLoading()
}
}
//分段下载并合并
async blockingDownload () {
let file = this.download
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/${file.objectName}`,{headers:{'range':`bytes= ${start}-${end}`},responseType:'blob'}).subscribe(data=>{
result(data) })
})
allFile.push(result)
this.downloadProgress = Number((i/allSlice).toFixed(2))*100
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 suffix = file.objectName.substring(file.objectName.lastIndexOf(".")+1,file.objectName.length) ;
link.setAttribute("download", file.fileName + "-" +this.uploadFileLonging.name + "." + suffix);
document.body.appendChild(link);
link.click();
// this.downloadProgress = 0
this.downloadisLoading = false
// this.setFileLoading()
}
} //for循环
}
//取消分块下载
cancelDowload () {
}
}
@ -112,14 +274,177 @@ export class newunitType{
unittype//预案类型
unitstate//审核状态
projectlevel//编制级别
close(){
this.dialogRef.close();
}
reservePlanType//预案类型
//上传
upload(){
document.getElementById('up').click()
}
upchange(e){
console.log(e)
//上传文件↓
file:any; //上传的文件
fileName:any; //上传文件name
uploadisLoading:boolean = false; //进度条loading加载
uploadProgress:number=0; //进度条进度
objectName:any; //上传对象名
uploadId:any; //上传分块上传事件编号
uploadover:any = false //上传完成之后提示
selectedPLanType:any//所选预案类型
selectedPLanName:any//所选预案名称
localup:boolean = false //本地上传
defaultisshow = '0' //默认显示上传input框
//上传文件input
filechange(e){
this.file = e.target.files[0] || null //上传的文件
}
//上传文件
startUploading (planType) {
let file = this.file || 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)
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.http.post(`/api/Objects/PlanPlatform/typeClass`,formData).subscribe((data:any)=>{
this.objectName = data.objectName
//console.log('上传成功')
let body:any = {
Name:this.unitname||'',
PlanCategory:8,
PlanLevel:1,
PlanMode:1,
attachmentUrls:[`${this.objectName}`]
}
this.http.post("/api/PlanComponentsMajor",body).subscribe((data:any)=>{
this.snackBar.open('创建成功!','确定',config);
this.dialogRef.close();
},err=>{
this.snackBar.open('创建失败!','确定',config);
})
},err=>{
this.snackBar.open('上传失败!','确定',config);
})
} else if (file && fileSize>shardSize) { //上传文件>5MB时,分块上传
let data = {filename: file.name}
this.uploadisLoading = true
this.http.post(`/api/NewMultipartUpload/PlanPlatform/typeClass`,{},{params:data}).subscribe((data:any)=>{ //初始化分段上传
this.objectName = data.objectName
this.uploadId = data.uploadId
this.subsectionUploading(planType)
})
}
}
PartNumberETag:any=[]; //每次返回需要保存的信息
//开始分段上传
async subsectionUploading (planType) {
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(planType)}
}//for循环
}
//完成分块上传
endUploading (planType) {
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
//console.log('创建成功')
this.uploadProgress = 0;
this.uploadisLoading = false
this.PartNumberETag =[] //清空保存返回的信息
this.uploadover = true
let body:any = {
Name:this.unitname||'',
PlanCategory:8,
PlanLevel:1,
PlanMode:1,
attachmentUrls:[`${this.objectName}`]
}
this.http.post("/api/PlanComponentsMajor",body).subscribe((data:any)=>{
this.snackBar.open('创建成功!','确定',config);
this.dialogRef.close();
},err=>{
this.snackBar.open('创建失败!','确定',config);
})
})
}
//取消分块上传
cancel () {
this.http.delete(`/api/MultipartUpload/PlanPlatform/${this.objectName}?uploadId=${this.uploadId}`).subscribe(data=>{
this.uploadProgress = 0;
this.uploadisLoading= false;
(<HTMLInputElement>document.getElementById('up')).value = null
this.PartNumberETag =[] //清空保存返回的信息
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('取消上传成功!','确定',config);
this.uploadover = false
this.file = null
})
}
//创建预案
newplan(){
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
if(this.unitname==undefined||this.unitname==''){
this.snackBar.open('请输入预案名称!','确定',config);
}
else if(this.file==undefined){
this.snackBar.open('请先上传文件!','确定',config);
}
else{
if(this.reservePlanType!='1'){
this.startUploading("非二维")
}
else{this.startUploading("二维")}
}
}
//取消按钮
close(){
this.dialogRef.close();
}
}

Loading…
Cancel
Save