浏览代码

护士端切换院区

seimin 3 年之前
父节点
当前提交
16a8d0f9de

+ 4 - 0
src/app/services/tool.service.ts

@@ -21,6 +21,10 @@ export class ToolService {
21
       ? JSON.parse(localStorage.getItem("user")).user.currentHospital
21
       ? JSON.parse(localStorage.getItem("user")).user.currentHospital
22
       : JSON.parse(localStorage.getItem("user")).infoPermission.hospitals[0];
22
       : JSON.parse(localStorage.getItem("user")).infoPermission.hospitals[0];
23
   }
23
   }
24
+  //获取当前用户科室
25
+  getCurrentUserDept() {
26
+    return JSON.parse(localStorage.getItem("user")).user.dept;
27
+  }
24
   //获取当前菜单的权限
28
   //获取当前菜单的权限
25
   initCoopBtns(route) {
29
   initCoopBtns(route) {
26
     let link;
30
     let link;

+ 18 - 3
src/app/share/hs-prompt-modal/hs-prompt-modal.component.html

@@ -2,7 +2,7 @@
2
   <div class="modalBody" *ngIf="changeShow">
2
   <div class="modalBody" *ngIf="changeShow">
3
     <div class="title">当前科室<i class="icon_transport transport-guanbi" (click)="hideModal()"></i></div>
3
     <div class="title">当前科室<i class="icon_transport transport-guanbi" (click)="hideModal()"></i></div>
4
     <div class="content">
4
     <div class="content">
5
-      <div class="defeat">{{currentDept}}</div>
5
+      <div class="defeat">{{currentDept.dept}}</div>
6
       <div class="countDown">关闭倒计时<em>{{closeTime}}s</em></div>
6
       <div class="countDown">关闭倒计时<em>{{closeTime}}s</em></div>
7
     </div>
7
     </div>
8
     <div class="display_flex justify-content_flex-center">
8
     <div class="display_flex justify-content_flex-center">
@@ -15,16 +15,31 @@
15
     <div class="content content-search">
15
     <div class="content content-search">
16
       <div class="defeat-search display_flex justify-content_flex-center flex-direction_column">
16
       <div class="defeat-search display_flex justify-content_flex-center flex-direction_column">
17
         <span>当前院区:<em>{{currentHospital.hosName}}</em></span>
17
         <span>当前院区:<em>{{currentHospital.hosName}}</em></span>
18
-        <span>当前科室:<em>{{currentDept}}</em></span>
18
+        <span>当前科室:<em>{{currentDept.dept}}</em></span>
19
       </div>
19
       </div>
20
       <div class="form">
20
       <div class="form">
21
         <form nz-form [formGroup]="validateForm">
21
         <form nz-form [formGroup]="validateForm">
22
+          <nz-form-item style="margin-bottom: 0;">
23
+            <nz-form-label class="label" [nzSm]="24" [nzXs]="24" nzRequired nzFor="hospital">搜索院区
24
+            </nz-form-label>
25
+            <nz-form-control class="control" [nzSm]="24" [nzXs]="24" nzErrorTip="请选择院区!">
26
+              <nz-select formControlName="hospital" [nzDropdownMatchSelectWidth]="false"
27
+                (ngModelChange)="searchHospital($event)" nzPlaceHolder="请选择院区">
28
+                <ng-container *ngFor="let option of hospitals">
29
+                  <nz-option *ngIf="!isLoading" [nzLabel]="option.hosName" [nzValue]="option.id"></nz-option>
30
+                </ng-container>
31
+                <nz-option *ngIf="isLoading" nzDisabled nzCustomContent>
32
+                  <i nz-icon nzType="loading" class="loading-icon"></i> 搜索中...
33
+                </nz-option>
34
+              </nz-select>
35
+            </nz-form-control>
36
+          </nz-form-item>
22
           <nz-form-item>
37
           <nz-form-item>
23
             <nz-form-label class="label" [nzSm]="24" [nzXs]="24" nzRequired nzFor="dutyDeptFc">搜索当值科室
38
             <nz-form-label class="label" [nzSm]="24" [nzXs]="24" nzRequired nzFor="dutyDeptFc">搜索当值科室
24
             </nz-form-label>
39
             </nz-form-label>
25
             <nz-form-control class="control" [nzSm]="24" [nzXs]="24" nzErrorTip="请选择当值科室!">
40
             <nz-form-control class="control" [nzSm]="24" [nzXs]="24" nzErrorTip="请选择当值科室!">
26
               <nz-select formControlName="dutyDeptFc" [nzDropdownMatchSelectWidth]="false" nzServerSearch nzShowSearch
41
               <nz-select formControlName="dutyDeptFc" [nzDropdownMatchSelectWidth]="false" nzServerSearch nzShowSearch
27
-                (nzOnSearch)="searchDept($event)" nzAllowClear nzPlaceHolder="请选择当值科室" [(ngModel)]="dutyDept">
42
+                (nzOnSearch)="searchDept(validateForm.controls.hospital.value,$event)" nzPlaceHolder="请选择当值科室">
28
                 <ng-container *ngFor="let option of dutyDepts">
43
                 <ng-container *ngFor="let option of dutyDepts">
29
                   <nz-option *ngIf="!isLoading" [nzLabel]="option.dept" [nzValue]="option.id"></nz-option>
44
                   <nz-option *ngIf="!isLoading" [nzLabel]="option.dept" [nzValue]="option.id"></nz-option>
30
                 </ng-container>
45
                 </ng-container>

+ 11 - 17
src/app/share/hs-prompt-modal/hs-prompt-modal.component.less

@@ -1,4 +1,3 @@
1
-
2
 @import "../../../../src/theme.less";
1
 @import "../../../../src/theme.less";
3
 .modal {
2
 .modal {
4
   position: fixed;
3
   position: fixed;
@@ -6,7 +5,7 @@
6
   top: 0;
5
   top: 0;
7
   width: 100%;
6
   width: 100%;
8
   height: 100%;
7
   height: 100%;
9
-  background: rgba(0, 0, 0, .4);
8
+  background: rgba(0, 0, 0, 0.4);
10
   z-index: 99;
9
   z-index: 99;
11
 
10
 
12
   .modalBody {
11
   .modalBody {
@@ -16,7 +15,7 @@
16
     border-radius: 5px;
15
     border-radius: 5px;
17
     padding: 10px 20px;
16
     padding: 10px 20px;
18
     color: #333;
17
     color: #333;
19
-    &.modalBody-search{
18
+    &.modalBody-search {
20
       width: 480px;
19
       width: 480px;
21
       min-height: 250px;
20
       min-height: 250px;
22
     }
21
     }
@@ -49,42 +48,42 @@
49
       flex-direction: column;
48
       flex-direction: column;
50
       justify-content: center;
49
       justify-content: center;
51
       align-items: center;
50
       align-items: center;
52
-      &.content-search{
51
+      &.content-search {
53
         min-height: 147px;
52
         min-height: 147px;
54
         justify-content: start;
53
         justify-content: start;
55
-        .defeat-search{
54
+        .defeat-search {
56
           width: 100%;
55
           width: 100%;
57
           height: 52px;
56
           height: 52px;
58
           display: flex;
57
           display: flex;
59
           justify-content: center;
58
           justify-content: center;
60
           align-items: center;
59
           align-items: center;
61
           border-bottom: solid 1px #e5e9ed;
60
           border-bottom: solid 1px #e5e9ed;
62
-          em{
61
+          em {
63
             color: #666;
62
             color: #666;
64
             font-style: normal;
63
             font-style: normal;
65
           }
64
           }
66
         }
65
         }
67
-        .form{
66
+        .form {
68
           width: 100%;
67
           width: 100%;
69
           padding: 0 16px;
68
           padding: 0 16px;
70
-          .ant-form-item-label,.ant-form-explain{
71
-            text-align: left!important;
69
+          .ant-form-item-label,
70
+          .ant-form-explain {
71
+            text-align: left !important;
72
           }
72
           }
73
         }
73
         }
74
       }
74
       }
75
 
75
 
76
       div {
76
       div {
77
-        text-align: center;
78
         margin: 0;
77
         margin: 0;
79
 
78
 
80
         &.defeat {
79
         &.defeat {
81
           color: #333;
80
           color: #333;
82
           font-size: 28px;
81
           font-size: 28px;
83
         }
82
         }
84
-        &.countDown{
83
+        &.countDown {
85
           font-size: 14px;
84
           font-size: 14px;
86
           color: 666;
85
           color: 666;
87
-          em{
86
+          em {
88
             font-style: normal;
87
             font-style: normal;
89
             color: @primary-color;
88
             color: @primary-color;
90
           }
89
           }
@@ -105,7 +104,6 @@
105
         margin-left: 8px;
104
         margin-left: 8px;
106
       }
105
       }
107
     }
106
     }
108
-
109
   }
107
   }
110
 
108
 
111
   // 新增
109
   // 新增
@@ -138,17 +136,13 @@
138
             }
136
             }
139
           }
137
           }
