|
@@ -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
|
}
|