Browse Source

[新增]报表查询和预案级别修改

guangxi
邵佳豪 2 years ago
parent
commit
fbe5cdc154
  1. 792
      src/app/plan-management/create-plan-online-five/create-plan-online-five.component.html
  2. 3561
      src/app/plan-management/create-plan-online-five/create-plan-online-five.component.ts
  3. 18
      src/app/plan-management/entry-plan-look/edit-plan-category/edit-plan-category.component.html
  4. 0
      src/app/plan-management/entry-plan-look/edit-plan-category/edit-plan-category.component.scss
  5. 25
      src/app/plan-management/entry-plan-look/edit-plan-category/edit-plan-category.component.spec.ts
  6. 37
      src/app/plan-management/entry-plan-look/edit-plan-category/edit-plan-category.component.ts
  7. 5
      src/app/plan-management/entry-plan-look/entry-plan-look.component.html
  8. 387
      src/app/plan-management/entry-plan-look/entry-plan-look.component.scss
  9. 18
      src/app/plan-management/entry-plan-look/entry-plan-look.component.ts
  10. 5
      src/app/plan-management/plan-management.module.ts
  11. 20
      src/app/statistic-analysis/combined-query/combined-query.component.html
  12. 811
      src/app/statistic-analysis/combined-query/combined-query.component.ts

792
src/app/plan-management/create-plan-online-five/create-plan-online-five.component.html

File diff suppressed because it is too large Load Diff

3561
src/app/plan-management/create-plan-online-five/create-plan-online-five.component.ts

File diff suppressed because it is too large Load Diff

18
src/app/plan-management/entry-plan-look/edit-plan-category/edit-plan-category.component.html

@ -0,0 +1,18 @@
<form (ngSubmit)="onSubmit(form.value)" #form="ngForm" class="example-container">
<div class="topbox" style="text-align: center;">
<span mat-dialog-title>修改预案级别</span>
</div>
<div class="mainbox">
<mat-form-field>
<mat-select placeholder='请选择预案级别' [(ngModel)]="planCategory" name="integritySort">
<mat-option [value]='3'>Ⅲ级预案</mat-option>
<mat-option [value]='4'>Ⅳ级预案</mat-option>
<mat-option [value]='5'>Ⅴ级预案</mat-option>
</mat-select>
</mat-form-field>
</div>
<div class="btn" style="margin-top:10px;">
<button mat-raised-button color="primary" style="margin-right: 12px;">确定</button>
<button type="button" mat-button (click)="onNoClick()" mat-raised-button>取消</button>
</div>
</form>

0
src/app/plan-management/entry-plan-look/edit-plan-category/edit-plan-category.component.scss

