Przeglądaj źródła

7.管理端中分组管理,保存成功后依然选中上次所选择的分组

seimin 3 lat temu
rodzic
commit
19af1f6528

+ 1 - 1
src/app/views/group-management/group-management.component.html

@@ -6,7 +6,7 @@
6 6
       <div *ngIf="coopBtns.edit" class="edit item" (click)="showCoopModal('edit')">编辑</div>
7 7
       <div *ngIf="coopBtns.del" class="del item" (click)="showDelModal()">删除</div>
8 8
     </div>
9
-    <div class="groups" *ngIf="!loading1">
9
+    <div class="groups" [ngStyle]="{display:!loading1?'block':'none'}">
10 10
       <overlay-scrollbars #osComponentRef1 [ngStyle]="{ height:'100%' }">
11 11
         <div [ngClass]="{'item':true,'checked':data.id==checkedGroup.id}" *ngFor="let data of groupList"
12 12
           (click)="checkGroup(data)" [title]="data.scheduleClass.name+' '+data.groupName">

+ 162 - 129
src/app/views/group-management/group-management.component.ts

@@ -1,22 +1,31 @@
1
-import { Component, OnInit, ViewChild } from '@angular/core';
2
-import { ActivatedRoute } from "@angular/router"
3
-import { FormBuilder, Validators, FormGroup } from '@angular/forms';
4
-import { NzMessageService } from 'ng-zorro-antd/message';
1
+import { Component, OnInit, ViewChild } from "@angular/core";
2
+import { ActivatedRoute } from "@angular/router";
3
+import { FormBuilder, Validators, FormGroup } from "@angular/forms";
4
+import { NzMessageService } from "ng-zorro-antd/message";
5 5
 
6 6
 import { MainService } from "../../services/main.service";
7
-import { OverlayScrollbarsComponent } from 'overlayscrollbars-ngx';
8
-import { ToolService } from '../../services/tool.service';
7
+import { OverlayScrollbarsComponent } from "overlayscrollbars-ngx";
8
+import { ToolService } from "../../services/tool.service";
9 9
 
10 10
 @Component({
11
-  selector: 'app-group-management',
12
-  templateUrl: './group-management.component.html',
13
-  styleUrls: ['./group-management.component.less']
11
+  selector: "app-group-management",
12
+  templateUrl: "./group-management.component.html",
13
+  styleUrls: ["./group-management.component.less"],
14 14
 })
