|
@@ -0,0 +1,226 @@
|
|
1
|
+import { Component, OnInit, ViewChild } from "@angular/core";
|
|
2
|
+import { ActivatedRoute, Router } from "@angular/router";
|
|
3
|
+
|
|
4
|
+import { OverlayScrollbarsComponent } from "overlayscrollbars-ngx";
|
|
5
|
+import { ToolService } from "../../services/tool.service";
|
|
6
|
+import { format, startOfDay, endOfDay, startOfWeek, endOfWeek, add } from 'date-fns';
|
|
7
|
+import { BuildingInspectionStatisticsService } from './building-inspection-statistics.service';
|
|
8
|
+import { Subject } from 'rxjs';
|
|
9
|
+import { debounceTime } from 'rxjs/operators';
|
|
10
|
+
|
|
11
|
+@Component({
|
|
12
|
+ selector: "app-building-inspection-statistics",
|
|
13
|
+ templateUrl: "./building-inspection-statistics.component.html",
|
|
14
|
+ styleUrls: ["./building-inspection-statistics.component.less"],
|
|
15
|
+})
|
|
16
|
+export class BuildingInspectionStatisticsComponent implements OnInit {
|
|
17
|
+ @ViewChild("osComponentRef1", {
|
|
18
|
+ read: OverlayScrollbarsComponent,
|
|
19
|
+ static: false,
|
|
20
|
+ })
|
|
21
|
+ osComponentRef1: OverlayScrollbarsComponent;
|
|
22
|
+ constructor(
|
|
23
|
+ private router: Router,
|
|
24
|
+ private route: ActivatedRoute,
|
|
25
|
+ private tool: ToolService,
|
|
26
|
+ private buildingInspectionStatisticsService: BuildingInspectionStatisticsService,
|
|
27
|
+ ) {}
|
|
28
|
+
|
|
29
|
+ listOfData: any[] = []; //表格数据
|
|
30
|
+ searchDto: any = {
|
|
31
|
+ dateRange: [startOfWeek(add(new Date(), { weeks: -1}), { weekStartsOn: 1 }), endOfWeek(add(new Date(), { weeks: -1}), { weekStartsOn: 1 })],
|
|
32
|
+ department: [],
|
|
33
|
+ buildingList: null,
|
|
34
|
+ }
|
|
35
|
+
|
|
36
|
+ hosId: any; //院区(搜索)
|
|
37
|
+ pageIndex: number = 1; //页码
|
|
38
|
+ listLength: number = 10; //总条数
|
|
39
|
+ pageSize: number = 10; //每页条数
|
|
40
|
+
|
|
41
|
+ // 初始化增删改按钮
|
|
42
|
+ coopBtns: any = {};
|
|
43
|
+
|
|
44
|
+ searchTimerSubject = new Subject();
|
|
45
|
+
|
|
46
|
+ ngOnInit() {
|
|
47
|
+ this.searchTimerSubject.pipe(debounceTime(500)).subscribe((v) => {
|
|
48
|
+ let fun = v[0];
|
|
49
|
+ fun.call(this, v[1]);
|
|
50
|
+ });
|
|
51
|
+ this.coopBtns = this.tool.initCoopBtns(this.route);
|
|
52
|
+ this.hosId = this.tool.getCurrentHospital().id;
|
|
53
|
+ this.getList(true);
|
|
54
|
+ this.getDeparts();
|
|
55
|
+ this.getBuildingList();
|
|
56
|
+ }
|
|
57
|
+
|
|
58
|
+ // 边输入边搜索节流阀
|
|
59
|
+ searchTimer(fun, e) {
|
|
60
|
+ this.isLoading = true;
|
|
61
|
+ this.searchTimerSubject.next([fun, e]);
|
|
62
|
+ }
|
|
63
|
+
|
|
64
|
+ // 科室边输边搜节流阀
|
|
65
|
+ isLoading = false;
|
|
66
|
+ changeInp(e) {
|
|
67
|
+ this.searchTimer(this.getDeparts, e);
|
|
68
|
+ }
|
|
69
|
+
|
|
70
|
+ // 获取科室
|
|
71
|
+ alldepart: any = []; //科室
|
|
72
|
+ getDeparts(dept?) {
|
|
73
|
+ let data = {
|
|
74
|
+ department: {
|
|
75
|
+ cascadeHosId: this.hosId,
|
|
76
|
+ dept: dept,
|
|
77
|
+ configRoom: 1,
|
|
78
|
+ },
|
|
79
|
+ idx: 0,
|
|
80
|
+ sum: 20,
|
|
81
|
+ };
|
|
82
|
+ this.isLoading = true;
|
|
83
|
+ this.buildingInspectionStatisticsService
|
|
84
|
+ .getDeparts(data)
|
|
85
|
+ .subscribe((data) => {
|
|
86
|
+ this.alldepart = data.list;
|
|
87
|
+ this.isLoading = false;
|
|
88
|
+ });
|
|
89
|
+ }
|
|
90
|
+
|
|
91
|
+ // 获取楼栋
|
|
92
|
+ buildingList: any = []; //楼栋
|
|
93
|
+ getBuildingList() {
|
|
94
|
+ let data = {
|
|
95
|
+ building: {
|
|
96
|
+ cascadeHosId: this.hosId,
|
|
97
|
+ },
|
|
98
|
+ idx: 0,
|
|
99
|
+ sum: 9999,
|
|
100
|
+ };
|
|
101
|
+ this.isLoading = true;
|
|
102
|
+ this.buildingInspectionStatisticsService
|
|
103
|
+ .getBuildingList(data)
|
|
104
|
+ .subscribe((data) => {
|
|
105
|
+ this.buildingList = data.list;
|
|
106
|
+ this.isLoading = false;
|
|
107
|
+ });
|
|
108
|
+ }
|
|
109
|
+
|
|
110
|
+ // 搜索
|
|
111
|
+ search() {
|
|
112
|
+ this.getList(true);
|
|
113
|
+ }
|
|
114
|
+ // 重置
|
|
115
|
+ reset() {
|
|
116
|
+ this.searchDto = {
|
|
117
|
+ dateRange: [startOfWeek(add(new Date(), { weeks: -1}), { weekStartsOn: 1 }), endOfWeek(add(new Date(), { weeks: -1}), { weekStartsOn: 1 })],
|
|
118
|
+ department: [],
|
|
119
|
+ buildingList: null,
|
|
120
|
+ }
|
|
121
|
+ this.search();
|
|
122
|
+ }
|
|
123
|
+ // 表格数据
|
|
124
|
+ loading1 = false;
|
|
125
|
+ statisticsObj:any = [];
|
|
126
|
+ getList(isResetPageIndex = false) {
|
|
127
|
+ isResetPageIndex && (this.pageIndex = 1);
|
|
128
|
+ let postData:any = {
|
|
129
|
+ idx: this.pageIndex - 1,
|
|
130
|
+ sum: this.pageSize,
|
|
131
|
+ hosId: this.hosId,
|
|
132
|
+ startTime: this.searchDto.dateRange[0] ? format(startOfDay(this.searchDto.dateRange[0]), 'yyyy-MM-dd HH:mm:ss') : undefined,
|
|
133
|
+ endTime: this.searchDto.dateRange[1] ? format(endOfDay(this.searchDto.dateRange[1]), 'yyyy-MM-dd HH:mm:ss') : undefined,
|
|
134
|
+ deptIds: this.searchDto.department.length ? this.searchDto.department.toString() : undefined,
|
|
135
|
+ buildingId: this.searchDto.building|| undefined,
|
|
136
|
+ };
|
|
137
|
+ this.loading1 = true;
|
|
138
|
+ this.buildingInspectionStatisticsService
|
|
139
|
+ .query(postData)
|
|
140
|
+ .subscribe((result) => {
|
|
141
|
+ this.loading1 = false;
|
|
142
|
+ result.data = result.data || [];
|
|
143
|
+ this.listOfData = result.data;
|
|
144
|
+ this.listLength = result.totalNum;
|
|
145
|
+ let summary = result.summary || [];
|
|
146
|
+ this.statisticsObj = summary.length ? summary[0] : [];
|
|
147
|
+ });
|
|
148
|
+ }
|
|
149
|
+
|
|
150
|
+ // 查看业务数据
|
|
151
|
+ businessDataModalShow = false; //业务数据弹窗开关
|
|
152
|
+ businessDataModalType = ''; //业务数据类型
|
|
153
|
+ dataInfo = null; //查看业务数据携带
|
|
154
|
+ viewDetail(data, type) {
|
|
155
|
+ this.dataInfo = data;
|
|
156
|
+ this.businessDataModalType = type;
|
|
157
|
+ this.businessDataModalShow = true;
|
|
158
|
+ }
|
|
159
|
+ // 关闭业务数据弹窗
|
|
160
|
+ closeModelBlood(e) {
|
|
161
|
+ this.businessDataModalShow = JSON.parse(e).show;
|
|
162
|
+ }
|
|
163
|
+
|
|
164
|
+ // 导出
|
|
165
|
+ loading2 = false;
|
|
166
|
+ export() {
|
|
167
|
+ let postData:any = {
|
|
168
|
+ idx: this.pageIndex - 1,
|
|
169
|
+ sum: this.pageSize,
|
|
170
|
+ hosId: this.hosId,
|
|
171
|
+ startTime: this.searchDto.dateRange[0] ? format(startOfDay(this.searchDto.dateRange[0]), 'yyyy-MM-dd HH:mm:ss') : undefined,
|
|
172
|
+ endTime: this.searchDto.dateRange[1] ? format(endOfDay(this.searchDto.dateRange[1]), 'yyyy-MM-dd HH:mm:ss') : undefined,
|
|
173
|
+ deptIds: this.searchDto.department.length ? this.searchDto.department.toString() : undefined,
|
|
174
|
+ buildingId: this.searchDto.building|| undefined,
|
|
175
|
+ };
|
|
176
|
+ this.loading2 = true;
|
|
177
|
+ this.buildingInspectionStatisticsService.exportReport(postData).subscribe(
|
|
178
|
+ (data) => {
|
|
179
|
+ this.loading2 = false;
|
|
180
|
+ this.showPromptModal("导出", true, "");
|
|
181
|
+ var file = new Blob([data], {
|
|
182
|
+ type: "application/vnd.ms-excel",
|
|
183
|
+ });
|
|
184
|
+ //trick to download store a file having its URL
|
|
185
|
+ var fileURL = URL.createObjectURL(file);
|
|
186
|
+ var a = document.createElement("a");
|
|
187
|
+ a.href = fileURL;
|
|
188
|
+ a.target = "_blank";
|
|
189
|
+ a.download = "楼栋检查统计.xls";
|
|
190
|
+ document.body.appendChild(a);
|
|
191
|
+ a.click();
|
|
192
|
+ },
|
|
193
|
+ (err) => {
|
|
194
|
+ this.loading2 = false;
|
|
195
|
+ this.showPromptModal("导出", false, "");
|
|
196
|
+ }
|
|
197
|
+ );
|
|
198
|
+ }
|
|
199
|
+
|
|
200
|
+ // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
|
|
201
|
+ promptContent: string; //操作提示框提示信息
|
|
202
|
+ ifSuccess: boolean; //操作成功/失败
|
|
203
|
+ promptInfo: string; //操作结果提示信息
|
|
204
|
+ promptModalShow: boolean; //操作提示框是否展示
|
|
205
|
+ showPromptModal(con, success, promptInfo?) {
|
|
206
|
+ this.promptModalShow = false;
|
|
207
|
+ this.promptContent = con;
|
|
208
|
+ this.ifSuccess = success;
|
|
209
|
+ this.promptInfo = promptInfo;
|
|
210
|
+ setTimeout(() => {
|
|
211
|
+ this.promptModalShow = true;
|
|
212
|
+ }, 100);
|
|
213
|
+ }
|
|
214
|
+
|
|
215
|
+ personDetail(dataInfo){
|
|
216
|
+ console.log(dataInfo);
|
|
217
|
+ let startDate = dataInfo.searchDto.dateRange[0] ? format(startOfDay(dataInfo.searchDto.dateRange[0]), 'yyyy-MM-dd HH:mm:ss') : 'null';
|
|
218
|
+ let endDate = dataInfo.searchDto.dateRange[1] ? format(endOfDay(dataInfo.searchDto.dateRange[1]), 'yyyy-MM-dd HH:mm:ss') : 'null';
|
|
219
|
+ let deptId = dataInfo.data[10] || 'null';
|
|
220
|
+ let countRemark = dataInfo.countRemark || 'null';
|
|
221
|
+ this.router.navigateByUrl(
|
|
222
|
+ `/main/buildingInspectionStatistics/workerStatisticsDetail/null/${startDate}/${endDate}/null/buildingInspectionStatistics/${deptId}/${countRemark}`
|
|
223
|
+ );
|
|
224
|
+ }
|
|
225
|
+}
|
|
226
|
+
|