瀏覽代碼

科室增加上下级

seimin 3 年之前
父節點
當前提交
efff45e22f

+ 4 - 0
src/app/views/office-detail/office-detail.component.html

@@ -24,6 +24,10 @@
24
             <span>科室电话</span>
24
             <span>科室电话</span>
25
             <span>{{officeInfo.manyPhone?officeInfo.manyPhone:'无'}}</span>
25
             <span>{{officeInfo.manyPhone?officeInfo.manyPhone:'无'}}</span>
26
           </div>
26
           </div>
27
+          <div class="item display_flex  justify-content_space-between align-items_flex-start">
28
+            <span>父级科室</span>
29
+            <span>{{officeInfo.parent?officeInfo.parent.dept:'无'}}</span>
30
+          </div>
27
         </div>
31
         </div>
28
       </div>
32
       </div>
29
     </div>
33
     </div>

+ 20 - 2
src/app/views/office-management/office-management.component.html

@@ -39,19 +39,21 @@
39
           <tr class="thead">
39
           <tr class="thead">
40
             <th nzWidth="5%" nzShowCheckbox [(nzChecked)]="isAllDisplayDataChecked"
40
             <th nzWidth="5%" nzShowCheckbox [(nzChecked)]="isAllDisplayDataChecked"
41
               (nzCheckedChange)="checkAll($event)"></th>
41
               (nzCheckedChange)="checkAll($event)"></th>
42
-            <th nzWidth="15%">科室名称</th>
42
+            <th nzWidth="10%">科室名称</th>
43
+            <th nzWidth="10%">父级科室名称</th>
43
             <th nzWidth="10%">别名</th>
44
             <th nzWidth="10%">别名</th>
44
             <th nzWidth="10%">科室编码</th>
45
             <th nzWidth="10%">科室编码</th>
45
             <th nzWidth="10%">科室电话</th>
46
             <th nzWidth="10%">科室电话</th>
46
             <th nzWidth="10%">科室类型</th>
47
             <th nzWidth="10%">科室类型</th>
47
             <th nzWidth="15%">科室位置</th>
48
             <th nzWidth="15%">科室位置</th>
48
-            <th nzWidth="25%">操作</th>
49
+            <th nzWidth="20%">操作</th>
49
           </tr>
50
           </tr>
50
         </thead>
51
         </thead>
51
         <tbody>
52
         <tbody>
52
           <tr *ngFor="let data of listOfData" (click)="selectedListData(data.id)">
53
           <tr *ngFor="let data of listOfData" (click)="selectedListData(data.id)">
53
             <td nzShowCheckbox [(nzChecked)]="mapOfCheckedId[data.id]" (nzCheckedChange)="refreshStatus()"></td>
54
             <td nzShowCheckbox [(nzChecked)]="mapOfCheckedId[data.id]" (nzCheckedChange)="refreshStatus()"></td>
54
             <td>{{ data.dept||'无' }}</td>
55
             <td>{{ data.dept||'无' }}</td>
56
+            <td>{{ data.parent?data.parent.dept:'无' }}</td>
55
             <td>{{ data.deptalias||'无' }}</td>
57
             <td>{{ data.deptalias||'无' }}</td>
56
             <td>{{ data.pcode||'无' }}</td>
58
             <td>{{ data.pcode||'无' }}</td>
57
             <td>
59
             <td>
@@ -88,6 +90,22 @@
88
       <overlay-scrollbars #osComponentRef1 class="content">
90
       <overlay-scrollbars #osComponentRef1 class="content">
89
         <form nz-form [formGroup]="validateForm" class="addForm" (ngSubmit)="submitForm()">
91
         <form nz-form [formGroup]="validateForm" class="addForm" (ngSubmit)="submitForm()">
90
           <nz-form-item>
92
           <nz-form-item>
93
+            <nz-form-label [nzSm]="6" [nzXs]="24" nzFor="parentOfficeName">父级科室</nz-form-label>
94
+            <nz-form-control nzErrorTip="请填写父级科室!">
95
+              <nz-select [nzDropdownMatchSelectWidth]="false" formControlName="parentOfficeName" nzShowSearch
96
+                nzPlaceHolder="请填写父级科室" nzServerSearch (nzOnSearch)="changeInp($event)"
97
+                (nzOpenChange)="openDeptSelect($event)">
98
+                <ng-container *ngFor="let data of allParentdepart">
99
+                  <nz-option *ngIf="!isLoading" [nzLabel]="data.dept" [nzValue]="data.id">
100
+                  </nz-option>
101
+                </ng-container>
102
+                <nz-option *ngIf="isLoading" nzDisabled nzCustomContent>
103
+                  <i nz-icon nzType="loading" class="loading-icon"></i> 搜索中...
104
+                </nz-option>
105
+              </nz-select>
106
+            </nz-form-control>
107
+          </nz-form-item>
108
+          <nz-form-item>
91
             <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="officeName">科室名称</nz-form-label>