15 15
 export class GroupManagementComponent implements OnInit {
16 16
   tableHeight;
17 17
 
18
-  constructor(private fb: FormBuilder, private route: ActivatedRoute, private mainService: MainService, private msg: NzMessageService, private tool: ToolService) { }
19
-  @ViewChild('osComponentRef1', { read: OverlayScrollbarsComponent, static: false })
18
+  constructor(
19
+    private fb: FormBuilder,
20
+    private route: ActivatedRoute,
21
+    private mainService: MainService,
22
+    private msg: NzMessageService,
23
+    private tool: ToolService
24
+  ) {}
25
+  @ViewChild("osComponentRef1", {
26
+    read: OverlayScrollbarsComponent,
27
+    static: false,
28
+  })
20 29
   osComponentRef1: OverlayScrollbarsComponent;
21 30
   ngOnInit() {
22 31
     this.initCoopBtns();
@@ -26,89 +35,96 @@ export class GroupManagementComponent implements OnInit {
26 35
     this.getScheduleList();
27 36
     this.tableHeight = document.body.clientHeight - 267;
28 37
   }
29
-  menu: any = JSON.parse(localStorage.getItem('menu')) || [];//菜单
38
+  menu: any = JSON.parse(localStorage.getItem("menu")) || []; //菜单
30 39
   isAllDisplayDataChecked = false;
31 40
   isIndeterminate = false;
32 41
   listOfDisplayData: any[] = [];
33
-  allUserList: any[] = [];//所有用户
34
-  groupUserList: any[] = [];//所选组内用户
42
+  allUserList: any[] = []; //所有用户
43
+  groupUserList: any[] = []; //所选组内用户
35 44
   mapOfCheckedId: { [key: string]: boolean } = {};
36
-  checkedGroup: any = {};//选中分组
37
-  groupList: Array<any> = [];//分组信息
38
-  hospitalList: Array<any> = [];//院区列表
39
-  hosId:any;//当前选择的院区id
40
-  scheduleList: Array<any> = [];//班次列表
41
-  searchName: string = '';//用户信息搜索输入框
45
+  checkedGroup: any = {}; //选中分组
46
+  groupList: Array<any> = []; //分组信息
47
+  hospitalList: Array<any> = []; //院区列表
48
+  hosId: any; //当前选择的院区id
49
+  scheduleList: Array<any> = []; //班次列表
50
+  searchName: string = ""; //用户信息搜索输入框
42 51
 
43
-  promptContent: string;//操作提示框提示信息
44
-  ifSuccess: boolean;//操作成功/失败
45
-  promptInfo: string;//操作结果提示信息
46
-  promptModalShow: boolean;//是否展示提示框
52
+  promptContent: string; //操作提示框提示信息
53
+  ifSuccess: boolean; //操作成功/失败
54
+  promptInfo: string; //操作结果提示信息
55
+  promptModalShow: boolean; //是否展示提示框
47 56
 
48
-  btnLoading: boolean = false;//确认按钮loading状态
49
-  saveLoading: boolean = false;//批量打印按钮loading状态
57
+  btnLoading: boolean = false; //确认按钮loading状态
58
+  saveLoading: boolean = false; //批量打印按钮loading状态
50 59
 
51 60
   // 初始化增删改按钮
52 61
   coopBtns: any = {
53 62
     look: false,
54 63
     add: false,
55 64
     edit: false,
56
-    del: false
65
+    del: false,
57 66
   };
58 67
 
59 68
   initCoopBtns() {
60 69
     // 二级菜单
61
-    let secondMenus = []
62
-    this.menu.forEach(e => {
63
-      e.childrens.forEach(el => {
64
-        secondMenus.push(el)
70
+    let secondMenus = [];
71
+    this.menu.forEach((e) => {
72
+      e.childrens.forEach((el) => {
73
+        secondMenus.push(el);
65 74
       });
66 75
     });
67 76
     let link = this.route.parent.snapshot.routeConfig.path;
68
-    let btns = []
69
-    secondMenus.forEach(e => {
77
+    let btns = [];
78
+    secondMenus.forEach((e) => {
70 79
       if (e.link == link) {
71 80
         btns = e.childrens || [];
72 81
       }
73 82
     });
74
-    btns.forEach(e => {
83
+    btns.forEach((e) => {
75 84
       switch (e.link) {
76
-        case 'look':
85
+        case "look":
77 86
           this.coopBtns.look = true;
78 87
           break;
79
-        case 'add':
88
+        case "add":
80 89
           this.coopBtns.add = true;
81 90
           break;
82
-        case 'edit':
91
+        case "edit":
83 92
           this.coopBtns.edit = true;
84 93
           break;
85
-        case 'del':
94
+        case "del":
86 95
           this.coopBtns.del = true;
87 96
           break;
88 97
       }
89
-    })
98
+    });
90 99
   }
91 100
   // 分组列表
92 101
   loading1 = false;
93 102
   getGroupList() {
94 103
     let that = this;
95 104
     let arr = [];
96
-    this.hospitalList.forEach(item => {
97
-      arr.push(item['id']);
98
-    })
105
+    this.hospitalList.forEach((item) => {
106
+      arr.push(item["id"]);
107
+    });
99 108
     let data = {
100 109
       idx: 0,
101 110
       sum: 999,
102 111
       group2: {
103
-        hospitals: arr.join()
104
-      }
105
-    }
112
+        hospitals: arr.join(),
113
+      },
114
+    };
106 115
     this.loading1 = true;
107
-    that.mainService.getFetchDataList('data', 'group2', data).subscribe(data1 => {
108
-      this.loading1 = false;
109
-      that.groupList = data1.list;
110
-      this.checkGroup(data1.list[0]);
111
-    })
116
+    that.mainService
117
+      .getFetchDataList("data", "group2", data)
118
+      .subscribe((data1) => {
119
+        this.loading1 = false;
120
+        that.groupList = data1.list;
121
+        console.log(this.checkedGroup);
122
+        if (Object.keys(this.checkedGroup).length) {
123
+          this.checkGroup(this.checkedGroup);
124
+        } else {
125
+          this.checkGroup(data1.list[0]);
126
+        }
127
+      });
112 128
   }
113 129
 
114 130
   // 获取选中院区下用户列表
@@ -124,26 +140,32 @@ export class GroupManagementComponent implements OnInit {
124 140
         user: {
125 141
           name: this.searchName,
126 142
           usertype: { id: 106 },
127
-          hospital: { id: this.checkedGroup['hospital']['id'] }
128
-        }
129
-      }
143
+          hospital: { id: this.checkedGroup["hospital"]["id"] },
144
+        },
145
+      };
130 146
       this.timeNum++;
131 147
       this.loading2 = true;
132
-      this.mainService.getFetchDataList('data', 'user', data).subscribe(result => {
133
-        this.timeNum--;
134
-        if (this.timeNum === 0) {
135
-          this.loading2 = false;
136
-          this.onlyFlag = false;
137
-        }
138
-        this.allUserList = result.list;
139
-        this.allUsers = JSON.parse(JSON.stringify(result.list));
140
-        this.refreshStatus(true)
141
-      })
148
+      this.mainService
149
+        .getFetchDataList("data", "user", data)
150
+        .subscribe((result) => {
151
+          this.timeNum--;
152
+          if (this.timeNum === 0) {
153
+            this.loading2 = false;
154
+            this.onlyFlag = false;
155
+          }
156
+          this.allUserList = result.list;
157
+          this.allUsers = JSON.parse(JSON.stringify(result.list));
158
+          this.refreshStatus(true);
159
+        });
142 160
     } else {
143
-      this.allUserList = this.allUsers.filter(item => {
144
-        return item.pinYin.includes(this.searchName) || item.name.includes(this.searchName) || item.inputCode.includes(this.searchName);
145
-      })
146
-      this.refreshStatus(true)
161
+      this.allUserList = this.allUsers.filter((item) => {
162
+        return (
163
+          item.pinYin.includes(this.searchName) ||
164
+          item.name.includes(this.searchName) ||
165
+          item.inputCode.includes(this.searchName)
166
+        );
167
+      });
168
+      this.refreshStatus(true);
147 169
     }
148 170
   }
149 171
   // 获取组内用户
@@ -179,19 +201,25 @@ export class GroupManagementComponent implements OnInit {
179 201
     const data = {
180 202
       idx: 0,
181 203
       scheduleClass: { hospital: { id: this.hosId } },
182
-      sum: 999
183
-    }
184
-    this.mainService.getFetchDataList('configuration', 'scheduleClass', data).subscribe(data => {
185
-      this.scheduleList = data.list;
186
-    })
204
+      sum: 999,
205
+    };
206
+    this.mainService
207
+      .getFetchDataList("configuration", "scheduleClass", data)
208
+      .subscribe((data) => {
209
+        this.scheduleList = data.list;
210
+      });
187 211
   }
188 212
 
189 213
   // 选中分组
214
+  positionY = 0; //记录其他建单Y轴滚动距离
190 215
   checkGroup(data) {
191
-    this.searchName = '';
216
+    this.positionY = this.osComponentRef1.osInstance().scroll().position.y; //内容滚动的距离
217
+    this.searchName = "";
192 218
     this.checkedGroup = data;
193 219
     this.mapOfCheckedId = {};
194
-    this.groupUserList = this.checkedGroup['users'] ? this.checkedGroup['users'] : [];
220
+    this.groupUserList = this.checkedGroup["users"]
221
+      ? this.checkedGroup["users"]
222
+      : [];
195 223
     this.getAllUser();
196 224
   }
197 225
 
@@ -204,8 +232,8 @@ export class GroupManagementComponent implements OnInit {
204 232
     if (first) {
205 233
       for (j = 0; j < that.groupUserList.length; j++) {
206 234
         for (i = 0; i < that.allUserList.length; i++) {
207
-          if (that.allUserList[i]['id'] == that.groupUserList[j]['id']) {
208
-            that.mapOfCheckedId[that.allUserList[i]['id']] = true;
235
+          if (that.allUserList[i]["id"] == that.groupUserList[j]["id"]) {
236
+            that.mapOfCheckedId[that.allUserList[i]["id"]] = true;
209 237
             break;
210 238
           }
211 239
         }
@@ -214,7 +242,7 @@ export class GroupManagementComponent implements OnInit {
214 242
     let arr = [];
215 243
     for (var m in that.mapOfCheckedId) {
216 244
       if (that.mapOfCheckedId[m]) {
217
-        arr.push({ 'id': m })
245
+        arr.push({ id: m });
218 246
       }
219 247
     }
220 248
     that.usersArr = arr;
@@ -226,34 +254,40 @@ export class GroupManagementComponent implements OnInit {
226 254
     that.saveLoading = true;
227 255
     let postData = {
228 256
       group2: {
229
-        id: that.checkedGroup['id'],
230
-        users: that.usersArr
231
-      }
232
-    }
233
-    that.mainService.coopData('updData', 'group2', postData).subscribe(data => {
234
-      that.saveLoading = false;
235
-      if (data.status == 200) {
236
-        that.showPromptModal('保存', true, '');
237
-      } else {
238
-        that.showPromptModal('保存', false, data.msg);
239
-      }
240
-    })
257
+        id: that.checkedGroup["id"],
258
+        users: that.usersArr,
259
+      },
260
+    };
261
+    that.mainService
262
+      .coopData("updData", "group2", postData)
263
+      .subscribe((data) => {
264
+        that.saveLoading = false;
265
+        if (data.status == 200) {
266
+          that.showPromptModal("保存", true, "");
267
+        } else {
268
+          that.showPromptModal("保存", false, data.msg);
269
+        }
270
+      });
241 271
   }
242 272
 
243 273
   // 新增/编辑模态框
244
-  coopModal: boolean = false;//模态框是否展示
245
-  add: boolean = true;//true:新增;false:编辑
274
+  coopModal: boolean = false; //模态框是否展示
275
+  add: boolean = true; //true:新增;false:编辑
246 276
   showCoopModal(type) {
247 277
     let that = this;
248
-    if (type == 'edit' && !that.checkedGroup['groupName']) {
249
-      that.msg.create('warning', '请选择需要编辑的分组!');
278
+    if (type == "edit" && !that.checkedGroup["groupName"]) {
279
+      that.msg.create("warning", "请选择需要编辑的分组!");
250 280
       return;
251 281
     }
252 282
     that.coopModal = true;
253
-    that.add = type == 'add';
254
-    if (type == 'edit') {
255
-      that.validateForm.controls.classes.setValue(that.checkedGroup['scheduleClass'].id + '');
256
-      that.validateForm.controls.groupName.setValue(that.checkedGroup['groupName']);
283
+    that.add = type == "add";
284
+    if (type == "edit") {
285
+      that.validateForm.controls.classes.setValue(
286
+        that.checkedGroup["scheduleClass"].id + ""
287
+      );
288
+      that.validateForm.controls.groupName.setValue(
289
+        that.checkedGroup["groupName"]
290
+      );
257 291
     } else {
258 292
       that.validateForm.controls.classes.setValue(null);
259 293
       that.validateForm.controls.groupName.setValue(null);
@@ -268,7 +302,7 @@ export class GroupManagementComponent implements OnInit {
268 302
   initForm() {
269 303
     this.validateForm = this.fb.group({
270 304
       classes: [null, [Validators.required]],
271
-      groupName: [null, [Validators.required]]
305
+      groupName: [null, [Validators.required]],
272 306
     });
273 307
   }
274 308
 
@@ -286,29 +320,31 @@ export class GroupManagementComponent implements OnInit {
286 320
       group2: {
287 321
         groupName: that.validateForm.value.groupName,
288 322
         hospital: { id: that.hosId - 0 },
289
-        scheduleClass: { id: that.validateForm.value.classes - 0 }
290
-      }
291
-    }
323
+        scheduleClass: { id: that.validateForm.value.classes - 0 },
324
+      },
325
+    };
292 326
     if (!that.add) {
293
-      data.group2['id'] = that.checkedGroup['id'];
327
+      data.group2["id"] = that.checkedGroup["id"];
294 328
     }
295
-    that.mainService.coopData((that.add ? 'addData' : 'updData'), 'group2', data).subscribe(data => {
296
-      that.hideCoopModal();
297
-      that.btnLoading = false;
298
-      that.initForm();
299
-      if (data.status == 200) {
300
-        that.showPromptModal((that.add ? '新增' : '编辑'), true, '');
301
-      } else {
302
-        that.showPromptModal((that.add ? '新增' : '编辑'), false, data.msg);
303
-      }
304
-    })
329
+    that.mainService
330
+      .coopData(that.add ? "addData" : "updData", "group2", data)
331
+      .subscribe((data) => {
332
+        that.hideCoopModal();
333
+        that.btnLoading = false;
334
+        that.initForm();
335
+        if (data.status == 200) {
336
+          that.showPromptModal(that.add ? "新增" : "编辑", true, "");
337
+        } else {
338
+          that.showPromptModal(that.add ? "新增" : "编辑", false, data.msg);
339
+        }
340
+      });
305 341
   }
306 342
 
307 343
   //删除modal
308 344
   delModal: boolean = false;
309 345
   showDelModal() {
310
-    if (!this.checkedGroup['groupName']) {
311
-      this.msg.create('warning', '请选择需要删除的分组!');
346
+    if (!this.checkedGroup["groupName"]) {
347
+      this.msg.create("warning", "请选择需要删除的分组!");
312 348
       return;
313 349
     }
314 350
     this.delModal = true;
@@ -320,16 +356,17 @@ export class GroupManagementComponent implements OnInit {
320 356
   confirmDel() {
321 357
     let that = this;
322 358
     that.btnLoading = true;
323
-    that.mainService.coopData('rmvData', 'group2', [that.checkedGroup['id']]).subscribe(data => {
324
-      that.hideDelModal();
325
-      that.btnLoading = false;
326
-      if (data.status == 200) {
327
-        that.showPromptModal('删除', true, '');
328
-      } else {
329
-        that.showPromptModal('删除', false, data.msg);
330
-      }
331
-    })
332
-
359
+    that.mainService
360
+      .coopData("rmvData", "group2", [that.checkedGroup["id"]])
361
+      .subscribe((data) => {
362
+        that.hideDelModal();
363
+        that.btnLoading = false;
364
+        if (data.status == 200) {
365
+          that.showPromptModal("删除", true, "");
366
+        } else {
367
+          that.showPromptModal("删除", false, data.msg);
368
+        }
369
+      });
333 370
   }
334 371
 
335 372
   // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
@@ -338,14 +375,10 @@ export class GroupManagementComponent implements OnInit {
338 375
     this.promptContent = con;
339 376
     this.ifSuccess = success;
340 377
     this.promptInfo = promptInfo;
378
+    this.osComponentRef1.osInstance().scroll({ x: 0, y: this.positionY });
341 379
     setTimeout(() => {
342 380
       this.promptModalShow = true;
343 381
       this.getGroupList();
344 382
     }, 100);
345 383
   }
346
-
347
-
348
-
349
-
350
-
351 384
 }

+ 13 - 15
src/app/views/hushijiandan/hushijiandan.component.ts

@@ -275,9 +275,8 @@ export class HushijiandanComponent implements OnInit {
275 275
   closeModel(e) {
276 276
     console.log(e);
277 277
     if (e === "other") {
278
-      this.getDeptTaskType("", "clear");
278
+      this.osComponentRef2.osInstance().scroll({ x: 0, y: this.positionY });
279 279
       this.getOrderList();
280
-      this.getSpecimenWorkOrderMsg();
281 280
     } else if (e === "bb") {
282 281
       this.getOrderList();
283 282
       this.getSpecimenWorkOrderMsg();
@@ -288,9 +287,9 @@ export class HushijiandanComponent implements OnInit {
288 287
   otherSearch = ""; //搜索的关键词
289 288
   oLoading = false;
290 289
   nLoading = false;
291
-  handleOffsetY=0;//记录其他建单Y轴滚动距离
290
+  positionY = 0; //记录其他建单Y轴滚动距离
292 291
   otherClick(item) {
293
-    this.handleOffsetY = this.osComponentRef2.osInstance().scroll().handleOffset.y;
292
+    this.positionY = this.osComponentRef2.osInstance().scroll().position.y; //内容滚动的距离
294 293
     this.selectOtherId = item.id;
295 294
     this.newShortcutOrder(item, "other");
296 295
   }
@@ -580,17 +579,16 @@ export class HushijiandanComponent implements OnInit {
580 579
               that.patientMsgList.push(e);
581 580
             }
582 581
           });
583
-          if (clear === "clear") {
584
-            this.otherSearch = "";
585
-            this.workOrderRemark = "";
586
-            this.customRemarks = [];
587
-            this.osComponentRef2.osInstance().scroll(this.handleOffsetY);
588
-            this.historyCustomRemarks = [];
589
-            let obj = that.othersList.find(
590
-              (item) => item.id == this.selectOtherId
591
-            );
592
-            obj && this.otherClick(obj);
593
-          }
582
+          // if (clear === "clear") {
583
+          //   this.otherSearch = "";
584
+          //   this.workOrderRemark = "";
585
+          //   this.customRemarks = [];
586
+          //   this.historyCustomRemarks = [];
587
+          //   let obj = that.othersList.find(
588
+          //     (item) => item.id == this.selectOtherId
589
+          //   );
590
+          //   obj && this.otherClick(obj);
591
+          // }
594 592
           console.log(this.selectOtherId);
595 593
           if (!this.selectOtherId) {
596 594
             if (that.othersList.length) {