|
@@ -0,0 +1,823 @@
|
|
1
|
+import { Component, OnInit, ViewChild } from "@angular/core";
|
|
2
|
+import { ActivatedRoute, Router } from "@angular/router";
|
|
3
|
+import {
|
|
4
|
+ FormBuilder,
|
|
5
|
+ Validators,
|
|
6
|
+ FormGroup,
|
|
7
|
+ FormControl,
|
|
8
|
+} from "@angular/forms";
|
|
9
|
+
|
|
10
|
+import { MainService } from "../../services/main.service";
|
|
11
|
+import { OverlayScrollbarsComponent } from "overlayscrollbars-ngx";
|
|
12
|
+import { ToolService } from "../../services/tool.service";
|
|
13
|
+import { Subject } from "rxjs";
|
|
14
|
+import { debounceTime } from "rxjs/operators";
|
|
15
|
+import { NzMessageService } from "ng-zorro-antd";
|
|
16
|
+import { format } from "date-fns";
|
|
17
|
+@Component({
|
|
18
|
+ selector: "app-keep-order-config",
|
|
19
|
+ templateUrl: "./keep-order-config.component.html",
|
|
20
|
+ styleUrls: ["./keep-order-config.component.less"],
|
|
21
|
+})
|
|
22
|
+export class KeepOrderConfigComponent implements OnInit {
|
|
23
|
+ @ViewChild("osComponentRef1", {
|
|
24
|
+ read: OverlayScrollbarsComponent,
|
|
25
|
+ static: false,
|
|
26
|
+ })
|
|
27
|
+ osComponentRef1: OverlayScrollbarsComponent;
|
|
28
|
+ constructor(
|
|
29
|
+ private message: NzMessageService,
|
|
30
|
+ private fb: FormBuilder,
|
|
31
|
+ private mainService: MainService,
|
|
32
|
+ private route: ActivatedRoute,
|
|
33
|
+ private router: Router,
|
|
34
|
+ private tool: ToolService
|
|
35
|
+ ) {}
|
|
36
|
+
|
|
37
|
+ userInfo: any = JSON.parse(localStorage.getItem("user")) || {}; //登录用户信息
|
|
38
|
+
|
|
39
|
+ searchCriteria = {
|
|
40
|
+ //搜索条件
|
|
41
|
+ name: "",
|
|
42
|
+ hospital: null,
|
|
43
|
+ endDepartment: null,
|
|
44
|
+ };
|
|
45
|
+ roundRobinTypes = []; //轮巡类型
|
|
46
|
+ timeSteps = [
|
|
47
|
+ // { id: "381", name: "每天轮巡" },
|
|
48
|
+ { key: "day", name: "每天" },
|
|
49
|
+ { key: "week", name: "每周" },
|
|
50
|
+ { key: "month", name: "每月" },
|
|
51
|
+ { key: "year", name: "每年" },
|
|
52
|
+ ]; //轮巡类型
|
|
53
|
+ createUser = "";
|
|
54
|
+ dayType = ["全部", "节假日", "工作日"]; //执行策略里的复选框数据字典
|
|
55
|
+ department = []; // 院区下的科室列表
|
|
56
|
+ departmentSearch = []; // 院区下的科室列表(搜索框)
|
|
57
|
+ allHospital: any = []; //院区下拉框
|
|
58
|
+ listOfData: any[] = []; //表格数据
|
|
59
|
+ pageIndex: number = 1; //表格当前页码
|
|
60
|
+ pageSize: number = 10; //表格每页展示条数
|
|
61
|
+ listLength: number = 10; //表格总数据量
|
|
62
|
+ tableHeight: number; //表格动态高
|
|
63
|
+ modal: boolean = false; //新增/编辑模态框
|
|
64
|
+ add: boolean; //true:新增;false:编辑
|
|
65
|
+ validateForm: FormGroup; //新增/编辑表单
|
|
66
|
+ coopId: number; //当前操作列id
|
|
67
|
+
|
|
68
|
+ hospitalList: Array<object> = []; //院区列表
|
|
69
|
+ hosId: any; //当前院区id
|
|
70
|
+ oneOption: any; //适用日期类型
|
|
71
|
+ btnLoading: boolean = false; //提交按钮loading状态
|
|
72
|
+
|
|
73
|
+ promptContent: string; //操作提示框提示信息
|
|
74
|
+ ifSuccess: boolean; //操作成功/失败
|
|
75
|
+ promptInfo: string; //操作结果提示信息
|
|
76
|
+ promptModalShow: boolean; //操作提示框是否展示
|
|
77
|
+ demoValue: number = 0;
|
|
78
|
+ changeInpSubject = new Subject();
|
|
79
|
+ changeInpTasktypeSubject = new Subject();
|
|
80
|
+ ngOnInit() {
|
|
81
|
+ this.changeInpSubject.pipe(debounceTime(500)).subscribe((v) => {
|
|
82
|
+ this.searchDepartment(v[0], v[1]);
|
|
83
|
+ });
|
|
84
|
+ this.changeInpTasktypeSubject
|
|
85
|
+ .pipe(debounceTime(500))
|
|
86
|
+ .subscribe((v: any) => {
|
|
87
|
+ this.getTasktypeByIds(v);
|
|
88
|
+ });
|
|
89
|
+ this.coopBtns = this.tool.initCoopBtns(this.route);
|
|
90
|
+ this.getAllHospital();
|
|
91
|
+ this.initForm();
|
|
92
|
+ this.getHospitalList();
|
|
93
|
+ }
|
|
94
|
+ // 重置
|
|
95
|
+ reset() {
|
|
96
|
+ this.searchCriteria = {
|
|
97
|
+ //搜索条件
|
|
98
|
+ name: "",
|
|
99
|
+ hospital: this.allHospital[0] ? this.allHospital[0]["id"] + "" : null,
|
|
100
|
+ endDepartment: null,
|
|
101
|
+ };
|
|
102
|
+ this.getList(1);
|
|
103
|
+ }
|
|
104
|
+ // 选择院区
|
|
105
|
+ changeHospital(id, type) {
|
|
106
|
+ if (type === "search") {
|
|
107
|
+ this.searchCriteria.endDepartment = null;
|
|
108
|
+ } else {
|
|
109
|
+ if (
|
|
110
|
+ this.validateForm &&
|
|
111
|
+ this.validateForm.value &&
|
|
112
|
+ this.validateForm.value.endDepartment
|
|
113
|
+ ) {
|
|
114
|
+ this.validateForm.controls.endDepartment.setValue(null);
|
|
115
|
+ }
|
|
116
|
+ }
|
|
117
|
+ let data = {
|
|
118
|
+ department: {
|
|
119
|
+ hospital: { id },
|
|
120
|
+ type: { id: 383 },
|
|
121
|
+ },
|
|
122
|
+ idx: 0,
|
|
123
|
+ sum: 20,
|
|
124
|
+ };
|
|
125
|
+ this.mainService
|
|
126
|
+ .getFetchDataList("data", "department", data)
|
|
127
|
+ .subscribe((data) => {
|
|
128
|
+ if (data.status == 200) {
|
|
129
|
+ if (type === "search") {
|
|
130
|
+ this.departmentSearch = data.list;
|
|
131
|
+ } else {
|
|
132
|
+ this.department = data.list;
|
|
133
|
+ }
|
|
134
|
+ }
|
|
135
|
+ });
|
|
136
|
+ }
|
|
137
|
+ // 打开搜索框
|
|
138
|
+ changeSearch(flag) {
|
|
139
|
+ if (flag) {
|
|
140
|
+ this.changeInp("no", "search");
|
|
141
|
+ }
|
|
142
|
+ }
|
|
143
|
+ changeForm(flag) {
|
|
144
|
+ if (flag) {
|
|
145
|
+ this.changeInp("no", "form");
|
|
146
|
+ }
|
|
147
|
+ }
|
|
148
|
+ changeFormTasktype(flag) {
|
|
149
|
+ if (flag) {
|
|
150
|
+ this.changeInpTasktype();
|
|
151
|
+ }
|
|
152
|
+ }
|
|
153
|
+ changeFormEnd(flag) {
|
|
154
|
+ if (flag) {
|
|
155
|
+ this.changeInp("no", "formEnd");
|
|
156
|
+ }
|
|
157
|
+ }
|
|
158
|
+ // 选择轮巡类型
|
|
159
|
+ selectedTasktype = null; //当前选中的轮巡类型
|
|
160
|
+ selectedTasktypeHandler(e) {
|
|
161
|
+ this.selectedTasktype = this.roundRobinTypes.find((item) => item.id == e);
|
|
162
|
+ this.requiredChange(
|
|
163
|
+ this.selectedTasktype.associationType.value == "specimenPlan",
|
|
164
|
+ "endDepartment"
|
|
165
|
+ );
|
|
166
|
+ console.log(this.selectedTasktype);
|
|
167
|
+ }
|
|
168
|
+ // 任务类型防抖搜索
|
|
169
|
+ changeInpTasktype(taskName = "") {
|
|
170
|
+ this.isLoading = true;
|
|
171
|
+ this.changeInpTasktypeSubject.next(taskName);
|
|
172
|
+ }
|
|
173
|
+ // 边输边搜节流阀
|
|
174
|
+ isLoading = false;
|
|
175
|
+ changeInp(dept, type) {
|
|
176
|
+ if (dept === "no") {
|
|
177
|
+ dept = "";
|
|
178
|
+ }
|
|
179
|
+ if (type === "form") {
|
|
180
|
+ if (!this.hosId) {
|
|
181
|
+ this.department = [];
|
|
182
|
+ return;
|
|
183
|
+ }
|
|
184
|
+ }
|
|
185
|
+ this.isLoading = true;
|
|
186
|
+ this.changeInpSubject.next([dept, type]);
|
|
187
|
+ }
|
|
188
|
+ // 搜索科室
|
|
189
|
+ depting = "";
|
|
190
|
+ searchDepartment(dept, type) {
|
|
191
|
+ this.depting = dept;
|
|
192
|
+ let postData={
|
|
193
|
+ department: {
|
|
194
|
+ dept,
|
|
195
|
+ hospital: { id: this.hosId },
|
|
196
|
+ cascadeHosId: this.hosId,
|
|
197
|
+ type: { id: null },
|
|
198
|
+ },
|
|
199
|
+ idx: 0,
|
|
200
|
+ sum: 5,
|
|
201
|
+ }
|
|
202
|
+ if(this.selectedTasktype.associationType.value == "specimen"){
|
|
203
|
+ postData.department.type.id = 282
|
|
204
|
+ delete postData.department.hospital
|
|
205
|
+ }else{
|
|
206
|
+ postData.department.type.id = 383
|
|
207
|
+ delete postData.department.cascadeHosId
|
|
208
|
+ }
|
|
209
|
+ this.mainService
|
|
210
|
+ .getFetchDataList("data", "department", postData)
|
|
211
|
+ .subscribe((result) => {
|
|
212
|
+ if (result.status == 200) {
|
|
213
|
+ if (type === "search" && this.depting === postData.department.dept) {
|
|
214
|
+ this.isLoading = false;
|
|
215
|
+ this.departmentSearch = result.list;
|
|
216
|
+ } else if (
|
|
217
|
+ type === "form" &&
|
|
218
|
+ this.depting === postData.department.dept
|
|
219
|
+ ) {
|
|
220
|
+ this.isLoading = false;
|
|
221
|
+ this.department = result.list;
|
|
222
|
+ }
|
|
223
|
+ }
|
|
224
|
+ });
|
|
225
|
+ }
|
|
226
|
+
|
|
227
|
+ // 初始化增删改按钮
|
|
228
|
+ coopBtns: any = {};
|
|
229
|
+
|
|
230
|
+ // 获取所有院区
|
|
231
|
+ /**
|
|
232
|
+ *
|
|
233
|
+ *
|
|
234
|
+ * @memberof RoundRobinComponent
|
|
235
|
+ */
|
|
236
|
+ getAllHospital() {
|
|
237
|
+ this.allHospital = [this.tool.getCurrentHospital()];
|
|
238
|
+ this.searchCriteria.hospital = this.tool.getCurrentHospital().id + "";
|
|
239
|
+ this.getList(1);
|
|
240
|
+ this.changeHospital(this.searchCriteria.hospital, "search");
|
|
241
|
+ }
|
|
242
|
+
|
|
243
|
+ // 表格数据
|
|
244
|
+ loading1 = false;
|
|
245
|
+ getList(type) {
|
|
246
|
+ if (type == 1) {
|
|
247
|
+ this.pageIndex = 1;
|
|
248
|
+ }
|
|
249
|
+ let data = {
|
|
250
|
+ idx: this.pageIndex - 1,
|
|
251
|
+ sum: this.pageSize,
|
|
252
|
+ orderPlan: {
|
|
253
|
+ hospital: this.searchCriteria.hospital,
|
|
254
|
+ targetDept:
|
|
255
|
+ this.searchCriteria.endDepartment === null
|
|
256
|
+ ? ""
|
|
257
|
+ : this.searchCriteria.endDepartment,
|
|
258
|
+ title:
|
|
259
|
+ this.searchCriteria.name === null ? "" : this.searchCriteria.name,
|
|
260
|
+ },
|
|
261
|
+ };
|
|
262
|
+ this.loading1 = true;
|
|
263
|
+ this.mainService
|
|
264
|
+ .getFetchDataList("configuration", "orderPlan", data)
|
|
265
|
+ .subscribe((data) => {
|
|
266
|
+ this.loading1 = false;
|
|
267
|
+ if (data.status == 200) {
|
|
268
|
+ this.listOfData = data.list;
|
|
269
|
+ this.listLength = data.totalNum;
|
|
270
|
+ this.listOfData.forEach((item) => {
|
|
271
|
+ if (item.timeStep == "week") {
|
|
272
|
+ let weeks = [
|
|
273
|
+ "周一",
|
|
274
|
+ "周二",
|
|
275
|
+ "周三",
|
|
276
|
+ "周四",
|
|
277
|
+ "周五",
|
|
278
|
+ "周六",
|
|
279
|
+ "周日",
|
|
280
|
+ ];
|
|
281
|
+ item.weekName = weeks[item.extra1 - 1];
|
|
282
|
+ }
|
|
283
|
+ });
|
|
284
|
+ }
|
|
285
|
+ });
|
|
286
|
+ }
|
|
287
|
+ //获取任务类型-标本检查和其他临床服务
|
|
288
|
+ taskNameing = "";
|
|
289
|
+ getTasktypeByIds(taskName = "") {
|
|
290
|
+ this.taskNameing = taskName;
|
|
291
|
+ let postData = {
|
|
292
|
+ idx: 0,
|
|
293
|
+ sum: 5,
|
|
294
|
+ taskType: {
|
|
295
|
+ hosIds: this.hosId + "",
|
|
296
|
+ associationTypeIds: "380,259,256",
|
|
297
|
+ taskName,
|
|
298
|
+ },
|
|
299
|
+ };
|
|
300
|
+ this.mainService
|
|
301
|
+ .getFetchDataList("configuration", "taskType", postData)
|
|
302
|
+ .subscribe((result) => {
|
|
303
|
+ if (
|
|
304
|
+ result.status == 200 &&
|
|
305
|
+ this.taskNameing === postData.taskType.taskName
|
|
306
|
+ ) {
|
|
307
|
+ this.isLoading = false;
|
|
308
|
+ this.roundRobinTypes = result.list;
|
|
309
|
+ }
|
|
310
|
+ });
|
|
311
|
+ }
|
|
312
|
+ // 新增/编辑弹框
|
|
313
|
+ addModal() {
|
|
314
|
+ this.add = true; //新增
|
|
315
|
+ this.modal = true;
|
|
316
|
+ this.selectedTasktype = null;
|
|
317
|
+ this.initForm();
|
|
318
|
+ }
|
|
319
|
+ //关闭新增/编辑弹框
|
|
320
|
+ hideAddModal() {
|
|
321
|
+ this.modal = false;
|
|
322
|
+ this.initForm();
|
|
323
|
+ }
|
|
324
|
+ // 是否是必选
|
|
325
|
+ requiredChange(required: boolean, formControlName: string): void {
|
|
326
|
+ if (!required) {
|
|
327
|
+ this.validateForm.get(formControlName)!.clearValidators();
|
|
328
|
+ this.validateForm.get(formControlName)!.markAsPristine();
|
|
329
|
+ } else {
|
|
330
|
+ this.validateForm
|
|
331
|
+ .get(formControlName)!
|
|
332
|
+ .setValidators(Validators.required);
|
|
333
|
+ this.validateForm.get(formControlName)!.markAsDirty();
|
|
334
|
+ }
|
|
335
|
+ this.validateForm.get(formControlName)!.updateValueAndValidity();
|
|
336
|
+ }
|
|
337
|
+ // 初始化新增form表单
|
|
338
|
+ initForm() {
|
|
339
|
+ this.createUser = this.userInfo.user.name ? this.userInfo.user.name : "";
|
|
340
|
+ this.oneOption = [
|
|
341
|
+ { label: "工作日", value: "工作日", checked: false },
|
|
342
|
+ { label: "节假日", value: "节假日", checked: false },
|
|
343
|
+ ];
|
|
344
|
+ this.validateForm = this.fb.group({
|
|
345
|
+ roundRobinName: [null, [Validators.required]],
|
|
346
|
+ roundRobinType: [null, [Validators.required]],
|
|
347
|
+ timeStep: [null, [Validators.required]],
|
|
348
|
+ datesType: [null, [this.dateValidator]],
|
|
349
|
+ executeTime: [null, [Validators.required]],
|
|
350
|
+ // executionTime: [null, [Validators.required]],
|
|
351
|
+ // time: [null],
|
|
352
|
+ endDepartment: [null, [Validators.required]],
|
|
353
|
+ openDepartments: [false],
|
|
354
|
+ });
|
|
355
|
+ this.validateForm.controls.timeStep.setValue(this.timeSteps[0].key);
|
|
356
|
+ this.timeSelectedValue = [];
|
|
357
|
+ }
|
|
358
|
+ // 修改轮巡策略
|
|
359
|
+ months = [...Array(32).keys()].slice(1);
|
|
360
|
+ timeStepChange(e) {
|
|
361
|
+ switch (e) {
|
|
362
|
+ case "day":
|
|
363
|
+ this.validateForm.removeControl("doWeek");
|
|
364
|
+ this.validateForm.removeControl("doMonth");
|
|
365
|
+ this.validateForm.removeControl("doYear");
|
|
366
|
+ break;
|
|
367
|
+ case "week":
|
|
368
|
+ this.validateForm.addControl(
|
|
369
|
+ "doWeek",
|
|
370
|
+ new FormControl(null, Validators.required)
|
|
371
|
+ );
|
|
372
|
+ this.validateForm.removeControl("doMonth");
|
|
373
|
+ this.validateForm.removeControl("doYear");
|
|
374
|
+ break;
|
|
375
|
+ case "month":
|
|
376
|
+ this.validateForm.addControl(
|
|
377
|
+ "doMonth",
|
|
378
|
+ new FormControl(null, Validators.required)
|
|
379
|
+ );
|
|
380
|
+ this.validateForm.removeControl("doWeek");
|
|
381
|
+ this.validateForm.removeControl("doYear");
|
|
382
|
+ break;
|
|
383
|
+ case "year":
|
|
384
|
+ this.validateForm.addControl(
|
|
385
|
+ "doYear",
|
|
386
|
+ new FormControl(null, Validators.required)
|
|
387
|
+ );
|
|
388
|
+ this.validateForm.removeControl("doWeek");
|
|
389
|
+ this.validateForm.removeControl("doMonth");
|
|
390
|
+ break;
|
|
391
|
+ }
|
|
392
|
+ }
|
|
393
|
+
|
|
394
|
+ //创建自定义校验规则dateValidator,用于复选框组校验时调用。
|
|
395
|
+ selectedDate: any = [];
|
|
396
|
+ dateValidator = (control: FormControl): { [s: string]: boolean } => {
|
|
397
|
+ this.selectedDate = [];
|
|
398
|
+ for (const i in control.value) {
|
|
399
|
+ if (control.value[i].checked) {
|
|
400
|
+ this.selectedDate.push(control.value[i]);
|
|
401
|
+ }
|
|
402
|
+ }
|
|
403
|
+ if (this.selectedDate.length == 0) {
|
|
404
|
+ return { required: true };
|
|
405
|
+ }
|
|
406
|
+ };
|
|
407
|
+
|
|
408
|
+ // 新增/编辑表单提交
|
|
409
|
+ submitForm(): void {
|
|
410
|
+ this.btnLoading = true;
|
|
411
|
+ for (const i in this.validateForm.controls) {
|
|
412
|
+ this.validateForm.controls[i].markAsDirty();
|
|
413
|
+ this.validateForm.controls[i].updateValueAndValidity();
|
|
414
|
+ }
|
|
415
|
+ if (this.selectedDate) {
|
|
416
|
+ var arr = [];
|
|
417
|
+ this.validateForm.value.datesType.forEach((e) => {
|
|
418
|
+ if (e.checked) {
|
|
419
|
+ arr.push(e.label);
|
|
420
|
+ }
|
|
421
|
+ });
|
|
422
|
+ if (arr.length == 2) {
|
|
423
|
+ this.validateForm.value.datesType = 0;
|
|
424
|
+ } else {
|
|
425
|
+ if (arr[0] == "工作日") {
|
|
426
|
+ this.validateForm.value.datesType = 2;
|
|
427
|
+ } else {
|
|
428
|
+ this.validateForm.value.datesType = 1;
|
|
429
|
+ }
|
|
430
|
+ }
|
|
431
|
+ }
|
|
432
|
+ if (this.validateForm.invalid) {
|
|
433
|
+ this.btnLoading = false;
|
|
434
|
+ return;
|
|
435
|
+ }
|
|
436
|
+ let postData: any = {};
|
|
437
|
+
|
|
438
|
+ if (this.add) {
|
|
439
|
+ //增加
|
|
440
|
+ postData = {
|
|
441
|
+ orderPlan: {
|
|
442
|
+ title: this.validateForm.value.roundRobinName,
|
|
443
|
+ hospital: this.hosId,
|
|
444
|
+ taskType: { id: this.validateForm.value.roundRobinType },
|
|
445
|
+ timeStep: this.validateForm.value.timeStep,
|
|
446
|
+ dayType: this.validateForm.value.datesType,
|
|
447
|
+ executeTime: new Date(this.validateForm.value.executeTime).getTime(),
|
|
448
|
+ },
|
|
449
|
+ };
|
|
450
|
+ if (this.selectedTasktype.associationType.value == "specimenPlan"||
|
|
451
|
+ this.selectedTasktype.associationType.value == "specimen") {
|
|
452
|
+ //标本轮巡
|
|
453
|
+ postData.orderPlan.targetDept =
|
|
454
|
+ this.validateForm.value.endDepartment.join();
|
|
455
|
+ } else if (this.selectedTasktype.associationType.value == "other") {
|
|
456
|
+ //其他配送
|
|
457
|
+ postData.orderPlan.taskTypeDeptOrder =
|
|
458
|
+ this.validateForm.value.openDepartments;
|
|
459
|
+ }
|
|
460
|
+ if (this.validateForm.value.timeStep == "day") {
|
|
461
|
+ delete postData.orderPlan.extra1;
|
|
462
|
+ } else if (this.validateForm.value.timeStep == "week") {
|
|
463
|
+ postData.orderPlan.extra1 = this.validateForm.value.doWeek;
|
|
464
|
+ } else if (this.validateForm.value.timeStep == "month") {
|
|
465
|
+ postData.orderPlan.extra1 = this.validateForm.value.doMonth;
|
|
466
|
+ } else if (this.validateForm.value.timeStep == "year") {
|
|
467
|
+ delete postData.orderPlan.extra1;
|
|
468
|
+ postData.orderPlan.executeTime = new Date(
|
|
469
|
+ format(new Date(this.validateForm.value.doYear), "yyyy-MM-dd") +
|
|
470
|
+ " " +
|
|
471
|
+ format(new Date(this.validateForm.value.executeTime), "HH:mm:ss")
|
|
472
|
+ ).getTime();
|
|
473
|
+ }
|
|
474
|
+ } else {
|
|
475
|
+ //编辑
|
|
476
|
+ postData = {
|
|
477
|
+ id: this.coopId,
|
|
478
|
+ title: this.validateForm.value.roundRobinName,
|
|
479
|
+ hospital: this.hosId,
|
|
480
|
+ taskType: { id: this.validateForm.value.roundRobinType },
|
|
481
|
+ timeStep: this.validateForm.value.timeStep,
|
|
482
|
+ dayType: this.validateForm.value.datesType,
|
|
483
|
+ executeTime: new Date(this.validateForm.value.executeTime).getTime(),
|
|
484
|
+ };
|
|
485
|
+ if (this.selectedTasktype.associationType.value == "specimenPlan"||
|
|
486
|
+ this.selectedTasktype.associationType.value == "specimen") {
|
|
487
|
+ //标本轮巡
|
|
488
|
+ postData.targetDept = this.validateForm.value.endDepartment.join();
|
|
489
|
+ } else if (this.selectedTasktype.associationType.value == "other") {
|
|
490
|
+ //其他配送
|
|
491
|
+ postData.taskTypeDeptOrder = this.validateForm.value.openDepartments;
|
|
492
|
+ }
|
|
493
|
+ if (this.validateForm.value.timeStep == "day") {
|
|
494
|
+ delete postData.extra1;
|
|
495
|
+ } else if (this.validateForm.value.timeStep == "week") {
|
|
496
|
+ postData.extra1 = this.validateForm.value.doWeek;
|
|
497
|
+ } else if (this.validateForm.value.timeStep == "month") {
|
|
498
|
+ postData.extra1 = this.validateForm.value.doMonth;
|
|
499
|
+ } else if (this.validateForm.value.timeStep == "year") {
|
|
500
|
+ delete postData.extra1;
|
|
501
|
+ postData.executeTime = new Date(
|
|
502
|
+ format(new Date(this.validateForm.value.doYear), "yyyy-MM-dd") +
|
|
503
|
+ " " +
|
|
504
|
+ format(new Date(this.validateForm.value.executeTime), "HH:mm:ss")
|
|
505
|
+ ).getTime();
|
|
506
|
+ }
|
|
507
|
+ }
|
|
508
|
+ console.log(postData);
|
|
509
|
+ // return; //baba
|
|
510
|
+ this.mainService
|
|
511
|
+ .addRoundRobin(this.add ? "addPlan" : "updatePlan", postData)
|
|
512
|
+ .subscribe((data) => {
|
|
513
|
+ this.btnLoading = false;
|
|
514
|
+ this.hideAddModal();
|
|
515
|
+ this.initForm();
|
|
516
|
+ if (data.status == 200) {
|
|
517
|
+ this.listLength++;
|
|
518
|
+ this.showPromptModal(this.add ? "新增" : "修改", true, "");
|
|
519
|
+ } else {
|
|
520
|
+ this.showPromptModal(this.add ? "新增" : "修改", false, data.msg);
|
|
521
|
+ }
|
|
522
|
+ });
|
|
523
|
+ }
|
|
524
|
+
|
|
525
|
+ // 编辑
|
|
526
|
+ executionTimeTemporaryStorage; //暂存执行时间
|
|
527
|
+ maskFlag: any = false;
|
|
528
|
+ maskFlagLoading1 = false;
|
|
529
|
+ maskFlagLoading2 = false;
|
|
530
|
+ edit(data) {
|
|
531
|
+ this.requiredChange(
|
|
532
|
+ data.taskType.associationType.value == "specimenPlan",
|
|
533
|
+ "endDepartment"
|
|
534
|
+ );
|
|
535
|
+ this.maskFlag = this.message.loading("正在加载中..", {
|
|
536
|
+ nzDuration: 0,
|
|
537
|
+ }).messageId;
|
|
538
|
+ this.maskFlagLoading1 = true;
|
|
539
|
+ this.maskFlagLoading2 = true;
|
|
540
|
+ this.add = false;
|
|
541
|
+ this.coopId = data.id;
|
|
542
|
+ this.createUser = data.createUser ? data.createUser.name : ""; //创建人
|
|
543
|
+ this.validateForm.controls.roundRobinName.setValue(data.title); //名称
|
|
544
|
+ // 轮巡类型 start
|
|
545
|
+ {
|
|
546
|
+ this.selectedTasktype = data.taskType;
|
|
547
|
+ let postData = {
|
|
548
|
+ idx: 0,
|
|
549
|
+ sum: 5,
|
|
550
|
+ taskType: {
|
|
551
|
+ hosIds: this.hosId + "",
|
|
552
|
+ associationTypeIds: "380,259,256",
|
|
553
|
+ taskName: "",
|
|
554
|
+ },
|
|
555
|
+ };
|
|
556
|
+ this.mainService
|
|
557
|
+ .getFetchDataList("configuration", "taskType", postData)
|
|
558
|
+ .subscribe((result) => {
|
|
559
|
+ this.maskFlagLoading1 = false;
|
|
560
|
+ if (!this.maskFlagLoading1 && !this.maskFlagLoading2) {
|
|
561
|
+ this.message.remove(this.maskFlag);
|
|
562
|
+ this.maskFlag = false;
|
|
563
|
+ this.modal = true;
|
|
564
|
+ }
|
|
565
|
+ if (result.status == 200) {
|
|
566
|
+ this.roundRobinTypes = result.list;
|
|
567
|
+ let flag = this.roundRobinTypes.some(
|
|
568
|
+ (item) => item.id == data.taskType.id
|
|
569
|
+ );
|
|
570
|
+ if (!flag) {
|
|
571
|
+ this.roundRobinTypes.unshift(data.taskType);
|
|
572
|
+ }
|
|
573
|
+ this.validateForm.controls.roundRobinType.setValue(
|
|
574
|
+ data.taskType.id
|
|
575
|
+ ); //轮巡类型
|
|
576
|
+ }
|
|
577
|
+ });
|
|
578
|
+ }
|
|
579
|
+ // 轮巡类型end
|
|
580
|
+ this.validateForm.controls.timeStep.setValue(data.timeStep); //轮巡策略
|
|
581
|
+ this.validateForm.controls.executeTime.setValue(new Date(data.executeTime)); //轮巡策略
|
|
582
|
+ this.defaultSelectTimesOption = data.executeTime;
|
|
583
|
+ //轮巡策略(时间) start
|
|
584
|
+ this.timeStepChange(data.timeStep);
|
|
585
|
+ if (data.timeStep == "year") {
|
|
586
|
+ this.validateForm.controls.doYear.setValue(
|
|
587
|
+ format(data.executeTime, "yyyy-MM-dd HH:mm:ss")
|
|
588
|
+ );
|
|
589
|
+ } else if (data.timeStep == "month") {
|
|
590
|
+ this.validateForm.controls.doMonth.setValue(data.extra1);
|
|
591
|
+ } else if (data.timeStep == "week") {
|
|
592
|
+ this.validateForm.controls.doWeek.setValue(data.extra1);
|
|
593
|
+ }
|
|
594
|
+ //轮巡策略(时间)end
|
|
595
|
+ // --------终点科室---
|
|
596
|
+ if (data.taskType.associationType.value == "specimenPlan" ||
|
|
597
|
+ this.selectedTasktype.associationType.value == "specimen") {
|
|
598
|
+ //标本轮巡,则回显
|
|
599
|
+ let targetDeptArr = [];
|
|
600
|
+ let targetDept = data.targetDept.split(",");
|
|
601
|
+ let targetDeptShow = data.targetDeptShow.split(",");
|
|
602
|
+ targetDept.forEach((item, index) => {
|
|
603
|
+ targetDeptArr.push({ id: item, dept: targetDeptShow[index] });
|
|
604
|
+ });
|
|
605
|
+ let query={
|
|
606
|
+ department: {
|
|
607
|
+ hospital: { id: data.hospital },
|
|
608
|
+ cascadeHosId:data.hospital,
|
|
609
|
+ type: { id: null },
|
|
610
|
+ },
|
|
611
|
+ idx: 0,
|
|
612
|
+ sum: 20,
|
|
613
|
+ }
|
|
614
|
+ if(this.selectedTasktype.associationType.value == "specimen"){
|
|
615
|
+ query.department.type.id = 282
|
|
616
|
+ delete query.department.hospital
|
|
617
|
+ }else{
|
|
618
|
+ query.department.type.id = 383
|
|
619
|
+ delete query.department.cascadeHosId
|
|
620
|
+ }
|
|
621
|
+ this.mainService
|
|
622
|
+ .getFetchDataList("data", "department", query)
|
|
623
|
+ .subscribe((data) => {
|
|
624
|
+ this.maskFlagLoading2 = false;
|
|
625
|
+ if (!this.maskFlagLoading1 && !this.maskFlagLoading2) {
|
|
626
|
+ this.message.remove(this.maskFlag);
|
|
627
|
+ this.maskFlag = false;
|
|
628
|
+ this.modal = true;
|
|
629
|
+ }
|
|
630
|
+ if (data.status == 200) {
|
|
631
|
+ let add = targetDeptArr.filter(
|
|
632
|
+ (item) => !data.list.some((ele) => ele.id == item.id)
|
|
633
|
+ );
|
|
634
|
+ this.department = add.concat(data.list);
|
|
635
|
+ this.validateForm.controls.endDepartment.setValue(targetDept);
|
|
636
|
+ }
|
|
637
|
+ });
|
|
638
|
+ } else {
|
|
639
|
+ this.maskFlagLoading2 = false;
|
|
640
|
+ if (!this.maskFlagLoading1 && !this.maskFlagLoading2) {
|
|
641
|
+ this.message.remove(this.maskFlag);
|
|
642
|
+ this.maskFlag = false;
|
|
643
|
+ this.modal = true;
|
|
644
|
+ }
|
|
645
|
+ }
|
|
646
|
+ // --------/终点科室---
|
|
647
|
+ if (
|
|
648
|
+ data.taskType.associationType.value == "other" &&
|
|
649
|
+ (data.taskType.carryingCourses[0].departmentStrategy.value == 1 ||
|
|
650
|
+ data.taskType.carryingCourses[1].departmentStrategy.value == 1)
|
|
651
|
+ ) {
|
|
652
|
+ this.validateForm.controls.openDepartments.setValue(
|
|
653
|
+ data.taskTypeDeptOrder
|
|
654
|
+ );
|
|
655
|
+ }
|
|
656
|
+ if (data.dayType == 1) {
|
|
657
|
+ //节假日
|
|
658
|
+ this.oneOption[1]["checked"] = true;
|
|
659
|
+ } else if (data.dayType == 2) {
|
|
660
|
+ //工作日
|
|
661
|
+ this.oneOption[0]["checked"] = true;
|
|
662
|
+ } else {
|
|
663
|
+ this.oneOption[0]["checked"] = true;
|
|
664
|
+ this.oneOption[1]["checked"] = true;
|
|
665
|
+ }
|
|
666
|
+ }
|
|
667
|
+ // 立即执行
|
|
668
|
+ coopItem: any = {};
|
|
669
|
+ execModal: boolean = false;
|
|
670
|
+ // 打开立即执行模态框
|
|
671
|
+ openExecModal(item) {
|
|
672
|
+ this.coopItem = item;
|
|
673
|
+ this.execModal = true;
|
|
674
|
+ }
|
|
675
|
+ // 确认立即执行
|
|
676
|
+ confirmExec() {
|
|
677
|
+ this.btnLoading = true;
|
|
678
|
+ this.mainService
|
|
679
|
+ .executeNowOrderPlan(this.coopItem.id)
|
|
680
|
+ .subscribe((result: any) => {
|
|
681
|
+ this.closeExecModal();
|
|
682
|
+ this.btnLoading = false;
|
|
683
|
+ if (result.status == 200) {
|
|
684
|
+ this.showPromptModal("立即执行", true, "");
|
|
685
|
+ } else {
|
|
686
|
+ this.showPromptModal("立即执行", false, result.msg);
|
|
687
|
+ }
|
|
688
|
+ });
|
|
689
|
+ }
|
|
690
|
+ // 关闭立即执行模态框
|
|
691
|
+ closeExecModal() {
|
|
692
|
+ this.execModal = false;
|
|
693
|
+ }
|
|
694
|
+ // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
|
|
695
|
+ showPromptModal(con, success, promptInfo?) {
|
|
696
|
+ this.promptModalShow = false;
|
|
697
|
+ this.promptContent = con;
|
|
698
|
+ this.ifSuccess = success;
|
|
699
|
+ this.promptInfo = promptInfo;
|
|
700
|
+ setTimeout(() => {
|
|
701
|
+ this.promptModalShow = true;
|
|
702
|
+ }, 100);
|
|
703
|
+ this.getList(0);
|
|
704
|
+ }
|
|
705
|
+
|
|
706
|
+ // 删除轮巡计划
|
|
707
|
+ delModal: boolean = false; //删除模态框
|
|
708
|
+ tipsMsg1: string; //提示框信息
|
|
709
|
+ tipsMsg2: string; //操作后信息
|
|
710
|
+ confirmDelType: string; //确认的类型(启用/停用,删除)
|
|
711
|
+ confirmDelIsSwitch: boolean; //启用/停用
|
|
712
|
+ showDelModal(
|
|
713
|
+ id: number,
|
|
714
|
+ tipsMsg1: string,
|
|
715
|
+ tipsMsg2: string,
|
|
716
|
+ type: string,
|
|
717
|
+ isSwitch?: boolean
|
|
718
|
+ ) {
|
|
719
|
+ this.confirmDelIsSwitch = isSwitch;
|
|
720
|
+ this.confirmDelType = type;
|
|
721
|
+ this.delModal = true;
|
|
722
|
+ this.coopId = id;
|
|
723
|
+ this.tipsMsg1 = tipsMsg1;
|
|
724
|
+ this.tipsMsg2 = tipsMsg2;
|
|
725
|
+ }
|
|
726
|
+ // 隐藏删除框
|
|
727
|
+ hideDelModal() {
|
|
728
|
+ this.delModal = false;
|
|
729
|
+ }
|
|
730
|
+ // 确认删除
|
|
731
|
+ confirmDel() {
|
|
732
|
+ this.btnLoading = true;
|
|
733
|
+ if (this.confirmDelType === "del") {
|
|
734
|
+ //删除
|
|
735
|
+ this.mainService.delRoundRobin(this.coopId).subscribe((data) => {
|
|
736
|
+ this.btnLoading = false;
|
|
737
|
+ this.delModal = false;
|
|
738
|
+ if (data.status == 200) {
|
|
739
|
+ console.log(this.pageIndex, this.listLength, this.pageSize, "lmm");
|
|
740
|
+ if (
|
|
741
|
+ this.listOfData.length == 1 &&
|
|
742
|
+ this.pageIndex == Math.ceil(this.listLength / this.pageSize)
|
|
743
|
+ ) {
|
|
744
|
+ this.listLength--;
|
|
745
|
+ if (this.listLength === 0) {
|
|
746
|
+ this.pageIndex = 1;
|
|
747
|
+ } else {
|
|
748
|
+ this.pageIndex = Math.ceil(this.listLength / this.pageSize);
|
|
749
|
+ }
|
|
750
|
+ }
|
|
751
|
+ this.showPromptModal(this.tipsMsg2, true, "");
|
|
752
|
+ } else {
|
|
753
|
+ this.showPromptModal(this.tipsMsg2, false, data.msg);
|
|
754
|
+ }
|
|
755
|
+ });
|
|
756
|
+ } else if (this.confirmDelType === "switch") {
|
|
757
|
+ //启用/停用
|
|
758
|
+ this.mainService
|
|
759
|
+ .switchRoundRobin(
|
|
760
|
+ this.confirmDelIsSwitch ? "stop" : "active",
|
|
761
|
+ this.coopId
|
|
762
|
+ )
|
|
763
|
+ .subscribe((data) => {
|
|
764
|
+ this.btnLoading = false;
|
|
765
|
+ this.delModal = false;
|
|
766
|
+ if (data.status == 200) {
|
|
767
|
+ this.showPromptModal(this.tipsMsg2, true, "");
|
|
768
|
+ } else {
|
|
769
|
+ this.showPromptModal(this.tipsMsg2, false, data.msg);
|
|
770
|
+ }
|
|
771
|
+ });
|
|
772
|
+ }
|
|
773
|
+ }
|
|
774
|
+
|
|
775
|
+ // 院区列表
|
|
776
|
+ getHospitalList() {
|
|
777
|
+ this.hospitalList = [this.tool.getCurrentHospital()];
|
|
778
|
+ this.hosId = this.tool.getCurrentHospital().id;
|
|
779
|
+ }
|
|
780
|
+ // 查看
|
|
781
|
+ detail(id) {
|
|
782
|
+ this.router.navigateByUrl("/main/roundRobin/roundRobinDetail/" + id);
|
|
783
|
+ }
|
|
784
|
+ //时间选择框相关
|
|
785
|
+ timeSelectedValue = [];
|
|
786
|
+ defaultSelectTimesOption = [];
|
|
787
|
+
|
|
788
|
+ time: Date | null = null;
|
|
789
|
+ defaultTimePickerOpenValue = new Date();
|
|
790
|
+ timePickerOpen = false;
|
|
791
|
+ timeSelectFocus() {
|
|
792
|
+ this.timePickerOpen = true;
|
|
793
|
+ }
|
|
794
|
+ timePickerClick() {
|
|
795
|
+ this.timePickerOpen = false;
|
|
796
|
+ this.time = this.time || new Date();
|
|
797
|
+ let hour = (this.time.getHours() + "").padStart(2, "0");
|
|
798
|
+ let minute = (this.time.getMinutes() + "").padStart(2, "0");
|
|
799
|
+ let str = `${hour}:${minute}`;
|
|
800
|
+ if (!this.timeSelectedValue.includes(str)) {
|
|
801
|
+ this.defaultSelectTimesOption.push(str);
|
|
802
|
+ this.timeSelectedValue.push(str);
|
|
803
|
+ }
|
|
804
|
+ }
|
|
805
|
+ timePickerChange() {
|
|
806
|
+ if (this.timePickerOpen) {
|
|
807
|
+ this.timePickerOpen = false;
|
|
808
|
+ }
|
|
809
|
+ }
|
|
810
|
+ // -----------------------------------------------------------------------
|
|
811
|
+ // 批量建单设置
|
|
812
|
+ batchOrdersFlag = false; //批量建单设置的弹窗
|
|
813
|
+ selectedBatchOrder = null; //当前选中的轮巡计划
|
|
814
|
+ //打开批量建单设置弹窗
|
|
815
|
+ batchOrdersHandler(data) {
|
|
816
|
+ this.batchOrdersFlag = true;
|
|
817
|
+ this.selectedBatchOrder = data;
|
|
818
|
+ }
|
|
819
|
+ //关闭批量建单设置弹窗
|
|
820
|
+ close() {
|
|
821
|
+ this.batchOrdersFlag = false;
|
|
822
|
+ }
|
|
823
|
+}
|