|
@@ -0,0 +1,131 @@
|
|
1
|
+import { format, addMonths, startOfMonth, endOfMonth } from 'date-fns';
|
|
2
|
+import { Component, OnInit } from "@angular/core";
|
|
3
|
+import { MainService } from 'src/app/services/main.service';
|
|
4
|
+@Component({
|
|
5
|
+ selector: "app-synthesize-statistics",
|
|
6
|
+ templateUrl: "./synthesize-statistics.component.html",
|
|
7
|
+ styleUrls: ["./synthesize-statistics.component.less"],
|
|
8
|
+})
|
|
9
|
+export class SynthesizeStatisticsComponent implements OnInit {
|
|
10
|
+ constructor(
|
|
11
|
+ private mainService: MainService,
|
|
12
|
+ ) {}
|
|
13
|
+
|
|
14
|
+ listOfData: any[] = []; //表格数据
|
|
15
|
+ pageIndex: number = 1; //表格当前页码
|
|
16
|
+ pageSize: number = 10; //表格每页展示条数
|
|
17
|
+ listLength: number = 10; //表格总数据量
|
|
18
|
+
|
|
19
|
+ ngOnInit() {
|
|
20
|
+ this.initSessionData();
|
|
21
|
+ this.search();
|
|
22
|
+ }
|
|
23
|
+
|
|
24
|
+ // 初始化缓存数据
|
|
25
|
+ queryType:any;
|
|
26
|
+ hosId:any;
|
|
27
|
+ dutyId:any;
|
|
28
|
+ parentDutyId:any;
|
|
29
|
+ initSessionData(){
|
|
30
|
+ let maintenanceStatistics = JSON.parse(sessionStorage.getItem('maintenanceStatistics'));
|
|
31
|
+ let queryType:any = maintenanceStatistics.queryType;
|
|
32
|
+ let hosId:any = maintenanceStatistics.hospitalId;
|
|
33
|
+ let dutyId:any = maintenanceStatistics.dutyId;
|
|
34
|
+
|
|
35
|
+ queryType = queryType ? +queryType : undefined;
|
|
36
|
+ hosId = hosId ? +hosId : undefined;
|
|
37
|
+ dutyId = dutyId ? +dutyId : undefined;
|
|
38
|
+
|
|
39
|
+ this.queryType = queryType;
|
|
40
|
+ if(queryType == 1){
|
|
41
|
+ this.hosId = undefined;
|
|
42
|
+ this.dutyId = undefined;
|
|
43
|
+ this.parentDutyId = undefined;
|
|
44
|
+ }else if(queryType == 2){
|
|
45
|
+ this.hosId = hosId;
|
|
46
|
+ this.dutyId = undefined;
|
|
47
|
+ this.parentDutyId = undefined;
|
|
48
|
+ }else if(queryType == 3){
|
|
49
|
+ this.hosId = undefined;
|
|
50
|
+ this.dutyId = dutyId;
|
|
51
|
+ this.parentDutyId = undefined;
|
|
52
|
+ }else if(queryType == 4){
|
|
53
|
+ this.hosId = undefined;
|
|
54
|
+ this.dutyId = undefined;
|
|
55
|
+ this.parentDutyId = dutyId;
|
|
56
|
+ }
|
|
57
|
+ }
|
|
58
|
+
|
|
59
|
+ // 表格数据
|
|
60
|
+ loading1 = false;
|
|
61
|
+ getList(num?: number, field?: string, sort?: string) {
|
|
62
|
+ if (num !== undefined) {
|
|
63
|
+ this.pageIndex = num;
|
|
64
|
+ }
|
|
65
|
+ let postData:any = {
|
|
66
|
+ idx: this.pageIndex - 1,
|
|
67
|
+ sum: this.pageSize,
|
|
68
|
+ startDate: this.dateRange[0],
|
|
69
|
+ endDate: this.dateRange[1],
|
|
70
|
+ hosId: this.hosId,
|
|
71
|
+ dutyId: this.dutyId,
|
|
72
|
+ parentDutyId: this.parentDutyId,
|
|
73
|
+ };
|
|
74
|
+ if (field && sort) {
|
|
75
|
+ postData.sort = `${field} ${sort === "ascend" ? `asc` : `desc`}`
|
|
76
|
+ }
|
|
77
|
+ this.loading1 = true;
|
|
78
|
+ this.mainService
|
|
79
|
+ .postCustom("itsm/report", "incidentWorkOrder", postData)
|
|
80
|
+ .subscribe((result) => {
|
|
81
|
+ this.loading1 = false;
|
|
82
|
+ this.listOfData = result.dataList || [];
|
|
83
|
+ this.listLength = result.totalCount;
|
|
84
|
+ });
|
|
85
|
+ }
|
|
86
|
+
|
|
87
|
+ // 列表排序
|
|
88
|
+ sortCurrent = {};
|
|
89
|
+ sortCurrentKey: string = "";
|
|
90
|
+ sortCurrentValue: string | null = "";
|
|
91
|
+ sort(e) {
|
|
92
|
+ const { key, value } = e;
|
|
93
|
+ this.sortCurrentKey = key;
|
|
94
|
+ this.sortCurrentValue = value;
|
|
95
|
+ this.getList(this.pageIndex, this.sortCurrentKey, this.sortCurrentValue);
|
|
96
|
+ }
|
|
97
|
+
|
|
98
|
+ // 搜索
|
|
99
|
+ search(num?: number) {
|
|
100
|
+ if (num !== undefined) {
|
|
101
|
+ this.getList(num, this.sortCurrentKey, this.sortCurrentValue);
|
|
102
|
+ } else {
|
|
103
|
+ this.getList(this.pageIndex, this.sortCurrentKey, this.sortCurrentValue);
|
|
104
|
+ }
|
|
105
|
+ }
|
|
106
|
+
|
|
107
|
+ // 日期选择 日
|
|
108
|
+ dateRange: any = [format(startOfMonth(addMonths(new Date(), -2)), 'yyyy-MM-dd HH:mm:ss'), format(endOfMonth(addMonths(new Date(), -1)), 'yyyy-MM-dd HH:mm:ss')]; //发起时间区间 天
|
|
109
|
+ changeDate(result?): void {
|
|
110
|
+ console.log(this.dateRange);
|
|
111
|
+ console.log(result);
|
|
112
|
+ result[0] = format(result[0], 'yyyy-MM-dd HH:mm:ss');
|
|
113
|
+ result[1] = format(result[1], 'yyyy-MM-dd HH:mm:ss');
|
|
114
|
+ this.dateRange = result;
|
|
115
|
+ this.search();
|
|
116
|
+ }
|
|
117
|
+
|
|
118
|
+ onCalendarChangeDate(dateArr){
|
|
119
|
+ console.log(dateArr)
|
|
120
|
+ if(dateArr.length == 2){
|
|
121
|
+ let dateStart = new Date(dateArr[0]);
|
|
122
|
+ let dateEnd = new Date(dateArr[1]);
|
|
123
|
+ dateStart.setHours(0,0,0);
|
|
124
|
+ dateEnd.setHours(23,59,59);
|
|
125
|
+ this.dateRange = [dateStart,dateEnd];
|
|
126
|
+ }
|
|
127
|
+ }
|
|
128
|
+
|
|
129
|
+ excelExport(){}
|
|
130
|
+ reset(){}
|
|
131
|
+}
|