Pārlūkot izejas kodu

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

seimin 3 gadi atpakaļ
vecāks
revīzija
758a72a30c

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

@@ -46,3 +46,5 @@
46 46
 <!-- 操作成功/失败提示框 -->
47 47
 <app-prompt-modal *ngIf="promptModalShow" [content]="promptContent" [success]="ifSuccess" [show]="promptModalShow"
48 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 7
   width: 100%;
8 8
   height: 100%;
9 9
   background: rgba(0, 0, 0, .4);
10
-  z-index: 999;
10
+  z-index: 99;
11 11
 
12 12
   .modalBody {
13 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 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
-

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

@@ -72,8 +72,6 @@
72 72
   </nz-layout>
73 73
 </nz-layout>
74 74
 
75
-
76
-
77 75
 <!-- 消息弹框模板 -->
78 76
 <ng-template #msgTemplate1 let-msg="data">
79 77
   <div class="msgTemBox ant-notification-notice-content">
@@ -92,7 +90,6 @@
92 90
   [nzOkLoading]="pwdIsOkLoading">
93 91
   <div>
94 92
     <label>原始密码:
95
-      <!-- <input nz-input placeholder="原始密码" [(ngModel)]="upModalData.pwdOld" /> -->
96 93
       <nz-input-group [nzSuffix]="suffixTemplate">
97 94
         <input maxlength="16" minlength="6" [type]="passwordVisible ? 'text' : 'password'" nz-input placeholder="原始密码"
98 95
           [(ngModel)]="upModalData.pwdOld" />
@@ -103,7 +100,6 @@
103 100
       </ng-template>
104 101
     </label>
105 102
     <label>新密码:
106
-      <!-- <input nz-input placeholder="新密码" [(ngModel)]="upModalData.newPwd" /> -->
107 103
       <nz-input-group [nzSuffix]="suffixTemplate">
108 104
         <input maxlength="16" minlength="6" [type]="passwordVisible ? 'text' : 'password'" nz-input placeholder="新密码"
109 105
           [(ngModel)]="upModalData.newPwd" />
@@ -146,3 +142,5 @@
146 142
     </div>
147 143
   </div>
148 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 389
   hosFlag1 = false;
389 390
   submitFormHand1(id) {
391
+    this.maskFlag = this.msg.loading("正在加载中..", {
392
+      nzDuration: 0,
393
+    }).messageId;
390 394
     this.mainService
391 395
       .changeHospital({ currentHosId: +id, loginType: "PC" })
392 396
       .subscribe((result) => {
397
+        this.msg.remove(this.maskFlag);
398
+        this.maskFlag = false;
393 399
         if (result.status == 200) {
394 400
           localStorage.setItem("user", JSON.stringify(result.user));
395 401
           location.reload(true);