|
@@ -1,101 +1,116 @@
|
1
|
|
-import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
2
|
|
-import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
|
3
|
|
-import { MainService } from '../../services/main.service';
|
4
|
|
-import { ToolService } from '../../services/tool.service';
|
5
|
|
-import { Subject } from 'rxjs';
|
6
|
|
-import { debounceTime } from 'rxjs/operators';
|
|
1
|
+import { Component, OnInit, Input, Output, EventEmitter } from "@angular/core";
|
|
2
|
+import {
|
|
3
|
+ FormBuilder,
|
|
4
|
+ FormControl,
|
|
5
|
+ FormGroup,
|
|
6
|
+ Validators,
|
|
7
|
+} from "@angular/forms";
|
|
8
|
+import { MainService } from "../../services/main.service";
|
|
9
|
+import { ToolService } from "../../services/tool.service";
|
|
10
|
+import { Subject } from "rxjs";
|
|
11
|
+import { debounceTime } from "rxjs/operators";
|
|
12
|
+import { NzMessageService } from "ng-zorro-antd";
|
7
|
13
|
|
8
|
14
|
@Component({
|
9
|
|
- selector: 'app-hs-prompt-modal',
|
10
|
|
- templateUrl: './hs-prompt-modal.component.html',
|
11
|
|
- styleUrls: ['./hs-prompt-modal.component.less']
|
|
15
|
+ selector: "app-hs-prompt-modal",
|
|
16
|
+ templateUrl: "./hs-prompt-modal.component.html",
|
|
17
|
+ styleUrls: ["./hs-prompt-modal.component.less"],
|
12
|
18
|
})
|
13
|
19
|
export class HsPromptModalComponent implements OnInit {
|
14
|
20
|
// 切换科室,切换弹窗
|
15
|
21
|
// changeShow = true //true显示第一个弹窗,false显示选择科室的弹窗
|
16
|
22
|
validateForm!: FormGroup;
|
17
|
|
- dutyDept;//当值科室
|
18
|
|
- dutyDepts = [];//当值科室列表
|
|
23
|
+ dutyDept; //当值科室
|
|
24
|
+ dutyDepts = []; //当值科室列表
|
19
|
25
|
isLoading = false;
|
20
|
|
- currentHospital;//当前院区
|
21
|
|
- currentDept = JSON.parse(localStorage.getItem('user')).user.dept.dept;//当前科室
|
|
26
|
+ currentHospital; //当前院区
|
|
27
|
+ currentDept = JSON.parse(localStorage.getItem("user")).user.dept.dept; //当前科室
|
22
|
28
|
@Input() show: Boolean;
|
23
|
29
|
@Input() changeShow: Boolean;
|
24
|
30
|
@Input() closeTime: Number;
|
25
|
31
|
|
26
|
|
- @Output() closeModelHs = new EventEmitter<any>();//1.组件暴露一个 EventEmitter 属性,当事件发生时,子组件利用该属性 emits(向上弹射)事件
|
27
|
|
- @Output() clearModelHs = new EventEmitter<any>();//1.组件暴露一个 EventEmitter 属性,当事件发生时,子组件利用该属性 emits(向上弹射)事件
|
|
32
|
+ @Output() closeModelHs = new EventEmitter<any>(); //1.组件暴露一个 EventEmitter 属性,当事件发生时,子组件利用该属性 emits(向上弹射)事件
|
|
33
|
+ @Output() clearModelHs = new EventEmitter<any>(); //1.组件暴露一个 EventEmitter 属性,当事件发生时,子组件利用该属性 emits(向上弹射)事件
|
28
|
34
|
|
29
|
|
- constructor(private fb: FormBuilder, private mainService: MainService, private tool: ToolService) { }
|
|
35
|
+ constructor(
|
|
36
|
+ private fb: FormBuilder,
|
|
37
|
+ private mainService: MainService,
|
|
38
|
+ private msg: NzMessageService,
|
|
39
|
+ private tool: ToolService
|
|
40
|
+ ) {}
|
30
|
41
|
searchDeptSubject = new Subject();
|
31
|
42
|
ngOnInit() {
|
32
|
|
- this.searchDeptSubject.pipe(debounceTime(500)).subscribe(v => {
|
|
43
|
+ this.searchDeptSubject.pipe(debounceTime(500)).subscribe((v) => {
|
33
|
44
|
this.search(v);
|
34
|
|
- })
|
|
45
|
+ });
|
35
|
46
|
this.currentHospital = this.tool.getCurrentHospital();
|
36
|
47
|
this.validateForm = this.fb.group({
|
37
|
|
- dutyDeptFc: [null, [Validators.required]],//当班科室
|
|
48
|
+ dutyDeptFc: [null, [Validators.required]], //当班科室
|
38
|
49
|
});
|
39
|
|
- this.search(false)
|
|
50
|
+ this.search(false);
|
40
|
51
|
}
|
41
|
52
|
// 关闭弹窗
|
42
|
53
|
hideModal() {
|
43
|
|
- this.closeModelHs.emit(JSON.stringify({ show: false, changeShow: true }));//emits(向上弹射)事件
|
44
|
|
- // this.changeShow = true
|
|
54
|
+ this.closeModelHs.emit(JSON.stringify({ show: false, changeShow: true })); //emits(向上弹射)事件
|
45
|
55
|
}
|
46
|
56
|
// 切换科室
|
47
|
57
|
changeModal() {
|
48
|
|
- // this.changeShow = false
|
49
|
|
- this.clearModelHs.emit(JSON.stringify({ clear: true, changeShow: false }));//emits(向上弹射)事件
|
|
58
|
+ this.clearModelHs.emit(JSON.stringify({ clear: true, changeShow: false })); //emits(向上弹射)事件
|
50
|
59
|
}
|
51
|
60
|
// 获取当前用户信息
|
52
|
61
|
getCurrentUserNow() {
|
53
|
|
- this.mainService.getCurrentUser1().subscribe(data => {
|
54
|
|
- if (data['status'] == 200) {
|
55
|
|
- let user = JSON.parse(localStorage.getItem('user'))
|
56
|
|
- user.user.dept = data['data'].dept
|
57
|
|
- localStorage.setItem('user', JSON.stringify(user))
|
58
|
|
- this.showPromptModal('切换科室', true, '')
|
59
|
|
- this.hideModal()
|
|
62
|
+ this.mainService.getCurrentUser1().subscribe((data) => {
|
|
63
|
+ if (data["status"] == 200) {
|
|
64
|
+ let user = JSON.parse(localStorage.getItem("user"));
|
|
65
|
+ user.user.dept = data["data"].dept;
|
|
66
|
+ localStorage.setItem("user", JSON.stringify(user));
|
|
67
|
+ this.showPromptModal("切换科室", true, "");
|
|
68
|
+ this.hideModal();
|
60
|
69
|
}
|
61
|
|
- })
|
|
70
|
+ });
|
62
|
71
|
}
|
63
|
72
|
// 确定
|
|
73
|
+ maskFlag: any = false;
|
64
|
74
|
ok() {
|
65
|
|
- let flag = true
|
|
75
|
+ let flag = true;
|
66
|
76
|
for (const i in this.validateForm.controls) {
|
67
|
77
|
this.validateForm.controls[i].markAsDirty();
|
68
|
78
|
this.validateForm.controls[i].updateValueAndValidity();
|
69
|
|
- if (this.validateForm.controls[i].valid === false) {//携带物品非必填
|
70
|
|
- flag = false
|
|
79
|
+ if (this.validateForm.controls[i].valid === false) {
|
|
80
|
+ //携带物品非必填
|
|
81
|
+ flag = false;
|
71
|
82
|
}
|
72
|
83
|
}
|
73
|
84
|
if (!flag) {
|
74
|
85
|
return;
|
75
|
86
|
}
|
76
|
87
|
let dataObj = {
|
77
|
|
- "user": {
|
78
|
|
- "dept": {
|
79
|
|
- "id": this.validateForm.controls.dutyDeptFc.value
|
|
88
|
+ user: {
|
|
89
|
+ dept: {
|
|
90
|
+ id: this.validateForm.controls.dutyDeptFc.value,
|
80
|
91
|
},
|
81
|
|
- "id": JSON.parse(localStorage.getItem('user')).user.id
|
82
|
|
- }
|
83
|
|
- }
|
84
|
|
-
|
85
|
|
- this.mainService.coopData('updData', 'user', dataObj).subscribe(data => {
|
|
92
|
+ id: JSON.parse(localStorage.getItem("user")).user.id,
|
|
93
|
+ },
|
|
94
|
+ };
|
|
95
|
+ this.maskFlag = this.msg.loading("正在加载中..", {
|
|
96
|
+ nzDuration: 0,
|
|
97
|
+ }).messageId;
|
|
98
|
+ this.mainService.coopData("updData", "user", dataObj).subscribe((data) => {
|
|
99
|
+ this.msg.remove(this.maskFlag);
|
|
100
|
+ this.maskFlag = false;
|
86
|
101
|
if (data.status == 200) {
|
87
|
|
- this.getCurrentUserNow()
|
|
102
|
+ this.getCurrentUserNow();
|
88
|
103
|
} else {
|
89
|
|
- this.showPromptModal('切换科室', false, '')
|
|
104
|
+ this.showPromptModal("切换科室", false, "");
|
90
|
105
|
}
|
91
|
|
- })
|
|
106
|
+ });
|
92
|
107
|
}
|
93
|
108
|
|
94
|
109
|
// 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
|
95
|
110
|
promptModalShow = false;
|
96
|
|
- promptContent = '';
|
|
111
|
+ promptContent = "";
|
97
|
112
|
ifSuccess = false;
|
98
|
|
- promptInfo = '';
|
|
113
|
+ promptInfo = "";
|
99
|
114
|
showPromptModal(con, success, promptInfo?) {
|
100
|
115
|
this.promptModalShow = false;
|
101
|
116
|
this.promptContent = con;
|
|
@@ -111,23 +126,24 @@ export class HsPromptModalComponent implements OnInit {
|
111
|
126
|
}
|
112
|
127
|
// 当值科室搜索
|
113
|
128
|
search(e) {
|
114
|
|
- let keywords = ''
|
|
129
|
+ let keywords = "";
|
115
|
130
|
if (e) {
|
116
|
|
- keywords = e
|
|
131
|
+ keywords = e;
|
117
|
132
|
}
|
118
|
133
|
let dataObj = {
|
119
|
|
- "idx": 0,
|
120
|
|
- "sum": 20,
|
121
|
|
- "department": {
|
122
|
|
- "hospital": { id: this.currentHospital.id },
|
123
|
|
- "keyWord": keywords
|
124
|
|
- }
|
125
|
|
- }
|
126
|
|
- this.mainService.getFetchDataList('data', 'department', dataObj).subscribe(data => {
|
127
|
|
- if (data.status == 200) {
|
128
|
|
- this.dutyDepts = data.list
|
129
|
|
- }
|
130
|
|
- })
|
|
134
|
+ idx: 0,
|
|
135
|
+ sum: 20,
|
|
136
|
+ department: {
|
|
137
|
+ hospital: { id: this.currentHospital.id },
|
|
138
|
+ keyWord: keywords,
|
|
139
|
+ },
|
|
140
|
+ };
|
|
141
|
+ this.mainService
|
|
142
|
+ .getFetchDataList("data", "department", dataObj)
|
|
143
|
+ .subscribe((data) => {
|
|
144
|
+ if (data.status == 200) {
|
|
145
|
+ this.dutyDepts = data.list;
|
|
146
|
+ }
|
|
147
|
+ });
|
131
|
148
|
}
|
132
|
149
|
}
|
133
|
|
-
|