|
@@ -0,0 +1,291 @@
|
|
1
|
+import { TabService } from '../../services/tab.service';
|
|
2
|
+import { debounceTime } from 'rxjs/operators';
|
|
3
|
+import { Subject } from 'rxjs';
|
|
4
|
+import { NzMessageService } from 'ng-zorro-antd/message';
|
|
5
|
+import { format, addMonths, startOfMonth, endOfMonth, startOfDay, endOfDay } from 'date-fns';
|
|
6
|
+import { Component, OnInit, HostListener, AfterViewInit } from "@angular/core";
|
|
7
|
+import { MainService } from 'src/app/services/main.service';
|
|
8
|
+import { ActivatedRoute } from '@angular/router';
|
|
9
|
+@Component({
|
|
10
|
+ selector: "app-work-hour-big-statistics",
|
|
11
|
+ templateUrl: "./work-hour-big-statistics.component.html",
|
|
12
|
+ styleUrls: ["./work-hour-big-statistics.component.less"],
|
|
13
|
+})
|
|
14
|
+export class WorkHourBigStatisticsComponent implements OnInit, AfterViewInit {
|
|
15
|
+ constructor(
|
|
16
|
+ private mainService: MainService,
|
|
17
|
+ private message: NzMessageService,
|
|
18
|
+ private route: ActivatedRoute,
|
|
19
|
+ private tabService: TabService,
|
|
20
|
+ ) {}
|
|
21
|
+
|
|
22
|
+ listOfData: any[] = []; //表格数据
|
|
23
|
+ listOfDataEnd: any[] = []; //表格合计
|
|
24
|
+ pageIndex: number = 1; //表格当前页码
|
|
25
|
+ pageSize: number = 30; //表格每页展示条数
|
|
26
|
+ listLength: number = 0; //表格总数据量
|
|
27
|
+
|
|
28
|
+ repairDeptId;//报修科室id
|
|
29
|
+
|
|
30
|
+ searchTimerSubject = new Subject();
|
|
31
|
+
|
|
32
|
+ ngOnInit() {
|
|
33
|
+ this.searchTimerSubject.pipe(debounceTime(500)).subscribe((v) => {
|
|
34
|
+ let fun = v[0];
|
|
35
|
+ fun.call(this, v[1]);
|
|
36
|
+ });
|
|
37
|
+ this.initSessionData();
|
|
38
|
+ this.getQueryParams();
|
|
39
|
+ this.search();
|
|
40
|
+ }
|
|
41
|
+
|
|
42
|
+ ngAfterViewInit(){
|
|
43
|
+ this.onResize();
|
|
44
|
+ }
|
|
45
|
+
|
|
46
|
+ tableHeight:number = 0;
|
|
47
|
+ @HostListener('window:resize')
|
|
48
|
+ onResize(): void {
|
|
49
|
+ setTimeout(() => {
|
|
50
|
+ this.tableHeight = window.innerHeight - (document.querySelector('.searchDataWrap') as HTMLElement).offsetHeight - 64 - 36 - 48 - 8 - (document.querySelector('.ant-table-header') as HTMLElement).offsetHeight - 55 - this.getMoreFilter + 14;
|
|
51
|
+
|
|
52
|
+ }, 0)
|
|
53
|
+ }
|
|
54
|
+
|
|
55
|
+ getQueryParams(){
|
|
56
|
+ let queryParams = this.tabService.getQueryParams();
|
|
57
|
+ this.tabService.clearQueryParams();
|
|
58
|
+ if(queryParams.dateRange){
|
|
59
|
+ this.dateRange = queryParams.dateRange;
|
|
60
|
+ }
|
|
61
|
+ }
|
|
62
|
+
|
|
63
|
+ get getMoreFilter(){
|
|
64
|
+ let flag = this.fieldConfig.fields.groupDTO || this.fieldConfig.fields.userDTO || this.fieldConfig.fields.category1DTO || this.fieldConfig.fields.category2DTO || this.fieldConfig.fields.category3DTO || this.fieldConfig.fields.buildingDTO || this.fieldConfig.fields.floorDTO || this.fieldConfig.fields.companyDTO;
|
|
65
|
+ return flag ? 37 : 0;
|
|
66
|
+ }
|
|
67
|
+
|
|
68
|
+ // 初始化缓存数据
|
|
69
|
+ queryType:any;
|
|
70
|
+ hosId:any;
|
|
71
|
+ dutyId:any;
|
|
72
|
+ parentDutyId:any;
|
|
73
|
+ initSessionData(){
|
|
74
|
+ let newStatistics = JSON.parse(sessionStorage.getItem('newStatistics'));
|
|
75
|
+ let queryType:any = newStatistics.queryType;
|
|
76
|
+ let hosId:any = newStatistics.hospitalId;
|
|
77
|
+ let dutyId:any = newStatistics.dutyId;
|
|
78
|
+
|
|
79
|
+ queryType = queryType ? +queryType : undefined;
|
|
80
|
+ hosId = hosId ? +hosId : undefined;
|
|
81
|
+ dutyId = dutyId ? +dutyId : undefined;
|
|
82
|
+
|
|
83
|
+ this.queryType = queryType;
|
|
84
|
+ if(queryType == 1){
|
|
85
|
+ this.hosId = undefined;
|
|
86
|
+ this.dutyId = undefined;
|
|
87
|
+ this.parentDutyId = undefined;
|
|
88
|
+ }else if(queryType == 2){
|
|
89
|
+ this.hosId = hosId;
|
|
90
|
+ this.dutyId = undefined;
|
|
91
|
+ this.parentDutyId = undefined;
|
|
92
|
+ }else if(queryType == 3){
|
|
93
|
+ this.hosId = undefined;
|
|
94
|
+ this.dutyId = dutyId;
|
|
95
|
+ this.parentDutyId = undefined;
|
|
96
|
+ }else if(queryType == 4){
|
|
97
|
+ this.hosId = undefined;
|
|
98
|
+ this.dutyId = undefined;
|
|
99
|
+ this.parentDutyId = dutyId;
|
|
100
|
+ }
|
|
101
|
+ }
|
|
102
|
+
|
|
103
|
+ get getHosId(){
|
|
104
|
+ return this.parentDutyId || this.dutyId || this.hosId;
|
|
105
|
+ }
|
|
106
|
+
|
|
107
|
+ // 表格数据
|
|
108
|
+ loading1 = false;
|
|
109
|
+ getList(num?: number, field?: string, sort?: string) {
|
|
110
|
+ if (num !== undefined) {
|
|
111
|
+ this.pageIndex = num;
|
|
112
|
+ }
|
|
113
|
+ let postData:any = {
|
|
114
|
+ idx: this.pageIndex - 1,
|
|
115
|
+ sum: this.pageSize,
|
|
116
|
+ startDate: this.dateRange[0] || undefined,
|
|
117
|
+ endDate: this.dateRange[1] || undefined,
|
|
118
|
+ hosId: this.hosId || undefined,
|
|
119
|
+ dutyId: this.dutyId || undefined,
|
|
120
|
+ parentDutyId: this.parentDutyId || undefined,
|
|
121
|
+ repairDeptId: this.repairDeptId || undefined,
|
|
122
|
+ groupId: this.fieldConfig.fields.userId ? undefined : (this.fieldConfig.fields.groupId || undefined),
|
|
123
|
+ userId: this.fieldConfig.fields.userId || undefined,
|
|
124
|
+ categoryId: this.fieldConfig.fields.categoryId || undefined,
|
|
125
|
+ hierarchy: this.fieldConfig.fields.hierarchy || undefined,
|
|
126
|
+ buildingId: this.fieldConfig.fields.buildingId || undefined,
|
|
127
|
+ placeId: this.fieldConfig.fields.floorId || undefined,
|
|
128
|
+ companyId: this.fieldConfig.fields.companyId || undefined,
|
|
129
|
+ };
|
|
130
|
+ if (field && sort) {
|
|
131
|
+ postData.sort = `${field} ${sort === "ascend" ? `asc` : `desc`}`
|
|
132
|
+ }
|
|
133
|
+ this.loading1 = true;
|
|
134
|
+ this.mainService
|
|
135
|
+ .postCustom("itsm/report", "workHourIncident", postData)
|
|
136
|
+ .subscribe((result) => {
|
|
137
|
+ this.loading1 = false;
|
|
138
|
+ this.listOfData = result.dataList.filter((v, i) => { return i != result.dataList.length - 1 });
|
|
139
|
+ this.listOfDataEnd = result.dataList.filter((v, i) => { return i == result.dataList.length - 1 });
|
|
140
|
+ this.listLength = result.totalCount;
|
|
141
|
+ });
|
|
142
|
+ }
|
|
143
|
+
|
|
144
|
+ // 列表排序
|
|
145
|
+ sortCurrent:any = {};
|
|
146
|
+ sortCurrentKey: string = "";
|
|
147
|
+ sortCurrentValue: string | null = "";
|
|
148
|
+ sort(e) {
|
|
149
|
+ const { key, value } = e;
|
|
150
|
+ this.sortCurrentKey = key;
|
|
151
|
+ this.sortCurrentValue = value;
|
|
152
|
+ this.getList(this.pageIndex, this.sortCurrentKey, this.sortCurrentValue);
|
|
153
|
+ }
|
|
154
|
+
|
|
155
|
+ // 搜索
|
|
156
|
+ search() {
|
|
157
|
+ this.getList(1, this.sortCurrentKey, this.sortCurrentValue);
|
|
158
|
+ }
|
|
159
|
+
|
|
160
|
+ // 日期选择
|
|
161
|
+ dateRange: any = [format(startOfMonth(addMonths(new Date(), -1)), 'yyyy-MM-dd HH:mm:ss'), format(endOfMonth(addMonths(new Date(), -1)), 'yyyy-MM-dd HH:mm:ss')];
|
|
162
|
+ changeDate(result?): void {
|
|
163
|
+ result[0] = format(startOfDay(result[0]), 'yyyy-MM-dd HH:mm:ss');
|
|
164
|
+ result[1] = format(endOfDay(result[1]), 'yyyy-MM-dd HH:mm:ss');
|
|
165
|
+ this.dateRange = result;
|
|
166
|
+ }
|
|
167
|
+
|
|
168
|
+ onCalendarChangeDate(dateArr){
|
|
169
|
+ console.log(dateArr)
|
|
170
|
+ if(dateArr.length == 2){
|
|
171
|
+ this.dateRange = [format(startOfDay(dateArr[0]), 'yyyy-MM-dd HH:mm:ss'), format(endOfDay(dateArr[1]), 'yyyy-MM-dd HH:mm:ss')];
|
|
172
|
+ }
|
|
173
|
+ }
|
|
174
|
+
|
|
175
|
+ // 导出
|
|
176
|
+ excelExportLoading:any = false;
|
|
177
|
+ excelExport(){
|
|
178
|
+ this.excelExportLoading = this.message.loading("导出中..", {
|
|
179
|
+ nzDuration: 0,
|
|
180
|
+ }).messageId;
|
|
181
|
+ let postData:any = {
|
|
182
|
+ startDate: this.dateRange[0] || undefined,
|
|
183
|
+ endDate: this.dateRange[1] || undefined,
|
|
184
|
+ hosId: this.hosId || undefined,
|
|
185
|
+ dutyId: this.dutyId || undefined,
|
|
186
|
+ parentDutyId: this.parentDutyId || undefined,
|
|
187
|
+ repairDeptId: this.repairDeptId || undefined,
|
|
188
|
+ groupId: this.fieldConfig.fields.userId ? undefined : (this.fieldConfig.fields.groupId || undefined),
|
|
189
|
+ userId: this.fieldConfig.fields.userId || undefined,
|
|
190
|
+ categoryId: this.fieldConfig.fields.categoryId || undefined,
|
|
191
|
+ hierarchy: this.fieldConfig.fields.hierarchy || undefined,
|
|
192
|
+ buildingId: this.fieldConfig.fields.buildingId || undefined,
|
|
193
|
+ placeId: this.fieldConfig.fields.floorId || undefined,
|
|
194
|
+ companyId: this.fieldConfig.fields.companyId || undefined,
|
|
195
|
+ };
|
|
196
|
+ if (this.sortCurrentKey && this.sortCurrentValue) {
|
|
197
|
+ postData.sort = `${this.sortCurrentKey} ${this.sortCurrentValue === "ascend" ? `asc` : `desc`}`
|
|
198
|
+ }
|
|
199
|
+ this.mainService
|
|
200
|
+ .postExportCustom("itsm/export", "workHourIncident", postData)
|
|
201
|
+ .subscribe((data) => {
|
|
202
|
+ this.message.remove(this.excelExportLoading);
|
|
203
|
+ this.excelExportLoading = false;
|
|
204
|
+ this.message.success('导出成功');
|
|
205
|
+ var file = new Blob([data], {
|
|
206
|
+ type: "application/vnd.ms-excel",
|
|
207
|
+ });
|
|
208
|
+ //trick to download store a file having its URL
|
|
209
|
+ var fileURL = URL.createObjectURL(file);
|
|
210
|
+ var a = document.createElement("a");
|
|
211
|
+ a.href = fileURL;
|
|
212
|
+ a.target = "_blank";
|
|
213
|
+ a.download = `${this.route.parent.routeConfig.data.title}.xls`;
|
|
214
|
+ document.body.appendChild(a);
|
|
215
|
+ a.click();
|
|
216
|
+ },(err) => {
|
|
217
|
+ this.message.remove(this.excelExportLoading);
|
|
218
|
+ this.excelExportLoading = false;
|
|
219
|
+ this.message.error('导出失败');
|
|
220
|
+ });
|
|
221
|
+ }
|
|
222
|
+ // 重置
|
|
223
|
+ reset(){
|
|
224
|
+ this.sortCurrentKey = "";
|
|
225
|
+ this.sortCurrentValue = "";
|
|
226
|
+ this.sortCurrent = {};
|
|
227
|
+ this.dateRange = [format(startOfMonth(addMonths(new Date(), -1)), 'yyyy-MM-dd HH:mm:ss'), format(endOfMonth(addMonths(new Date(), -1)), 'yyyy-MM-dd HH:mm:ss')]
|
|
228
|
+ this.repairDeptId = undefined;
|
|
229
|
+ this.fieldConfig.fields = {groupId: undefined, userId: undefined, categoryId: undefined, buildingId: undefined, floorId: undefined, companyId: undefined};
|
|
230
|
+ this.search();
|
|
231
|
+ }
|
|
232
|
+
|
|
233
|
+ // 科室搜索
|
|
234
|
+ changeRepairDeptInp(e) {
|
|
235
|
+ this.searchTimer(this.getRepairDeptList, e);
|
|
236
|
+ }
|
|
237
|
+
|
|
238
|
+ // 防抖
|
|
239
|
+ isLoading = false;
|
|
240
|
+ searchTimer(fun, e) {
|
|
241
|
+ this.isLoading = true;
|
|
242
|
+ this.searchTimerSubject.next([fun, e]);
|
|
243
|
+ }
|
|
244
|
+
|
|
245
|
+ openChangeRepairDept(flag){
|
|
246
|
+ flag && this.getRepairDeptList();
|
|
247
|
+ }
|
|
248
|
+
|
|
249
|
+ // 获取报修科室列表
|
|
250
|
+ repairDeptList:any[] = [];
|
|
251
|
+ getRepairDeptList(keyword?) {
|
|
252
|
+ let data = {
|
|
253
|
+ department: {
|
|
254
|
+ statisticalHosId: this.getHosId,
|
|
255
|
+ dept: keyword,
|
|
256
|
+ searchType: 1,
|
|
257
|
+ },
|
|
258
|
+ idx: 0,
|
|
259
|
+ sum: 20,
|
|
260
|
+ };
|
|
261
|
+ this.isLoading = true;
|
|
262
|
+ this.mainService
|
|
263
|
+ .getFetchDataList("data", "department", data)
|
|
264
|
+ .subscribe((data) => {
|
|
265
|
+ this.isLoading = false;
|
|
266
|
+ this.repairDeptList = data.list;
|
|
267
|
+ });
|
|
268
|
+ }
|
|
269
|
+
|
|
270
|
+ // 详细搜索
|
|
271
|
+ fieldConfig:any = {
|
|
272
|
+ fields: {groupId: undefined, userId: undefined, categoryId: undefined, buildingId: undefined, floorId: undefined, companyId: undefined},
|
|
273
|
+ config: {groupAndUser: true, category123: true, buildingAndFloor: true, company: true},
|
|
274
|
+ }
|
|
275
|
+ showSearchMore:boolean = false;
|
|
276
|
+ showMore(){
|
|
277
|
+ this.showSearchMore = true;
|
|
278
|
+ }
|
|
279
|
+
|
|
280
|
+ cancelEvent(){
|
|
281
|
+ this.showSearchMore = false;
|
|
282
|
+ }
|
|
283
|
+
|
|
284
|
+ submitEvent(fields){
|
|
285
|
+ this.showSearchMore = false;
|
|
286
|
+ this.fieldConfig.fields = fields;
|
|
287
|
+ console.log('this.fieldConfig.fields:', this.fieldConfig.fields)
|
|
288
|
+ this.search();
|
|
289
|
+ this.onResize();
|
|
290
|
+ }
|
|
291
|
+}
|