Browse Source

护士端切换院区

seimin 3 years ago
parent
commit
16a8d0f9de

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

@@ -21,6 +21,10 @@ export class ToolService {
21 21
       ? JSON.parse(localStorage.getItem("user")).user.currentHospital
22 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 29
   initCoopBtns(route) {
26 30
     let link;

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

@@ -2,7 +2,7 @@
2 2
   <div class="modalBody" *ngIf="changeShow">
3 3
     <div class="title">当前科室<i class="icon_transport transport-guanbi" (click)="hideModal()"></i></div>
4 4
     <div class="content">
5
-      <div class="defeat">{{currentDept}}</div>
5
+      <div class="defeat">{{currentDept.dept}}</div>
6 6
       <div class="countDown">关闭倒计时<em>{{closeTime}}s</em></div>
7 7
     </div>
8 8
     <div class="display_flex justify-content_flex-center">
@@ -15,16 +15,31 @@
15 15
     <div class="content content-search">
16 16
       <div class="defeat-search display_flex justify-content_flex-center flex-direction_column">
17 17
         <span>当前院区:<em>{{currentHospital.hosName}}</em></span>
18
-        <span>当前科室:<em>{{currentDept}}</em></span>
18
+        <span>当前科室:<em>{{currentDept.dept}}</em></span>
19 19
       </div>
20 20
       <div class="form">
21 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 37
           <nz-form-item>
23 38
             <nz-form-label class="label" [nzSm]="24" [nzXs]="24" nzRequired nzFor="dutyDeptFc">搜索当值科室
24 39
             </nz-form-label>
25 40
             <nz-form-control class="control" [nzSm]="24" [nzXs]="24" nzErrorTip="请选择当值科室!">
26 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 43
                 <ng-container *ngFor="let option of dutyDepts">
29 44
                   <nz-option *ngIf="!isLoading" [nzLabel]="option.dept" [nzValue]="option.id"></nz-option>
30 45
                 </ng-container>

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

@@ -1,4 +1,3 @@
1
-
2 1
 @import "../../../../src/theme.less";
3 2
 .modal {
4 3
   position: fixed;
@@ -6,7 +5,7 @@
6 5
   top: 0;
7 6
   width: 100%;
8 7
   height: 100%;
9
-  background: rgba(0, 0, 0, .4);
8
+  background: rgba(0, 0, 0, 0.4);
10 9
   z-index: 99;
11 10
 
12 11
   .modalBody {
@@ -16,7 +15,7 @@
16 15
     border-radius: 5px;
17 16
     padding: 10px 20px;
18 17
     color: #333;
19
-    &.modalBody-search{
18
+    &.modalBody-search {
20 19
       width: 480px;
21 20
       min-height: 250px;
22 21
     }
@@ -49,42 +48,42 @@
49 48
       flex-direction: column;
50 49
       justify-content: center;
51 50
       align-items: center;
52
-      &.content-search{
51
+      &.content-search {
53 52
         min-height: 147px;
54 53
         justify-content: start;
55
-        .defeat-search{
54
+        .defeat-search {
56 55
           width: 100%;
57 56
           height: 52px;
58 57
           display: flex;
59 58
           justify-content: center;
60 59
           align-items: center;
61 60
           border-bottom: solid 1px #e5e9ed;
62
-          em{
61
+          em {
63 62
             color: #666;
64 63
             font-style: normal;
65 64
           }
66 65
         }
67
-        .form{
66
+        .form {
68 67
           width: 100%;
69 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 76
       div {
77
-        text-align: center;
78 77
         margin: 0;
79 78
 
80 79
         &.defeat {
81 80
           color: #333;
82 81
           font-size: 28px;
83 82
         }
84
-        &.countDown{
83
+        &.countDown {
85 84
           font-size: 14px;
86 85
           color: 666;
87
-          em{
86
+          em {
88 87
             font-style: normal;
89 88
             color: @primary-color;
90 89
           }
@@ -105,7 +104,6 @@
105 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 141
       button {
145 142
         &:nth-child(1) {
146 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 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
         }