소스 검색

新增院区增加复制功能

seimin 3 년 전
부모
커밋
2aa1649947

+ 112 - 21
src/app/views/hospital-management/hospital-management.component.html

@@ -1,14 +1,19 @@
1 1
 <div class="list-template">
2 2
   <div class="list-template__content">
3 3
     <div *ngIf="currentUserAccount == 'dsadmin'" class="list-template__top">
4
-      <div nz-col nzXl='18' class="list-template__searchBox"></div>
5
-      <div nz-col nzXl='6' class="list-template__btns">
4
+      <div nz-col nzXl="18" class="list-template__searchBox"></div>
5
+      <div nz-col nzXl="6" class="list-template__btns">
6 6
         <button nz-button class="btn default" (click)="addModal()">新增</button>
7 7
       </div>
8 8
     </div>
9 9
     <div class="list-template__bottom">
10
-      <nz-table class="list-template__nzTable" [nzData]="listOfData" nzSize="middle" [nzShowPagination]="false"
11
-        [nzLoading]="loading1">
10
+      <nz-table
11
+        class="list-template__nzTable"
12
+        [nzData]="listOfData"
13
+        nzSize="middle"
14
+        [nzShowPagination]="false"
15
+        [nzLoading]="loading1"
16
+      >
12 17
         <thead>
13 18
           <tr class="thead">
14 19
             <th nzWidth="20%">院区名称</th>
@@ -23,55 +28,141 @@
23 28
             <td>
24 29
               <div class="coop">
25 30
                 <span *ngIf="coopBtns.edit" (click)="edit(data)">编辑</span>
26
-                <span *ngIf="coopBtns.del" (click)="showDelModal(data.id)">删除</span>
31
+                <span *ngIf="coopBtns.del" (click)="showDelModal(data.id)"
32
+                  >删除</span
33
+                >
27 34
               </div>
28 35
             </td>
29 36
           </tr>
30 37
         </tbody>
31 38
       </nz-table>
32 39
       <div class="list-template__pagination">
33
-        <nz-pagination [(nzPageIndex)]="pageIndex" [(nzTotal)]="listLength" nzShowSizeChanger [(nzPageSize)]="pageSize"
34
-          (nzPageIndexChange)="getList()" (nzPageSizeChange)="getList()">
40
+        <nz-pagination
41
+          [(nzPageIndex)]="pageIndex"
42
+          [(nzTotal)]="listLength"
43
+          nzShowSizeChanger
44
+          [(nzPageSize)]="pageSize"
45
+          (nzPageIndexChange)="getList()"
46
+          (nzPageSizeChange)="getList()"
47
+        >
35 48
         </nz-pagination>
36 49
       </div>
37 50
     </div>
38 51
   </div>
39 52
 
40 53
   <!-- 新增/编辑模态框 -->
41
-  <div class="save align-items_center display_flex justify-content_flex-center add" *ngIf="modal">
54
+  <div
55
+    class="save align-items_center display_flex justify-content_flex-center add"
56
+    *ngIf="modal"
57
+  >
42 58
     <div class="modalBody">
43
-      <div class="title">{{add?"新增":"编辑"}}院区信息<i class="icon_transport transport-guanbi" (click)="hideAddModal()"></i>
59
+      <div class="title">
60
+        {{ add ? "新增" : "编辑" }}院区信息<i
61
+          class="icon_transport transport-guanbi"
62
+          (click)="hideAddModal()"
63
+        ></i>
44 64
       </div>
45 65
       <div class="content">
46
-        <form nz-form [formGroup]="validateForm" class="addForm" (ngSubmit)="submitForm()">
66
+        <form
67
+          nz-form
68
+          [formGroup]="validateForm"
69
+          class="addForm"
70
+          (ngSubmit)="submitForm()"
71
+        >
47 72
           <nz-form-item>
48
-            <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="hospitalName">院区名称</nz-form-label>
73
+            <nz-form-label
74
+              [nzSm]="6"
75
+              [nzXs]="24"
76
+              nzRequired
77
+              nzFor="hospitalName"
78
+              >院区名称</nz-form-label
79
+            >
49 80
             <nz-form-control nzErrorTip="请输入院区名称!">
50 81
               <nz-input-group>
51
-                <input type="hospitalName" nz-input formControlName="hospitalName" placeholder="请输入院区名称" />
82
+                <input
83
+                  type="hospitalName"
84
+                  nz-input
85
+                  formControlName="hospitalName"
86
+                  placeholder="请输入院区名称"
87
+                />
52 88
               </nz-input-group>
53 89
             </nz-form-control>
54 90
           </nz-form-item>
55 91
           <nz-form-item>
56
-            <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="hospitalNum">院区编码</nz-form-label>
92
+            <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="hospitalNum"
93
+              >院区编码</nz-form-label
94
+            >
57 95
             <nz-form-control nzErrorTip="请输入院区编码!">
58 96
               <nz-input-group>
59
-                <input type="hospitalNum" nz-input formControlName="hospitalNum" placeholder="请输入院区编码" />
97
+                <input
98
+                  type="hospitalNum"
99
+                  nz-input
100
+                  formControlName="hospitalNum"
101
+                  placeholder="请输入院区编码"
102
+                />
60 103
               </nz-input-group>
