Browse Source

[新增]导出统计报表

master
邵佳豪 1 year ago
parent
commit
8c68858095
  1. 2
      src/app/app.component.ts
  2. 6
      src/app/pages/statistics/bg-station/bg-station.component.html
  3. 37
      src/app/pages/statistics/bg-station/bg-station.component.ts
  4. 12
      src/app/pages/statistics/bg-violation/bg-violation.component.html
  5. 41
      src/app/pages/statistics/bg-violation/bg-violation.component.ts

2
src/app/app.component.ts

@ -21,7 +21,7 @@ export class AppComponent {
) {}
ngOnInit(): void {
console.log("更新日期:20230807");
console.log("更新日期:20230815");
// console.log("window.parent", window.parent.location.href);
// alert(window.parent.location.href)
// 监听父页面向子页面的传参

6
src/app/pages/statistics/bg-station/bg-station.component.html

@ -108,6 +108,12 @@
[nzType]="'sync'"></i>重置</button>
</nz-form-control>
</nz-form-item>
<nz-form-item class="btn">
<nz-form-control>
<button nz-button type="button" class="reset" (click)="export($event)"><i nz-icon
[nzType]="'file'"></i>导出</button>
</nz-form-control>
</nz-form-item>
</form>
</div>

37
src/app/pages/statistics/bg-station/bg-station.component.ts

@ -299,6 +299,43 @@ export class BgStationComponent implements OnInit {
this.getViolateRecordList();
}
export($event) {
const httpOptions = {
responseType: "blob" as "json",
params: {
ViolateTime: this.validateForm.value.datePicker
? [
moment(this.validateForm.value.datePicker[0]).format(
"yyyy-MM-DD"
) + " 00:00:00",
moment(this.validateForm.value.datePicker[1]).format(
"yyyy-MM-DD"
) + " 23:59:59",
]
: null,
},
};
this.http
.get(`/api/services/app/ViolateRecordVerification/ExportPositiveRateByStation`, httpOptions)
.subscribe(
(data: any) => {
// console.log('导出成功')
// 文件名中有中文 则对文件名进行转码
const link = document.createElement("a");
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);
this.message.create("success", `导出成功`);
},
(err) => {
this.message.create("error", `导出失败`);
}
);
}
//预警类型接口
warningTypes: any; //预警接口数据
warningTypesDetails: any;

12
src/app/pages/statistics/bg-violation/bg-violation.component.html

@ -108,6 +108,12 @@
[nzType]="'sync'"></i>重置</button>
</nz-form-control>
</nz-form-item>
<nz-form-item class="btn">
<nz-form-control>
<button nz-button type="button" class="reset" (click)="export($event)"><i nz-icon
[nzType]="'file'"></i>导出</button>
</nz-form-control>
</nz-form-item>
</form>
</div>
@ -133,11 +139,13 @@
<td nzEllipsis>{{key+1}}</td>
<td nzEllipsis [title]="item.violationName">{{item.violationName}}</td>
<td nzEllipsis [title]="item.positiveCount"> {{item.positiveCount}}</td>
<td nzEllipsis [title]="item.totalCount - item.positiveCount"> {{item.totalCount - item.positiveCount}}
<td nzEllipsis [title]="item.totalCount - item.positiveCount"> {{item.totalCount -
item.positiveCount}}
</td>
<td nzEllipsis [title]="item.totalCount"> {{item.totalCount}}
</td>
<td nzEllipsis [title]="item.positiveCount/item.totalCount"> {{item.positiveCount/item.totalCount}}</td>
<td nzEllipsis [title]="item.positiveCount/item.totalCount">
{{item.positiveCount/item.totalCount}}</td>
</tr>
</tbody>

41
src/app/pages/statistics/bg-violation/bg-violation.component.ts

@ -299,6 +299,47 @@ export class BgViolationComponent implements OnInit {
this.getViolateRecordList();
}
export($event) {
const httpOptions = {
responseType: "blob" as "json",
params: {
ViolateTime: this.validateForm.value.datePicker
? [
moment(this.validateForm.value.datePicker[0]).format(
"yyyy-MM-DD"
) + " 00:00:00",
moment(this.validateForm.value.datePicker[1]).format(
"yyyy-MM-DD"
) + " 23:59:59",
]
: null,
},
};
this.http
.get(
`/api/services/app/ViolateRecordVerification/ExportPositiveRateByViolation`,
httpOptions
)
.subscribe(
(data: any) => {
// console.log('导出成功')
// 文件名中有中文 则对文件名进行转码
const link = document.createElement("a");
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);
this.message.create("success", `导出成功`);
},
(err) => {
this.message.create("error", `导出失败`);
}
);
}
//预警类型接口
warningTypes: any; //预警接口数据
warningTypesDetails: any;

Loading…
Cancel
Save