Ver código fonte

增加用户类型三方人员,增加三方公司

seimin 8 meses atrás
pai
commit
3d4a8b3ef5

+ 1 - 8
src/app/views/configuration-center/configuration-center.component.html

@@ -171,17 +171,10 @@
171 171
                   <nz-form-item>
172 172
                     <nz-form-control [nzSpan]="24" nzErrorTip="请输入值!">
173 173
                       <nz-input-group>
174
-                        <nz-input-number [formControlName]="'value_' + data.id" class="valueInput"></nz-input-number>
174
+                        <input [formControlName]="'value_' + data.id" nz-input class="valueInput">
175 175
                       </nz-input-group>
176 176
                     </nz-form-control>
177 177
                   </nz-form-item>
178
-                  <!-- <nz-form-item class="ml8">
179
-                    <nz-form-control [nzSpan]="24" nzErrorTip="请输入排序号!">
180
-                      <nz-input-group>
181
-                        <nz-input-number [formControlName]="'orders_' + data.id" class="nameInput"></nz-input-number>
182
-                      </nz-input-group>
183
-                    </nz-form-control>
184
-                  </nz-form-item> -->
185 178
                   <i class="icon_transport transport-tag27fuben ml8" (click)="addField(i)"></i>
186 179
                   <i class="icon_transport transport-shanchu1 ml8" *ngIf="dictionaryList.length > 1 && !data.system" (click)="removeField(data, i)"></i>
187 180
                 </div>

+ 15 - 8
src/app/views/configuration-center/configuration-center.component.ts

@@ -1,9 +1,8 @@
1 1
 import { Component, OnInit, ViewChild, AfterViewInit } from "@angular/core";
2 2
 import { Location } from '@angular/common';
3
-import { NzFormatEmitEvent, NzTreeNodeOptions, NzTreeComponent, NzMessageService } from 'ng-zorro-antd';
3
+import { NzTreeNodeOptions, NzTreeComponent, NzMessageService } from 'ng-zorro-antd';
4 4
 import { ToolService } from 'src/app/services/tool.service';
5 5
 import { MainService } from 'src/app/services/main.service';
6
-import cloneDeep from 'lodash-es/cloneDeep'
7 6
 import { OverlayScrollbarsComponent } from 'overlayscrollbars-ngx';
8 7
 import { Router, ActivatedRoute } from '@angular/router';
9 8
 import { Subject } from 'rxjs';
@@ -692,7 +691,7 @@ export class ConfigurationCenterComponent implements OnInit, AfterViewInit {
692 691
       idx: 0,
693 692
       sum: 9999,
694 693
       dictionary: {
695
-        key: "incident_category_score"
694
+        key: this.activeDictionaryKey.key,
696 695
       }
697 696
     }