140
         }
138
         }
141
-
142
       }
139
       }
143
 
140
 
144
       button {
141
       button {
145
         &:nth-child(1) {
142
         &:nth-child(1) {
146
           margin-right: 20px;
143
           margin-right: 20px;
147
-
148
         }
144
         }
149
       }
145
       }
150
-
151
     }
146
     }
152
   }
147
   }
153
-
154
 }
148
 }

+ 57 - 32
src/app/share/hs-prompt-modal/hs-prompt-modal.component.ts

@@ -1,10 +1,5 @@
1
 import { Component, OnInit, Input, Output, EventEmitter } from "@angular/core";
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
 import { MainService } from "../../services/main.service";
3
 import { MainService } from "../../services/main.service";
9
 import { ToolService } from "../../services/tool.service";
4
 import { ToolService } from "../../services/tool.service";
10
 import { Subject } from "rxjs";
5
 import { Subject } from "rxjs";
@@ -20,11 +15,11 @@ export class HsPromptModalComponent implements OnInit {
20
   // 切换科室,切换弹窗
15
   // 切换科室,切换弹窗
21
   // changeShow = true //true显示第一个弹窗,false显示选择科室的弹窗
16
   // changeShow = true //true显示第一个弹窗,false显示选择科室的弹窗
22
   validateForm!: FormGroup;
17
   validateForm!: FormGroup;
23
-  dutyDept; //当值科室
24
   dutyDepts = []; //当值科室列表
18
   dutyDepts = []; //当值科室列表
25
   isLoading = false;
19
   isLoading = false;
26
   currentHospital; //当前院区
20
   currentHospital; //当前院区
27
-  currentDept = JSON.parse(localStorage.getItem("user")).user.dept.dept; //当前科室
21
+  hospitals = []; //所有院区
22
+  currentDept; //当前科室
28
   @Input() show: Boolean;
23
   @Input() show: Boolean;
29
   @Input() changeShow: Boolean;
24
   @Input() changeShow: Boolean;
30
   @Input() closeTime: Number;
25
   @Input() closeTime: Number;
@@ -40,17 +35,24 @@ export class HsPromptModalComponent implements OnInit {
40
   ) {}
35
   ) {}
