|
@@ -0,0 +1,443 @@
|
|
1
|
+import { Component, OnInit } from "@angular/core";
|
|
2
|
+import { ActivatedRoute, Router } from "@angular/router";
|
|
3
|
+
|
|
4
|
+import { MainService } from "../../services/main.service";
|
|
5
|
+import { ToolService } from "../../services/tool.service";
|
|
6
|
+import { Subject } from "rxjs";
|
|
7
|
+import { debounceTime } from "rxjs/operators";
|
|
8
|
+import { NzMessageService } from 'ng-zorro-antd/message';
|
|
9
|
+import { format } from 'date-fns';
|
|
10
|
+import { FormGroup, Validators, FormBuilder } from '@angular/forms';
|
|
11
|
+@Component({
|
|
12
|
+ selector: "app-incident-management",
|
|
13
|
+ templateUrl: "./incident-management.component.html",
|
|
14
|
+ styleUrls: ["./incident-management.component.less"],
|
|
15
|
+})
|
|
16
|
+export class IncidentManagementComponent implements OnInit {
|
|
17
|
+ constructor(
|
|
18
|
+ public route: ActivatedRoute,
|
|
19
|
+ private router: Router,
|
|
20
|
+ private mainService: MainService,
|
|
21
|
+ private tool: ToolService,
|
|
22
|
+ private message: NzMessageService,
|
|
23
|
+ private fb: FormBuilder,
|
|
24
|
+ ) {}
|
|
25
|
+ loginUser: any = localStorage.getItem("user")
|
|
26
|
+ ? JSON.parse(localStorage.getItem("user")).user
|
|
27
|
+ : null; //登录人信息
|
|
28
|
+ listOfData: any[] = []; //表格数据
|
|
29
|
+ coopId: string; //表格中执行操作的id
|
|
30
|
+ hospital: string; //选中院区
|
|
31
|
+ alldepart: any = []; //当前院区所属科室
|
|
32
|
+ worker: number; //选择执行配送人员
|
|
33
|
+ allWorker: any = []; //当前院区执行配送人员列表
|
|
34
|
+ gdState: number; //选择工单状态
|
|
35
|
+ gdStates: any; //工单状态列表
|
|
36
|
+ pageIndex: number = 1; //页码
|
|
37
|
+ listLength: number = 10; //总条数
|
|
38
|
+ pageSize: number = 10; //每页条数
|
|
39
|
+
|
|
40
|
+ promptContent: string; //操作提示框提示信息
|
|
41
|
+ ifSuccess: boolean; //操作成功/失败
|
|
42
|
+ promptInfo: string; //操作结果提示信息
|
|
43
|
+ promptModalShow: boolean; //操作提示框是否展示
|
|
44
|
+
|
|
45
|
+ btnLoading: boolean = false; //提交按钮loading状态
|
|
46
|
+
|
|
47
|
+ tabs:any[] = [
|
|
48
|
+ // {key: 'all', value: '全部故障', num: 0},
|
|
49
|
+ {key: 'todo', value: '待我接单', num: 0},
|
|
50
|
+ {key: 'doing', value: '待我处理', num: 0},
|
|
51
|
+ // {key: 'reassign', value: '重新指派', num: 0},
|
|
52
|
+ // {key: 'callback', value: '待我回访', num: 0},
|
|
53
|
+ {key: 'resolve', value: '由我解决', num: 0},
|
|
54
|
+ {key: 'owns', value: '与我关联', num: 0},
|
|
55
|
+ {key: 'storage', value: '暂存', num: 0},
|
|
56
|
+ // {key: 'badEvaluate', value: '异常评价', num: 0},
|
|
57
|
+ ]
|
|
58
|
+
|
|
59
|
+ searchDTO: any = {};
|
|
60
|
+
|
|
61
|
+ searchTimerSubject = new Subject();
|
|
62
|
+
|
|
63
|
+ // 初始化增删改按钮
|
|
64
|
+ coopBtns: any = {};
|
|
65
|
+
|
|
66
|
+ // 选择tab
|
|
67
|
+ queryTask:string = 'todo';//默认待我接单
|
|
68
|
+ changeTab(key){
|
|
69
|
+ this.queryTask = key;
|
|
70
|
+ }
|
|
71
|
+
|
|
72
|
+ ngOnInit() {
|
|
73
|
+ this.searchTimerSubject.pipe(debounceTime(500)).subscribe((v) => {
|
|
74
|
+ let fun = v[0];
|
|
75
|
+ fun.call(this, v[1]);
|
|
76
|
+ });
|
|
77
|
+ this.coopBtns = this.tool.initCoopBtns(this.route);
|
|
78
|
+ this.initTabs();
|
|
79
|
+ this.getAllHos();
|
|
80
|
+ this.getGdStates();
|
|
81
|
+ }
|
|
82
|
+
|
|
83
|
+ // 初始化tab
|
|
84
|
+ initTabs(){
|
|
85
|
+ if (this.coopBtns.all) {
|
|
86
|
+ this.tabs.splice(0, 0 , {key: 'all', value: '全部故障', num: 0});
|
|
87
|
+ }
|
|
88
|
+ if (this.coopBtns.callback) {
|
|
89
|
+ let index = this.tabs.findIndex(v => v.key == 'resolve');
|
|
90
|
+ this.tabs.splice(index, 0 , {key: 'callback', value: '待我回访', num: 0});
|
|
91
|
+ }
|
|
92
|
+ if (this.coopBtns.reassign) {
|
|
93
|
+ let index = this.tabs.findIndex(v => v.key == 'doing');
|
|
94
|
+ this.tabs.splice(index + 1, 0 , {key: 'reassign', value: '重新指派', num: 0});
|
|
95
|
+ }
|
|
96
|
+ if (this.coopBtns.badEvaluate) {
|
|
97
|
+ this.tabs.push({key: 'badEvaluate', value: '异常评价', num: 0});
|
|
98
|
+ }
|
|
99
|
+ }
|
|
100
|
+
|
|
101
|
+ // 搜索
|
|
102
|
+ search() {
|
|
103
|
+ this.pageIndex = 1;
|
|
104
|
+ this.getList();
|
|
105
|
+ }
|
|
106
|
+ // 重置
|
|
107
|
+ reset() {
|
|
108
|
+ this.pageIndex = 1;
|
|
109
|
+ if (!(this.coopBtns.currentDept && !this.coopBtns.allOrders)) {
|
|
110
|
+ this.searchDTO.department = null;
|
|
111
|
+ }
|
|
112
|
+ if (!(this.coopBtns.currentUser && !this.coopBtns.allOrders)) {
|
|
113
|
+ this.worker = null;
|
|
114
|
+ }
|
|
115
|
+ this.gdState = null;
|
|
116
|
+ this.searchDTO = {};
|
|
117
|
+ this.changeDate();
|
|
118
|
+ this.getList();
|
|
119
|
+ }
|
|
120
|
+
|
|
121
|
+ // 获取院区
|
|
122
|
+ getAllHos() {
|
|
123
|
+ this.hospital = this.tool.getCurrentHospital().id + "";
|
|
124
|
+ this.changeHos();
|
|
125
|
+ }
|
|
126
|
+ // 修改院区获取对应科室,工单类型,执行配送人员
|
|
127
|
+ changeHos() {
|
|
128
|
+ this.searchDTO.department = null;
|
|
129
|
+ this.worker = null;
|
|
130
|
+ this.getDeparts();
|
|
131
|
+ this.getAllWorker();
|
|
132
|
+ }
|
|
133
|
+
|
|
134
|
+ // 获取配送人员
|
|
135
|
+ getAllWorker(e?, those?) {
|
|
136
|
+ let that = those || this;
|
|
137
|
+ let postData = {
|
|
138
|
+ user: {
|
|
139
|
+ name: e || "",
|
|
140
|
+ hospital: { id: that.hospital },
|
|
141
|
+ usertype: { id: 106 }, //配送人员
|
|
142
|
+ },
|
|
143
|
+ idx: 0,
|
|
144
|
+ sum: 20,
|
|
145
|
+ };
|
|
146
|
+ that.isLoading = true;
|
|
147
|
+ that.mainService
|
|
148
|
+ .getFetchDataList("data", "user", postData)
|
|
149
|
+ .subscribe((data) => {
|
|
150
|
+ that.allWorker = data.list;
|
|
151
|
+ that.isLoading = false;
|
|
152
|
+ });
|
|
153
|
+ }
|
|
154
|
+
|
|
155
|
+ onCalendarChangeDate(dateArr){
|
|
156
|
+ console.log(dateArr)
|
|
157
|
+ if(dateArr.length == 2){
|
|
158
|
+ let dateStart = new Date(dateArr[0]);
|
|
159
|
+ let dateEnd = new Date(dateArr[1]);
|
|
160
|
+ dateStart.setHours(0,0,0);
|
|
161
|
+ dateEnd.setHours(23,59,59);
|
|
162
|
+ this.searchDTO.dateRange = [dateStart,dateEnd];
|
|
163
|
+ }
|
|
164
|
+ }
|
|
165
|
+ // 表格数据
|
|
166
|
+ loading1 = false;
|
|
167
|
+ getList() {
|
|
168
|
+ var that = this;
|
|
169
|
+ let data: any = {
|
|
170
|
+ idx: that.pageIndex - 1,
|
|
171
|
+ sum: that.pageSize,
|
|
172
|
+ workOrder: {
|
|
173
|
+ worker: { id: that.worker },
|
|
174
|
+ gdState: { id: that.gdState },
|
|
175
|
+ gdcode: this.searchDTO.gdcode,
|
|
176
|
+ createDept: that.searchDTO.department,
|
|
177
|
+ hosId: that.hospital,
|
|
178
|
+ },
|
|
179
|
+ };
|
|
180
|
+
|
|
181
|
+ if (!data.workOrder.worker.id) {
|
|
182
|
+ delete data.workOrder.worker;
|
|
183
|
+ }
|
|
184
|
+ if (!data.workOrder.gdState.id) {
|
|
185
|
+ delete data.workOrder.gdState;
|
|
186
|
+ }
|
|
187
|
+ if (
|
|
188
|
+ data.workOrder.specialCloseFlag === undefined ||
|
|
189
|
+ data.workOrder.specialCloseFlag === null
|
|
190
|
+ ) {
|
|
191
|
+ delete data.workOrder.specialCloseFlag;
|
|
192
|
+ }
|
|
193
|
+ if (!data.workOrder.createDept) {
|
|
194
|
+ delete data.workOrder.createDept;
|
|
195
|
+ }
|
|
196
|
+ delete data.workOrder.overdueTime24;
|
|
197
|
+ delete data.workOrder.startTime1;
|
|
198
|
+ delete data.workOrder.endTime1;
|
|
199
|
+ if (false) {
|
|
200
|
+ data.workOrder.overdueTime24 = true;
|
|
201
|
+ } else if (that.startDate && that.endDate) {
|
|
202
|
+ data.workOrder.startTime1 = that.startDate;
|
|
203
|
+ data.workOrder.endTime1 = that.endDate;
|
|
204
|
+ }
|
|
205
|
+ that.loading1 = true;
|
|
206
|
+ that.mainService
|
|
207
|
+ .getFetchDataList("data", "workOrder", data)
|
|
208
|
+ .subscribe((result) => {
|
|
209
|
+ that.loading1 = false;
|
|
210
|
+ that.listOfData = result.list.map(v => ({...v, endDeptsName: v.endDepts ? v.endDepts.map(v => v.dept).toString() : ''}));
|
|
211
|
+ that.listLength = result.totalNum;
|
|
212
|
+ });
|
|
213
|
+ }
|
|
214
|
+
|
|
215
|
+ // 获取所有科室
|
|
216
|
+ getDeparts(dept?) {
|
|
217
|
+ let data = {
|
|
218
|
+ department: {
|
|
219
|
+ cascadeHosId: this.hospital,
|
|
220
|
+ dept: dept,
|
|
221
|
+ },
|
|
222
|
+ idx: 0,
|
|
223
|
+ sum: 20,
|
|
224
|
+ };
|
|
225
|
+ this.isLoading = true;
|
|
226
|
+ this.mainService
|
|
227
|
+ .getFetchDataList("data", "department", data)
|
|
228
|
+ .subscribe((data) => {
|
|
229
|
+ this.alldepart = data.list;
|
|
230
|
+ this.isLoading = false;
|
|
231
|
+ if (dept === undefined && this.coopBtns.currentDept && !this.coopBtns.allOrders) {
|
|
232
|
+ // 初次渲染,权限有当前科室工单,没有全部工单,则回显申请科室
|
|
233
|
+ this.alldepart = [this.loginUser.dept];
|
|
234
|
+ this.searchDTO.department = this.loginUser.dept.id;
|
|
235
|
+ }
|
|
236
|
+ if (dept === undefined && this.coopBtns.currentUser && !this.coopBtns.allOrders) {
|
|
237
|
+ // 初次渲染,权限有当前人员工单,没有全部工单,则回显执行配送人员
|
|
238
|
+ this.allWorker = [this.loginUser];
|
|
239
|
+ this.worker = this.loginUser.id;
|
|
240
|
+ }
|
|
241
|
+ this.getList();
|
|
242
|
+ });
|
|
243
|
+ }
|
|
244
|
+
|
|
245
|
+ // 获取工单状态
|
|
246
|
+ getGdStates() {
|
|
247
|
+ var that = this;
|
|
248
|
+ that.mainService.getDictionary("list", "gdstate").subscribe((data) => {
|
|
249
|
+ that.gdStates = data;
|
|
250
|
+ });
|
|
251
|
+ }
|
|
252
|
+
|
|
253
|
+ // 日期选择
|
|
254
|
+ startDate: string; //发起时间开始
|
|
255
|
+ endDate: string; //发起时间结束
|
|
256
|
+ changeDate(result?): void {
|
|
257
|
+ if (!result) {
|
|
258
|
+ this.startDate = this.endDate = "";
|
|
259
|
+ return;
|
|
260
|
+ }
|
|
261
|
+ this.startDate = format(result[0], 'yyyy-MM-dd HH:mm:ss');
|
|
262
|
+ this.endDate = format(result[1], 'yyyy-MM-dd HH:mm:ss');
|
|
263
|
+ }
|
|
264
|
+
|
|
265
|
+ // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
|
|
266
|
+ showPromptModal(con, success, promptInfo?) {
|
|
267
|
+ this.promptModalShow = false;
|
|
268
|
+ this.promptContent = con;
|
|
269
|
+ this.ifSuccess = success;
|
|
270
|
+ this.promptInfo = promptInfo;
|
|
271
|
+ setTimeout(() => {
|
|
272
|
+ this.promptModalShow = true;
|
|
273
|
+ }, 100);
|
|
274
|
+ this.getList();
|
|
275
|
+ }
|
|
276
|
+
|
|
277
|
+ // 查看
|
|
278
|
+ detail(e, id) {
|
|
279
|
+ e.stopPropagation();
|
|
280
|
+ this.router.navigateByUrl("/main/orderManagement/orderDetail/" + id);
|
|
281
|
+ }
|
|
282
|
+
|
|
283
|
+ //删除
|
|
284
|
+ loading3 = false;
|
|
285
|
+ delModal: boolean = false; //删除模态框
|
|
286
|
+ showDelModal(e, id) {
|
|
287
|
+ e.stopPropagation();
|
|
288
|
+ this.delModal = true;
|
|
289
|
+ this.coopId = id + "";
|
|
290
|
+ }
|
|
291
|
+ hideDelModal() {
|
|
292
|
+ this.delModal = false;
|
|
293
|
+ }
|
|
294
|
+ confirmDel() {
|
|
295
|
+ this.loading3 = true;
|
|
296
|
+ this.mainService[this.coopId.includes(",") ? "delOrders" : "delOrder"](
|
|
297
|
+ this.coopId
|
|
298
|
+ ).subscribe((data) => {
|
|
299
|
+ this.loading3 = false;
|
|
300
|
+ this.delModal = false;
|
|
301
|
+ if (data.status == 200) {
|
|
302
|
+ if (
|
|
303
|
+ this.listOfData.length == 1 &&
|
|
304
|
+ this.pageIndex == Math.ceil(this.listLength / this.pageSize)
|
|
305
|
+ ) {
|
|
306
|
+ this.listLength--;
|
|
307
|
+ this.pageIndex = Math.ceil(this.listLength / this.pageSize);
|
|
308
|
+ }
|
|
309
|
+ this.showPromptModal("删除", true, "");
|
|
310
|
+ } else {
|
|
311
|
+ this.showPromptModal("删除", false, data.msg);
|
|
312
|
+ }
|
|
313
|
+ });
|
|
314
|
+ }
|
|
315
|
+
|
|
316
|
+ // 导出
|
|
317
|
+ loading2 = false;
|
|
318
|
+ export() {
|
|
319
|
+ // 有备注,无发起时间则提示
|
|
320
|
+ if(!this.searchDTO.dateRange.length){
|
|
321
|
+ this.message.info('请选择发起时间!');
|
|
322
|
+ return;
|
|
323
|
+ }
|
|
324
|
+ // 三个权限都没有,则不展示
|
|
325
|
+ if(!this.coopBtns.currentDept && !this.coopBtns.currentUser && !this.coopBtns.allOrders){
|
|
326
|
+ return;
|
|
327
|
+ }
|
|
328
|
+ let that = this;
|
|
329
|
+ let postData: any = {
|
|
330
|
+ idx: that.pageIndex - 1,
|
|
331
|
+ sum: that.pageSize,
|
|
332
|
+ workOrder: {
|
|
333
|
+ worker: { id: that.worker },
|
|
334
|
+ gdState: { id: that.gdState },
|
|
335
|
+ gdcode: this.searchDTO.gdcode,
|
|
336
|
+ createDept: that.searchDTO.department,
|
|
337
|
+ hosId: that.hospital,
|
|
338
|
+ },
|
|
339
|
+ };
|
|
340
|
+
|
|
341
|
+ if (!postData.workOrder.worker.id) {
|
|
342
|
+ delete postData.workOrder.worker;
|
|
343
|
+ }
|
|
344
|
+ if (!postData.workOrder.gdState.id) {
|
|
345
|
+ delete postData.workOrder.gdState;
|
|
346
|
+ }
|
|
347
|
+ if (
|
|
348
|
+ postData.workOrder.specialCloseFlag === undefined ||
|
|
349
|
+ postData.workOrder.specialCloseFlag === null
|
|
350
|
+ ) {
|
|
351
|
+ delete postData.workOrder.specialCloseFlag;
|
|
352
|
+ }
|
|
353
|
+ if (!postData.workOrder.createDept) {
|
|
354
|
+ delete postData.workOrder.createDept;
|
|
355
|
+ }
|
|
356
|
+ delete postData.workOrder.overdueTime24;
|
|
357
|
+ delete postData.workOrder.startTime1;
|
|
358
|
+ delete postData.workOrder.endTime1;
|
|
359
|
+ if (false) {
|
|
360
|
+ postData.workOrder.overdueTime24 = true;
|
|
361
|
+ } else if (that.startDate && that.endDate) {
|
|
362
|
+ postData.workOrder.startTime1 = that.startDate;
|
|
363
|
+ postData.workOrder.endTime1 = that.endDate;
|
|
364
|
+ }
|
|
365
|
+ this.loading2 = true;
|
|
366
|
+ that.mainService.dataExport("workOrder", postData).subscribe(
|
|
367
|
+ (data) => {
|
|
368
|
+ this.loading2 = false;
|
|
369
|
+ this.showPromptModal("导出", true, "");
|
|
370
|
+ var file = new Blob([data], {
|
|
371
|
+ type: "application/vnd.ms-excel",
|
|
372
|
+ });
|
|
373
|
+ //trick to download store a file having its URL
|
|
374
|
+ var fileURL = URL.createObjectURL(file);
|
|
375
|
+ var a = document.createElement("a");
|
|
376
|
+ a.href = fileURL;
|
|
377
|
+ a.target = "_blank";
|
|
378
|
+ a.download = "工单列表.xls";
|
|
379
|
+ document.body.appendChild(a);
|
|
380
|
+ a.click();
|
|
381
|
+ },
|
|
382
|
+ (err) => {
|
|
383
|
+ this.loading2 = false;
|
|
384
|
+ this.showPromptModal("导出", false, "");
|
|
385
|
+ }
|
|
386
|
+ );
|
|
387
|
+ }
|
|
388
|
+
|
|
389
|
+ // 申请科室边输边搜节流阀
|
|
390
|
+ isLoading = false;
|
|
391
|
+ changeInp(e) {
|
|
392
|
+ this.searchTimer(this.getDeparts, e);
|
|
393
|
+ }
|
|
394
|
+
|
|
395
|
+ // 用户输入搜索配送人员
|
|
396
|
+ changeUser(e) {
|
|
397
|
+ this.searchTimer(this.getAllWorker, e);
|
|
398
|
+ }
|
|
399
|
+
|
|
400
|
+ // 边输入边搜索节流阀
|
|
401
|
+ searchTimer(fun, e) {
|
|
402
|
+ this.isLoading = true;
|
|
403
|
+ this.searchTimerSubject.next([fun, e]);
|
|
404
|
+ }
|
|
405
|
+
|
|
406
|
+ // 截取意见内容(ie内核截取)
|
|
407
|
+ spliceContent(con) {
|
|
408
|
+ if (con.length >= 41 && navigator.userAgent.indexOf("Trident") > -1) {
|
|
409
|
+ return con.slice(0, 20) + "...";
|
|
410
|
+ } else {
|
|
411
|
+ return con;
|
|
412
|
+ }
|
|
413
|
+ }
|
|
414
|
+
|
|
415
|
+ // 详细搜索
|
|
416
|
+ searchModal: boolean = false; //新增/编辑模态框
|
|
417
|
+ modelName = ""; //模态框名称
|
|
418
|
+ add: boolean; //true:新增;false:编辑
|
|
419
|
+ validateSearchForm: FormGroup; //新增/编辑表单
|
|
420
|
+ coopData: any; //当前操作列
|
|
421
|
+ // 新增弹框
|
|
422
|
+ addModal() {
|
|
423
|
+ this.modelName = "新增";
|
|
424
|
+ this.add = true; //新增
|
|
425
|
+ this.searchModal = true;
|
|
426
|
+ this.initSearchForm();
|
|
427
|
+ }
|
|
428
|
+ //关闭新增/编辑弹框
|
|
429
|
+ hideAddModal() {
|
|
430
|
+ this.searchModal = false;
|
|
431
|
+ this.initSearchForm();
|
|
432
|
+ }
|
|
433
|
+
|
|
434
|
+ // 初始化新增form表单
|
|
435
|
+ initSearchForm() {
|
|
436
|
+ this.validateSearchForm = this.fb.group({
|
|
437
|
+ subType: [null],
|
|
438
|
+ description: [''],
|
|
439
|
+ supplierIds: [[]],
|
|
440
|
+ manufacturerIds: [[]],
|
|
441
|
+ });
|
|
442
|
+ }
|
|
443
|
+}
|