|
@@ -12,6 +12,8 @@ import { OverlayScrollbarsComponent } from "overlayscrollbars-ngx";
|
12
|
12
|
import { ToolService } from "../../services/tool.service";
|
13
|
13
|
import { format } from "date-fns";
|
14
|
14
|
import { NzMessageService } from "ng-zorro-antd";
|
|
15
|
+import { Subject } from "rxjs";
|
|
16
|
+import { debounceTime } from "rxjs/operators";
|
15
|
17
|
|
16
|
18
|
@Component({
|
17
|
19
|
selector: "app-office-management",
|
|
@@ -34,6 +36,14 @@ export class OfficeManagementComponent implements OnInit {
|
34
|
36
|
) {}
|
35
|
37
|
|
36
|
38
|
ngOnInit() {
|
|
39
|
+ this.searchParentDeptSubject.pipe(debounceTime(500)).subscribe((v: any) => {
|
|
40
|
+ this.getAllParentdepart(v).subscribe((result) => {
|
|
41
|
+ this.isLoading = false;
|
|
42
|
+ if (result.status == 200) {
|
|
43
|
+ this.allParentdepart = result.list;
|
|
44
|
+ }
|
|
45
|
+ });
|
|
46
|
+ });
|
37
|
47
|
this.coopBtns = this.tool.initCoopBtns(this.route);
|
38
|
48
|
this.initForm();
|
39
|
49
|
this.getAllHospital();
|
|
@@ -62,9 +72,44 @@ export class OfficeManagementComponent implements OnInit {
|
62
|
72
|
deptPhones: any = []; //新添加的科室电话列表
|
63
|
73
|
isAddDeptsPhone = true; //添加新的科室电话是否禁用
|
64
|
74
|
deptsPhoneId = 1; //科室电话自增id
|
65
|
|
-
|
|
75
|
+ allParentdepart: any = []; //所有的父级科室列表
|
|
76
|
+ searchParentDeptSubject = new Subject();
|
66
|
77
|
// 初始化增删改按钮
|
67
|
78
|
coopBtns: any = {};
|
|
79
|
+ //搜索父级科室
|
|
80
|
+ changeInp(e) {
|
|
81
|
+ this.isLoading = true;
|
|
82
|
+ this.searchParentDeptSubject.next(e);
|
|
83
|
+ }
|
|
84
|
+ // 打开父级科室下拉框baba
|
|
85
|
+ isLoading = false;
|
|
86
|
+ openDeptSelect(flag) {
|
|
87
|
+ if (flag) {
|
|
88
|
+ this.isLoading = true;
|
|
89
|
+ this.getAllParentdepart().subscribe((result) => {
|
|
90
|
+ this.isLoading = false;
|
|
91
|
+ if (result.status == 200) {
|
|
92
|
+ this.allParentdepart = result.list;
|
|
93
|
+ }
|
|
94
|
+ });
|
|
95
|
+ }
|
|
96
|
+ }
|
|
97
|
+ //获取所有的父级科室列表baba
|
|
98
|
+ getAllParentdepart(keyWord = "") {
|
|
99
|
+ let postData: any = {
|
|
100
|
+ idx: 0,
|
|
101
|
+ sum: 10,
|
|
102
|
+ department: {
|
|
103
|
+ hospital: { id: this.hospital },
|
|
104
|
+ keyWord: keyWord,
|
|
105
|
+ },
|
|
106
|
+ };
|
|
107
|
+ if (this.coopItem) {
|
|
108
|
+ // 过滤这个科室及其子科室
|
|
109
|
+ postData.department.filterByDeptId = this.coopItem.id;
|
|
110
|
+ }
|
|
111
|
+ return this.mainService.getFetchDataList("data", "department", postData);
|
|
112
|
+ }
|
68
|
113
|
// 新添加科室号码
|
69
|
114
|
addDeptPhone(e: MouseEvent) {
|
70
|
115
|
e.preventDefault();
|
|
@@ -251,6 +296,7 @@ export class OfficeManagementComponent implements OnInit {
|
251
|
296
|
this.deptPhones = [];
|
252
|
297
|
}
|
253
|
298
|
hideModal() {
|
|
299
|
+ this.coopItem = null;
|
254
|
300
|
this.modal = false;
|
255
|
301
|
this.initForm();
|
256
|
302
|
}
|
|
@@ -265,6 +311,7 @@ export class OfficeManagementComponent implements OnInit {
|
265
|
311
|
this.startTime2Hourdis = () => [];
|
266
|
312
|
this.startTime2Mindis = () => [];
|
267
|
313
|
this.validateForm = this.fb.group({
|
|
314
|
+ parentOfficeName: [null],
|
268
|
315
|
officeName: [null, [Validators.required]],
|
269
|
316
|
deptalias: [null],
|
270
|
317
|
officeNo: [null, [Validators.required]],
|
|
@@ -356,7 +403,7 @@ export class OfficeManagementComponent implements OnInit {
|
356
|
403
|
console.log(that.validateForm);
|
357
|
404
|
if (that.validateForm.invalid) return;
|
358
|
405
|
let deptsPhone = this.deptPhones.map((item) => item.phone).join();
|
359
|
|
- let data = {
|
|
406
|
+ let data: any = {
|
360
|
407
|
department: {
|
361
|
408
|
dept: that.validateForm.value.officeName,
|
362
|
409
|
deptalias: that.validateForm.value.deptalias,
|
|
@@ -371,6 +418,9 @@ export class OfficeManagementComponent implements OnInit {
|
371
|
418
|
type: { id: that.validateForm.value.officeType },
|
372
|
419
|
},
|
373
|
420
|
};
|
|
421
|
+ if (this.validateForm.value.parentOfficeName) {
|
|
422
|
+ data.department.parent = { id: this.validateForm.value.parentOfficeName };
|
|
423
|
+ }
|
374
|
424
|
if (
|
375
|
425
|
this.validateForm.value.startTime1 ||
|
376
|
426
|
this.validateForm.value.endTime1
|
|
@@ -430,10 +480,12 @@ export class OfficeManagementComponent implements OnInit {
|
430
|
480
|
}
|
431
|
481
|
|
432
|
482
|
// 编辑
|
|
483
|
+ coopItem: any = null;
|
433
|
484
|
edit(e, data) {
|
434
|
485
|
e.stopPropagation();
|
435
|
486
|
this.add = false;
|
436
|
487
|
this.coopId = data.id;
|
|
488
|
+ this.coopItem = data;
|
437
|
489
|
this.isAddDeptsPhone = false;
|
438
|
490
|
this.deptPhones = [];
|
439
|
491
|
let phones = data.manyPhone ? data.manyPhone.split(",") : [];
|
|
@@ -461,6 +513,14 @@ export class OfficeManagementComponent implements OnInit {
|
461
|
513
|
this.validateForm.controls.endTime2.setValue(new Date(data.endTime2));
|
462
|
514
|
}
|
463
|
515
|
this.validateForm.controls.officeAddress.setValue(data.address);
|
|
516
|
+ if (data.parent) {
|
|
517
|
+ this.getAllParentdepart(data.parent.dept).subscribe((res) => {
|
|
518
|
+ if (res.status == 200) {
|
|
519
|
+ this.allParentdepart = res.list;
|
|
520
|
+ this.validateForm.controls.parentOfficeName.setValue(data.parent.id);
|
|
521
|
+ }
|
|
522
|
+ });
|
|
523
|
+ }
|
464
|
524
|
this.validateForm.controls.officeName.setValue(data.dept);
|
465
|
525
|
this.validateForm.controls.deptalias.setValue(data.deptalias);
|
466
|
526
|
this.validateForm.controls.officeNo.setValue(data.pcode);
|