fix bug
This commit is contained in:
@ -3,6 +3,7 @@ import { STColumn, STComponent } from '@delon/abc/st';
|
||||
import { DatePipe, _HttpClient } from '@delon/theme';
|
||||
import { differenceInCalendarDays } from 'date-fns';
|
||||
import { DataService } from '../../../services/data.service';
|
||||
import { OperationCurveComponent } from '../../operationtable/curve/curve.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-datatable-customindex',
|
||||
@ -13,6 +14,7 @@ import { DataService } from '../../../services/data.service';
|
||||
})
|
||||
export class DatatableCustomindexComponent implements OnInit {
|
||||
@ViewChild('st') private readonly st!: STComponent;
|
||||
@ViewChild('curve') private readonly curve!: OperationCurveComponent;
|
||||
type = 1;
|
||||
mode = 'year';
|
||||
date: any = null;
|
||||
@ -24,7 +26,8 @@ export class DatatableCustomindexComponent implements OnInit {
|
||||
modeNext = 'year';
|
||||
timeNext: any = ['2022-01-01 00:00:00']
|
||||
chartData: any;
|
||||
|
||||
flag = false;
|
||||
|
||||
|
||||
columns: STColumn[] = [
|
||||
{ title: '用户类型', index: 'networkTransporterName', className: 'text-center' },
|
||||
@ -59,7 +62,30 @@ export class DatatableCustomindexComponent implements OnInit {
|
||||
}
|
||||
|
||||
constructor(public service: DataService, private datePipe: DatePipe) { }
|
||||
ngOnInit(): void { }
|
||||
ngOnInit(): void {
|
||||
this.initCurveData()
|
||||
}
|
||||
initCurveData() {
|
||||
let type = 1
|
||||
if (this.mode === 'year') {
|
||||
type = 1
|
||||
} else if (this.mode === 'month') {
|
||||
type = 2
|
||||
}
|
||||
const params: any = {
|
||||
time: this.timeNext,
|
||||
type
|
||||
};
|
||||
this.flag = true
|
||||
this.service.request(this.service.$api_operationalReportHistogram, params).subscribe(res => {
|
||||
if (res) {
|
||||
this.chartData = res
|
||||
if (this.flag) {
|
||||
this.curve.reRender()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
changeData() {
|
||||
if (this.mode === 'year') {
|
||||
@ -86,22 +112,24 @@ export class DatatableCustomindexComponent implements OnInit {
|
||||
// Can not select days before today and today
|
||||
differenceInCalendarDays(current, this.today) > 0;
|
||||
|
||||
|
||||
changeDataNext() {
|
||||
if (this.mode === 'year') {
|
||||
if(this.mode === 'year') {
|
||||
this.dateFormat = 'yyyy'
|
||||
} else if (this.mode === 'month') {
|
||||
} else if(this.mode === 'month') {
|
||||
this.dateFormat = 'yyyy-MM'
|
||||
}
|
||||
}
|
||||
onChangeNext(result: any) {
|
||||
if (this.mode === 'year') {
|
||||
if(result === null) {
|
||||
return
|
||||
}
|
||||
if(this.mode === 'year') {
|
||||
this.timeNext = [this.datePipe.transform(this.dateNext, 'yyyy') + '-01-01 00:00:00']
|
||||
} else if (this.mode === 'month') {
|
||||
} else if(this.mode === 'month') {
|
||||
this.timeNext = [this.datePipe.transform(this.dateNext, 'yyyy-MM') + '-01 00:00:00']
|
||||
}
|
||||
}
|
||||
exportFun() {
|
||||
|
||||
this.initCurveData()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user