This commit is contained in:
wangshiming
2022-04-15 17:14:15 +08:00
parent 58375de2f7
commit 16ac865866
3 changed files with 66 additions and 31 deletions

View File

@ -4,17 +4,16 @@
* @Author : Shiming * @Author : Shiming
* @Date : 2022-03-30 13:55:41 * @Date : 2022-03-30 13:55:41
* @LastEditors : Shiming * @LastEditors : Shiming
* @LastEditTime : 2022-04-15 16:40:11 * @LastEditTime : 2022-04-15 17:13:53
* @FilePath : \\tms-obc-web\\src\\app\\routes\\datatable\\components\\compliance\\customer\\customer.component.html * @FilePath : \\tms-obc-web\\src\\app\\routes\\datatable\\components\\compliance\\customer\\customer.component.html
* Copyright (C) 2022 huzhenhong. All rights reserved. * Copyright (C) 2022 huzhenhong. All rights reserved.
--> -->
<!-- 页头 --> <!-- 页头 -->
<page-header-wrapper [title]="'数据报表'"></page-header-wrapper> <page-header-wrapper [title]="'数据报表'"></page-header-wrapper>
<nz-card> <nz-card>
<sf #sf mode="search" [schema]="searchSchema" (formSubmit)="st.reset($event)" (formReset)="st.reset($event)"></sf> <sf #sf mode="search" [schema]="searchSchema" button="none"></sf>
<div class="chooseBox"> <div class="chooseBox">
<!-- <button nz-button nzType="primary" (click)="exportFun()">导出</button> --> <div class="timeBox">
<!-- <div class="timeBox">
<nz-radio-group [(ngModel)]="mode" nzButtonStyle="solid" (ngModelChange)="changeData()"> <nz-radio-group [(ngModel)]="mode" nzButtonStyle="solid" (ngModelChange)="changeData()">
<label nz-radio-button nzValue="year"></label> <label nz-radio-button nzValue="year"></label>
<label nz-radio-button nzValue="month"></label> <label nz-radio-button nzValue="month"></label>
@ -26,7 +25,7 @@
<nz-range-picker [(ngModel)]="defineDate" [nzFormat]="dateFormat" *ngIf="mode === 'define'" [nzDisabledDate]="disabledDate" (ngModelChange)="onChange($event)"></nz-range-picker> <nz-range-picker [(ngModel)]="defineDate" [nzFormat]="dateFormat" *ngIf="mode === 'define'" [nzDisabledDate]="disabledDate" (ngModelChange)="onChange($event)"></nz-range-picker>
</div> </div>
</div> --> </div>
</div> </div>
<st <st
#st #st
@ -34,8 +33,8 @@
[scroll]="{ x: '2000px' }" [scroll]="{ x: '2000px' }"
[data]="service.$api_listCusComplianceReportPage" [data]="service.$api_listCusComplianceReportPage"
[columns]="columns" [columns]="columns"
[req]="{ process: beforeReq }" [req]="{ method: 'POST', allInBody: true, reName: { pi: 'pageIndex', ps: 'pageSize' }, params: reqParams }"
[res]="{ reName: { list: 'data.records', total: 'data.total' } , process: afterRes}" [scroll]="{ x: '1200px' }" [res]="{ reName: { list: 'data.records', total: 'data.total' } }"
[page]="{ show: true, showSize: true, pageSizes: [10, 20, 30, 50, 100, 200, 300, 500, 1000] }" [page]="{ show: true, showSize: true, pageSizes: [10, 20, 30, 50, 100, 200, 300, 500, 1000] }"
[loading]="false" [loading]="false"
> >

View File

@ -0,0 +1,11 @@
.chooseBox{
display: flex;
}
.timeBox{
display: flex;
margin: 0 0 0 10px;
}
.dateBox{
display: inline-block;
margin: 0 0 0 10px;
}

View File

