Browse Source

[新增]预警记录导出

beijing
邵佳豪 3 years ago
parent
commit
68fd94ce5b
  1. 6
      src/app/pages/criminal-records-admin/criminal-records-admin.component.html
  2. 51
      src/app/pages/criminal-records-admin/criminal-records-admin.component.ts
  3. 12
      src/app/pages/criminal-records/criminal-records.component.html
  4. 50
      src/app/pages/criminal-records/criminal-records.component.ts

6
src/app/pages/criminal-records-admin/criminal-records-admin.component.html

@ -153,6 +153,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)="exportExcel()"><i nz-icon
[nzType]="'file'"></i>导出文档</button>
</nz-form-control>
</nz-form-item>
</form>
</div>
<div class="tablebox">

51
src/app/pages/criminal-records-admin/criminal-records-admin.component.ts

@ -855,4 +855,55 @@ export class CriminalRecordsAdminComponent implements OnInit {
});
const instance = modal.getContentComponent();
}
exportExcel() {
// console.log(this.validateForm)
let ViolationIds = []
// console.log(this.validateForm.value.event)
if (this.validateForm.value.event) {
ViolationIds = this.validateForm.value.event
}
if (this.validateForm.value.type && !this.validateForm.value.event) {
this.warningTypesDetails.forEach(item => {
item.id ? ViolationIds.push(item.id) : null
});
}
let disposalState
if (this.validateForm.value.disposalState == '0') {
disposalState = true
} else if (this.validateForm.value.disposalState == '1') {
disposalState = false
} else {
disposalState = null
}
const httpOptions = {
responseType: 'blob' as 'json',
params: {
Level: this.validateForm.value.level,
ViolationIds: ViolationIds,
ViolateAreas: this.validateForm.value.site,
OrganizationUnitId: this.validateForm.value.organization,
IsContainsChildren: 'true',
IsHandled: disposalState,
ViolateTime: this.validateForm.value.datePicker ? [moment(this.validateForm.value.datePicker[0]).format('yyyy-MM-DD'), moment(this.validateForm.value.datePicker[1]).format('yyyy-MM-DD')] : null,
Positive: this.validateForm.value.misinformation
}
};
this.http.get(`/api/services/app/ViolateRecord/ExportExcel`, 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', `导出失败`);
})
}
}

12
src/app/pages/criminal-records/criminal-records.component.html

@ -77,7 +77,8 @@
<nz-form-item class="searchParamsZ eventInput">
<nz-form-control>
<nz-select [nzMaxTagCount]="1" nzMode="multitagsple" nzAllowClear formControlName="event" nzPlaceHolder="请选择预警事件">
<nz-select [nzMaxTagCount]="1" nzMode="multitagsple" nzAllowClear formControlName="event"
nzPlaceHolder="请选择预警事件">
<nz-option *ngFor="let item of warningTypesDetails" [nzValue]="item.id" [nzLabel]="item.eventSystemName">
</nz-option>
</nz-select>
@ -85,7 +86,8 @@
</nz-form-item>
<nz-form-item class="searchParamsS eventInput">
<nz-form-control>
<nz-select [nzMaxTagCount]="1" nzMode="multitagsple" nzAllowClear formControlName="site" nzPlaceHolder="请选择站内发生区域">
<nz-select [nzMaxTagCount]="1" nzMode="multitagsple" nzAllowClear formControlName="site"
nzPlaceHolder="请选择站内发生区域">
<nz-option nzValue="出入口" nzLabel="出入口"></nz-option>
<nz-option nzValue="加油区" nzLabel="加油区"></nz-option>
<nz-option nzValue="油罐区" nzLabel="油罐区"></nz-option>
@ -129,6 +131,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)="exportExcel()"><i nz-icon
[nzType]="'file'"></i>导出文档</button>
</nz-form-control>
</nz-form-item>
</form>
</div>
<div class="tablebox">

50
src/app/pages/criminal-records/criminal-records.component.ts

@ -764,4 +764,54 @@ export class CriminalRecordsComponent implements OnInit {
}
exportExcel() {
// console.log(this.validateForm)
let ViolationIds = []
// console.log(this.validateForm.value.event)
if (this.validateForm.value.event) {
ViolationIds = this.validateForm.value.event
}
if (this.validateForm.value.type && !this.validateForm.value.event) {
this.warningTypesDetails.forEach(item => {
item.id ? ViolationIds.push(item.id) : null
});
}
let disposalState
if (this.validateForm.value.disposalState == '0') {
disposalState = true
} else if (this.validateForm.value.disposalState == '1') {
disposalState = false
} else {
disposalState = null
}
const httpOptions = {
responseType: 'blob' as 'json',
params: {
Level: this.validateForm.value.level,
ViolationIds: ViolationIds,
ViolateAreas: this.validateForm.value.site,
OrganizationUnitId: JSON.parse(sessionStorage.getItem('userdataOfgasstation')).organization.id,
IsContainsChildren: 'true',
ViolateTime: this.validateForm.value.datePicker ? [moment(this.validateForm.value.datePicker[0]).format('yyyy-MM-DD'), moment(this.validateForm.value.datePicker[1]).format('yyyy-MM-DD')] : null,
IsHandled: disposalState,
Positive: this.validateForm.value.misinformation
}
};
this.http.get(`/api/services/app/ViolateRecord/ExportExcel`, 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', `导出失败`);
})
}
}

Loading…
Cancel
Save