61 104
             </nz-form-control>
62 105
           </nz-form-item>
106
+          <nz-form-item *ngIf="isShowCopyHosId">
107
+            <nz-form-label
108
+              style="line-height: 1"
109
+              [nzSm]="6"
110
+              [nzXs]="24"
111
+              nzFor="copyHosId"
112
+              >复制的院区</nz-form-label
113
+            >
114
+            <nz-form-control nzErrorTip="请选择复制的院区!">
115
+              <nz-select
116
+                nzAllowClear
117
+                [nzDropdownMatchSelectWidth]="false"
118
+                formControlName="copyHosId"
119
+                nzPlaceHolder="请选择复制的院区"
120
+              >
121
+                <nz-option
122
+                  *ngFor="let item of listOfData"
123
+                  [nzLabel]="item.hosName"
124
+                  [nzValue]="item.id"
125
+                >
126
+                </nz-option>
127
+              </nz-select>
128
+            </nz-form-control>
129
+          </nz-form-item>
63 130
         </form>
64 131
       </div>
65
-      <div class=" display_flex justify-content_flex-center">
66
-        <button nzType="primary" [nzLoading]="btnLoading" nz-button (click)="submitForm()">确认</button>
67
-        <button class="btn cancel" nz-button nzType="default" (click)="hideAddModal()">取消</button>
132
+      <div class="display_flex justify-content_flex-center">
133
+        <button
134
+          nzType="primary"
135
+          [nzLoading]="btnLoading"
136
+          nz-button
137
+          (click)="submitForm()"
138
+        >
139
+          确认
140
+        </button>
141
+        <button
142
+          class="btn cancel"
143
+          nz-button
144
+          nzType="default"
145
+          (click)="hideAddModal()"
146
+        >
147
+          取消
148
+        </button>
68 149
       </div>
69 150
     </div>
70 151
   </div>
71 152
   <!-- 删除模态框 -->
72
-  <app-dialog-delete [delModal]="delModal" (hideDelModalEvent)="hideDelModal()" [btnLoading]="btnLoading"
73
-    (confirmDelEvent)="confirmDel()" content="您确认要删除此院区吗?"></app-dialog-delete>
153
+  <app-dialog-delete
154
+    [delModal]="delModal"
155
+    (hideDelModalEvent)="hideDelModal()"
156
+    [btnLoading]="btnLoading"
157
+    (confirmDelEvent)="confirmDel()"
158
+    content="您确认要删除此院区吗?"
159
+  ></app-dialog-delete>
74 160
 </div>
75 161
 <!-- 操作成功/失败提示框 -->
76
-<app-prompt-modal *ngIf="promptModalShow" [content]="promptContent" [success]="ifSuccess" [show]="promptModalShow"
77
-  [info]="promptInfo"></app-prompt-modal>
162
+<app-prompt-modal
163
+  *ngIf="promptModalShow"
164
+  [content]="promptContent"
165
+  [success]="ifSuccess"
166
+  [show]="promptModalShow"
167
+  [info]="promptInfo"
168
+></app-prompt-modal>

+ 14 - 1
src/app/views/hospital-management/hospital-management.component.ts

@@ -1,5 +1,10 @@
1 1
 import { Component, OnInit } from "@angular/core";
2
-import { FormBuilder, Validators, FormGroup } from "@angular/forms";
2
+import {
3
+  FormBuilder,
4
+  Validators,
5
+  FormGroup,
6
+  FormControl,
7
+} from "@angular/forms";
3 8
 import { ActivatedRoute } from "@angular/router";
4 9
 
5 10
 import { MainService } from "../../services/main.service";
@@ -67,6 +72,8 @@ export class HospitalManagementComponent implements OnInit {
67 72
     this.modal = true;
68 73
     this.validateForm.controls.hospitalName.setValue("");
69 74
     this.validateForm.controls.hospitalNum.setValue("");
75
+    this.validateForm.addControl("copyHosId", new FormControl(null));
76
+    this.isShowCopyHosId = true;
70 77
   }
71 78
   hideAddModal() {
72 79
     this.modal = false;
@@ -95,6 +102,9 @@ export class HospitalManagementComponent implements OnInit {
95 102
         hosNo: that.validateForm.value.hospitalNum,
96 103
       },
97 104
     };
105
+    if (that.add && that.validateForm.value.copyHosId) {
106
+      data.hospital["copyHosId"] = that.validateForm.value.copyHosId;
107
+    }
98 108
     if (!that.add) {
99 109
       data.hospital["id"] = that.coopId;
100 110
     }
@@ -113,12 +123,15 @@ export class HospitalManagementComponent implements OnInit {
113 123
   }
114 124
 
115 125
   // 编辑
126
+  isShowCopyHosId = false;
116 127
   edit(data) {
117 128
     this.add = false;
118 129
     this.modal = true;
119 130
     this.coopId = data.id;
120 131
     this.validateForm.controls.hospitalName.setValue(data.hosName);
121 132
     this.validateForm.controls.hospitalNum.setValue(data.hosNo);
133
+    this.validateForm.removeControl("copyHosId");
134
+    this.isShowCopyHosId = false;
122 135
   }
123 136
 
124 137
   delModal: boolean = false; //删除模态框