@ -5,26 +5,31 @@ import { SFComponent } from '@delon/form';
* @Author : Shiming * @Author : Shiming
* @Date : 2022-03-30 13:55:41 * @Date : 2022-03-30 13:55:41
* @LastEditors : Shiming * @LastEditors : Shiming
* @LastEditTime : 2022-04-15 16:35:10 * @LastEditTime : 2022-04-15 17:13:03
* @FilePath : \\tms-obc-web\\src\\app\\routes\\datatable\\components\\compliance\\customer\\customer.component.ts * @FilePath : \\tms-obc-web\\src\\app\\routes\\datatable\\components\\compliance\\customer\\customer.component.ts
* Copyright (C) 2022 huzhenhong. All rights reserved. * Copyright (C) 2022 huzhenhong. All rights reserved.
*/ */
import { Component, OnInit, ViewChild } from '@angular/core'; import { Component, OnInit, ViewChild } from '@angular/core';
import { STColumn, STComponent, STRequestOptions } from '@delon/abc/st'; import { STColumn, STComponent, STRequestOptions } from '@delon/abc/st';
import { SFSchema } from '@delon/form'; import { SFSchema } from '@delon/form';
import { ModalHelper, _HttpClient } from '@delon/theme'; import { ModalHelper, _HttpClient ,DatePipe} from '@delon/theme';
import { DataService } from '../../../services/data.service'; import { DataService } from '../../../services/data.service';
import { differenceInCalendarDays } from 'date-fns';
@Component({ @Component({
selector: 'app-datatable-compliance-customer', selector: 'app-datatable-compliance-customer',
templateUrl: './customer.component.html', templateUrl: './customer.component.html',
styleUrls: ['./customer.component.less'],
providers: [DatePipe]
}) })
export class DatatableComplianceCustomerComponent implements OnInit { export class DatatableComplianceCustomerComponent implements OnInit {
@ViewChild('sf', {static: false}) sf!: SFComponent @ViewChild('sf', {static: false}) sf!: SFComponent
mode = 'year'; mode = 'year';
type = 1;
date: any = null; date: any = null;
defineDate = []; defineDate = [];
time: any = ['2022-01-01 00:00:00'] time: any = ['2022']
dateFormat = 'yyyy'; dateFormat = 'yyyy';
dateNext: any = null; dateNext: any = null;
modeNext = 'year'; modeNext = 'year';
@ -67,29 +72,49 @@ export class DatatableComplianceCustomerComponent implements OnInit {
]; ];
constructor(private http: _HttpClient, private modal: ModalHelper,public service: DataService,) { } constructor(private http: _HttpClient, private modal: ModalHelper,public service: DataService,private datePipe: DatePipe) { }
beforeReq = (requestOptions: STRequestOptions) => { /**
* 查询参数
*/
get reqParams() {
if (this.mode === 'year') {
this.type = 1
} else if (this.mode === 'month') {
this.type = 2
} else if (this.mode === 'date') {
this.type = 3
} else {
this.type = 4
}
const params: any = Object.assign({}, this.sf?.value || {}); const params: any = Object.assign({}, this.sf?.value || {});
delete params._$expand; params.type = this.type
console.log(params); params.queryTime = this.time
if (this.sf) { delete params._$expand;
Object.assign(requestOptions.body, { return { ...params };
...params,
});
} }
return requestOptions;
};
afterRes = (data: any[], rawData?: any) => {
return data.map(item => ({
...item,
}));
};
ngOnInit(): void { } ngOnInit(): void { }
onChange(result: any) {
add(): void { if (this.mode === 'year') {
// this.modal this.time = [this.datePipe.transform(this.date, 'yyyy') + '-01-01 00:00:00']
// .createStatic(FormEditComponent, { i: { id: 0 } }) } else if (this.mode === 'month') {
// .subscribe(() => this.st.reload()); this.time = [this.datePipe.transform(this.date, 'yyyy-MM') + '-01 00:00:00']
} else if (this.mode === 'date') {
this.time = [this.datePipe.transform(this.date, 'yyyy-MM-dd') + ' 00:00:00']
} else {
this.time = [this.datePipe.transform(this.defineDate[0], 'yyyy-MM-dd') + '00:00:00', this.datePipe.transform(this.defineDate[1], 'yyyy-MM-dd') + ' 00:00:00']
}
this.st.reload({ ...this.reqParams });
} }
changeData() {
if (this.mode === 'year') {
this.dateFormat = 'yyyy'
} else if (this.mode === 'month') {
this.dateFormat = 'yyyy-MM'
} else {
this.dateFormat = 'yyyy-MM-dd'
}
}
disabledDate = (current: Date): boolean =>
// Can not select days before today and today
differenceInCalendarDays(current, this.today) > 0;
} }