Newer
Older
import {Component, OnInit} from '@angular/core';
import {AnalysisService} from '../analysis.service';
import {NzMessageService} from 'ng-zorro-antd';
import {DatePipe} from '@angular/common';
import {OverAllService} from '../../overAll/overAll.service';
import {WorkService} from '../../work/work.service';
import {CommonService} from '../../shared/common/common.service';
import {change_level} from '../../system-change/system-change.constants';
import {SystemChangeService} from '../../system-change/system-change.service';
@Component({
selector: 'smart-sys-change-count',
templateUrl: './sys-change-count.component.html',
styles: []
})
export class SysChangeCountComponent implements OnInit {
startTime;
endTime;
chartTopOption;
topList;
//显示无数据图片
data = {
left: false,
right: false,
};
chartLastOption;
lastList;
obj = {
classifyId: null,
type: null,
startTime: '',
endTime: ''
};
typeList;
isDownload = false;
constructor(private analysisSer: AnalysisService, private message: NzMessageService, private datePipe: DatePipe,
private systemChangeSer: SystemChangeService,
private overAllSer: OverAllService, private workSer: WorkService, private commonSer: CommonService) {
}
ngOnInit() {
this.obj.startTime = this.commonSer.getTimeByType('4').startTime;
this.obj.endTime = this.commonSer.getTimeByType('4').endTime;
}
//变更分类
getType() {
this.systemChangeSer.findByType('sys_change_type').subscribe(
(res) => {
if (res.data) {
this.typeList = res.data;
} else {
this.message.warning('暂无变更类型');
}
}
);
}
//获取Top图表 变更状态统计
getTopEcharts() {
this.analysisSer.statusReport(this.obj).subscribe(
(res) => {
this.isLoading = false;
if (res.errCode == 10000) {
res.data.forEach(e => {
if (e.status == 1) e.name = '待提交';
if (e.status == 2) e.name = '待审核';
if (e.status == 3) e.name = '审核通过';
if (e.status == 4) e.name = '审核未通过';
if (e.status == 5) e.name = '退回关闭';
if (e.status == 6) e.name = '处理中';
if (e.status == 7) e.name = '变更完成';
});
if (res.data.length > 0) {
this.data.left = false;
this.topList = res.data;
this.setTopEcharts();
} else {
this.data.left = true;
}
}
}
);
}
//变更状态统计
setTopEcharts() {
this.chartTopOption = {
title: {
text: '变更状态统计'
},
tooltip: {
trigger: 'axis',
axisPointer: { // 坐标轴指示器,坐标轴触发有效
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
},
}
},
xAxis: {
type: 'category',
data: this.topList.map(e => {
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
}),
},
yAxis: {
type: 'value',
axisLabel: {
show: true,
interval: 'auto',
},
},
series: [{
name: '变更状态统计',
data: this.topList.map(e => {
return e.count;
}),
type: 'bar'
}]
};
this.isLoading = false;
}
//获取last图表
getLastEcharts() {
this.analysisSer.dateReport(this.obj).subscribe(
(res) => {
if (res.errCode == 10000) {
if (res.data.length > 0) {
this.data.right = false;
this.lastList = res.data;
this.setLastEcharts();
} else {
this.data.right = true;
this.isLoading = false;
}
}
}
);
}
//设置last图表
setLastEcharts() {
this.chartLastOption = {
title: {
text: '数量变化趋势'
},
tooltip: {
trigger: 'axis',
axisPointer: { // 坐标轴指示器,坐标轴触发有效
},
xAxis: {
type: 'category',
data: this.lastList.map(e => {
return e.createDate;
})
},
yAxis: {
type: 'value',
axisLabel: {
show: true,
interval: 'auto',
},
},
series: [{
name: '数量变化趋势',
data: this.lastList.map(e => {
return e.count;
}),
}]
};
this.isLoading = false;
}
//时间改变
changeType() {
this.obj.startTime = this.commonSer.getTimeByType(this.timeType).startTime;
this.obj.endTime = this.commonSer.getTimeByType(this.timeType).endTime;
this.obj.startTime = this.datePipe.transform(this.startTime, 'yyyy-MM-dd HH:mm:ss');
this.obj.endTime = this.datePipe.transform(this.endTime, 'yyyy-MM-dd HH:mm:ss');
}
this.getLastEcharts();
this.getTopEcharts();
}
//导出 可用性
downLoadCommon() {
this.isDownload = true;
this.isDownload = false;
this.commonSer.downloadFile('变更.xlsx', res);