浏览代码

切换院区和切换科室时发送增加load动画效果

seimin 3 年之前
父节点
当前提交
758a72a30c

+ 2 - 0
src/app/share/hs-prompt-modal/hs-prompt-modal.component.html

@@ -46,3 +46,5 @@
46
 <!-- 操作成功/失败提示框 -->
46
 <!-- 操作成功/失败提示框 -->
47
 <app-prompt-modal *ngIf="promptModalShow" [content]="promptContent" [success]="ifSuccess" [show]="promptModalShow"
47
 <app-prompt-modal *ngIf="promptModalShow" [content]="promptContent" [success]="ifSuccess" [show]="promptModalShow"
48
   [info]="promptInfo" [isReLoad]="true"></app-prompt-modal>
48
   [info]="promptInfo" [isReLoad]="true"></app-prompt-modal>
49
+<!-- 遮罩 -->
50
+<app-mask *ngIf="maskFlag"></app-mask>

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

@@ -7,7 +7,7 @@
7
   width: 100%;
7
   width: 100%;
8
   height: 100%;
8
   height: 100%;
9
   background: rgba(0, 0, 0, .4);
9
   background: rgba(0, 0, 0, .4);
10
-  z-index: 999;
10
+  z-index: 99;
11
 
11
 
12
   .modalBody {
12
   .modalBody {
13
     width: 350px;
13
     width: 350px;

+ 79 - 63
src/app/share/hs-prompt-modal/hs-prompt-modal.component.ts

@@ -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
 @Component({
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
 export class HsPromptModalComponent implements OnInit {
19
 export class HsPromptModalComponent implements OnInit {
14
   // 切换科室,切换弹窗
20
   // 切换科室,切换弹窗
15
   // changeShow = true //true显示第一个弹窗,false显示选择科室的弹窗
21
   // changeShow = true //true显示第一个弹窗,false显示选择科室的弹窗
16
   validateForm!: FormGroup;
22
   validateForm!: FormGroup;
17
-  dutyDept;//当值科室
18
-  dutyDepts = [];//当值科室列表
23
+  dutyDept; //当值科室
24
+  dutyDepts = []; //当值科室列表
19
   isLoading = false;
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
   @Input() show: Boolean;
28
   @Input() show: Boolean;
23
   @Input() changeShow: Boolean;
29
   @Input() changeShow: Boolean;
24
   @Input() closeTime: Number;
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
   searchDeptSubject = new Subject();
41
   searchDeptSubject = new Subject();
31
   ngOnInit() {
42
   ngOnInit() {
32
-    this.searchDeptSubject.pipe(debounceTime(500)).subscribe(v => {
43
+    this.searchDeptSubject.pipe(debounceTime(500)).subscribe((v) => {
33
       this.search(v);
44
       this.search(v);
34
-    })
45
+    });
35
     this.currentHospital = this.tool.getCurrentHospital();
46
     this.currentHospital = this.tool.getCurrentHospital();
36
     this.validateForm = this.fb.group({
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
   hideModal() {
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
   changeModal() {
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
   getCurrentUserNow() {
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
   ok() {
74
   ok() {
65
-    let flag = true
75
+    let flag = true;
66
     for (const i in this.validateForm.controls) {
76
     for (const i in this.validateForm.controls) {
67
       this.validateForm.controls[i].markAsDirty();
77
       this.validateForm.controls[i].markAsDirty();
68
       this.validateForm.controls[i].updateValueAndValidity();
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
     if (!flag) {
84
     if (!flag) {
74
       return;
85
       return;
75
     }
86
     }
76
     let dataObj = {
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
       if (data.status == 200) {
101
       if (data.status == 200) {
87
-        this.getCurrentUserNow()
102
+        this.getCurrentUserNow();
88
       } else {
103
       } else {
89
-        this.showPromptModal('切换科室', false, '')
104
+        this.showPromptModal("切换科室", false, "");
90
       }
105
       }
91
-    })
106
+    });
92
   }
107
   }
93
 
108
 
94
   // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
109
   // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
95
   promptModalShow = false;
110
   promptModalShow = false;
96
-  promptContent = '';
111
+  promptContent = "";
97
   ifSuccess = false;
112
   ifSuccess = false;
98
-  promptInfo = '';
113
+  promptInfo = "";
99
   showPromptModal(con, success, promptInfo?) {
114
   showPromptModal(con, success, promptInfo?) {
100
     this.promptModalShow = false;
115
     this.promptModalShow = false;
101
     this.promptContent = con;
116
     this.promptContent = con;
@@ -111,23 +126,24 @@ export class HsPromptModalComponent implements OnInit {
111
   }
126
   }
112
   // 当值科室搜索
127
   // 当值科室搜索
113
   search(e) {
128
   search(e) {
114
-    let keywords = ''
129
+    let keywords = "";
115
     if (e) {
130
     if (e) {
116
-      keywords = e
131
+      keywords = e;
117
     }
132
     }
118
     let dataObj = {
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
-

+ 2 - 4
src/app/views/main/main.component.html

@@ -72,8 +72,6 @@
72
   </nz-layout>
72
   </nz-layout>
73
 </nz-layout>
73
 </nz-layout>
74
 
74
 
75
-
76
-
77
 <!-- 消息弹框模板 -->
75
 <!-- 消息弹框模板 -->
78
 <ng-template #msgTemplate1 let-msg="data">
76
 <ng-template #msgTemplate1 let-msg="data">
79
   <div class="msgTemBox ant-notification-notice-content">
77
   <div class="msgTemBox ant-notification-notice-content">
@@ -92,7 +90,6 @@
92
   [nzOkLoading]="pwdIsOkLoading">
90
   [nzOkLoading]="pwdIsOkLoading">
93
   <div>
91
   <div>
94
     <label>原始密码:
92
     <label>原始密码:
95
-      <!-- <input nz-input placeholder="原始密码" [(ngModel)]="upModalData.pwdOld" /> -->
96
       <nz-input-group [nzSuffix]="suffixTemplate">
93
       <nz-input-group [nzSuffix]="suffixTemplate">
97
         <input maxlength="16" minlength="6" [type]="passwordVisible ? 'text' : 'password'" nz-input placeholder="原始密码"
94
         <input maxlength="16" minlength="6" [type]="passwordVisible ? 'text' : 'password'" nz-input placeholder="原始密码"
98
           [(ngModel)]="upModalData.pwdOld" />
95
           [(ngModel)]="upModalData.pwdOld" />
@@ -103,7 +100,6 @@
103
       </ng-template>
100
       </ng-template>
104
     </label>
101
     </label>
105
     <label>新密码:
102
     <label>新密码:
106
-      <!-- <input nz-input placeholder="新密码" [(ngModel)]="upModalData.newPwd" /> -->
107
       <nz-input-group [nzSuffix]="suffixTemplate">
103
       <nz-input-group [nzSuffix]="suffixTemplate">
108
         <input maxlength="16" minlength="6" [type]="passwordVisible ? 'text' : 'password'" nz-input placeholder="新密码"
104
         <input maxlength="16" minlength="6" [type]="passwordVisible ? 'text' : 'password'" nz-input placeholder="新密码"
109
           [(ngModel)]="upModalData.newPwd" />
105
           [(ngModel)]="upModalData.newPwd" />
@@ -146,3 +142,5 @@
146
     </div>
142
     </div>
147
   </div>
143
   </div>
148
 </div>
144
 </div>
145
+<!-- 遮罩 -->
146
+<app-mask *ngIf="maskFlag"></app-mask>

+ 6 - 0
src/app/views/main/main.component.ts

@@ -385,11 +385,17 @@ export class MainComponent implements OnInit {
385
     }
385
     }
386
   }
386
   }
387
   // 切换院区
387
   // 切换院区
388
+  maskFlag: any = false;
388
   hosFlag1 = false;
389
   hosFlag1 = false;
389
   submitFormHand1(id) {
390
   submitFormHand1(id) {
391
+    this.maskFlag = this.msg.loading("正在加载中..", {
392
+      nzDuration: 0,
393
+    }).messageId;
390
     this.mainService
394
     this.mainService
391
       .changeHospital({ currentHosId: +id, loginType: "PC" })
395
       .changeHospital({ currentHosId: +id, loginType: "PC" })
392
       .subscribe((result) => {
396
       .subscribe((result) => {
397
+        this.msg.remove(this.maskFlag);
398
+        this.maskFlag = false;
393
         if (result.status == 200) {
399
         if (result.status == 200) {
394
           localStorage.setItem("user", JSON.stringify(result.user));
400
           localStorage.setItem("user", JSON.stringify(result.user));
395
           location.reload(true);
401
           location.reload(true);