41
   searchDeptSubject = new Subject();
36
   searchDeptSubject = new Subject();
42
   ngOnInit() {
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
     this.currentHospital = this.tool.getCurrentHospital();
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
     this.validateForm = this.fb.group({
48
     this.validateForm = this.fb.group({
49
+      hospital: [this.currentHospital.id, [Validators.required]], //院区
48
       dutyDeptFc: [null, [Validators.required]], //当班科室
50
       dutyDeptFc: [null, [Validators.required]], //当班科室
49
     });
51
     });
50
-    this.search(false);
51
   }
52
   }
52
   // 关闭弹窗
53
   // 关闭弹窗
53
   hideModal() {
54
   hideModal() {
55
+    this.initForm();
54
     this.closeModelHs.emit(JSON.stringify({ show: false, changeShow: true })); //emits(向上弹射)事件
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
   getCurrentUserNow() {
63
   getCurrentUserNow() {
62
     this.mainService.getCurrentUser1().subscribe((data) => {
64
     this.mainService.getCurrentUser1().subscribe((data) => {
65
+      this.msg.remove(this.maskFlag);
66
+      this.maskFlag = false;
63
       if (data["status"] == 200) {
67
       if (data["status"] == 200) {
64
         let user = JSON.parse(localStorage.getItem("user"));
68
         let user = JSON.parse(localStorage.getItem("user"));
65
         user.user.dept = data["data"].dept;
69
         user.user.dept = data["data"].dept;
70
+        user.user.currentHospital = data["data"].currentHospital;
66
         localStorage.setItem("user", JSON.stringify(user));
71
         localStorage.setItem("user", JSON.stringify(user));
67
         this.showPromptModal("切换科室", true, "");
72
         this.showPromptModal("切换科室", true, "");
68
         this.hideModal();
73
         this.hideModal();
@@ -77,31 +82,40 @@ export class HsPromptModalComponent implements OnInit {
77
       this.validateForm.controls[i].markAsDirty();
82
       this.validateForm.controls[i].markAsDirty();
78
       this.validateForm.controls[i].updateValueAndValidity();
83
       this.validateForm.controls[i].updateValueAndValidity();
79
       if (this.validateForm.controls[i].valid === false) {
84
       if (this.validateForm.controls[i].valid === false) {
80
-        //携带物品非必填
81
         flag = false;
85
         flag = false;
82
       }
86
       }
83
     }
87
     }
84
     if (!flag) {
88
     if (!flag) {
85
       return;
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
     this.maskFlag = this.msg.loading("正在加载中..", {
91
     this.maskFlag = this.msg.loading("正在加载中..", {
96
       nzDuration: 0,
92
       nzDuration: 0,
97
     }).messageId;
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
     }, 100);
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
     let keywords = "";
150
     let keywords = "";
130
     if (e) {
151
     if (e) {
131
       keywords = e;
152
       keywords = e;
132
     }
153
     }
154
+    this.currentKeywords = keywords;
133
     let dataObj = {
155
     let dataObj = {
134
       idx: 0,
156
       idx: 0,
135
-      sum: 20,
157
+      sum: 10,
136
       department: {
158
       department: {
137
-        hospital: { id: this.currentHospital.id },
159
+        hospital: { id: hosId },
138
         keyWord: keywords,
160
         keyWord: keywords,
139
       },
161
       },
140
     };
162
     };
141
     this.mainService
163
     this.mainService
142
       .getFetchDataList("data", "department", dataObj)
164
       .getFetchDataList("data", "department", dataObj)
143
       .subscribe((data) => {
165
       .subscribe((data) => {
166
+        if (this.currentKeywords == keywords) {
167
+          this.isLoading = false;
168
+        }
144
         if (data.status == 200) {
169
         if (data.status == 200) {
145
           this.dutyDepts = data.list;
170
           this.dutyDepts = data.list;
146
         }
171
         }