|
@@ -0,0 +1,309 @@
|
|
1
|
+import { Component, OnInit } from "@angular/core";
|
|
2
|
+import { ActivatedRoute, Router } from "@angular/router";
|
|
3
|
+
|
|
4
|
+import { MainService } from "../../services/main.service";
|
|
5
|
+import { DateService } from "../../services/date.service";
|
|
6
|
+import { MyServiceService } from "../../services/my-service.service";
|
|
7
|
+import { ToolService } from "../../services/tool.service";
|
|
8
|
+import { Subject } from "rxjs";
|
|
9
|
+import { debounceTime } from "rxjs/operators";
|
|
10
|
+
|
|
11
|
+@Component({
|
|
12
|
+ selector: "app-inspect-active",
|
|
13
|
+ templateUrl: "./inspect-active.component.html",
|
|
14
|
+ styleUrls: ["./inspect-active.component.less"],
|
|
15
|
+})
|
|
16
|
+export class InspectActiveComponent implements OnInit {
|
|
17
|
+ constructor(
|
|
18
|
+ private route: ActivatedRoute,
|
|
19
|
+ private router: Router,
|
|
20
|
+ private mainService: MainService,
|
|
21
|
+ private dateService: DateService,
|
|
22
|
+ private myService: MyServiceService,
|
|
23
|
+ private tool: ToolService
|
|
24
|
+ ) {}
|
|
25
|
+ searchTimerSubject = new Subject();
|
|
26
|
+ ngOnInit() {
|
|
27
|
+ this.searchTimerSubject.pipe(debounceTime(500)).subscribe((v) => {
|
|
28
|
+ this.getAllWorker(v);
|
|
29
|
+ });
|
|
30
|
+ this.getSearchData();
|
|
31
|
+ this.coopBtns = this.tool.initCoopBtns(this.route);
|
|
32
|
+ this.getAllHos();
|
|
33
|
+ }
|
|
34
|
+
|
|
35
|
+ defRange = "1"; //默认上周
|
|
36
|
+ defRanges = [
|
|
37
|
+ {
|
|
38
|
+ label: "上周",
|
|
39
|
+ id: 1,
|
|
40
|
+ },
|
|
41
|
+ {
|
|
42
|
+ label: "上月",
|
|
43
|
+ id: 2,
|
|
44
|
+ },
|
|
45
|
+ {
|
|
46
|
+ label: "上年",
|
|
47
|
+ id: 3,
|
|
48
|
+ },
|
|
49
|
+ ]; //时间默认区间
|
|
50
|
+
|
|
51
|
+ listOfData: any[] = []; //表格数据
|
|
52
|
+ pageIndex: number = 1; //表格当前页码
|
|
53
|
+ pageSize: number = 10; //表格每页展示条数
|
|
54
|
+ listLength: number = 10; //表格总数据量
|
|
55
|
+
|
|
56
|
+ dateRange: any = []; //发起时间区间 天
|
|
57
|
+
|
|
58
|
+ promptContent: string; //操作提示框提示信息
|
|
59
|
+ ifSuccess: boolean; //操作成功/失败
|
|
60
|
+ promptInfo: string; //操作结果提示信息
|
|
61
|
+ promptModalShow: boolean; //操作提示框是否展示
|
|
62
|
+
|
|
63
|
+ // 初始化增删改按钮
|
|
64
|
+ coopBtns: any = {};
|
|
65
|
+ searchData: any = {}; // 综合统计页面带过来的参数
|
|
66
|
+ getSearchData() {
|
|
67
|
+ let that = this;
|
|
68
|
+ let sub = that.myService.getMsg().subscribe((msg) => {
|
|
69
|
+ // 从综合报表跳转过来
|
|
70
|
+ that.searchData = msg;
|
|
71
|
+ console.log(that.searchData);
|
|
72
|
+ console.log(66);
|
|
73
|
+ sub.unsubscribe(); //取消订阅,否则订阅函数会累加执行
|
|
74
|
+ that.hospital = that.searchData["hosId"];
|
|
75
|
+ that.changeDate(that.searchData["range"]);
|
|
76
|
+ that.defRange = that.searchData["defRange"];
|
|
77
|
+ that.search();
|
|
78
|
+ });
|
|
79
|
+ // 不是从综合报表页面跳转过来的
|
|
80
|
+ setTimeout(() => {
|
|
81
|
+ if (!sub["isStopped"]) {
|
|
82
|
+ that.changeDateRange(that.defRange);
|
|
83
|
+ that.search();
|
|
84
|
+ }
|
|
85
|
+ }, 100);
|
|
86
|
+ }
|
|
87
|
+ // 搜索
|
|
88
|
+ search(num?: number) {
|
|
89
|
+ if (this.hospital) {
|
|
90
|
+ this.searchData["hosId"] = this.hospital;
|
|
91
|
+ }
|
|
92
|
+ if (this.startDate) {
|
|
93
|
+ this.searchData["dateRange"] = {
|
|
94
|
+ start: this.startDate + " " + "00:00:00",
|
|
95
|
+ end: this.endDate + " " + "23:59:59",
|
|
96
|
+ };
|
|
97
|
+ }
|
|
98
|
+ if (num !== undefined) {
|
|
99
|
+ this.getList(num);
|
|
100
|
+ } else {
|
|
101
|
+ this.getList();
|
|
102
|
+ }
|
|
103
|
+ }
|
|
104
|
+ // 导出
|
|
105
|
+ loading2 = false;
|
|
106
|
+ export() {
|
|
107
|
+ let that = this;
|
|
108
|
+ let postData = {
|
|
109
|
+ hosId: that.hospital,
|
|
110
|
+ startTime: this.startDate + " " + "00:00:00",
|
|
111
|
+ endTime: this.endDate + " " + "23:59:59",
|
|
112
|
+ groupId: that.group || "",
|
|
113
|
+ };
|
|
114
|
+ this.loading2 = true;
|
|
115
|
+ that.mainService.exportReport("user", postData).subscribe(
|
|
116
|
+ (data) => {
|
|
117
|
+ this.loading2 = false;
|
|
118
|
+ this.showPromptModal("导出", true, "");
|
|
119
|
+ var file = new Blob([data], {
|
|
120
|
+ type: "application/vnd.ms-excel",
|
|
121
|
+ });
|
|
122
|
+ //trick to download store a file having its URL
|
|
123
|
+ var fileURL = URL.createObjectURL(file);
|
|
124
|
+ var a = document.createElement("a");
|
|
125
|
+ a.href = fileURL;
|
|
126
|
+ a.target = "_blank";
|
|
127
|
+ a.download = "支助人员统计.xls";
|
|
128
|
+ document.body.appendChild(a);
|
|
129
|
+ a.click();
|
|
130
|
+ },
|
|
131
|
+ (err) => {
|
|
132
|
+ this.loading2 = false;
|
|
133
|
+ this.showPromptModal("导出", false, "");
|
|
134
|
+ }
|
|
135
|
+ );
|
|
136
|
+ }
|
|
137
|
+ // 重置
|
|
138
|
+ reset() {
|
|
139
|
+ this.changeDateRange("1");
|
|
140
|
+ this.group = null;
|
|
141
|
+ this.search();
|
|
142
|
+ }
|
|
143
|
+ // 表格数据
|
|
144
|
+ loading1 = false;
|
|
145
|
+ getList(num?: number) {
|
|
146
|
+ if (num !== undefined) {
|
|
147
|
+ this.pageIndex = num;
|
|
148
|
+ }
|
|
149
|
+ let postData = {
|
|
150
|
+ idx: this.pageIndex - 1,
|
|
151
|
+ sum: this.pageSize,
|
|
152
|
+ startTime: this.searchData.dateRange.start,
|
|
153
|
+ endTime: this.searchData.dateRange.end,
|
|
154
|
+ hosId: this.searchData.hosId,
|
|
155
|
+ groupId: this.group || "",
|
|
156
|
+ };
|
|
157
|
+ this.loading1 = true;
|
|
158
|
+ this.mainService
|
|
159
|
+ .postCustom("report", "user", postData)
|
|
160
|
+ .subscribe((result) => {
|
|
161
|
+ this.loading1 = false;
|
|
162
|
+ this.listOfData = result.list || [];
|
|
163
|
+ this.listLength = result.totalNum;
|
|
164
|
+ });
|
|
165
|
+ }
|
|
166
|
+ // 获取院区/分组
|
|
167
|
+ hospital: string; //选中院区
|
|
168
|
+ group: string; //选中组
|
|
169
|
+ allWorker: any = []; //支助人员列表
|
|
170
|
+ getAllHos() {
|
|
171
|
+ this.hospital = this.tool.getCurrentHospital().id + "";
|
|
172
|
+ this.getAllWorker();
|
|
173
|
+ }
|
|
174
|
+ // 用户输入搜索支助人员
|
|
175
|
+ changeUser(e = "") {
|
|
176
|
+ this.isLoading = true;
|
|
177
|
+ this.searchTimerSubject.next(e);
|
|
178
|
+ }
|
|
179
|
+ // 获取支助人员列表
|
|
180
|
+ worker: number; //选中的支助人员
|
|
181
|
+ isLoading = false;
|
|
182
|
+ getAllWorker(e: any = "") {
|
|
183
|
+ let postData = {
|
|
184
|
+ user: {
|
|
185
|
+ name: e || "",
|
|
186
|
+ hospital: { id: this.hospital },
|
|
187
|
+ usertype: { id: 106 }, //支助人员
|
|
188
|
+ },
|
|
189
|
+ idx: 0,
|
|
190
|
+ sum: 10,
|
|
191
|
+ };
|
|
192
|
+ this.isLoading = true;
|
|
193
|
+ this.mainService
|
|
194
|
+ .getFetchDataList("data", "user", postData)
|
|
195
|
+ .subscribe((data) => {
|
|
196
|
+ this.allWorker = data.list;
|
|
197
|
+ this.isLoading = false;
|
|
198
|
+ });
|
|
199
|
+ }
|
|
200
|
+
|
|
201
|
+ // 日期选择 日
|
|
202
|
+ startDate: string; //发起时间开始
|
|
203
|
+ endDate: string; //发起时间结束
|
|
204
|
+ changeDate(result?): void {
|
|
205
|
+ console.log(this.dateRange);
|
|
206
|
+ console.log(result);
|
|
207
|
+ this.dateRange = result;
|
|
208
|
+ if (!this.quick) {
|
|
209
|
+ // 不是快捷选择
|
|
210
|
+ this.defRange = null;
|
|
211
|
+ }
|
|
212
|
+ if (!result || !result.length) {
|
|
213
|
+ this.startDate = this.endDate = "";
|
|
214
|
+ return;
|
|
215
|
+ }
|
|
216
|
+ this.startDate =
|
|
217
|
+ result[0].getFullYear() +
|
|
218
|
+ "-" +
|
|
219
|
+ (result[0].getMonth() + 1) +
|
|
220
|
+ "-" +
|
|
221
|
+ result[0].getDate();
|
|
222
|
+ this.endDate =
|
|
223
|
+ result[1].getFullYear() +
|
|
224
|
+ "-" +
|
|
225
|
+ (result[1].getMonth() + 1) +
|
|
226
|
+ "-" +
|
|
227
|
+ result[1].getDate();
|
|
228
|
+ this.search();
|
|
229
|
+ }
|
|
230
|
+ // 修改搜素条件工作组
|
|
231
|
+ searchGroup(e) {
|
|
232
|
+ this.group = e;
|
|
233
|
+ this.search();
|
|
234
|
+ }
|
|
235
|
+ // 日期选择 快速修改时间区间
|
|
236
|
+ nowdate = new Date();
|
|
237
|
+ quick: boolean = false;
|
|
238
|
+ changeDateRange(res) {
|
|
239
|
+ this.defRange = res;
|
|
240
|
+ console.log(res);
|
|
241
|
+ this.quick = true;
|
|
242
|
+ switch (res) {
|
|
243
|
+ case "1":
|
|
244
|
+ // 上周
|
|
245
|
+ let lastweekstartdate = this.dateService.date().lastWeekStartDate;
|
|
246
|
+ let lastweekenddate = this.dateService.date().lastWeekEndDate;
|
|
247
|
+ console.log(lastweekstartdate, lastweekenddate);
|
|
248
|
+ this.changeDate([lastweekstartdate, lastweekenddate]);
|
|
249
|
+ break;
|
|
250
|
+ case "2":
|
|
251
|
+ // 上月
|
|
252
|
+ let lastmonthstartdate = this.dateService.date().lastMonthStartDate;
|
|
253
|
+ let lastmonthenddate = this.dateService.date().lastMonthEndDate;
|
|
254
|
+ console.log(lastmonthstartdate, lastmonthenddate);
|
|
255
|
+ this.changeDate([lastmonthstartdate, lastmonthenddate]);
|
|
256
|
+ break;
|
|
257
|
+ case "3":
|
|
258
|
+ // 上年
|
|
259
|
+ let lastyearstartdate = this.dateService.date().lastYearStartDate;
|
|
260
|
+ let lastyearenddate = this.dateService.date().lastYearEndDate;
|
|
261
|
+ console.log(lastyearstartdate, lastyearenddate);
|
|
262
|
+ this.changeDate([lastyearstartdate, lastyearenddate]);
|
|
263
|
+ break;
|
|
264
|
+ }
|
|
265
|
+ this.quick = false;
|
|
266
|
+ }
|
|
267
|
+
|
|
268
|
+ // 更多
|
|
269
|
+ toMore(type) {
|
|
270
|
+ let sendData = this.searchData;
|
|
271
|
+ console.log(sendData);
|
|
272
|
+ this.myService.sendMsg(sendData);
|
|
273
|
+ this.router.navigateByUrl("/main/" + type);
|
|
274
|
+ }
|
|
275
|
+
|
|
276
|
+ // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
|
|
277
|
+ showPromptModal(con, success, promptInfo?) {
|
|
278
|
+ this.promptModalShow = false;
|
|
279
|
+ this.promptContent = con;
|
|
280
|
+ this.ifSuccess = success;
|
|
281
|
+ this.promptInfo = promptInfo;
|
|
282
|
+ setTimeout(() => {
|
|
283
|
+ this.promptModalShow = true;
|
|
284
|
+ }, 100);
|
|
285
|
+ }
|
|
286
|
+
|
|
287
|
+ // 边输入边搜索节流阀
|
|
288
|
+ searchTimer(fun, e, those) {
|
|
289
|
+ fun(e, those);
|
|
290
|
+ }
|
|
291
|
+
|
|
292
|
+ // 截取意见内容(ie内核截取)
|
|
293
|
+ spliceContent(con) {
|
|
294
|
+ if (con.length >= 41 && navigator.userAgent.indexOf("Trident") > -1) {
|
|
295
|
+ return con.slice(0, 20) + "...";
|
|
296
|
+ } else {
|
|
297
|
+ return con;
|
|
298
|
+ }
|
|
299
|
+ }
|
|
300
|
+ //获取支助人员工单详情列表
|
|
301
|
+ personDetail(workerId) {
|
|
302
|
+ let startDate = this.startDate + " " + "00:00:00";
|
|
303
|
+ let endDate = this.endDate + " " + "23:59:59";
|
|
304
|
+ let group = this.group || "null";
|
|
305
|
+ this.router.navigateByUrl(
|
|
306
|
+ `/main/workerStatistics/workerStatisticsDetail/${workerId}/${startDate}/${endDate}/${group}`
|
|
307
|
+ );
|
|
308
|
+ }
|
|
309
|
+}
|