698 697
     this.maskFlag = this.message.loading("正在加载中..", {
@@ -729,7 +728,7 @@ export class ConfigurationCenterComponent implements OnInit, AfterViewInit {
729 728
       this.dictionaryList.forEach((obj, i) => {
730 729
         for (const key in obj) {
731 730
           if(key !== 'id' && key !== 'system'){
732
-            this.validateDictionaryForm.addControl(key + '_' + obj.id, new FormControl(obj[key], [Validators.required]))
731
+            this.validateDictionaryForm.addControl(key + '_' + obj.id, new FormControl({value: obj[key], disabled: key === 'value' ? obj.system : false}, [Validators.required]))
733 732
           }
734 733
         }
735 734
       })
@@ -743,12 +742,13 @@ export class ConfigurationCenterComponent implements OnInit, AfterViewInit {
743 742
       name: null,
744 743
       value: null,
745 744
       orders: null,
745
+      system: false,
746 746
     };
747 747
 
748 748
     // 动态添加表单
749 749
     for (const key in obj) {
750 750
       console.log(key + '_' + obj.id)
751
-      if(key !== 'id'){
751
+      if(key !== 'id' && key !== 'system'){
752 752
         this.validateDictionaryForm.addControl(key + '_' + obj.id, new FormControl(null, [Validators.required]))
753 753
       }
754 754
     }
@@ -791,8 +791,8 @@ export class ConfigurationCenterComponent implements OnInit, AfterViewInit {
791 791
         name: this.validateDictionaryForm.value['name_' + this.dictionaryList[i].id],
792 792
         value: this.validateDictionaryForm.value['value_' + this.dictionaryList[i].id],
793 793
         orders: this.validateDictionaryForm.value['orders_' + this.dictionaryList[i].id],
794
-        system: !uuidValidate(this.dictionaryList[i].id),
795
-        key: 'incident_category_score',
794
+        system: uuidValidate(this.dictionaryList[i].id) ? false : this.dictionaryList[i].system,
795
+        key: this.activeDictionaryKey.key,
796 796
       })
797 797
     }
798 798
     console.log(postData);
@@ -884,13 +884,20 @@ export class ConfigurationCenterComponent implements OnInit, AfterViewInit {
884 884
 
885 885
   // 数据字典key列表
886 886
   dictionaryKeyList: any[] = [
887
-    { id: 1, name: '积分配置',},
887
+    { id: 1, name: '积分配置', key: "incident_category_score"},
888
+    { id: 2, name: '事件来源', key: "incident_source"},
889
+    { id: 3, name: '处理结果', key: "incident_closecode"},
890
+    { id: 4, name: '处理方式', key: "incident_handle_type"},
891
+    { id: 5, name: '状态', key: "incident_status"},
892
+    { id: 6, name: '维修记录', key: "repair_type"},
893
+    { id: 7, name: '满意度评价', key: "incident_degree"},
888 894
   ];
889 895
 
890 896
   // 点击数据字典key
891 897
   activeDictionaryKey:any = this.dictionaryKeyList[0];
892 898
   clickDictionaryKey(item){
893 899
     this.activeDictionaryKey = item;
900
+    this.getDictionaryList();
894 901
   }
895 902
 
896 903
   // 点击故障现象

+ 17 - 5
src/app/views/users-management/users-management.component.html

@@ -138,8 +138,22 @@
138 138
           <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="usertype">用户类型</nz-form-label>
139 139
           <nz-form-control nzErrorTip="请选择用户类型!">
140 140
             <nz-select [nzDropdownMatchSelectWidth]="false" type="usertype" nzShowSearch nzAllowClear
141
-              formControlName="usertype" nzPlaceHolder="请选择用户类型" (ngModelChange)="usertypeChange()">
142
-              <nz-option nzLabel="{{data.name}}" nzValue="{{data.id}}" *ngFor="let data of userTypes">
141
+              formControlName="usertype" nzPlaceHolder="请选择用户类型" (ngModelChange)="usertypeChange($event)">
142
+              <nz-option nzLabel="{{data.name}}" nzValue="{{data.value}}" *ngFor="let data of userTypes">
143
+              </nz-option>
144
+            </nz-select>
145
+          </nz-form-control>
146
+        </nz-form-item>
147
+        <nz-form-item *ngIf="validateForm.value.usertype == 4">
148
+          <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="companyId">所属公司</nz-form-label>
149
+          <nz-form-control nzErrorTip="请选择所属公司!">
150
+            <nz-select (nzOnSearch)="changeCompanyInp(hosId,'add',$event)" [nzDropdownMatchSelectWidth]="false"
151
+              nzServerSearch nzShowSearch nzAllowClear formControlName="companyId" nzPlaceHolder="请选择所属公司">
152
+              <ng-container *ngFor="let option of allcompany">
153
+                <nz-option *ngIf="!isLoading" [nzLabel]="option.name" [nzValue]="option.id"></nz-option>
154
+              </ng-container>
155
+              <nz-option *ngIf="isLoading" nzDisabled nzCustomContent>
156
+                <i nz-icon nzType="loading" class="loading-icon"></i> 搜索中...
143 157
               </nz-option>
144 158
             </nz-select>
145 159
           </nz-form-control>
@@ -149,8 +163,6 @@
149 163
           <nz-form-control nzErrorTip="请选择所属科室!">
150 164
             <nz-select (nzOnSearch)="changeInp(hosId,'add',$event)" [nzDropdownMatchSelectWidth]="false" type="dept"
151 165
               nzServerSearch nzShowSearch nzAllowClear formControlName="dept" nzPlaceHolder="请选择所属科室">
152
-              <!-- <nz-option nzLabel="{{data.dept}}" nzValue="{{data.id}}" *ngFor="let data of alldepart">
153
-              </nz-option> -->
154 166
               <ng-container *ngFor="let option of alldepart">
155 167
                 <nz-option *ngIf="!isLoading" [nzLabel]="option.dept" [nzValue]="option.id"></nz-option>
156 168
               </ng-container>
@@ -169,7 +181,7 @@
169 181
           </nz-form-control>
170 182
         </nz-form-item>
171 183
         <nz-form-item>
172
-          <nz-form-label style="line-height:40px;" [nzSm]="6" [nzXs]="24" nzRequired nzFor="gender">性别</nz-form-label>
184
+          <nz-form-label style="line-height:40px;" [nzSm]="3" [nzXs]="24" nzRequired nzFor="gender">性别</nz-form-label>
173 185
           <nz-form-control nzErrorTip="请选择性别!">
174 186
             <nz-radio-group type="gender" formControlName="gender">
175 187
               <label nz-radio nzValue="{{data.id}}" *ngFor="let data of genders">{{data.name}}</label>

+ 148 - 46
src/app/views/users-management/users-management.component.ts

@@ -49,6 +49,7 @@ export class UsersManagementComponent implements OnInit {
49 49
   userTypes: Array<any> = []; //所有用户类型
50 50
   alldepart: any = []; //所有所属科室
51 51
   alldepart1: any = []; //所有所属科室(搜索)
52
+  allcompany: any = []; //所有所属公司
52 53
   allUserGroup: Array<any>; //所有用户组
53 54
   allUserGroup1: Array<any>; //用户组(搜索)
54 55
   allUserRole: Array<any>; //所有角色
@@ -64,14 +65,18 @@ export class UsersManagementComponent implements OnInit {
64 65
   btnLoading: boolean = false; //提交按钮loading状态
65 66
   wxRequired = false; //新增或编辑用户的时候,微信号是否必填
66 67
   changeInpSubject = new Subject(); //防抖
68
+  changeInpCompanySubject = new Subject(); //防抖
67 69
 
68 70
   ngOnInit() {
69 71
     //防抖
70 72
     this.changeInpSubject.pipe(debounceTime(500)).subscribe((v) => {
71 73
       this.getDeparts(v[0], v[1], v[2]);
72 74
     });
75
+    //防抖
76
+    this.changeInpCompanySubject.pipe(debounceTime(500)).subscribe((v) => {
77
+      this.getCompany(v[0], v[1], v[2]);
78
+    });
73 79
     this.coopBtns = this.tool.initCoopBtns(this.route);
74
-    this.initForm();
75 80
     this.getAllRole();
76 81
     this.getUserTypes();
77 82
     this.getGender();
@@ -257,6 +262,14 @@ export class UsersManagementComponent implements OnInit {
257 262
       idx: 0,
258 263
       sum: 9999,
259 264
     };
265
+    let companyData = {
266
+      company: {
267
+        busiType: {key: "company_busi_type", value: "2"},
268
+        hosId: hid,
269
+      },
270
+      idx: 0,
271
+      sum: 20,
272
+    };
260 273
     this.maskFlag = this.message.loading("正在加载中..", {
261 274
       nzDuration: 0,
262 275
     }).messageId;
@@ -266,12 +279,14 @@ export class UsersManagementComponent implements OnInit {
266 279
       data
267 280
     );
268 281
     let group$ = this.mainService.getFetchDataList("data", "group2", groupData);
269
-    forkJoin(department$, group$).subscribe((res) => {
282
+    let company$ = this.mainService.getFetchDataList("simple/data", "company", companyData);
283
+    forkJoin(department$, group$, company$).subscribe((res) => {
270 284
       this.message.remove(this.maskFlag);
271 285
       this.maskFlag = false;
272 286
       this.modal = true;
273 287
       this.alldepart = res[0]["list"];
274 288
       this.allUserGroup = res[1]["list"];
289
+      this.allcompany = res[2]["list"];
275 290
     });
276 291
   }
277 292
   // 切换院区选项获取对应科室列表(搜索)seimin
@@ -318,23 +333,25 @@ export class UsersManagementComponent implements OnInit {
318 333
   showModal() {
319 334
     this.add = true;
320 335
     this.initForm();
336
+    this.requiredConfigChange('companyId', false);
321 337
     this.changeHosp();
322 338
   }
323 339
   hideModal() {
324 340
     this.modal = false;
325
-    this.initForm();
326 341
   }
327 342
 
328 343
   // 初始化新增form表单
329 344
   initForm() {
330 345
     if (this.add) {
331 346
       this.alldepart = [];
347
+      this.allcompany = [];
332 348
       this.allUserGroup = [];
333 349
     }
334 350
     this.validateForm = this.fb.group({
335 351
       name: [null, [Validators.required]],
336 352
       account: [null, [Validators.required]],
337 353
       usertype: [null, [Validators.required]],
354
+      companyId: [null],
338 355
       dept: [null, [Validators.required]],
339 356
       deptPhone: [null, [Validators.required]],
340 357
       gender: [null, [Validators.required]],
@@ -344,7 +361,7 @@ export class UsersManagementComponent implements OnInit {
344 361
     });
345 362
   }
346 363
   // 选择用户类型
347
-  usertypeChange() {
364
+  usertypeChange(value) {
348 365
     // if (this.validateForm.value.usertype == 106) {
349 366
     //   //配送人员
350 367
     //   this.wxRequired = true;
@@ -360,6 +377,14 @@ export class UsersManagementComponent implements OnInit {
360 377
     this.validateForm.get("weixin")!.markAsPristine();
361 378
 
362 379
     this.validateForm.get("weixin")!.updateValueAndValidity();
380
+
381
+    this.validateForm.controls.companyId.setValue(null);
382
+    if(value == 4){
383
+      // 三方人员
384
+      this.requiredConfigChange('companyId', true);
385
+    }else{
386
+      this.requiredConfigChange('companyId', false);
387
+    }
363 388
   }
364 389
   // 表单提交
365 390
   submitForm(): void {
@@ -385,13 +410,14 @@ export class UsersManagementComponent implements OnInit {
385 410
         name: that.validateForm.value.name,
386 411
         account: that.validateForm.value.account,
387 412
         gender: { id: that.validateForm.value.gender, key: "user_gender" },
388
-        usertype: { id: that.validateForm.value.usertype },
413
+        usertype: this.userTypes.find(v => v.value == that.validateForm.value.usertype),
389 414
         dept: { id: that.validateForm.value.dept },
390 415
         group: groups,
391 416
         role: roles,
392 417
         phone: that.validateForm.value.deptPhone,
393 418
         hospital: { id: that.hosId },
394 419
         weixin: that.validateForm.value.weixin,
420
+        companyId: that.validateForm.value.companyId || undefined,
395 421
       },
396 422
     };
397 423
     if (!that.validateForm.value.userGroup) {
@@ -416,9 +442,21 @@ export class UsersManagementComponent implements OnInit {
416 442
       });
417 443
   }
418 444
 
445
+  requiredConfigChange(name: string, required: boolean): void {
446
+    if (!required) {
447
+      this.validateForm.get(name)!.clearValidators();
448
+      this.validateForm.get(name)!.markAsPristine();
449
+    } else {
450
+      this.validateForm.get(name)!.setValidators(Validators.required);
451
+      this.validateForm.get(name)!.markAsDirty();
452
+    }
453
+    this.validateForm.get(name)!.updateValueAndValidity();
454
+  }
455
+
419 456
   // 编辑
420 457
   maskFlag: any = false;
421 458
   edit(data) {
459
+    this.initForm();
422 460
     // ----------------
423 461
     var hid = data.hospital.id;
424 462
     let departmentData = {
@@ -436,6 +474,14 @@ export class UsersManagementComponent implements OnInit {
436 474
       idx: 0,
437 475
       sum: 9999,
438 476
     };
477
+    let companyData = {
478
+      company: {
479
+        busiType: {key: "company_busi_type", value: "2"},
480
+        hosId: hid,
481
+      },
482
+      idx: 0,
483
+      sum: 20,
484
+    };
439 485
     this.maskFlag = this.message.loading("正在加载中..", {
440 486
       nzDuration: 0,
441 487
     }).messageId;
@@ -446,9 +492,6 @@ export class UsersManagementComponent implements OnInit {
446 492
         this.mainService
447 493
           .getFetchDataList("data", "department", departmentData)
448 494
           .subscribe((item2) => {
449
-            this.message.remove(this.maskFlag);
450
-            this.maskFlag = false;
451
-            this.modal = true;
452 495
             this.alldepart = item2.list;
453 496
             if (data.dept) {
454 497
               let has = item2.list.some((d) => d.id == data.dept.id);
@@ -456,39 +499,56 @@ export class UsersManagementComponent implements OnInit {
456 499
                 this.alldepart = [data.dept, ...item2.list];
457 500
               }
458 501
             }
459
-            this.isLoading = false;
460
-            // ------------------------
461
-            this.add = false;
462
-            this.coopId = data.id;
463
-            let groups = [],
464
-              roles = [];
465
-            if (data.group) {
466
-              data.group.forEach((element) => {
467
-                groups.push(element["id"] + "");
468
-              });
469
-            }
470
-            if (data.role) {
471
-              data.role.forEach((element) => {
472
-                roles.push(element["id"] + "");
473
-              });
474
-            }
475
-            this.validateForm.controls.name.setValue(data.name);
476
-            this.validateForm.controls.account.setValue(data.account);
477
-            this.validateForm.controls.usertype.setValue(data.usertype.id + "");
478
-            if (data.dept) {
479
-              this.validateForm.controls.dept.setValue(data.dept.id);
480
-            }
481
-            this.validateForm.controls.deptPhone.setValue(data.phone);
482
-            this.validateForm.controls.gender.setValue(data.gender.id + "");
483
-            this.validateForm.controls.userGroup.setValue(
484
-              groups.length ? groups : null
485
-            );
486
-            this.validateForm.controls.role.setValue(
487
-              roles.length ? roles : null
488
-            );
489
-            this.validateForm.controls.gender.setValue(data.gender.id + "");
490
-            this.validateForm.controls.weixin.setValue(data.weixin);
491
-            this.usertypeChange();
502
+            this.mainService
503
+            .getFetchDataList("simple/data", "company", companyData)
504
+            .subscribe((item3) => {
505
+              this.message.remove(this.maskFlag);
506
+              this.maskFlag = false;
507
+              this.modal = true;
508
+              this.allcompany = item3.list;
509
+              if (data.companyDTO) {
510
+                let has = item3.list.some((d) => d.id == data.companyDTO.id);
511
+                if (!has) {
512
+                  this.allcompany = [data.companyDTO, ...item3.list];
513
+                }
514
+              }
515
+              this.isLoading = false;
516
+              // ------------------------
517
+              this.add = false;
518
+              this.coopId = data.id;
519
+              let groups = [],
520
+                roles = [];
521
+              if (data.group) {
522
+                data.group.forEach((element) => {
523
+                  groups.push(element["id"] + "");
524
+                });
525
+              }
526
+              if (data.role) {
527
+                data.role.forEach((element) => {
528
+                  roles.push(element["id"] + "");
529
+                });
530
+              }
531
+              this.validateForm.controls.name.setValue(data.name);
532
+              this.validateForm.controls.account.setValue(data.account);
533
+              this.validateForm.controls.usertype.setValue(data.usertype.value);
534
+              if (data.dept) {
535
+                this.validateForm.controls.dept.setValue(data.dept.id);
536
+              }
537
+              this.validateForm.controls.deptPhone.setValue(data.phone);
538
+              this.validateForm.controls.gender.setValue(data.gender.id + "");
539
+              this.validateForm.controls.userGroup.setValue(
540
+                groups.length ? groups : null
541
+              );
542
+              this.validateForm.controls.role.setValue(
543
+                roles.length ? roles : null
544
+              );
545
+              this.validateForm.controls.gender.setValue(data.gender.id + "");
546
+              this.validateForm.controls.weixin.setValue(data.weixin);
547
+              this.usertypeChange(data.usertype.value);
548
+              if (data.companyDTO) {
549
+                this.validateForm.controls.companyId.setValue(data.companyDTO.id);
550
+              }
551
+            });
492 552
           });
493 553
       });
494 554
     // ----------------
@@ -603,8 +663,8 @@ export class UsersManagementComponent implements OnInit {
603 663
   }
604 664
   // 边输边搜节流阀
605 665
   isLoading = false;
606
-  changeInp(deptId, type, e) {
607
-    if (!deptId) {
666
+  changeInp(hosId, type, e) {
667
+    if (!hosId) {
608 668
       if (type == "search") {
609 669
         this.alldepart1 = [];
610 670
       } else if (type == "add") {
@@ -613,17 +673,30 @@ export class UsersManagementComponent implements OnInit {
613 673
       return;
614 674
     }
615 675
     this.isLoading = true;
616
-    this.changeInpSubject.next([deptId, type, e]);
676
+    this.changeInpSubject.next([hosId, type, e]);
677
+  }
678
+
679
+  changeCompanyInp(hosId, type, e) {
680
+    if (!hosId) {
681
+      if (type == "search") {
682
+
683
+      } else if (type == "add") {
684
+        this.allcompany = [];
685
+      }
686
+      return;
687
+    }
688
+    this.isLoading = true;
689
+    this.changeInpCompanySubject.next([hosId, type, e]);
617 690
   }
618 691
   // 获取所有科室
619 692
   snum = 0;
620
-  getDeparts(deptId, type, dept) {
693
+  getDeparts(hosId, type, dept) {
621 694
     var that = this;
622 695
     let data = {
623 696
       department: {
624 697
         dept,
625 698
         hospital: {
626
-          id: deptId,
699
+          id: hosId,
627 700
         },
628 701
       },
629 702
       idx: 0,
@@ -644,4 +717,33 @@ export class UsersManagementComponent implements OnInit {
644 717
         }
645 718
       });
646 719
   }
720
+
721
+  // 获取所有科室
722
+  cnum = 0;
723
+  getCompany(hosId, type, keyword) {
724
+    var that = this;
725
+    let data = {
726
+      company: {
727
+        name: keyword,
728
+        busiType: {key: "company_busi_type", value: "2"},
729
+        hosId,
730
+      },
731
+      idx: 0,
732
+      sum: 20,
733
+    };
734
+    this.cnum++;
735
+    that.mainService
736
+      .getFetchDataList("simple/data", "company", data)
737
+      .subscribe((data) => {
738
+        this.cnum--;
739
+        if (type == "search") {
740
+
741
+        } else if (type == "add") {
742
+          that.allcompany = data.list;
743
+        }
744
+        if (this.cnum === 0) {
745
+          that.isLoading = false;
746
+        }
747
+      });
748
+  }
647 749
 }