浏览代码

科室增加上下级

seimin 3 年之前
父节点
当前提交
efff45e22f

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

@@ -24,6 +24,10 @@
24 24
             <span>科室电话</span>
25 25
             <span>{{officeInfo.manyPhone?officeInfo.manyPhone:'无'}}</span>
26 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 31
         </div>
28 32
       </div>
29 33
     </div>

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

@@ -39,19 +39,21 @@
39 39
           <tr class="thead">
40 40
             <th nzWidth="5%" nzShowCheckbox [(nzChecked)]="isAllDisplayDataChecked"
41 41
               (nzCheckedChange)="checkAll($event)"></th>
42
-            <th nzWidth="15%">科室名称</th>
42
+            <th nzWidth="10%">科室名称</th>
43
+            <th nzWidth="10%">父级科室名称</th>
43 44
             <th nzWidth="10%">别名</th>
44 45
             <th nzWidth="10%">科室编码</th>
45 46
             <th nzWidth="10%">科室电话</th>
46 47
             <th nzWidth="10%">科室类型</th>
47 48
             <th nzWidth="15%">科室位置</th>
48
-            <th nzWidth="25%">操作</th>
49
+            <th nzWidth="20%">操作</th>
49 50
           </tr>
50 51
         </thead>
51 52
         <tbody>
52 53
           <tr *ngFor="let data of listOfData" (click)="selectedListData(data.id)">
53 54
             <td nzShowCheckbox [(nzChecked)]="mapOfCheckedId[data.id]" (nzCheckedChange)="refreshStatus()"></td>
54 55
             <td>{{ data.dept||'无' }}</td>
56
+            <td>{{ data.parent?data.parent.dept:'无' }}</td>
55 57
             <td>{{ data.deptalias||'无' }}</td>
56 58
             <td>{{ data.pcode||'无' }}</td>
57 59
             <td>
@@ -88,6 +90,22 @@
88 90
       <overlay-scrollbars #osComponentRef1 class="content">
89 91
         <form nz-form [formGroup]="validateForm" class="addForm" (ngSubmit)="submitForm()">
90 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 109
             <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="officeName">科室名称</nz-form-label>
92 110
             <nz-form-control nzErrorTip="请填写科室名称!">
93 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 12
 import { ToolService } from "../../services/tool.service";
13 13
 import { format } from "date-fns";
14 14
 import { NzMessageService } from "ng-zorro-antd";
15
+import { Subject } from "rxjs";
16
+import { debounceTime } from "rxjs/operators";
15 17
 
16 18
 @Component({
17 19
   selector: "app-office-management",
@@ -34,6 +36,14 @@ export class OfficeManagementComponent implements OnInit {
34 36
   ) {}
35 37
 
36 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 47
     this.coopBtns = this.tool.initCoopBtns(this.route);
38 48
     this.initForm();
39 49
     this.getAllHospital();
@@ -62,9 +72,44 @@ export class OfficeManagementComponent implements OnInit {
62 72
   deptPhones: any = []; //新添加的科室电话列表
63 73
   isAddDeptsPhone = true; //添加新的科室电话是否禁用
64 74
   deptsPhoneId = 1; //科室电话自增id
65
-
75
+  allParentdepart: any = []; //所有的父级科室列表
76
+  searchParentDeptSubject = new Subject();
66 77
   // 初始化增删改按钮
67 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 114
   addDeptPhone(e: MouseEvent) {
70 115
     e.preventDefault();
@@ -251,6 +296,7 @@ export class OfficeManagementComponent implements OnInit {
251 296
     this.deptPhones = [];
252 297
   }
253 298
   hideModal() {
299
+    this.coopItem = null;
254 300
     this.modal = false;
255 301
     this.initForm();
256 302
   }
@@ -265,6 +311,7 @@ export class OfficeManagementComponent implements OnInit {
265 311
     this.startTime2Hourdis = () => [];
266 312
     this.startTime2Mindis = () => [];
267 313
     this.validateForm = this.fb.group({
314
+      parentOfficeName: [null],
268 315
       officeName: [null, [Validators.required]],
269 316
       deptalias: [null],
270 317
       officeNo: [null, [Validators.required]],
@@ -356,7 +403,7 @@ export class OfficeManagementComponent implements OnInit {
356 403
     console.log(that.validateForm);
357 404
     if (that.validateForm.invalid) return;
358 405
     let deptsPhone = this.deptPhones.map((item) => item.phone).join();
359
-    let data = {
406
+    let data: any = {
360 407
       department: {
361 408
         dept: that.validateForm.value.officeName,
362 409
         deptalias: that.validateForm.value.deptalias,
@@ -371,6 +418,9 @@ export class OfficeManagementComponent implements OnInit {
371 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 424
     if (
375 425
       this.validateForm.value.startTime1 ||
376 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 484
   edit(e, data) {
434 485
     e.stopPropagation();
435 486
     this.add = false;
436 487
     this.coopId = data.id;
488
+    this.coopItem = data;
437 489
     this.isAddDeptsPhone = false;
438 490
     this.deptPhones = [];
439 491
     let phones = data.manyPhone ? data.manyPhone.split(",") : [];
@@ -461,6 +513,14 @@ export class OfficeManagementComponent implements OnInit {
461 513
       this.validateForm.controls.endTime2.setValue(new Date(data.endTime2));
462 514
     }
463 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 524
     this.validateForm.controls.officeName.setValue(data.dept);
465 525
     this.validateForm.controls.deptalias.setValue(data.deptalias);
466 526
     this.validateForm.controls.officeNo.setValue(data.pcode);