Bladeren bron

PC上下班

seimin 1 jaar geleden
bovenliggende
commit
0cb907325d

+ 21 - 0
src/app/services/main.service.ts

@@ -715,4 +715,25 @@ export class MainService {
715 715
   getSysNameAndLogo(): any {
716 716
     return this.http.get(host.host + "/auth/getSysNameAndLogo", {});
717 717
   }
718
+
719
+  //获取启动中的工作分配方案
720
+  getUserWorkDept(data) {
721
+    return this.http.post(
722
+      host.host + "/auth/getUserWorkDept",
723
+      data,
724
+      {
725
+        headers: this.headers,
726
+      }
727
+    );
728
+  }
729
+  //上下班
730
+  onOrOffLine(data) {
731
+    return this.http.post(
732
+      host.host + "/auth/onOrOffLine",
733
+      data,
734
+      {
735
+        headers: this.headers,
736
+      }
737
+    );
738
+  }
718 739
 }

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

@@ -43,7 +43,9 @@
43 43
           <button nz-button nzType="primary" *ngIf="disinfectionSupplyRole" (click)="toDisinfectionSupply()">全局业务查看</button>
44 44
         </div>
45 45
         <div class="right">
46
-          <div class="msg">
46
+          <button class="mr8" nz-button nzType="primary" *ngIf='PCCommutesToWork && userInfo.user && !userInfo.user.online' (click)="GoWork()">我要上班</button>
47
+          <button class="mr8" nz-button nzType="primary" *ngIf='PCCommutesToWork && userInfo.user && userInfo.user.online' (click)="GoWork()">我要下班</button>
48
+          <!-- <div class="msg">
47 49
             <div class="msgBtn display_flex align-items_center justify-content_flex-center" nz-popover [nzPopoverContent]="contentTemplate" nzPopoverPlacement="bottomRight">
48 50
               <i nz-icon nzType="bell" nzTheme="outline"></i>
49 51
             </div>
@@ -52,7 +54,7 @@
52 54
                 <p>消息通知</p>
53 55
               </div>
54 56
             </ng-template>
55
-          </div>
57
+          </div> -->
56 58
           <div class="userInfo">
57 59
             <div class="wel">欢迎您,{{currentHospital.hosName}}:</div>
58 60
             <div class="user"><img src="../../assets/images/icon_keshi.png" alt="">{{(userInfo&&userInfo.user)?userInfo.user.name:''}}</div>
@@ -73,6 +75,10 @@
73 75
   </nz-layout>
74 76
 </nz-layout>
75 77
 
78
+<!-- 上下班模态框 -->
79
+<app-dialog-delete [delModal]="workModal" (hideDelModalEvent)="hideWorkModal()" [btnLoading]="loading3"
80
+(confirmDelEvent)="confirmWork()" [content]="types"></app-dialog-delete>
81
+
76 82
 <!-- 消息弹框模板 -->
77 83
 <ng-template #msgTemplate1 let-msg="data">
78 84
   <div class="msgTemBox ant-notification-notice-content">

+ 10 - 1
src/app/views/main/main.component.less

