|
@@ -0,0 +1,295 @@
|
|
1
|
+import { Component, OnInit, ViewChild } from "@angular/core";
|
|
2
|
+import { ActivatedRoute } from "@angular/router";
|
|
3
|
+import { FormBuilder, Validators, FormGroup } from "@angular/forms";
|
|
4
|
+
|
|
5
|
+import { OverlayScrollbarsComponent } from "overlayscrollbars-ngx";
|
|
6
|
+import { ToolService } from "../../services/tool.service";
|
|
7
|
+import { Subject } from "rxjs";
|
|
8
|
+import { debounceTime } from "rxjs/operators";
|
|
9
|
+import { DepartmentDistanceService } from './department-distance.service';
|
|
10
|
+
|
|
11
|
+@Component({
|
|
12
|
+ selector: "app-department-distance",
|
|
13
|
+ templateUrl: "./department-distance.component.html",
|
|
14
|
+ styleUrls: ["./department-distance.component.less"],
|
|
15
|
+})
|
|
16
|
+export class DepartmentDistanceComponent implements OnInit {
|
|
17
|
+ @ViewChild("osComponentRef1", {
|
|
18
|
+ read: OverlayScrollbarsComponent,
|
|
19
|
+ static: false,
|
|
20
|
+ })
|
|
21
|
+ osComponentRef1: OverlayScrollbarsComponent;
|
|
22
|
+ constructor(
|
|
23
|
+ private fb: FormBuilder,
|
|
24
|
+ private route: ActivatedRoute,
|
|
25
|
+ private tool: ToolService,
|
|
26
|
+ private departmentDistanceService: DepartmentDistanceService,
|
|
27
|
+ ) {}
|
|
28
|
+
|
|
29
|
+ listOfData: any[] = []; //表格数据
|
|
30
|
+
|
|
31
|
+ modal: boolean = false; //新增/编辑模态框
|
|
32
|
+ add: boolean; //true:新增;false:编辑
|
|
33
|
+ validateForm: FormGroup; //新增/编辑表单
|
|
34
|
+ coopId: number; //表格中执行操作的id
|
|
35
|
+ department: any; //所属科室
|
|
36
|
+ hosId: any; //院区(搜索)
|
|
37
|
+ deptList: Array<any>; //所有班次
|
|
38
|
+ taskTypeList: Array<any>; //所有其他临床服务
|
|
39
|
+ pageIndex: number = 1; //页码
|
|
40
|
+ listLength: number = 10; //总条数
|
|
41
|
+ pageSize: number = 10; //每页条数
|
|
42
|
+
|
|
43
|
+ promptContent: string; //操作提示框提示信息
|
|
44
|
+ ifSuccess: boolean; //操作成功/失败
|
|
45
|
+ promptInfo: string; //操作结果提示信息
|
|
46
|
+ promptModalShow: boolean; //操作提示框是否展示
|
|
47
|
+
|
|
48
|
+ btnLoading: boolean = false; //提交按钮loading状态
|
|
49
|
+ changeInpSubject = new Subject(); //防抖
|
|
50
|
+ changeScheduleSubject = new Subject(); //防抖
|
|
51
|
+
|
|
52
|
+ // 初始化增删改按钮
|
|
53
|
+ coopBtns: any = {};
|
|
54
|
+
|
|
55
|
+ ngOnInit() {
|
|
56
|
+ //防抖
|
|
57
|
+ this.changeInpSubject.pipe(debounceTime(500)).subscribe((v) => {
|
|
58
|
+ this.getOtherTasktype(v[0]);
|
|
59
|
+ });
|
|
60
|
+ //防抖
|
|
61
|
+ this.changeScheduleSubject.pipe(debounceTime(500)).subscribe((v) => {
|
|
62
|
+ this.getDeptList(v[0]);
|
|
63
|
+ });
|
|
64
|
+ this.coopBtns = this.tool.initCoopBtns(this.route);
|
|
65
|
+ this.initForm();
|
|
66
|
+ this.hosId = this.tool.getCurrentHospital().id;
|
|
67
|
+ this.getList(true);
|
|
68
|
+ }
|
|
69
|
+
|
|
70
|
+ // 搜索
|
|
71
|
+ search() {
|
|
72
|
+ this.getList(true);
|
|
73
|
+ }
|
|
74
|
+ // 表格数据
|
|
75
|
+ loading1 = false;
|
|
76
|
+ getList(isResetPageIndex = false) {
|
|
77
|
+ isResetPageIndex && (this.pageIndex = 1);
|
|
78
|
+ let data = {
|
|
79
|
+ pageIndex: this.pageIndex,
|
|
80
|
+ pageSize: this.pageSize,
|
|
81
|
+ hosId: this.hosId,
|
|
82
|
+ };
|
|
83
|
+ this.loading1 = true;
|
|
84
|
+ this.departmentDistanceService
|
|
85
|
+ .query(data)
|
|
86
|
+ .subscribe((result) => {
|
|
87
|
+ this.loading1 = false;
|
|
88
|
+ result.list = result.list || [];
|
|
89
|
+ result.list.forEach(v => {
|
|
90
|
+ v.taskNames = v.taskTypeList.map(v => v.taskName).toString();
|
|
91
|
+ })
|
|
92
|
+ this.listOfData = result.list;
|
|
93
|
+ this.listLength = result.totalNum;
|
|
94
|
+ });
|
|
95
|
+ }
|
|
96
|
+
|
|
97
|
+ // 获取任务类型列表-其他临床服务
|
|
98
|
+ getOtherTasktype(keywords = '') {
|
|
99
|
+ let hosId = this.tool.getCurrentHospital().id;
|
|
100
|
+ this.isLoading = true;
|
|
101
|
+ this.departmentDistanceService.queryOtherTasktype({
|
|
102
|
+ hosId,
|
|
103
|
+ keywords,
|
|
104
|
+ }).subscribe((res) => {
|
|
105
|
+ this.isLoading = false;
|
|
106
|
+ this.taskTypeList = res.list || [];
|
|
107
|
+ });
|
|
108
|
+ }
|
|
109
|
+
|
|
110
|
+ // 获取科室
|
|
111
|
+ getDeptList(keywords = '') {
|
|
112
|
+ let hosId = this.tool.getCurrentHospital().id;
|
|
113
|
+ this.isLoading = true;
|
|
114
|
+ let postData = {
|
|
115
|
+ idx: 0,
|
|
116
|
+ sum: 9999,
|
|
117
|
+ department: {
|
|
118
|
+ searchType: 1,// 简单查询
|
|
119
|
+ dept: keywords,
|
|
120
|
+ hospital: { id: hosId },
|
|
121
|
+ }
|
|
122
|
+ };
|
|
123
|
+ this.departmentDistanceService.getDepartments(postData).subscribe((res) => {
|
|
124
|
+ this.isLoading = false;
|
|
125
|
+ this.deptList = res.list || [];
|
|
126
|
+ });
|
|
127
|
+ }
|
|
128
|
+
|
|
129
|
+ // 新增弹框
|
|
130
|
+ showModal() {
|
|
131
|
+ this.add = true;
|
|
132
|
+ this.modal = true;
|
|
133
|
+ this.initForm();
|
|
134
|
+ this.validateForm.controls.start.setValue(false);
|
|
135
|
+ this.validateForm.controls.end.setValue(false);
|
|
136
|
+ }
|
|
137
|
+ hideModal() {
|
|
138
|
+ this.modal = false;
|
|
139
|
+ this.initForm();
|
|
140
|
+ }
|
|
141
|
+
|
|
142
|
+ // 初始化新增form表单
|
|
143
|
+ initForm() {
|
|
144
|
+ if (this.add) {
|
|
145
|
+ this.deptList = [];
|
|
146
|
+ this.taskTypeList = [];
|
|
147
|
+ }
|
|
148
|
+ this.validateForm = this.fb.group({
|
|
149
|
+ grade: [0, [Validators.required]],
|
|
150
|
+ deptId: [null, [Validators.required]],
|
|
151
|
+ taskTypeIds: [null, [Validators.required]],
|
|
152
|
+ start: [null, [Validators.required]],
|
|
153
|
+ end: [null, [Validators.required]],
|
|
154
|
+ });
|
|
155
|
+ }
|
|
156
|
+ // 表单提交
|
|
157
|
+ submitForm(): void {
|
|
158
|
+ for (const i in this.validateForm.controls) {
|
|
159
|
+ this.validateForm.controls[i].markAsDirty({ onlySelf: true });
|
|
160
|
+ this.validateForm.controls[i].updateValueAndValidity();
|
|
161
|
+ }
|
|
162
|
+ if (this.validateForm.invalid) return;
|
|
163
|
+ this.btnLoading = true;
|
|
164
|
+ if(this.add){
|
|
165
|
+ this.departmentDistanceService
|
|
166
|
+ .add({
|
|
167
|
+ grade: this.validateForm.value.grade,
|
|
168
|
+ deptId: this.validateForm.value.deptId,
|
|
169
|
+ taskTypeIds: this.validateForm.value.taskTypeIds.toString(),
|
|
170
|
+ start: this.validateForm.value.start,
|
|
171
|
+ end: this.validateForm.value.end,
|
|
172
|
+ hosId: this.hosId,
|
|
173
|
+ })
|
|
174
|
+ .subscribe((data) => {
|
|
175
|
+ this.btnLoading = false;
|
|
176
|
+ this.hideModal();
|
|
177
|
+ this.initForm();
|
|
178
|
+ if (data.status == 200) {
|
|
179
|
+ this.showPromptModal(this.add ? "新增" : "编辑", true, "");
|
|
180
|
+ } else {
|
|
181
|
+ this.showPromptModal(this.add ? "新增" : "编辑", false, data.msg);
|
|
182
|
+ }
|
|
183
|
+ });
|
|
184
|
+ }else{
|
|
185
|
+ this.departmentDistanceService
|
|
186
|
+ .update({
|
|
187
|
+ ...this.coopData,
|
|
188
|
+ grade: this.validateForm.value.grade,
|
|
189
|
+ deptId: this.validateForm.value.deptId,
|
|
190
|
+ taskTypeIds: this.validateForm.value.taskTypeIds.toString(),
|
|
191
|
+ start: this.validateForm.value.start,
|
|
192
|
+ end: this.validateForm.value.end,
|
|
193
|
+ })
|
|
194
|
+ .subscribe((data) => {
|
|
195
|
+ this.btnLoading = false;
|
|
196
|
+ this.hideModal();
|
|
197
|
+ this.initForm();
|
|
198
|
+ if (data.status == 200) {
|
|
199
|
+ this.showPromptModal(this.add ? "新增" : "编辑", true, "");
|
|
200
|
+ } else {
|
|
201
|
+ this.showPromptModal(this.add ? "新增" : "编辑", false, data.msg);
|
|
202
|
+ }
|
|
203
|
+ });
|
|
204
|
+ }
|
|
205
|
+ }
|
|
206
|
+
|
|
207
|
+ // 编辑
|
|
208
|
+ maskFlag: any = false;
|
|
209
|
+ coopData = {};
|
|
210
|
+ edit(data) {
|
|
211
|
+ this.validateForm.controls.grade.setValue(data.grade);
|
|
212
|
+ this.validateForm.controls.deptId.setValue(data.deptId);
|
|
213
|
+ this.validateForm.controls.taskTypeIds.setValue(data.taskTypeList ? data.taskTypeList.map(v => v.id) : null);
|
|
214
|
+ this.validateForm.controls.start.setValue(data.start);
|
|
215
|
+ this.validateForm.controls.end.setValue(data.end);
|
|
216
|
+ this.modal = true;
|
|
217
|
+ this.add = false;
|
|
218
|
+ this.coopId = data.id;
|
|
219
|
+ this.coopData = data;
|
|
220
|
+ this.getOtherTasktype();
|
|
221
|
+ this.getDeptList();
|
|
222
|
+ }
|
|
223
|
+
|
|
224
|
+ // 删除
|
|
225
|
+ delModal: boolean = false; //删除模态框
|
|
226
|
+ del(data) {
|
|
227
|
+ this.coopId = data.id;
|
|
228
|
+ this.delModal = true;
|
|
229
|
+ }
|
|
230
|
+ // 确认删除
|
|
231
|
+ confirmDel() {
|
|
232
|
+ this.btnLoading = true;
|
|
233
|
+ this.departmentDistanceService
|
|
234
|
+ .delete({
|
|
235
|
+ id: this.coopId
|
|
236
|
+ })
|
|
237
|
+ .subscribe((data) => {
|
|
238
|
+ this.btnLoading = false;
|
|
239
|
+ this.hideDelModal();
|
|
240
|
+ if (data.status == 200) {
|
|
241
|
+ if (this.listOfData.length == 1 && this.pageIndex == Math.ceil(this.listLength / this.pageSize)) {
|
|
242
|
+ this.listLength--;
|
|
243
|
+ this.pageIndex = Math.ceil(this.listLength / this.pageSize);
|
|
244
|
+ }
|
|
245
|
+ this.showPromptModal("删除", true, "");
|
|
246
|
+ } else {
|
|
247
|
+ this.showPromptModal("删除", false, data.msg);
|
|
248
|
+ }
|
|
249
|
+ });
|
|
250
|
+ }
|
|
251
|
+
|
|
252
|
+ // 关闭删除模态框
|
|
253
|
+ hideDelModal() {
|
|
254
|
+ this.delModal = false;
|
|
255
|
+ }
|
|
256
|
+
|
|
257
|
+ // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
|
|
258
|
+ showPromptModal(con, success, promptInfo?) {
|
|
259
|
+ this.promptModalShow = false;
|
|
260
|
+ this.promptContent = con;
|
|
261
|
+ this.ifSuccess = success;
|
|
262
|
+ this.promptInfo = promptInfo;
|
|
263
|
+ setTimeout(() => {
|
|
264
|
+ this.promptModalShow = true;
|
|
265
|
+ }, 100);
|
|
266
|
+ this.getList(true);
|
|
267
|
+ }
|
|
268
|
+
|
|
269
|
+ // 边输边搜节流阀
|
|
270
|
+ isLoading = false;
|
|
271
|
+ changeInp(e) {
|
|
272
|
+ this.changeInpSubject.next([e]);
|
|
273
|
+ }
|
|
274
|
+
|
|
275
|
+ // 边输边搜节流阀
|
|
276
|
+ changeSchedule(e) {
|
|
277
|
+ this.changeScheduleSubject.next([e]);
|
|
278
|
+ }
|
|
279
|
+
|
|
280
|
+ // 打开任务类型
|
|
281
|
+ openOtherTasktype(e){
|
|
282
|
+ if(e){
|
|
283
|
+ this.getOtherTasktype();
|
|
284
|
+ }
|
|
285
|
+ }
|
|
286
|
+
|
|
287
|
+ // 打开班次
|
|
288
|
+ openSchedule(e){
|
|
289
|
+ if(e){
|
|
290
|
+ this.getDeptList();
|
|
291
|
+ }
|
|
292
|
+ }
|
|
293
|
+}
|
|
294
|
+
|
|
295
|
+
|