|
@@ -1,10 +1,5 @@
|
1
|
1
|
import { Component, OnInit, Input, Output, EventEmitter } from "@angular/core";
|
2
|
|
-import {
|
3
|
|
- FormBuilder,
|
4
|
|
- FormControl,
|
5
|
|
- FormGroup,
|
6
|
|
- Validators,
|
7
|
|
-} from "@angular/forms";
|
|
2
|
+import { FormBuilder, FormGroup, Validators } from "@angular/forms";
|
8
|
3
|
import { MainService } from "../../services/main.service";
|
9
|
4
|
import { ToolService } from "../../services/tool.service";
|
10
|
5
|
import { Subject } from "rxjs";
|
|
@@ -20,11 +15,11 @@ export class HsPromptModalComponent implements OnInit {
|
20
|
15
|
// 切换科室,切换弹窗
|
21
|
16
|
// changeShow = true //true显示第一个弹窗,false显示选择科室的弹窗
|
22
|
17
|
validateForm!: FormGroup;
|
23
|
|
- dutyDept; //当值科室
|
24
|
18
|
dutyDepts = []; //当值科室列表
|
25
|
19
|
isLoading = false;
|
26
|
20
|
currentHospital; //当前院区
|
27
|
|
- currentDept = JSON.parse(localStorage.getItem("user")).user.dept.dept; //当前科室
|
|
21
|
+ hospitals = []; //所有院区
|
|
22
|
+ currentDept; //当前科室
|
28
|
23
|
@Input() show: Boolean;
|
29
|
24
|
@Input() changeShow: Boolean;
|
30
|
25
|
@Input() closeTime: Number;
|
|
@@ -40,17 +35,24 @@ export class HsPromptModalComponent implements OnInit {
|
40
|
35
|
) {}
|
41
|
36
|
searchDeptSubject = new Subject();
|
42
|
37
|
ngOnInit() {
|
43
|
|
- this.searchDeptSubject.pipe(debounceTime(500)).subscribe((v) => {
|
44
|
|
- this.search(v);
|
|
38
|
+ this.searchDeptSubject.pipe(debounceTime(500)).subscribe((v: any) => {
|
|
39
|
+ this.search(v.hosId, v.e);
|
45
|
40
|
});
|
|
41
|
+ this.hospitals = this.tool.getHospitalList();
|
46
|
42
|
this.currentHospital = this.tool.getCurrentHospital();
|
|
43
|
+ this.currentDept = this.tool.getCurrentUserDept();
|
|
44
|
+ this.initForm();
|
|
45
|
+ }
|
|
46
|
+ initForm() {
|
|
47
|
+ this.search(this.currentHospital.id, "");
|
47
|
48
|
this.validateForm = this.fb.group({
|
|
49
|
+ hospital: [this.currentHospital.id, [Validators.required]], //院区
|
48
|
50
|
dutyDeptFc: [null, [Validators.required]], //当班科室
|
49
|
51
|
});
|
50
|
|
- this.search(false);
|
51
|
52
|
}
|
52
|
53
|
// 关闭弹窗
|
53
|
54
|
hideModal() {
|
|
55
|
+ this.initForm();
|
54
|
56
|
this.closeModelHs.emit(JSON.stringify({ show: false, changeShow: true })); //emits(向上弹射)事件
|
55
|
57
|
}
|
56
|
58
|
// 切换科室
|
|
@@ -60,9 +62,12 @@ export class HsPromptModalComponent implements OnInit {
|
60
|
62
|
// 获取当前用户信息
|
61
|
63
|
getCurrentUserNow() {
|
62
|
64
|
this.mainService.getCurrentUser1().subscribe((data) => {
|
|
65
|
+ this.msg.remove(this.maskFlag);
|
|
66
|
+ this.maskFlag = false;
|
63
|
67
|
if (data["status"] == 200) {
|
64
|
68
|
let user = JSON.parse(localStorage.getItem("user"));
|
65
|
69
|
user.user.dept = data["data"].dept;
|
|
70
|
+ user.user.currentHospital = data["data"].currentHospital;
|
66
|
71
|
localStorage.setItem("user", JSON.stringify(user));
|
67
|
72
|
this.showPromptModal("切换科室", true, "");
|
68
|
73
|
this.hideModal();
|
|
@@ -77,31 +82,40 @@ export class HsPromptModalComponent implements OnInit {
|
77
|
82
|
this.validateForm.controls[i].markAsDirty();
|
78
|
83
|
this.validateForm.controls[i].updateValueAndValidity();
|
79
|
84
|
if (this.validateForm.controls[i].valid === false) {
|
80
|
|
- //携带物品非必填
|
81
|
85
|
flag = false;
|
82
|
86
|
}
|
83
|
87
|
}
|
84
|
88
|
if (!flag) {
|
85
|
89
|
return;
|
86
|
90
|
}
|
87
|
|
- let dataObj = {
|
88
|
|
- user: {
|
89
|
|
- dept: {
|
90
|
|
- id: this.validateForm.controls.dutyDeptFc.value,
|
91
|
|
- },
|
92
|
|
- id: JSON.parse(localStorage.getItem("user")).user.id,
|
93
|
|
- },
|
94
|
|
- };
|
95
|
91
|
this.maskFlag = this.msg.loading("正在加载中..", {
|
96
|
92
|
nzDuration: 0,
|
97
|
93
|
}).messageId;
|
98
|
|
- this.mainService.coopData("updData", "user", dataObj).subscribe((data) => {
|
99
|
|
- this.msg.remove(this.maskFlag);
|
100
|
|
- this.maskFlag = false;
|
101
|
|
- if (data.status == 200) {
|
102
|
|
- this.getCurrentUserNow();
|
103
|
|
- } else {
|
104
|
|
- this.showPromptModal("切换科室", false, "");
|
|
94
|
+ let postData = {
|
|
95
|
+ currentHosId: this.validateForm.controls.hospital.value,
|
|
96
|
+ loginType: "PC",
|
|
97
|
+ };
|
|
98
|
+ this.mainService.changeHospital(postData).subscribe((result) => {
|
|
99
|
+ if (result.status == 200) {
|
|
100
|
+ let dataObj = {
|
|
101
|
+ user: {
|
|
102
|
+ dept: {
|
|
103
|
+ id: this.validateForm.controls.dutyDeptFc.value,
|
|
104
|
+ },
|
|
105
|
+ id: JSON.parse(localStorage.getItem("user")).user.id,
|
|
106
|
+ },
|
|
107
|
+ };
|
|
108
|
+ this.mainService
|
|
109
|
+ .coopData("updData", "user", dataObj)
|
|
110
|
+ .subscribe((data) => {
|
|
111
|
+ if (data.status == 200) {
|
|
112
|
+ this.getCurrentUserNow();
|
|
113
|
+ } else {
|
|
114
|
+ this.showPromptModal("切换科室", false, "");
|
|
115
|
+ this.msg.remove(this.maskFlag);
|
|
116
|
+ this.maskFlag = false;
|
|
117
|
+ }
|
|
118
|
+ });
|
105
|
119
|
}
|
106
|
120
|
});
|
107
|
121
|
}
|
|
@@ -121,26 +135,37 @@ export class HsPromptModalComponent implements OnInit {
|
121
|
135
|
}, 100);
|
122
|
136
|
}
|
123
|
137
|
//当值科室搜索
|
124
|
|
- searchDept(e) {
|
125
|
|
- this.searchDeptSubject.next(e);
|
|
138
|
+ searchDept(hosId, e) {
|
|
139
|
+ this.isLoading = true;
|
|
140
|
+ this.searchDeptSubject.next({ hosId, e });
|
|
141
|
+ }
|
|
142
|
+ // 院区选择
|
|
143
|
+ searchHospital(hosId) {
|
|
144
|
+ this.validateForm.controls.dutyDeptFc.setValue(null);
|
|
145
|
+ this.searchDept(hosId, "");
|
126
|
146
|
}
|
127
|
147
|
// 当值科室搜索
|
128
|
|
- search(e) {
|
|
148
|
+ currentKeywords = "";
|
|
149
|
+ search(hosId, e) {
|
129
|
150
|
let keywords = "";
|
130
|
151
|
if (e) {
|
131
|
152
|
keywords = e;
|
132
|
153
|
}
|
|
154
|
+ this.currentKeywords = keywords;
|
133
|
155
|
let dataObj = {
|
134
|
156
|
idx: 0,
|
135
|
|
- sum: 20,
|
|
157
|
+ sum: 10,
|
136
|
158
|
department: {
|
137
|
|
- hospital: { id: this.currentHospital.id },
|
|
159
|
+ hospital: { id: hosId },
|
138
|
160
|
keyWord: keywords,
|
139
|
161
|
},
|
140
|
162
|
};
|
141
|
163
|
this.mainService
|
142
|
164
|
.getFetchDataList("data", "department", dataObj)
|
143
|
165
|
.subscribe((data) => {
|
|
166
|
+ if (this.currentKeywords == keywords) {
|
|
167
|
+ this.isLoading = false;
|
|
168
|
+ }
|
144
|
169
|
if (data.status == 200) {
|
145
|
170
|
this.dutyDepts = data.list;
|
146
|
171
|
}
|