25
src/app/plan-management/entry-plan-look/edit-plan-category/edit-plan-category.component.spec.ts

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { EditPlanCategoryComponent } from './edit-plan-category.component';
describe('EditPlanCategoryComponent', () => {
let component: EditPlanCategoryComponent;
let fixture: ComponentFixture<EditPlanCategoryComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ EditPlanCategoryComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(EditPlanCategoryComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

37
src/app/plan-management/entry-plan-look/edit-plan-category/edit-plan-category.component.ts

@ -0,0 +1,37 @@
import { HttpClient } from "@angular/common/http";
import { Component, OnInit, Inject } from "@angular/core";
import { MatDialogRef, MAT_DIALOG_DATA } from "@angular/material/dialog";
import { MatSnackBar } from "@angular/material/snack-bar";
@Component({
selector: "app-edit-plan-category",
templateUrl: "./edit-plan-category.component.html",
styleUrls: ["./edit-plan-category.component.scss"],
})
export class EditPlanCategoryComponent implements OnInit {
constructor(
private http: HttpClient,
public dialogRef: MatDialogRef<EditPlanCategoryComponent>,
@Inject(MAT_DIALOG_DATA) public data,
public snackBar: MatSnackBar
) {}
planCategory;
ngOnInit(): void {
this.planCategory = this.data.planCategory;
}
onNoClick(): void {
this.dialogRef.close();
}
onSubmit(value) {
let body = {
planCategory: this.planCategory,
};
this.http
.put(`/api/PlanComponents/${this.data.id}`, body)
.subscribe((data) => {
this.dialogRef.close("success");
});
}
}

5
src/app/plan-management/entry-plan-look/entry-plan-look.component.html

@ -67,7 +67,10 @@
<ng-container matColumnDef="planCategory"> <ng-container matColumnDef="planCategory">
<th mat-header-cell *matHeaderCellDef>预案级别</th> <th mat-header-cell *matHeaderCellDef>预案级别</th>
<td mat-cell *matCellDef="let element"> <td mat-cell *matCellDef="let element">
{{element.planCategory=='3'?'Ⅲ级预案':element.planCategory=='4'?'Ⅳ级预案':'Ⅴ级预案'}}</td> {{element.planCategory=='3'?'Ⅲ级预案':element.planCategory=='4'?'Ⅳ级预案':'Ⅴ级预案'}}
<mat-icon *ngIf="element.auditStatus==8 || element.maintenanceVerifyState=='未提交审核'"
class="editPlanCategory" (click)="editPlanCategory(element)">create</mat-icon>
</td>
</ng-container> </ng-container>
<ng-container matColumnDef="plantype"> <ng-container matColumnDef="plantype">
<th mat-header-cell *matHeaderCellDef style="width: 150px;">预案类型</th> <th mat-header-cell *matHeaderCellDef style="width: 150px;">预案类型</th>

387
src/app/plan-management/entry-plan-look/entry-plan-look.component.scss

@ -1,160 +1,203 @@
.header{ .header {
height: 130px; height: 130px;
// border-bottom: 1px solid rgba(0, 0, 0, 0.12); // border-bottom: 1px solid rgba(0, 0, 0, 0.12);
display: flex; display: flex;
flex-direction: row; flex-direction: row;
flex-wrap: wrap; flex-wrap: wrap;
align-items:center; align-items: center;
// justify-content:center;
div{ // justify-content:center;
width: 300px; div {
height: 30px; width: 300px;
// margin: 0 30px; height: 30px;
margin-left: 80px; // margin: 0 30px;
} margin-left: 80px;
// margin-bottom: 30px; }
// margin-bottom: 30px;
} }
.body{
.body {
overflow: auto;
.btn {
button {
width: 80px;
height: 40px;
margin-left: 2%;
}
}
.tablebox {
overflow: auto; overflow: auto;
.btn{
button{ .add {
width: 80px; cursor: auto;
height: 40px; text-decoration: none;
margin-left: 2%; display: block;
} width: 40px;
height: 20px;
background: #1AE2AC;
font-size: 12px;
line-height: 20px;
color: #FFFFFF;
margin-left: 50px;
} }
.tablebox{
overflow: auto; .weihu {
.add{ cursor: auto;
cursor: auto; text-decoration: none;
text-decoration: none; display: block;
display: block; width: 64px;
width: 40px; height: 20px;
height: 20px; background: #FFC94B;
background: #1AE2AC; font-size: 12px;
font-size: 12px; color: #FFFFFF;
line-height: 20px; line-height: 20px;
color: #FFFFFF; margin-left: 40px;
margin-left: 50px;
}
.weihu{
cursor: auto;
text-decoration: none;
display: block;
width: 64px;
height: 20px;
background: #FFC94B;
font-size: 12px;
color: #FFFFFF;
line-height: 20px;
margin-left: 40px;
}
table{
width: 100%;
margin-left: 0%;
margin-top: 15px;
}
mat-paginator{
width: 100%;
margin-left: 0%;
// margin-top: 30px;
}
} }
}
.upbox{ .editPlanCategory {
height: 100px; width: 13px;
margin-bottom: 15px; height: 13px;
mat-radio-group{ font-size: 18px;
div{ vertical-align: sub;
margin: 10px 0; cursor: pointer;
} }
table {
width: 100%;
margin-left: 0%;
margin-top: 15px;
} }
mat-paginator {
width: 100%;
margin-left: 0%;
// margin-top: 30px;
}
}
} }
.createbtnbox{
button{ .upbox {
margin: 0 6px; height: 100px;
margin-bottom: 15px;
mat-radio-group {
div {
margin: 10px 0;
} }
}
} }
.mat-header-cell{
text-align: center; .createbtnbox {
button {
margin: 0 6px;
}
} }
.mat-cell{
text-align: center; .mat-header-cell {
span{ text-align: center;
color: #0000BF; }
margin: 0 3px;
cursor: pointer; .mat-cell {
} text-align: center;
.grey{
color: grey; span {
pointer-events: none; color: #0000BF;
} margin: 0 3px;
cursor: pointer;
}
.grey {
color: grey;
pointer-events: none;
}
} }
//进度条 //进度条
.progressBox{ .progressBox {
line-height: 49px; line-height: 49px;
height: 49px; height: 49px;
position: relative; position: relative;
display: inline-block;
width: 100%;
button {
float: right;
}
.progress {
display: inline-block; display: inline-block;
width: 100%; position: absolute;
button{ width: 500px;
float: right; top: 22px;
} left: 32px;
.progress{ }
display: inline-block;
position: absolute;
width: 500px;
top: 22px;
left: 32px;
}
.filename{ .filename {
display: inline-block; display: inline-block;
max-width: 180px; max-width: 180px;
overflow: hidden; overflow: hidden;
white-space: nowrap; white-space: nowrap;
text-overflow: ellipsis; text-overflow: ellipsis;
// margin-left: 160px; // margin-left: 160px;
} }
} }
.fileDiv{ .fileDiv {
cursor: pointer; cursor: pointer;
}
.fileDiv:hover{
background-color: #fafafa;
} }
.auditDiv{
p{ .fileDiv:hover {
margin: 8px 0; background-color: #fafafa;
margin-left: 16px;
}
} }
.btn{
text-align: center; .auditDiv {
button{ p {
margin: 0 3px; margin: 8px 0;
} margin-left: 16px;
}
}
.btn {
text-align: center;
button {
margin: 0 3px;
}
} }
#viewer { #viewer {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
.mat-dialog-container{
padding: 0; .mat-dialog-container {
} padding: 0;
//预览图片旋转角度 }
.rotateA {transform: rotate(90deg) scale(0.75);}
.rotateB {transform: rotate(180deg)} //预览图片旋转角度
.rotateC {transform: rotate(270deg) scale(0.75);} .rotateA {
@media screen and (max-width:1200px){ transform: rotate(90deg) scale(0.75);
.bigimgbox{ }
.rotateB {
transform: rotate(180deg)
}
.rotateC {
transform: rotate(270deg) scale(0.75);
}
@media screen and (max-width:1200px) {
.bigimgbox {
width: 880px; width: 880px;
height: 580px; height: 580px;
//预览图片 //预览图片
.previewImgBox { .previewImgBox {
width: 800px; width: 800px;
@ -163,10 +206,12 @@
} }
} }
} }
@media screen and (min-width:1200px) and (max-width:1400px){
.bigimgbox{ @media screen and (min-width:1200px) and (max-width:1400px) {
width:880px; .bigimgbox {
width: 880px;
height: 610px; height: 610px;
//预览图片 //预览图片
.previewImgBox { .previewImgBox {
width: 800px; width: 800px;
@ -174,47 +219,53 @@
text-align: center; text-align: center;
} }
} }
} }
@media screen and (min-width:1400px){
.bigimgbox{ @media screen and (min-width:1400px) {
width:1110px; .bigimgbox {
width: 1110px;
height: 860px; height: 860px;
//预览图片 //预览图片
.previewImgBox { .previewImgBox {
width: 900px; width: 900px;
height: 100%; height: 100%;
text-align: center; text-align: center;
} }
.previewImgBottom { .previewImgBottom {
text-align: center; text-align: center;
height: 30px; height: 30px;
margin: 20px auto; margin: 20px auto;
}
}
}
.shadow{
height: 100%;
width: 100%;
z-index:998;
background-color:#FFFFFF;
opacity:0.3;
mat-spinner{
position: relative;
top: 40%;
left: 40%;
} }
}
}
.shadow {
height: 100%;
width: 100%;
z-index: 998;
background-color: #FFFFFF;
opacity: 0.3;
mat-spinner {
position: relative;
top: 40%;
left: 40%;
}
} }
//修改上传文件 //修改上传文件
.upload{ .upload {
width: 100%; width: 100%;
height: 100%; height: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
.file{
text-align: center; .file {
} text-align: center;
} }
}

18
src/app/plan-management/entry-plan-look/entry-plan-look.component.ts

@ -27,6 +27,7 @@ import { STEPPER_GLOBAL_OPTIONS } from "@angular/cdk/stepper";
import Swiper from "swiper"; import Swiper from "swiper";
import { resolve } from "dns"; import { resolve } from "dns";
import { DomSanitizer } from "@angular/platform-browser"; import { DomSanitizer } from "@angular/platform-browser";
import { EditPlanCategoryComponent } from "./edit-plan-category/edit-plan-category.component";
declare var CryptoJS; declare var CryptoJS;
@Component({ @Component({
selector: "app-entry-plan-look", selector: "app-entry-plan-look",
@ -614,6 +615,23 @@ export class EntryPlanLookComponent implements OnInit {
} }
}); });
} }
//修改预案级别
editPlanCategory(data) {
console.log(data);
const dialogRef = this.dialog.open(EditPlanCategoryComponent, {
data: data,
});
dialogRef.afterClosed().subscribe((data) => {
if (data) {
const config = new MatSnackBarConfig();
config.verticalPosition = "top";
config.duration = 3000;
this.snackBar.open("修改成功!", "确定", config);
this.getAllPlanComponents();
}
});
}
//获得所有预案组件 //获得所有预案组件
audit: boolean; audit: boolean;
getAllPlanComponents() { getAllPlanComponents() {

5
src/app/plan-management/plan-management.module.ts

@ -76,13 +76,14 @@ import { updataHl } from './create-plan-online-five/create-plan-online-five.comp
import {ChangeUrl} from './entry-plan-look/entry-plan-look.component' import {ChangeUrl} from './entry-plan-look/entry-plan-look.component'
import {adddwsurveys} from './create-plan-online-five/create-plan-online-five.component' import {adddwsurveys} from './create-plan-online-five/create-plan-online-five.component'
import { editUpload } from './entry-plan-look/entry-plan-look.component' import { editUpload } from './entry-plan-look/entry-plan-look.component'
import { wenbenUpload } from './entry-plan-look/entry-plan-look.component' import { wenbenUpload } from './entry-plan-look/entry-plan-look.component';
import { EditPlanCategoryComponent } from './entry-plan-look/edit-plan-category/edit-plan-category.component'
@NgModule({ @NgModule({
declarations: [EntryPlanComponent, PassPlanComponent, OpenPlanComponent, EntryPlanLookComponent, AddPlanone, PlanType, AuditSatus, PlanLevel, DownloadFile, AuditResult, ChangeName, declarations: [EntryPlanComponent, PassPlanComponent, OpenPlanComponent, EntryPlanLookComponent, AddPlanone, PlanType, AuditSatus, PlanLevel, DownloadFile, AuditResult, ChangeName,
WebLookComponent, OnetwoEntryPlanComponent, newunitComponent, MeetPlanComponent, newunitMeet, TypePlanComponent, newunitType, PsViewer, onetwoAuditResult, meetAuditResult, WebLookComponent, OnetwoEntryPlanComponent, newunitComponent, MeetPlanComponent, newunitMeet, TypePlanComponent, newunitType, PsViewer, onetwoAuditResult, meetAuditResult,
typeAuditResult, MaintainUpComponent, GkPsViewer, GkhtmlPsViewer, UnitInfo, ReinforcePlanComponent, state, ImgDetails, CreatePlanOnlineFiveComponent, CreatePlanOnlineThreeComponent, typeAuditResult, MaintainUpComponent, GkPsViewer, GkhtmlPsViewer, UnitInfo, ReinforcePlanComponent, state, ImgDetails, CreatePlanOnlineFiveComponent, CreatePlanOnlineThreeComponent,
OpenPlanToolDialog,yinYong,newTitle,disaster,updataHl,ChangeUrl,adddwsurveys,editUpload,wenbenUpload], OpenPlanToolDialog,yinYong,newTitle,disaster,updataHl,ChangeUrl,adddwsurveys,editUpload,wenbenUpload, EditPlanCategoryComponent],
imports: [ imports: [
CommonModule, CommonModule,
PlanManagementRoutingModule, PlanManagementRoutingModule,

20
src/app/statistic-analysis/combined-query/combined-query.component.html

@ -121,6 +121,24 @@
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
</div> </div>
<div class="queryField" *ngIf="preparelevels==0">
<label style="margin-right: 10px;">重点单位:</label>
<mat-form-field>
<mat-select placeholder='是否为重点单位' [(ngModel)]="unitIsFollowed" name="integritySort">
<mat-option [value]='true'>重点单位</mat-option>
<mat-option [value]='false'>一般单位</mat-option>
</mat-select>
</mat-form-field>
</div>
<div class="queryField" *ngIf="preparelevels==1">
<label style="margin-right: 10px;">重点单位:</label>
<mat-form-field>
<mat-select placeholder='是否为重点单位' [(ngModel)]="planIsFollowed" name="integritySort">
<mat-option [value]='true'>重点单位</mat-option>
<mat-option [value]='false'>一般单位</mat-option>
</mat-select>
</mat-form-field>
</div>
<div class="queryField" *ngIf="preparelevels==0||preparelevels==1"> <div class="queryField" *ngIf="preparelevels==0||preparelevels==1">
<button mat-raised-button color="primary">查询</button> <button mat-raised-button color="primary">查询</button>
<button mat-raised-button style="margin-left: 25px;" type="button" (click)="reset()">重置</button> <button mat-raised-button style="margin-left: 25px;" type="button" (click)="reset()">重置</button>
@ -177,4 +195,4 @@
</ng-template> </ng-template>
</mat-tab> </mat-tab>
</mat-tab-group> </mat-tab-group>
</div> </div>

811
src/app/statistic-analysis/combined-query/combined-query.component.ts

@ -1,93 +1,104 @@
import { Component, OnInit, ViewChild, Inject } from '@angular/core'; import { Component, OnInit, ViewChild, Inject } from "@angular/core";
import { HttpClient } from '@angular/common/http' import { HttpClient } from "@angular/common/http";
import { MatTreeFlatDataSource, MatTreeFlattener } from '@angular/material/tree'; import {
import { MatPaginator } from '@angular/material/paginator'; MatTreeFlatDataSource,
import { FlatTreeControl } from '@angular/cdk/tree'; MatTreeFlattener,
import { FormControl } from '@angular/forms'; } from "@angular/material/tree";
import { Router, ActivatedRoute } from '@angular/router' import { MatPaginator } from "@angular/material/paginator";
import { PageEvent } from '@angular/material/paginator'; import { FlatTreeControl } from "@angular/cdk/tree";
import { MatDialogRef, MatDialog, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { FormControl } from "@angular/forms";
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar'; import { Router, ActivatedRoute } from "@angular/router";
import { TreeService } from '../../http-interceptors/tree.service' import { PageEvent } from "@angular/material/paginator";
import { Viewer } from 'photo-sphere-viewer'; import {
import { timeStamp } from 'console'; MatDialogRef,
MatDialog,
MAT_DIALOG_DATA,
} from "@angular/material/dialog";
import { MatSnackBar, MatSnackBarConfig } from "@angular/material/snack-bar";
import { TreeService } from "../../http-interceptors/tree.service";
import { Viewer } from "photo-sphere-viewer";
import { timeStamp } from "console";
@Component({ @Component({
selector: 'app-combined-query', selector: "app-combined-query",
templateUrl: './combined-query.component.html', templateUrl: "./combined-query.component.html",
styleUrls: ['./combined-query.component.scss'] styleUrls: ["./combined-query.component.scss"],
}) })
export class CombinedQueryComponent implements OnInit { export class CombinedQueryComponent implements OnInit {
constructor(
constructor(private http: HttpClient, private router: Router, private route: ActivatedRoute, private tree: TreeService, public dialog: MatDialog, public snackBar: MatSnackBar) { } private http: HttpClient,
private router: Router,
private route: ActivatedRoute,
private tree: TreeService,
public dialog: MatDialog,
private _transformer = (node, level: number) => { //初始化tree public snackBar: MatSnackBar
) {}
private _transformer = (node, level: number) => {
//初始化tree
return { return {
expandable: !!node.children && node.children.length > 0, expandable: !!node.children && node.children.length > 0,
name: node.name, name: node.name,
level: level, level: level,
id: node.id, id: node.id,
parentId: node.parentId, parentId: node.parentId,
children: node.children children: node.children,
}; };
} };
treeControl = new FlatTreeControl<any>(node => node.level, node => node.expandable); treeControl = new FlatTreeControl<any>(
treeFlattener = new MatTreeFlattener(this._transformer, node => node.level, node => node.expandable, node => node.children); (node) => node.level,
(node) => node.expandable
);
treeFlattener = new MatTreeFlattener(
this._transformer,
(node) => node.level,
(node) => node.expandable,
(node) => node.children
);
dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener); dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener);
myControl = new FormControl(); myControl = new FormControl();
hasChild = (_: number, node: any) => node.expandable; hasChild = (_: number, node: any) => node.expandable;
displayedColumns: string[] = ["组织名称", "总数"]; //, 'addtime', 'plantype', 'auditStatus', 'openRange', 'projectlevel', 'operation'
yuanColumns: string[] = ["组织名称", "总数"];
tabledataSource = []; //单位表格数据
yuanTable = []; //预案表格数据
excelData: any;
findTj = 0; //查询条件
displayedColumns: string[] = ['组织名称', '总数'];//, 'addtime', 'plantype', 'auditStatus', 'openRange', 'projectlevel', 'operation' allPlanInfo: any; //存储所有预案信息
yuanColumns: string[] = ['组织名称', '总数']; lable = ["单位查询", "预案查询"];
tabledataSource = [] //单位表格数据
yuanTable = []//预案表格数据
excelData: any
findTj = 0//查询条件
allPlanInfo: any //存储所有预案信息
lable = ['单位查询', '预案查询']
selected = new FormControl(0); //选项卡实例 selected = new FormControl(0); //选项卡实例
//判断选了哪一个 //判断选了哪一个
selectedIndexChange(e) { selectedIndexChange(e) {
this.orRecord = [] this.orRecord = [];
this.selected.setValue(e) this.selected.setValue(e);
this.preparelevels = Number(e) this.preparelevels = Number(e);
if (this.preparelevels == 0) { if (this.preparelevels == 0) {
this.js = this.organizationName this.js = this.organizationName;
this.jsId = this.organizationId this.jsId = this.organizationId;
this.jscheck = true this.jscheck = true;
this.unittype = [] this.unittype = [];
this.allunittype.forEach(element => { this.allunittype.forEach((element) => {
this.unittype.push(element.id) this.unittype.push(element.id);
}); });
this.preparelevel = [1] this.preparelevel = [1];
this.dwaddtime = '2020-01-01'//单位查询开始时间 this.dwaddtime = "2020-01-01"; //单位查询开始时间
this.dwendtime = this.getNowFormatDate()//单位结束时间 this.dwendtime = this.getNowFormatDate(); //单位结束时间
} else if (this.preparelevels == 1) { } else if (this.preparelevels == 1) {
this.yuanjs = this.organizationName this.yuanjs = this.organizationName;
this.yuanjsId = this.organizationId this.yuanjsId = this.organizationId;
this.yuanaddtime = '2020-01-01'//预案查询开始时间 this.yuanaddtime = "2020-01-01"; //预案查询开始时间
this.yuanendtime = this.getNowFormatDate()//预案查询结束时间 this.yuanendtime = this.getNowFormatDate(); //预案查询结束时间
this.yuanjscheck = true this.yuanjscheck = true;
this.reservePlanType = ['1', '2', '4', '16'] this.reservePlanType = ["1", "2", "4", "16"];
this.planCategory = ['1', '2', '3', '4', '5'] this.planCategory = ["1", "2", "3", "4", "5"];
} }
this.getAllPlanInfo() this.getAllPlanInfo();
} }
getNowFormatDate() { getNowFormatDate() {
var date = new Date(); var date = new Date();
var seperator1 = "-"; var seperator1 = "-";
@ -105,478 +116,498 @@ export class CombinedQueryComponent implements OnInit {
} }
async ngOnInit(): Promise<void> { async ngOnInit(): Promise<void> {
await this.getunitdata(); await this.getunitdata();
await this.getOrganizations(); await this.getOrganizations();
await this.getUnittype(); await this.getUnittype();
this.jscheck = true this.jscheck = true;
this.yuanjscheck = true this.yuanjscheck = true;
this.dwaddtime = '2020-01-01'//单位查询开始时间 this.dwaddtime = "2020-01-01"; //单位查询开始时间
this.dwendtime = this.getNowFormatDate()//单位结束时间 this.dwendtime = this.getNowFormatDate(); //单位结束时间
this.yuanaddtime = '2020-01-01'//预案查询开始时间 this.yuanaddtime = "2020-01-01"; //预案查询开始时间
this.yuanendtime = this.getNowFormatDate()//预案查询结束时间 this.yuanendtime = this.getNowFormatDate(); //预案查询结束时间
this.reservePlanType = ['1', '2', '4', '16'] this.reservePlanType = ["1", "2", "4", "16"];
this.planCategory = ['1', '2', '3', '4', '5'] this.planCategory = ["1", "2", "3", "4", "5"];
this.getAllPlanInfo(); this.getAllPlanInfo();
} }
//得到当前单位信息 //得到当前单位信息
organizationName: any //当前单位组织机构名称 organizationName: any; //当前单位组织机构名称
organizationId: any //当前单位组织机构id organizationId: any; //当前单位组织机构id
async getunitdata() { async getunitdata() {
await new Promise<void>((resolve, reject) => { await new Promise<void>((resolve, reject) => {
this.http.get("/api/Account/Profiles").subscribe( this.http.get("/api/Account/Profiles").subscribe((data: any) => {
(data: any) => { console.log("当前登陆用户信息", data);
console.log('当前登陆用户信息', data) resolve(data);
resolve(data) this.organizationName = data.organizationName;
this.organizationName = data.organizationName this.organizationId = data.organizationId;
this.organizationId = data.organizationId });
} });
)
})
} }
//获得所有组织机构 //获得所有组织机构
allorganizations: any //所有组织机构 allorganizations: any; //所有组织机构
treedata: any //组织机构树型数据 treedata: any; //组织机构树型数据
newallorganizations: any //用于存储在原始数据基础上的每个机构增加children字段 newallorganizations: any; //用于存储在原始数据基础上的每个机构增加children字段
async getOrganizations() { async getOrganizations() {
await new Promise<void>((resolve, reject) => { await new Promise<void>((resolve, reject) => {
this.http.get('/api/Organizations').subscribe( this.http.get("/api/Organizations").subscribe((data: any) => {
(data: any) => { this.allorganizations = data;
this.allorganizations = data this.treedata = this.tree.toTree(data);
this.treedata = this.tree.toTree(data); this.getpresentOrganization();
this.getpresentOrganization(); resolve(data);
resolve(data) });
} });
)
})
} }
//得到当前单位所在组织机构的tree型数据 //得到当前单位所在组织机构的tree型数据
getpresentOrganization() { getpresentOrganization() {
this.newallorganizations = this.allorganizations this.newallorganizations = this.allorganizations;
this.newallorganizations.forEach(item => { this.newallorganizations.forEach((item) => {
item.children = [] item.children = [];
this.newallorganizations.forEach(element => { this.newallorganizations.forEach((element) => {
if (element.parentId == item.id) { if (element.parentId == item.id) {
item.children.push(element) item.children.push(element);
} }
}); });
}); });
if (this.organizationName) { if (this.organizationName) {
this.newallorganizations.forEach(item => { this.newallorganizations.forEach((item) => {
if (item.name == this.organizationName) { if (item.name == this.organizationName) {
this.dataSource.data = [item] this.dataSource.data = [item];
} }
}); });
} else { } else {
this.dataSource.data = this.tree.toTree(this.treedata); this.dataSource.data = this.tree.toTree(this.treedata);
} }
this.js = this.organizationName this.js = this.organizationName;
this.jsId = this.organizationId this.jsId = this.organizationId;
this.yuanjs = this.organizationName this.yuanjs = this.organizationName;
this.yuanjsId = this.organizationId this.yuanjsId = this.organizationId;
} }
//获得所有单位类型 //获得所有单位类型
allunittype: any //所有单位类型 allunittype: any; //所有单位类型
async getUnittype() { async getUnittype() {
await new Promise<void>((resolve, reject) => { await new Promise<void>((resolve, reject) => {
this.http.get('/api/BuildingTypes/Simple').subscribe( this.http.get("/api/BuildingTypes/Simple").subscribe((data: any) => {
(data: any) => { this.allunittype = data;
this.allunittype = data console.log("单位类型", data);
console.log('单位类型', data) this.allunittype.forEach((element) => {
this.allunittype.forEach(element => { this.unittype.push(element.id);
this.unittype.push(element.id) });
}); resolve(data);
resolve(data) });
} });
)
})
} }
//获得所有预案或单位信息 //获得所有预案或单位信息
tableDataNull = false tableDataNull = false;
preparelevels: Number = 0 preparelevels: Number = 0;
companyName: any //单位名称 companyName: any; //单位名称
js: any //单位所选组织机构 js: any; //单位所选组织机构
jsId: any //单位所选组织机构的id jsId: any; //单位所选组织机构的id
jscheck: boolean //单位所选组织机构勾选框 jscheck: boolean; //单位所选组织机构勾选框
yuanjs: any //预案所选组织机构 yuanjs: any; //预案所选组织机构
yuanjsId: any //预案所选组织机构的id yuanjsId: any; //预案所选组织机构的id
yuanjscheck: boolean //预案所选组织机构勾选框 yuanjscheck: boolean; //预案所选组织机构勾选框
dwaddtime//单位查询开始时间 dwaddtime; //单位查询开始时间
dwendtime//单位结束时间 dwendtime; //单位结束时间
yuanaddtime//预案查询开始时间 yuanaddtime; //预案查询开始时间
yuanendtime//预案查询结束时间 yuanendtime; //预案查询结束时间
unittype = [] //单位类型 unittype = []; //单位类型
reservePlanType = [] //预案类型 reservePlanType = []; //预案类型
preparelevel = [1] //单位状态 preparelevel = [1]; //单位状态
plcheck: boolean //编制级别勾选框 plcheck: boolean; //编制级别勾选框
planCategory = [] //预案级别 planCategory = []; //预案级别
integritySort //单位排序字段 integritySort; //单位排序字段
yuanintegritySort //预案排序字段 yuanintegritySort; //预案排序字段
isMasklayer = false
unitIsFollowed = ""; //单位 重点
planIsFollowed = ""; //预案 重点单位
isMasklayer = false;
async getAllPlanInfo() { async getAllPlanInfo() {
console.log(this.preparelevel)
let paramsdata: any = { let paramsdata: any = {
QueryMode: this.preparelevels, QueryMode: this.preparelevels,
OrganizationId: this.jsId || '', OrganizationId: this.jsId || "",
HasChildren: this.jscheck || '', HasChildren: this.jscheck || "",
TimeIntervalStart: this.dwaddtime || '', TimeIntervalStart: this.dwaddtime || "",
TimeIntervalEnd: this.dwendtime || '', TimeIntervalEnd: this.dwendtime || "",
BuildingTypeIds: this.unittype || [], BuildingTypeIds: this.unittype || [],
CompanyStatuses: this.preparelevel || [], CompanyStatuses: this.preparelevel || [],
SortBy: this.integritySort ? 'totalCount' : '', SortBy: this.integritySort ? "totalCount" : "",
SortType: this.integritySort || '' SortType: this.integritySort || "",
} IsFollowed: String(this.unitIsFollowed) || "",
};
let yuandata = { let yuandata = {
QueryMode: this.preparelevels, QueryMode: this.preparelevels,
OrganizationId: this.yuanjsId || '', OrganizationId: this.yuanjsId || "",
HasChildren: this.yuanjscheck || '', HasChildren: this.yuanjscheck || "",
TimeIntervalStart: this.yuanaddtime || '', TimeIntervalStart: this.yuanaddtime || "",
TimeIntervalEnd: this.yuanendtime || '', TimeIntervalEnd: this.yuanendtime || "",
PlanCategories: this.planCategory || [], PlanCategories: this.planCategory || [],
PlanTypes: this.reservePlanType || [], PlanTypes: this.reservePlanType || [],
SortBy: this.yuanintegritySort ? 'totalCount' : '', SortBy: this.yuanintegritySort ? "totalCount" : "",
SortType: this.yuanintegritySort || '' SortType: this.yuanintegritySort || "",
} IsFollowed: String(this.planIsFollowed) || "",
// console.log(666, paramsdata) };
this.isMasklayer = true this.isMasklayer = true;
let result = await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
this.http.get("/api/StatisticsAnalysis/ReportTable", { params: this.preparelevels == 0 ? paramsdata : yuandata }).subscribe((data: any) => { this.http
console.log('接口数据', data) .get("/api/StatisticsAnalysis/ReportTable", {
this.excelData = data params: this.preparelevels == 0 ? paramsdata : yuandata,
if (data.length == 0) { })
this.tableDataNull = true .subscribe((data: any) => {
} else { console.log("接口数据", data);
this.tableDataNull = false this.excelData = data;
if (this.preparelevels == 0) { if (data.length == 0) {
//单位查询 this.tableDataNull = true;
if (this.preparelevel.length == 0) { } else {
//必须选择单位状态 this.tableDataNull = false;
let config = new MatSnackBarConfig(); if (this.preparelevels == 0) {
config.verticalPosition = 'top'; //单位查询
config.duration = 3000 if (this.preparelevel.length == 0) {
this.snackBar.open('请选择单位状态', '确定', config); //必须选择单位状态
} else { let config = new MatSnackBarConfig();
this.tabledataSource = [] config.verticalPosition = "top";
this.displayedColumns = ['组织名称', '总数'] config.duration = 3000;
data.forEach((element, i, value) => { this.snackBar.open("请选择单位状态", "确定", config);
this.tabledataSource.push({ name: [element.orgName, element.companyStatistics.totalCount] })
if (value[0].companyStatistics.buildingTypesCounts != null) {
value[i].companyStatistics.buildingTypesCounts.forEach((build, bi, bvalue) => {
if (i == 0) {
this.displayedColumns.push(value[0].companyStatistics.buildingTypesCounts[bi].buildingTypeName)
this.tabledataSource[0].name.push(value[0].companyStatistics.buildingTypesCounts[bi].count)
} else {
this.tabledataSource[i].name.push(bvalue[bi].count)
}
});
}
});
}
}
else if (this.preparelevels == 1) {
//预案查询
this.yuanColumns = ['组织名称', '总数']
this.yuanTable = [{ name: [0, 0] }]
if (this.planCategory.length != 0) {
this.planCategory.forEach(element => {
if (element == 1) {
this.yuanColumns.push('Ⅰ级')
this.yuanTable[0].name.push(0)
} else if (element == 2) {
this.yuanColumns.push('Ⅱ级')
this.yuanTable[0].name.push(0)
} else if (element == 3) {
this.yuanColumns.push('Ⅲ级')
this.yuanTable[0].name.push(0)
} else if (element == 4) {
this.yuanColumns.push('Ⅳ级')
this.yuanTable[0].name.push(0)
} else if (element == 5) {
this.yuanColumns.push('Ⅴ级')
this.yuanTable[0].name.push(0)
}
})
}
if (this.reservePlanType.length != 0) {
this.reservePlanType.forEach(element => {
if (element == 1) {
this.yuanColumns.push('二维')
this.yuanTable[0].name.push(0)
} else if (element == 2) {
this.yuanColumns.push('三维')
this.yuanTable[0].name.push(0)
} else if (element == 4) {
this.yuanColumns.push('其他')
this.yuanTable[0].name.push(0)
} else if (element == 16) {
this.yuanColumns.push('文本')
this.yuanTable[0].name.push(0)
}
});
}
data.forEach((element, i, value) => {
if (i == 0) {
this.yuanTable[0].name[0] = value[0].orgName
this.yuanTable[0].name[1] = value[0].planStatistics.totalCount
} else { } else {
this.yuanTable.push({ name: [value[i].orgName, value[i].planStatistics.totalCount] }) this.tabledataSource = [];
} this.displayedColumns = ["组织名称", "总数"];
});
this.yuanTable.forEach((element, i, value) => {
if (i > 0) {
for (let a = value[i].name.length; a < value[0].name.length; a++) {
value[i].name.push(0)
}
}
})
this.yuanTable.forEach((yuan, yuani, yuanval) => {
this.yuanColumns.forEach((th, thi, thvalu) => {
data.forEach((element, i, value) => { data.forEach((element, i, value) => {
//预案级别数据 this.tabledataSource.push({
if (value[i].planStatistics.planCategoryStatistics != null) { name: [
value[i].planStatistics.planCategoryStatistics.planCategories.forEach((jibie, ji, jval) => { element.orgName,
if (thvalu[thi].indexOf(jval[ji].planCategoryName) != -1 && yuani == i) { element.companyStatistics.totalCount,
yuanval[yuani].name[thi] = jval[ji].count ],
});
if (value[0].companyStatistics.buildingTypesCounts != null) {
value[i].companyStatistics.buildingTypesCounts.forEach(
(build, bi, bvalue) => {
if (i == 0) {
this.displayedColumns.push(
value[0].companyStatistics.buildingTypesCounts[bi]
.buildingTypeName
);
this.tabledataSource[0].name.push(
value[0].companyStatistics.buildingTypesCounts[bi]
.count
);
} else {
this.tabledataSource[i].name.push(bvalue[bi].count);
}
} }
}); );
} }
if (value[i].planStatistics.planTypeStatistics != null) { });
//预案类型数据 }
value[i].planStatistics.planTypeStatistics.planTypes.forEach((planlx, lxi, lxval) => { } else if (this.preparelevels == 1) {
if (thvalu[thi].indexOf(lxval[lxi].planTypeName) != -1 && yuani == i) { //预案查询
yuanval[yuani].name[thi] = lxval[lxi].count this.yuanColumns = ["组织名称", "总数"];
} this.yuanTable = [{ name: [0, 0] }];
}); if (this.planCategory.length != 0) {
this.planCategory.forEach((element) => {
if (element == 1) {
this.yuanColumns.push("Ⅰ级");
this.yuanTable[0].name.push(0);
} else if (element == 2) {
this.yuanColumns.push("Ⅱ级");
this.yuanTable[0].name.push(0);
} else if (element == 3) {
this.yuanColumns.push("Ⅲ级");
this.yuanTable[0].name.push(0);
} else if (element == 4) {
this.yuanColumns.push("Ⅳ级");
this.yuanTable[0].name.push(0);
} else if (element == 5) {
this.yuanColumns.push("Ⅴ级");
this.yuanTable[0].name.push(0);
} }
}); });
}) }
if (this.reservePlanType.length != 0) {
this.reservePlanType.forEach((element) => {
if (element == 1) {
this.yuanColumns.push("二维");
this.yuanTable[0].name.push(0);
} else if (element == 2) {
this.yuanColumns.push("三维");
this.yuanTable[0].name.push(0);
} else if (element == 4) {
this.yuanColumns.push("其他");
this.yuanTable[0].name.push(0);
} else if (element == 16) {
this.yuanColumns.push("文本");
this.yuanTable[0].name.push(0);
}
});
}
}) data.forEach((element, i, value) => {
if (i == 0) {
this.yuanTable[0].name[0] = value[0].orgName;
this.yuanTable[0].name[1] =
value[0].planStatistics.totalCount;
} else {
this.yuanTable.push({
name: [
value[i].orgName,
value[i].planStatistics.totalCount,
],
});
}
});
this.yuanTable.forEach((element, i, value) => {
if (i > 0) {
for (
let a = value[i].name.length;
a < value[0].name.length;
a++
) {
value[i].name.push(0);
}
}
});
this.yuanTable.forEach((yuan, yuani, yuanval) => {
this.yuanColumns.forEach((th, thi, thvalu) => {
data.forEach((element, i, value) => {
//预案级别数据
if (
value[i].planStatistics.planCategoryStatistics != null
) {
value[
i
].planStatistics.planCategoryStatistics.planCategories.forEach(
(jibie, ji, jval) => {
if (
thvalu[thi].indexOf(jval[ji].planCategoryName) !=
-1 &&
yuani == i
) {
yuanval[yuani].name[thi] = jval[ji].count;
}
}
);
}
if (value[i].planStatistics.planTypeStatistics != null) {
//预案类型数据
value[
i
].planStatistics.planTypeStatistics.planTypes.forEach(
(planlx, lxi, lxval) => {
if (
thvalu[thi].indexOf(lxval[lxi].planTypeName) !=
-1 &&
yuani == i
) {
yuanval[yuani].name[thi] = lxval[lxi].count;
}
}
);
}
});
});
});
}
} }
} this.isMasklayer = false;
this.isMasklayer = false resolve(this.excelData);
resolve(this.excelData) });
} });
)
})
} }
integrityScoreMin; //完整度最小值
integrityScoreMax; //完整度最大值
newArr: any = [];
integrityScoreMin//完整度最小值
integrityScoreMax//完整度最大值
newArr: any = []
//辖区中队div是否显示 //辖区中队div是否显示
isorganizationbox: boolean = false isorganizationbox: boolean = false;
//点击辖区中队树,将选择的辖区中队添加到变量 //点击辖区中队树,将选择的辖区中队添加到变量
add(node) { add(node) {
this.isorganizationbox = false this.isorganizationbox = false;
if (this.preparelevels == 0) { if (this.preparelevels == 0) {
this.js = node.name this.js = node.name;
this.jsId = node.id this.jsId = node.id;
} else if (this.preparelevels == 1) { } else if (this.preparelevels == 1) {
this.yuanjs = node.name this.yuanjs = node.name;
this.yuanjsId = node.id this.yuanjsId = node.id;
} }
} }
//关闭辖区中队隐藏框 //关闭辖区中队隐藏框
closeorganizationbox() { closeorganizationbox() {
this.isorganizationbox = false this.isorganizationbox = false;
} }
//打开辖区中队隐藏框 //打开辖区中队隐藏框
openorganizationbox() { openorganizationbox() {
this.isorganizationbox = true this.isorganizationbox = true;
} }
//关闭出现的组织机构div //关闭出现的组织机构div
closediv() { closediv() {
this.isorganizationbox = false this.isorganizationbox = false;
} }
//查询 //查询
onSubmit(e) { onSubmit(e) {
let config = new MatSnackBarConfig(); let config = new MatSnackBarConfig();
config.verticalPosition = 'top'; config.verticalPosition = "top";
config.duration = 3000 config.duration = 3000;
if (this.dwendtime < this.dwaddtime || this.yuanaddtime > this.yuanendtime) { if (
this.snackBar.open('开始时间不能早于结束时间', '确定', config); this.dwendtime < this.dwaddtime ||
this.yuanaddtime > this.yuanendtime
) {
this.snackBar.open("开始时间不能早于结束时间", "确定", config);
} }
this.getAllPlanInfo(); this.getAllPlanInfo();
} }
//重置 //重置
reset() { reset() {
this.orRecord = [] this.orRecord = [];
this.integritySort = '' this.integritySort = "";
this.yuanintegritySort = '' this.yuanintegritySort = "";
if (this.preparelevels == 0) { if (this.preparelevels == 0) {
this.js = this.organizationName this.js = this.organizationName;
this.jsId = this.organizationId this.jsId = this.organizationId;
this.jscheck = true this.jscheck = true;
this.unittype = [] this.unittype = [];
this.allunittype.forEach(element => { this.allunittype.forEach((element) => {
this.unittype.push(element.id) this.unittype.push(element.id);
}); });
this.preparelevel = [1] this.preparelevel = [1];
this.dwaddtime = '2020-01-01'//单位查询开始时间 this.dwaddtime = "2020-01-01"; //单位查询开始时间
this.dwendtime = this.getNowFormatDate()//单位结束时间 this.dwendtime = this.getNowFormatDate(); //单位结束时间
this.unitIsFollowed = ""; //单位 重点
} else if (this.preparelevels == 1) { } else if (this.preparelevels == 1) {
this.yuanjs = this.organizationName this.yuanjs = this.organizationName;
this.yuanjsId = this.organizationId this.yuanjsId = this.organizationId;
this.yuanaddtime = '2020-01-01'//预案查询开始时间 this.yuanaddtime = "2020-01-01"; //预案查询开始时间
this.yuanendtime = this.getNowFormatDate()//预案查询结束时间 this.yuanendtime = this.getNowFormatDate(); //预案查询结束时间
this.yuanjscheck = true this.yuanjscheck = true;
this.reservePlanType = ['1', '2', '4', '16'] this.reservePlanType = ["1", "2", "4", "16"];
this.planCategory = ['1', '2', '3', '4', '5'] this.planCategory = ["1", "2", "3", "4", "5"];
this.planIsFollowed = ""; //预案 重点单位
} }
//重新获取初始化列表 //重新获取初始化列表
this.getAllPlanInfo(); this.getAllPlanInfo();
} }
orRecord = [] orRecord = [];
//进入下一层 //进入下一层
clicktd(key, element) { clicktd(key, element) {
let config = new MatSnackBarConfig(); let config = new MatSnackBarConfig();
config.verticalPosition = 'top'; config.verticalPosition = "top";
config.duration = 3000 config.duration = 3000;
if (key == 0 && element != '合计') { if (key == 0 && element != "合计") {
let clickOr let clickOr;
this.allorganizations.forEach(item => { this.allorganizations.forEach((item) => {
if (element === item.name) { if (element === item.name) {
clickOr = item clickOr = item;
} }
}); });
// console.log(clickOr) // console.log(clickOr)
if (this.preparelevels == 0) { if (this.preparelevels == 0) {
if (element == this.js) { if (element == this.js) {
this.snackBar.open('已在当前查询的消防救援站下,无法下钻', '确定', config); this.snackBar.open(
return "已在当前查询的消防救援站下,无法下钻",
"确定",
config
);
return;
} }
} else if (this.preparelevels == 1) { } else if (this.preparelevels == 1) {
if (element == this.yuanjs) { if (element == this.yuanjs) {
this.snackBar.open('已在当前查询的消防救援站下,无法下钻', '确定', config); this.snackBar.open(
return "已在当前查询的消防救援站下,无法下钻",
"确定",
config
);
return;
} }
} }
if (clickOr.children.length == 0 && this.excelData.length == 1) { if (clickOr.children.length == 0 && this.excelData.length == 1) {
this.snackBar.open('无下级消防救援站,无法下钻', '确定', config); this.snackBar.open("无下级消防救援站,无法下钻", "确定", config);
return return;
} }
//记录点击过的消防救援站 //记录点击过的消防救援站
this.orRecord.push({ name: this.js, id: this.jsId }) this.orRecord.push({ name: this.js, id: this.jsId });
if (this.preparelevels == 0) { if (this.preparelevels == 0) {
this.js = element this.js = element;
this.jsId = clickOr.id this.jsId = clickOr.id;
} else if (this.preparelevels == 1) { } else if (this.preparelevels == 1) {
this.yuanjs = element this.yuanjs = element;
this.yuanjsId = clickOr.id this.yuanjsId = clickOr.id;
} }
console.log(this.orRecord) console.log(this.orRecord);
this.getAllPlanInfo(); this.getAllPlanInfo();
} }
} }
goBack() { goBack() {
if (this.preparelevels == 0) { if (this.preparelevels == 0) {
this.js = this.orRecord[this.orRecord.length - 1].name this.js = this.orRecord[this.orRecord.length - 1].name;
this.jsId = this.orRecord[this.orRecord.length - 1].id this.jsId = this.orRecord[this.orRecord.length - 1].id;
} else if (this.preparelevels == 1) { } else if (this.preparelevels == 1) {
this.yuanjs = this.orRecord[this.orRecord.length - 1].name this.yuanjs = this.orRecord[this.orRecord.length - 1].name;
this.yuanjsId = this.orRecord[this.orRecord.length - 1].id this.yuanjsId = this.orRecord[this.orRecord.length - 1].id;
} }
this.orRecord.pop(); this.orRecord.pop();
console.log(this.orRecord) console.log(this.orRecord);
this.getAllPlanInfo(); this.getAllPlanInfo();
} }
exal() { exal() {
var uri = 'data:application/vnd.ms-excel;base64,', var uri = "data:application/vnd.ms-excel;base64,",
template =
template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>', '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>',
base64 = function (s) { base64 = function (s) {
return window.btoa(unescape(encodeURIComponent(s)));
return window.btoa(unescape(encodeURIComponent(s)))
}, },
format = function (s, c) { format = function (s, c) {
return s.replace(/{(\w+)}/g, function (m, p) { return s.replace(/{(\w+)}/g, function (m, p) {
return c[p]; return c[p];
});
}) };
}
return function (table, name) { return function (table, name) {
if (!table.nodeType) table = document.getElementById(table); if (!table.nodeType) table = document.getElementById(table);
var ctx = { var ctx = {
worksheet: name || "Worksheet",
worksheet: name || 'Worksheet', table: table.innerHTML,
table: table.innerHTML
}; };
window.location.href = uri + base64(format(template, ctx)); window.location.href = uri + base64(format(template, ctx));
};
}
} }
export() { export() {
const httpOptions = { const httpOptions = {
responseType: 'blob' as 'json' responseType: "blob" as "json",
}; };
this.http.post(`/api/StatisticsAnalysis/Excel?queryMode=${this.preparelevels}`, this.excelData, httpOptions).subscribe((data: any) => { this.http
// // 文件名中有中文 则对文件名进行转码 .post(
const link = document.createElement('a'); `/api/StatisticsAnalysis/Excel?queryMode=${this.preparelevels}`,
const blob = new Blob([data], { type: 'application/vnd.ms-excel' }); this.excelData,
link.setAttribute('href', window.URL.createObjectURL(blob)); httpOptions
link.setAttribute('download', '报表统计' + '.xls'); )
link.style.visibility = 'hidden'; .subscribe((data: any) => {
document.body.appendChild(link); // // 文件名中有中文 则对文件名进行转码
link.click(); const link = document.createElement("a");
document.body.removeChild(link); const blob = new Blob([data], { type: "application/vnd.ms-excel" });
}) link.setAttribute("href", window.URL.createObjectURL(blob));
link.setAttribute("download", "报表统计" + ".xls");
link.style.visibility = "hidden";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
});
} }
} }

Loading…
Cancel
Save