|
@@ -9,6 +9,8 @@ import { ActivatedRoute } from "@angular/router";
|
9
|
9
|
|
10
|
10
|
import { MainService } from "../../services/main.service";
|
11
|
11
|
import { ToolService } from "src/app/services/tool.service";
|
|
12
|
+import { Subject } from 'rxjs';
|
|
13
|
+import { debounceTime } from 'rxjs/operators';
|
12
|
14
|
|
13
|
15
|
@Component({
|
14
|
16
|
selector: "app-hospital-management",
|
|
@@ -24,6 +26,14 @@ export class HospitalManagementComponent implements OnInit {
|
24
|
26
|
) {}
|
25
|
27
|
|
26
|
28
|
ngOnInit() {
|
|
29
|
+ this.searchParentHospitalSubject.pipe(debounceTime(500)).subscribe((v: any) => {
|
|
30
|
+ this.getAllParentHospital(v).subscribe((result) => {
|
|
31
|
+ this.isLoading = false;
|
|
32
|
+ if (result.status == 200) {
|
|
33
|
+ this.parentHospitals = result.list;
|
|
34
|
+ }
|
|
35
|
+ });
|
|
36
|
+ });
|
27
|
37
|
this.coopBtns = this.tool.initCoopBtns(this.route);
|
28
|
38
|
this.getList();
|
29
|
39
|
this.initForm();
|
|
@@ -51,6 +61,42 @@ export class HospitalManagementComponent implements OnInit {
|
51
|
61
|
|
52
|
62
|
// 初始化增删改按钮
|
53
|
63
|
coopBtns: any = {};
|
|
64
|
+ //所有院区
|
|
65
|
+ parentHospitals: any = [];
|
|
66
|
+ searchParentHospitalSubject = new Subject();
|
|
67
|
+ //搜索父级院区
|
|
68
|
+ changeInp(e) {
|
|
69
|
+ this.isLoading = true;
|
|
70
|
+ this.searchParentHospitalSubject.next(e);
|
|
71
|
+ }
|
|
72
|
+ // 打开父级科室下拉框
|
|
73
|
+ isLoading = false;
|
|
74
|
+ openHospitalSelect(flag) {
|
|
75
|
+ if (flag) {
|
|
76
|
+ this.isLoading = true;
|
|
77
|
+ this.getAllParentHospital().subscribe((result) => {
|
|
78
|
+ this.isLoading = false;
|
|
79
|
+ if (result.status == 200) {
|
|
80
|
+ this.parentHospitals = result.list;
|
|
81
|
+ }
|
|
82
|
+ });
|
|
83
|
+ }
|
|
84
|
+ }
|
|
85
|
+ //获取所有的父级院区列表
|
|
86
|
+ getAllParentHospital(keyWord = "") {
|
|
87
|
+ let postData: any = {
|
|
88
|
+ idx: 0,
|
|
89
|
+ sum: 10,
|
|
90
|
+ hospital: {
|
|
91
|
+ keyWord: keyWord,
|
|
92
|
+ },
|
|
93
|
+ };
|
|
94
|
+ if (this.coopId) {
|
|
95
|
+ // 过滤这个院区及其子院区
|
|
96
|
+ postData.hospital.filterByDeptId = this.coopId;
|
|
97
|
+ }
|
|
98
|
+ return this.mainService.getFetchDataList("data", "hospital", postData);
|
|
99
|
+ }
|
54
|
100
|
|
55
|
101
|
// 表格数据
|
56
|
102
|
loading1 = false;
|
|
@@ -72,6 +118,7 @@ export class HospitalManagementComponent implements OnInit {
|
72
|
118
|
addModal() {
|
73
|
119
|
this.add = true;
|
74
|
120
|
this.modal = true;
|
|
121
|
+ this.validateForm.controls.parentHospital.setValue("");
|
75
|
122
|
this.validateForm.controls.hospitalName.setValue("");
|
76
|
123
|
this.validateForm.controls.hospitalNum.setValue("");
|
77
|
124
|
}
|
|
@@ -123,6 +170,7 @@ export class HospitalManagementComponent implements OnInit {
|
123
|
170
|
// 初始化新增form表单
|
124
|
171
|
initForm() {
|
125
|
172
|
this.validateForm = this.fb.group({
|
|
173
|
+ parentHospital: [null],
|
126
|
174
|
hospitalName: [null, [Validators.required]],
|
127
|
175
|
hospitalNum: [null, [Validators.required]],
|
128
|
176
|
});
|
|
@@ -137,12 +185,15 @@ export class HospitalManagementComponent implements OnInit {
|
137
|
185
|
}
|
138
|
186
|
if (that.validateForm.invalid) return;
|
139
|
187
|
that.btnLoading = true;
|
140
|
|
- let data = {
|
|
188
|
+ let data: any = {
|
141
|
189
|
hospital: {
|
142
|
190
|
hosName: that.validateForm.value.hospitalName,
|
143
|
191
|
hosNo: that.validateForm.value.hospitalNum,
|
144
|
192
|
},
|
145
|
193
|
};
|
|
194
|
+ if (this.validateForm.value.parentHospital) {
|
|
195
|
+ data.hospital.parent = { id: this.validateForm.value.parentHospital };
|
|
196
|
+ }
|
146
|
197
|
if (!that.add) {
|
147
|
198
|
data.hospital["id"] = that.coopId;
|
148
|
199
|
}
|
|
@@ -165,6 +216,14 @@ export class HospitalManagementComponent implements OnInit {
|
165
|
216
|
this.add = false;
|
166
|
217
|
this.modal = true;
|
167
|
218
|
this.coopId = data.id;
|
|
219
|
+ if (data.parent) {
|
|
220
|
+ this.getAllParentHospital(data.parent.dept).subscribe((res) => {
|
|
221
|
+ if (res.status == 200) {
|
|
222
|
+ this.parentHospitals = res.list;
|
|
223
|
+ this.validateForm.controls.parentHospital.setValue(data.parent.id);
|
|
224
|
+ }
|
|
225
|
+ });
|
|
226
|
+ }
|
168
|
227
|
this.validateForm.controls.hospitalName.setValue(data.hosName);
|
169
|
228
|
this.validateForm.controls.hospitalNum.setValue(data.hosNo);
|
170
|
229
|
}
|