109
             <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="officeName">科室名称</nz-form-label>
92
             <nz-form-control nzErrorTip="请填写科室名称!">
110
             <nz-form-control nzErrorTip="请填写科室名称!">
93
               <nz-input-group>
111
               <nz-input-group>

+ 62 - 2
src/app/views/office-management/office-management.component.ts

@@ -12,6 +12,8 @@ import { OverlayScrollbarsComponent } from "overlayscrollbars-ngx";
12
 import { ToolService } from "../../services/tool.service";
12
 import { ToolService } from "../../services/tool.service";
13
 import { format } from "date-fns";
13
 import { format } from "date-fns";
14
 import { NzMessageService } from "ng-zorro-antd";
14
 import { NzMessageService } from "ng-zorro-antd";
15
+import { Subject } from "rxjs";
16
+import { debounceTime } from "rxjs/operators";
15
 
17
 
16
 @Component({
18
 @Component({
17
   selector: "app-office-management",
19
   selector: "app-office-management",
@@ -34,6 +36,14 @@ export class OfficeManagementComponent implements OnInit {
34
   ) {}
36
   ) {}
35
 
37
 
36
   ngOnInit() {
38
   ngOnInit() {
39
+    this.searchParentDeptSubject.pipe(debounceTime(500)).subscribe((v: any) => {
40
+      this.getAllParentdepart(v).subscribe((result) => {
41
+        this.isLoading = false;
42
+        if (result.status == 200) {
43
+          this.allParentdepart = result.list;
44
+        }
45
+      });
46
+    });
37
     this.coopBtns = this.tool.initCoopBtns(this.route);
47
     this.coopBtns = this.tool.initCoopBtns(this.route);
38
     this.initForm();
48
     this.initForm();
39
     this.getAllHospital();
49
     this.getAllHospital();
@@ -62,9 +72,44 @@ export class OfficeManagementComponent implements OnInit {
62
   deptPhones: any = []; //新添加的科室电话列表
72
   deptPhones: any = []; //新添加的科室电话列表
63
   isAddDeptsPhone = true; //添加新的科室电话是否禁用
73
   isAddDeptsPhone = true; //添加新的科室电话是否禁用
64
   deptsPhoneId = 1; //科室电话自增id
74
   deptsPhoneId = 1; //科室电话自增id
65
-
75
+  allParentdepart: any = []; //所有的父级科室列表
76
+  searchParentDeptSubject = new Subject();
66
   // 初始化增删改按钮
77
   // 初始化增删改按钮
67
   coopBtns: any = {};
78
   coopBtns: any = {};
79
+  //搜索父级科室
80
+  changeInp(e) {
81
+    this.isLoading = true;
82
+    this.searchParentDeptSubject.next(e);
83
+  }
84
+  // 打开父级科室下拉框baba
85
+  isLoading = false;
86
+  openDeptSelect(flag) {
87
+    if (flag) {
88
+      this.isLoading = true;
89
+      this.getAllParentdepart().subscribe((result) => {
90
+        this.isLoading = false;
91
+        if (result.status == 200) {
92
+          this.allParentdepart = result.list;
93
+        }
94
+      });
95
+    }
96
+  }
97
+  //获取所有的父级科室列表baba
98
+  getAllParentdepart(keyWord = "") {
99
+    let postData: any = {
100
+      idx: 0,
101
+      sum: 10,
102
+      department: {
103
+        hospital: { id: this.hospital },
104
+        keyWord: keyWord,
105
+      },
106
+    };
107
+    if (this.coopItem) {
108
+      // 过滤这个科室及其子科室
109
+      postData.department.filterByDeptId = this.coopItem.id;
110
+    }
111
+    return this.mainService.getFetchDataList("data", "department", postData);
112
+  }
68
   // 新添加科室号码
113
   // 新添加科室号码
69
   addDeptPhone(e: MouseEvent) {
114
   addDeptPhone(e: MouseEvent) {
70
     e.preventDefault();
115
     e.preventDefault();
@@ -251,6 +296,7 @@ export class OfficeManagementComponent implements OnInit {
251
     this.deptPhones = [];
296
     this.deptPhones = [];
252
   }
297
   }
253
   hideModal() {
298
   hideModal() {
299
+    this.coopItem = null;
254
     this.modal = false;
300
     this.modal = false;
255
     this.initForm();
301
     this.initForm();
256
   }
302
   }
@@ -265,6 +311,7 @@ export class OfficeManagementComponent implements OnInit {
265
     this.startTime2Hourdis = () => [];
311
     this.startTime2Hourdis = () => [];
266
     this.startTime2Mindis = () => [];
312
     this.startTime2Mindis = () => [];
267
     this.validateForm = this.fb.group({
313
     this.validateForm = this.fb.group({
314
+      parentOfficeName: [null],
268
       officeName: [null, [Validators.required]],
315
       officeName: [null, [Validators.required]],
269
       deptalias: [null],
316
       deptalias: [null],
270
       officeNo: [null, [Validators.required]],
317
       officeNo: [null, [Validators.required]],
@@ -356,7 +403,7 @@ export class OfficeManagementComponent implements OnInit {
356
     console.log(that.validateForm);
403
     console.log(that.validateForm);
357
     if (that.validateForm.invalid) return;
404
     if (that.validateForm.invalid) return;
358
     let deptsPhone = this.deptPhones.map((item) => item.phone).join();
405
     let deptsPhone = this.deptPhones.map((item) => item.phone).join();
359
-    let data = {
406
+    let data: any = {
360
       department: {
407
       department: {
361
         dept: that.validateForm.value.officeName,
408
         dept: that.validateForm.value.officeName,
362
         deptalias: that.validateForm.value.deptalias,
409
         deptalias: that.validateForm.value.deptalias,
@@ -371,6 +418,9 @@ export class OfficeManagementComponent implements OnInit {
371
         type: { id: that.validateForm.value.officeType },
418
         type: { id: that.validateForm.value.officeType },
372
       },
419
       },
373
     };
420
     };
421
+    if (this.validateForm.value.parentOfficeName) {
422
+      data.department.parent = { id: this.validateForm.value.parentOfficeName };
423
+    }
374
     if (
424
     if (
375
       this.validateForm.value.startTime1 ||
425
       this.validateForm.value.startTime1 ||
376
       this.validateForm.value.endTime1
426
       this.validateForm.value.endTime1
@@ -430,10 +480,12 @@ export class OfficeManagementComponent implements OnInit {
430
   }
480
   }
431
 
481
 
432
   // 编辑
482
   // 编辑
483
+  coopItem: any = null;
433
   edit(e, data) {
484
   edit(e, data) {
434
     e.stopPropagation();
485
     e.stopPropagation();
435
     this.add = false;
486
     this.add = false;
436
     this.coopId = data.id;
487
     this.coopId = data.id;
488
+    this.coopItem = data;
437
     this.isAddDeptsPhone = false;
489
     this.isAddDeptsPhone = false;
438
     this.deptPhones = [];
490
     this.deptPhones = [];
439
     let phones = data.manyPhone ? data.manyPhone.split(",") : [];
491
     let phones = data.manyPhone ? data.manyPhone.split(",") : [];
@@ -461,6 +513,14 @@ export class OfficeManagementComponent implements OnInit {
461
       this.validateForm.controls.endTime2.setValue(new Date(data.endTime2));
513
       this.validateForm.controls.endTime2.setValue(new Date(data.endTime2));
462
     }
514
     }
463
     this.validateForm.controls.officeAddress.setValue(data.address);
515
     this.validateForm.controls.officeAddress.setValue(data.address);
516
+    if (data.parent) {
517
+      this.getAllParentdepart(data.parent.dept).subscribe((res) => {
518
+        if (res.status == 200) {
519
+          this.allParentdepart = res.list;
520
+          this.validateForm.controls.parentOfficeName.setValue(data.parent.id);
521
+        }
522
+      });
523
+    }
464
     this.validateForm.controls.officeName.setValue(data.dept);
524
     this.validateForm.controls.officeName.setValue(data.dept);
465
     this.validateForm.controls.deptalias.setValue(data.deptalias);
525
     this.validateForm.controls.deptalias.setValue(data.deptalias);
466
     this.validateForm.controls.officeNo.setValue(data.pcode);
526
     this.validateForm.controls.officeNo.setValue(data.pcode);