@@ -160,6 +160,10 @@ nz-header.ant-layout-header {
160 160
     border-bottom: 1px solid rgba(0, 21, 41, 0.08);
161 161
 
162 162
     .left {
163
+      flex: 1;
164
+      display: flex;
165
+      flex-wrap: wrap;
166
+      align-items: center;
163 167
       .menuLabel {
164 168
         color: #333;
165 169
         font-size: 22px;
@@ -172,12 +176,17 @@ nz-header.ant-layout-header {
172 176
       }
173 177
 
174 178
       button {
175
-        margin-right: 15px;
179
+        margin-right: 8px;
180
+        margin-top: 4px;
181
+        margin-bottom: 4px;
176 182
       }
177 183
     }
178 184
 
179 185
     .right {
180 186
       height: 100%;
187
+      flex-shrink: 0;
188
+      display: flex;
189
+      align-items: center;
181 190
 
182 191
       .msg {
183 192
         float: left;

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

@@ -30,6 +30,7 @@ export class MainComponent implements OnInit {
30 30
   specimenViewRole: boolean = false; //业务视图权限
31 31
   specimenViewRole2: boolean = false; //标本视图权限
32 32
   disinfectionSupplyRole: boolean = false; //全局业务查看权限
33
+  PCCommutesToWork: boolean = false; //PC上下班权限
33 34
   @ViewChild("osComponentRef1", {
34 35
     read: OverlayScrollbarsComponent,
35 36
     static: false,
@@ -63,6 +64,158 @@ export class MainComponent implements OnInit {
63 64
     // 断掉连接
64 65
     this.webs.closeWs(true);
65 66
   }
67
+
68
+  //上下班
69
+  loading3 = false;
70
+  workModal: boolean = false; //模态框
71
+  showWorkModal() {
72
+    this.workModal = true;
73
+  }
74
+  hideWorkModal() {
75
+    this.workModal = false;
76
+  }
77
+  confirmWork() {
78
+    this.loading3 = true;
79
+    if (this.userInfo.user.online) {
80
+      // 判断当前启用的工作方案是自主还是综合排班
81
+      this.getUserWorkDept().then((ress:any) => {
82
+        if (ress.status == 200) {
83
+          let workType = ress.settings ? ress.settings.workType : -1; //1是综合,2是自主
84
+          // 自主下班,并且是科室绑定人员,科室绑定分组,绑定分组
85
+          if (workType == 2) {
86
+            this.loading3 = false;
87
+            this.msg.info('不支持此上班模式!');
88
+          } else {
89
+            this.mainService.onOrOffLine({
90
+              type: "off",
91
+            }).subscribe((res:any) => {
92
+              if (res.status == 200) {
93
+                this.getCurrentUserNow();
94
+              } else {
95
+                this.loading3 = false;
96
+                this.msg.error('操作失败');
97
+              }
98
+            });
99
+          }
100
+        } else if (ress.status == 500) {
101
+          //500的时候自选下班
102
+          this.customOff();
103
+        } else {
104
+          this.loading3 = false;
105
+          this.msg.error('操作失败');
106
+        }
107
+      });
108
+    } else {
109
+      this.getWorkScheme();
110
+    }
111
+  }
112
+
113
+  // 获取启动中的工作分配方案
114
+  workSchemeType:any = ""; //启动中工作分配方案类型
115
+  getWorkScheme() {
116
+    let postData = {
117
+      idx: 0,
118
+      workScheme: {
119
+        status: 1,
120
+        hosId: this.currentHospital.id
121
+      },
122
+      sum: 1,
123
+    };
124
+    this.mainService.getFetchDataList("simple/data", "workScheme", postData).subscribe((res) => {
125
+      if (res.status == 200) {
126
+        if(Array.isArray(res.list) && res.list.length){
127
+          this.workSchemeType = res.list[0].workType;
128
+          if (this.workSchemeType == 2) {
129
+            this.loading3 = false;
130
+            this.msg.info('不支持此上班模式!');
131
+          } else if (this.workSchemeType == 1) {
132
+            this.mainService.onOrOffLine({
133
+              type: "on",
134
+            }).subscribe((res:any) => {
135
+              if (res.status == 200) {
136
+                this.getCurrentUserNow();
137
+              } else {
138
+                this.loading3 = false;
139
+                this.msg.error('操作失败');
140
+              }
141
+            });
142
+          }
143
+        }
144
+      } else {
145
+        this.loading3 = false;
146
+        this.msg.error('操作失败');
147
+      }
148
+    });
149
+  }
150
+
151
+  // 下班
152
+  customOff() {
153
+    this.mainService.onOrOffLine({
154
+      type: "off",
155
+      customWorking: "off",
156
+    }).subscribe((res:any) => {
157
+      if (res.status == 200) {
158
+        this.getCurrentUserNow();
159
+      } else {
160
+        this.loading3 = false;
161
+        this.msg.error('操作失败');
162
+      }
163
+    });
164
+  }
165
+
166
+  // 获取执行中列表
167
+  getWorkingNum() {
168
+    return this.mainService.coopWorkerOrder("executingOrders", {
169
+      idx: 0,
170
+      sum: 1,
171
+    }).toPromise();
172
+  }
173
+
174
+  // 获取启动中的工作分配方案
175
+  getUserWorkDept() {
176
+    return this.mainService.getUserWorkDept({}).toPromise();
177
+  }
178
+
179
+  // 获取当前用户信息
180
+  getCurrentUserNow() {
181
+    this.mainService.getCurrentUser1().subscribe((data:any) => {
182
+      this.loading3 = false;
183
+      if (data.status == 200) {
184
+        let user = JSON.parse(localStorage.getItem("user"));
185
+        user.user = data.data;
186
+        this.userInfo.user = data.data;
187
+        localStorage.setItem("user", JSON.stringify(user));
188
+        this.hideWorkModal();
189
+        this.msg.success('操作成功!');
190
+      }
191
+    });
192
+  }
193
+
194
+  // 上下班
195
+  types = "";
196
+  async GoWork() {
197
+    let workingNum = 0;
198
+    if (this.userInfo.user.online) {
199
+      this.maskFlag = this.msg.loading("正在加载中..", {
200
+        nzDuration: 0,
201
+      }).messageId;
202
+      let workingNumResult = await this.getWorkingNum();
203
+      this.msg.remove(this.maskFlag);
204
+      this.maskFlag = false;
205
+      if (workingNumResult.status == 200) {
206
+        workingNum = workingNumResult.data.data.length;
207
+      }
208
+      if (workingNum) {
209
+        this.types = "您还<b style='color:red'>有未完成的工单</b>,确定下班后,<b style='color:red'>未完成工单将不计算积分。</b>";
210
+      } else {
211
+        this.types = "确定是否下班 ?";
212
+      }
213
+    } else {
214
+      this.types = "确定是否上班 ?";
215
+    }
216
+    this.showWorkModal();
217
+  }
218
+
66 219
   // 根据url高亮菜单baba
67 220
   highlightMenuByUrl() {
68 221
     console.log(this.router.url);
@@ -130,6 +283,10 @@ export class MainComponent implements OnInit {
130 283
         this.disinfectionSupplyRole = true;
131 284
         console.log("全局业务查看权限");
132 285
       }
286
+      if (e.link == "PCCommutesToWork") {
287
+        this.PCCommutesToWork = true;
288
+        console.log("PC上下班");
289
+      }
133 290
       if (!e.link) {
134 291
         arr.push(e);
135 292
       }