Browse Source

3.系统运行配置新增楼栋楼层菜单

seimin 3 years ago
parent
commit
d34edae4ba

+ 1 - 1
package.json

@@ -2,7 +2,7 @@
2 2
   "name": "itsm-zy",
3 3
   "version": "0.0.0",
4 4
   "scripts": {
5
-    "210": "ng serve --proxy-config proxy.conf.json --port 4210 --disable-host-check --public-host=dashitech.com",
5
+    "210": "ng serve --proxy-config proxy.conf.json --port 4210 --disable-host-check --public-host=dashitech.com --host 0.0.0.0",
6 6
     "ng": "ng",
7 7
     "start": "ng serve",
8 8
     "build": "ng build --prod",

+ 1 - 1
proxy.conf.json

@@ -1,6 +1,6 @@
1 1
 {
2 2
   "/service": {
3
-    "target": "http://192.168.3.108",
3
+    "target": "http://192.168.3.96",
4 4
     "logLevel": "debug",
5 5
     "changeOrigin": true,
6 6
     "pathRewrite": {

+ 52 - 7
src/app/services/tool.service.ts

@@ -1,21 +1,66 @@
1
-import { Injectable } from '@angular/core';
1
+import { Injectable } from "@angular/core";
2 2
 
3 3
 @Injectable({
4
-  providedIn: 'root'
4
+  providedIn: "root",
5 5
 })
6 6
 export class ToolService {
7
-
8
-  constructor() { }
7
+  menu: any = JSON.parse(localStorage.getItem("menu")) || []; //菜单
8
+  constructor() {}
9 9
   // 获取权限中的院区
10 10
   getHospitalList() {
11
-    return JSON.parse(localStorage.getItem('user')).infoPermission.hospitals || [];
11
+    return (
12
+      JSON.parse(localStorage.getItem("user")).infoPermission.hospitals || []
13
+    );
12 14
   }
13 15
   // 获取权限中的分组
14 16
   getGroupList() {
15
-    return JSON.parse(localStorage.getItem('user')).infoPermission.groups || [];
17
+    return JSON.parse(localStorage.getItem("user")).infoPermission.groups || [];
16 18
   }
17 19
   // 获取当前院区
18 20
   getCurrentHospital() {
19
-    return JSON.parse(localStorage.getItem('user')).user.currentHospital ? JSON.parse(localStorage.getItem('user')).user.currentHospital : JSON.parse(localStorage.getItem('user')).infoPermission.hospitals[0];
21
+    return JSON.parse(localStorage.getItem("user")).user.currentHospital
22
+      ? JSON.parse(localStorage.getItem("user")).user.currentHospital
23
+      : JSON.parse(localStorage.getItem("user")).infoPermission.hospitals[0];
24
+  }
25
+  //获取当前菜单的权限
26
+  initCoopBtns(route) {
27
+    // 二级菜单
28
+    let secondMenus = [];
29
+    // 初始化增删改权限
30
+    let coopBtns: any = {
31
+      look: false,
32
+      add: false,
33
+      edit: false,
34
+      del: false,
35
+    };
36
+    this.menu.forEach((e) => {
37
+      e.childrens.forEach((el) => {
38
+        secondMenus.push(el);
39
+      });
40
+    });
41
+    let link = route.parent.snapshot.routeConfig.path;
42
+    let btns = [];
43
+    secondMenus.forEach((e) => {
44
+      if (e.link == link) {
45
+        btns = e.childrens || [];
46
+      }
47
+    });
48
+    btns.forEach((e) => {
49
+      switch (e.link) {
50
+        case "look":
51
+          coopBtns.look = true;
52
+          break;
53
+        case "add":
54
+          coopBtns.add = true;
55
+          break;
56
+        case "edit":
57
+          coopBtns.edit = true;
58
+          break;
59
+        case "del":
60
+          coopBtns.del = true;
61
+          break;
62
+      }
63
+    });
64
+    return coopBtns;
20 65
   }
21 66
 }

+ 1 - 1
src/app/share/generate-floor/generate-floor.component.html

@@ -5,7 +5,7 @@
5 5
     <div class="content">
6 6
       <div class="formItem">
7 7
         <nz-select class="w120" [ngClass]="{errorMsg:!building}" [(ngModel)]="building" [nzLoading]="loading1"
8
-          nzPlaceHolder="请选择楼栋">
8
+          nzPlaceHolder="请选择楼栋" [nzDisabled]="buildId">
9 9
           <nz-option [nzValue]="building" [nzLabel]="building.buildingName" *ngFor="let building of buildingList">
10 10
           </nz-option>
11 11
         </nz-select>

+ 41 - 27
src/app/share/generate-floor/generate-floor.component.ts

@@ -1,33 +1,30 @@
1
-import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
2
-import { MainService } from 'src/app/services/main.service';
3
-import { ToolService } from 'src/app/services/tool.service';
1
+import { Component, EventEmitter, Input, OnInit, Output } from "@angular/core";
2
+import { MainService } from "src/app/services/main.service";
3
+import { ToolService } from "src/app/services/tool.service";
4 4
 
5 5
 @Component({
6
-  selector: 'app-generate-floor',
7
-  templateUrl: './generate-floor.component.html',
8
-  styleUrls: ['./generate-floor.component.less']
6
+  selector: "app-generate-floor",
7
+  templateUrl: "./generate-floor.component.html",
8
+  styleUrls: ["./generate-floor.component.less"],
9 9
 })
10 10
 export class GenerateFloorComponent implements OnInit {
11 11
   @Output() hideGenerateModalEvent = new EventEmitter<any>();
12 12
   @Output() confirmGenerateEvent = new EventEmitter<any>();
13 13
   @Input() btnLoading: boolean = false;
14 14
   @Input() generateModal: boolean = false;
15
-  constructor(
16
-    private mainService: MainService,
17
-    private tool: ToolService,
18
-  ) { }
19
-  hosId;//院区
20
-  building = null;//选择的楼栋
21
-  startFloor = null;//起始楼层
22
-  startFloorMin = 1;//起始楼层最小
23
-  startFloorMax = Infinity;//起始楼层最大
24
-  endFloor = null;//结束楼层
25
-  endFloorMin = 1;//结束楼层最小
26
-  endFloorMax = Infinity;//结束楼层最大
15
+  @Input() buildId: any;
16
+  constructor(private mainService: MainService, private tool: ToolService) {}
17
+  hosId; //院区
18
+  building = null; //选择的楼栋
19
+  startFloor = null; //起始楼层
20
+  startFloorMin = 1; //起始楼层最小
21
+  startFloorMax = Infinity; //起始楼层最大
22
+  endFloor = null; //结束楼层
23
+  endFloorMin = 1; //结束楼层最小
24
+  endFloorMax = Infinity; //结束楼层最大
27 25
   delModal = false;
28
-  tipsMsg1 = '';
26
+  tipsMsg1 = "";
29 27
   ngOnInit() {
30
-    this.building = null;
31 28
     this.startFloor = null;
32 29
     this.endFloor = null;
33 30
     this.hosId = this.tool.getCurrentHospital().id;
@@ -38,12 +35,25 @@ export class GenerateFloorComponent implements OnInit {
38 35
   buildingList = [];
39 36
   getBuildings(hosId) {
40 37
     this.loading1 = true;
41
-    this.mainService.getFetchDataList('simple/data', 'building', { idx: 0, sum: 9999, building: { hosId } }).subscribe(result => {
42
-      this.loading1 = false;
43
-      if (result['status'] == 200) {
44
-        this.buildingList = result['list'];
45
-      }
46
-    })
38
+    this.mainService
39
+      .getFetchDataList("simple/data", "building", {
40
+        idx: 0,
41
+        sum: 9999,
42
+        building: { hosId },
43
+      })
44
+      .subscribe((result) => {
45
+        this.loading1 = false;
46
+        if (result["status"] == 200) {
47
+          this.buildingList = result["list"];
48
+          if (this.buildId) {
49
+            this.building = this.buildingList.filter(
50
+              (item) => item.id == this.buildId
51
+            )[0];
52
+          } else {
53
+            this.building = null;
54
+          }
55
+        }
56
+      });
47 57
   }
48 58
   //修改起始楼层
49 59
   startFloorChange(e) {
@@ -75,6 +85,10 @@ export class GenerateFloorComponent implements OnInit {
75 85
   }
76 86
   //确认生成楼层
77 87
   confirmDel() {
78
-    this.confirmGenerateEvent.emit([this.building, this.startFloor, this.endFloor]);
88
+    this.confirmGenerateEvent.emit([
89
+      this.building,
90
+      this.startFloor,
91
+      this.endFloor,
92
+    ]);
79 93
   }
80 94
 }

+ 11 - 0
src/app/views/building-floor/building-floor-routing.module.ts

@@ -0,0 +1,11 @@
1
+import { NgModule } from "@angular/core";
2
+import { Routes, RouterModule } from "@angular/router";
3
+import { BuildingFloorComponent } from "./building-floor.component";
4
+
5
+const routes: Routes = [{ path: "", component: BuildingFloorComponent }];
6
+
7
+@NgModule({
8
+  imports: [RouterModule.forChild(routes)],
9
+  exports: [RouterModule],
10
+})
11
+export class BuildingFloorRoutingModule {}

+ 125 - 0
src/app/views/building-floor/building-floor.component.html

@@ -0,0 +1,125 @@
1
+<div class="groupManagement">
2
+  <div class="groupInfo">
3
+    <div class="title">楼栋楼层</div>
4
+    <div class="operate">
5
+      <div *ngIf="coopBtns.add" class="add item" (click)="showCoopModal('add')">新增</div>
6
+      <div *ngIf="coopBtns.edit" class="edit item" (click)="showCoopModal('edit')">编辑</div>
7
+      <div *ngIf="coopBtns.del" class="del item" (click)="showDelModal()">删除</div>
8
+    </div>
9
+    <div class="groups" [ngStyle]="{display:!loading1?'block':'none'}">
10
+      <overlay-scrollbars #osComponentRef1 [ngStyle]="{ height:'100%' }">
11
+        <div [ngClass]="{'item':true,'checked':data.id==checkedBuilding.id}" *ngFor="let data of buildingList"
12
+          (click)="checkGroup(data)" [title]="data.buildingName">{{data.buildingName}}</div>
13
+      </overlay-scrollbars>
14
+    </div>
15
+    <div class="groups" *ngIf="loading1">
16
+      <div class="loadingFull display_flex justify-content_flex-center align-items_center">
17
+        <div class="loadingFullInner">
18
+          <img src="../../../assets/images/loading.gif" alt="">
19
+          <div>加载中...</div>
20
+        </div>
21
+      </div>
22
+    </div>
23
+  </div>
24
+  <div class="userInfo">
25
+    <div class="top display_flex justify-content_flex-end align-items_center">
26
+      <div class="display_flex align-items_center">
27
+        <span>已选择 {{usersArr.length}} 个楼层</span>
28
+        <button class="btn default" *ngIf="coopBtns.add" nzType="primary" nz-button [nzLoading]="saveLoading"
29
+          (click)="showFloorModal($event,'add')">新增</button>
30
+        <button class="btn default" *ngIf="coopBtns.del" nzType="primary" nz-button [nzLoading]="saveLoading"
31
+          (click)="showDelFloorModal($event)">批量删除</button>
32
+        <button class="btn default" *ngIf="coopBtns.add" nzType="primary" nz-button [nzLoading]="saveLoading"
33
+          (click)="generate()">生成楼层</button>
34
+      </div>
35
+    </div>
36
+    <div class="table" *ngIf="!loading1">
37
+      <nz-table class="groupManagementTable" #rowSelectionTable [nzPageSize]="9999" [nzData]="allFloorList"
38
+        [nzShowPagination]="false" #fixedTable [nzScroll]="{ y: tableHeight+'px' }" [nzLoading]="loading2">
39
+        <tbody>
40
+          <tr *ngFor="let data of rowSelectionTable.data" (click)="selectedUser(data)">
41
+            <td style="width:5%" nzShowCheckbox [(nzDisabled)]="!coopBtns.edit" [(nzChecked)]="mapOfCheckedId[data.id]"
42
+              (nzCheckedChange)="refreshStatus()"></td>
43
+            <td style="width:75%">{{ data.floorName }}</td>
44
+            <td style="width:20%">
45
+              <button nz-button nzType="primary" nzSize="small" (click)="showFloorModal($event,'edit',data)">编辑</button>
46
+              <button nz-button nzType="primary" nzSize="small" class="ml8"
47
+                (click)="showDelFloorModal($event,data)">删除</button>
48
+            </td>
49
+          </tr>
50
+        </tbody>
51
+      </nz-table>
52
+    </div>
53
+  </div>
54
+
55
+  <!-- 新增/编辑楼栋模态框 -->
56
+  <div class="save display_flex justify-content_flex-center align-items_center add" *ngIf="coopModal">
57
+    <div class="modalBody">
58
+      <div class="title">{{add?'新增':'编辑'}}楼栋信息<i class="icon_transport transport-guanbi" (click)="hideCoopModal()"></i>
59
+      </div>
60
+      <div class="content">
61
+        <form nz-form [formGroup]="validateForm" class="addForm" (ngSubmit)="submitForm()">
62
+          <nz-form-item>
63
+            <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="buildingName">楼栋名称</nz-form-label>
64
+            <nz-form-control nzErrorTip="请输入楼栋名称!">
65
+              <nz-input-group>
66
+                <input nz-input formControlName="buildingName" placeholder="请输入楼栋名称" />
67
+              </nz-input-group>
68
+            </nz-form-control>
69
+          </nz-form-item>
70
+        </form>
71
+      </div>
72
+      <div class=" display_flex justify-content_flex-center">
73
+        <button nzType="primary" [nzLoading]="btnLoading" nz-button (click)="submitForm()">确认</button>
74
+        <button class="btn cancel" nz-button nzType="default" (click)="hideCoopModal()">取消</button>
75
+      </div>
76
+    </div>
77
+  </div>
78
+  <!-- 新增/编辑楼层模态框 -->
79
+  <div class="save display_flex justify-content_flex-center align-items_center add" *ngIf="floorModal">
80
+    <div class="modalBody">
81
+      <div class="title">{{add?'新增':'编辑'}}楼层信息<i class="icon_transport transport-guanbi" (click)="hideFloorModal()"></i>
82
+      </div>
83
+      <div class="content">
84
+        <form nz-form [formGroup]="validateFloorForm" class="addForm" (ngSubmit)="submitFormFloor()">
85
+          <nz-form-item>
86
+            <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="buildId">楼栋</nz-form-label>
87
+            <nz-form-control nzErrorTip="请选择楼栋!">
88
+              <nz-select formControlName="buildId" nzPlaceHolder="请选择楼栋" nzDisabled>
89
+                <nz-option *ngFor="let option of buildingList" [nzLabel]="option.buildingName" [nzValue]="option.id">
90
+                </nz-option>
91
+              </nz-select>
92
+            </nz-form-control>
93
+          </nz-form-item>
94
+          <nz-form-item>
95
+            <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="floorName">楼层名称</nz-form-label>
96
+            <nz-form-control nzErrorTip="请输入楼层名称!">
97
+              <nz-input-group>
98
+                <input nz-input formControlName="floorName" placeholder="请输入楼层名称" />
99
+              </nz-input-group>
100
+            </nz-form-control>
101
+          </nz-form-item>
102
+        </form>
103
+      </div>
104
+      <div class="display_flex justify-content_flex-center">
105
+        <button nzType="primary" [nzLoading]="btnLoading" nz-button (click)="submitFormFloor()">确认</button>
106
+        <button class="btn cancel" nz-button nzType="default" (click)="hideFloorModal()">取消</button>
107
+      </div>
108
+    </div>
109
+  </div>
110
+  <!-- 删除楼栋模态框 -->
111
+  <app-dialog-delete [delModal]="delModal" (hideDelModalEvent)="hideDelModal()" [btnLoading]="btnLoading"
112
+    (confirmDelEvent)="confirmDel()" content="您确认要删除楼栋吗?" tips="删除后对应的楼栋积分配置也会删除"></app-dialog-delete>
113
+  <!-- 删除楼层模态框 -->
114
+  <app-dialog-delete [delModal]="delFloorModal" (hideDelModalEvent)="hideDelFloorModal()" [btnLoading]="btnLoading"
115
+    (confirmDelEvent)="confirmFloorDel()" content="您确认要删除楼层吗?"></app-dialog-delete>
116
+  <!-- 生成楼层模态框 -->
117
+  <app-generate-floor #generate1 *ngIf="generateModal" [generateModal]="generateModal"
118
+    (hideGenerateModalEvent)="hideGenerateModal()" [btnLoading]="btnLoading"
119
+    (confirmGenerateEvent)="confirmGenerate($event)" [buildId]="checkedBuilding.id"></app-generate-floor>
120
+</div>
121
+
122
+<!-- 操作成功/失败提示框 -->
123
+<app-prompt-modal *ngIf="promptModalShow" [content]="promptContent" [success]="ifSuccess" [show]="promptModalShow"
124
+  [info]="promptInfo">
125
+</app-prompt-modal>

+ 279 - 0
src/app/views/building-floor/building-floor.component.less

@@ -0,0 +1,279 @@
1
+@import "../../../../src/theme.less";
2
+:host {
3
+  width: 100%;
4
+  height: 100%;
5
+}
6
+
7
+.groupManagement {
8
+  width: 100%;
9
+  height: 100%;
10
+  background: #f9fafb;
11
+  padding: 16px 20px;
12
+  min-height: 532px;
13
+  overflow: hidden;
14
+
15
+  .groupInfo {
16
+    float: left;
17
+    width: 24%;
18
+    height: 100%;
19
+    min-height: calc(100vh - 120px);
20
+    border: 1px solid #e5e9ed;
21
+    background: #fff;
22
+    color: #333;
23
+    font-size: 14px;
24
+    position: relative;
25
+    overflow: hidden;
26
+
27
+    .title {
28
+      width: 100%;
29
+      height: 40px;
30
+      line-height: 40px;
31
+      padding-left: 16px;
32
+      border-bottom: 1px solid #e5e9ed;
33
+      position: relative;
34
+      background: #fff;
35
+      z-index: 2;
36
+    }
37
+
38
+    .operate {
39
+      width: 100%;
40
+      border-bottom: 1px solid #e5e9ed;
41
+      position: relative;
42
+      background: #fff;
43
+      z-index: 2;
44
+
45
+      .item {
46
+        display: inline-block;
47
+        width: 33.33%;
48
+        height: 34px;
49
+        line-height: 34px;
50
+        border-right: 1px solid #e5e9ed;
51
+        text-align: center;
52
+        color: #666;
53
+        cursor: pointer;
54
+
55
+        &:nth-last-child(1) {
56
+          border: none;
57
+        }
58
+      }
59
+    }
60
+
61
+    .groups {
62
+      width: 100%;
63
+      height: 100%;
64
+      // padding-right: 10%;
65
+      position: absolute;
66
+      top: 0;
67
+      padding-top: 74px;
68
+      overflow-y: auto;
69
+      z-index: 1;
70
+
71
+      .item {
72
+        width: 100%;
73
+        height: 34px;
74
+        line-height: 34px;
75
+        text-align: center;
76
+        cursor: pointer;
77
+        overflow: hidden;
78
+        text-overflow: ellipsis;
79
+        white-space: nowrap;
80
+
81
+        &:hover {
82
+          color: @primary-color;
83
+          background: #f0f6ed;
84
+        }
85
+
86
+        &.checked {
87
+          color: @primary-color;
88
+          background: #f0f6ed;
89
+        }
90
+      }
91
+    }
92
+  }
93
+
94
+  .userInfo {
95
+    float: right;
96
+    width: 74%;
97
+    height: 100%;
98
+    min-height: calc(100vh - 120px);
99
+    border: 1px solid #e5e9ed;
100
+    background: #fff;
101
+    color: #333;
102
+    position: relative;
103
+
104
+    .top {
105
+      height: 74px;
106
+      padding: 0 16px;
107
+      line-height: 74px;
108
+      border-bottom: 1px solid #e5e9ed;
109
+      position: relative;
110
+      z-index: 2;
111
+
112
+      & > div {
113
+        input {
114
+          width: 224px;
115
+        }
116
+
117
+        button {
118
+          margin-left: 8px;
119
+        }
120
+      }
121
+    }
122
+
123
+    .table {
124
+      width: 100%;
125
+      height: 100%;
126
+      padding: 15px;
127
+      position: absolute;
128
+      top: 0;
129
+      padding-top: 90px;
130
+
131
+      .groupManagementTable {
132
+        border-radius: 5px;
133
+        padding: 16px;
134
+        background: #f9fafb;
135
+        border: 1px solid #e5e9ed;
136
+
137
+        .ant-table-tbody {
138
+          tr {
139
+            td {
140
+              text-align: center;
141
+            }
142
+          }
143
+
144
+          tr:nth-child(2n-1) {
145
+            background: #f9fafb;
146
+          }
147
+        }
148
+      }
149
+    }
150
+  }
151
+
152
+  .save {
153
+    position: fixed;
154
+    left: 0;
155
+    top: 0;
156
+    width: 100%;
157
+    height: 100%;
158
+    background: rgba(0, 0, 0, 0.4);
159
+    z-index: 99;
160
+
161
+    .modalBody {
162
+      width: 350px;
163
+      height: 220px;
164
+      background: #fff;
165
+      border-radius: 5px;
166
+      padding: 10px 20px;
167
+      color: #333;
168
+
169
+      .title {
170
+        width: 100%;
171
+        text-align: center;
172
+        font-size: 18px;
173
+        position: relative;
174
+
175
+        i {
176
+          position: absolute;
177
+          right: 0;
178
+          top: 0;
179
+          font-size: 20px;
180
+          color: #666;
181
+          cursor: pointer;
182
+          padding: 0 5px;
183
+        }
184
+      }
185
+
186
+      .content {
187
+        width: 310px;
188
+        height: 117px;
189
+        background: #f9fafb;
190
+        border: 1px solid #e5e9ed;
191
+        border-radius: 5px;
192
+        overflow: hidden;
193
+        margin-top: 12px;
194
+
195
+        div {
196
+          text-align: center;
197
+          margin: 0;
198
+
199
+          &.icon {
200
+            margin-top: 17px;
201
+
202
+            i {
203
+              color: #34b349;
204
+              font-size: 30px !important;
205
+
206
+              &.transport-wenhao {
207
+                color: #f5a523;
208
+              }
209
+
210
+              &.transport-shibai {
211
+                color: #ff3a52;
212
+              }
213
+            }
214
+          }
215
+
216
+          &.defeat {
217
+            color: #333;
218
+            font-size: 18px;
219
+          }
220
+
221
+          &:nth-child(3) {
222
+            font-size: 14px;
223
+            color: #666;
224
+          }
225
+        }
226
+      }
227
+
228
+      button {
229
+        margin-top: 10px;
230
+
231
+        &.btn {
232
+          margin-left: 8px;
233
+        }
234
+      }
235
+    }
236
+
237
+    // 新增
238
+    &.add {
239
+      .modalBody {
240
+        width: 480px;
241
+        height: auto;
242
+
243
+        .content {
244
+          width: 100%;
245
+          height: auto;
246
+          padding: 18px 14px 0 14px;
247
+
248
+          .addForm {
249
+            .ant-form-item {
250
+              margin-bottom: 15px;
251
+
252
+              .ant-form-item-label {
253
+                line-height: 0;
254
+                text-align: left;
255
+              }
256
+            }
257
+          }
258
+
259
+          .editForm {
260
+            .ant-form-item {
261
+              margin-bottom: 15px;
262
+
263
+              .ant-form-item-label {
264
+                line-height: 0;
265
+                text-align: left;
266
+              }
267
+            }
268
+          }
269
+        }
270
+
271
+        button {
272
+          &:nth-child(1) {
273
+            margin-right: 20px;
274
+          }
275
+        }
276
+      }
277
+    }
278
+  }
279
+}

+ 415 - 0
src/app/views/building-floor/building-floor.component.ts

@@ -0,0 +1,415 @@
1
+import { Component, OnInit, ViewChild } from "@angular/core";
2
+import { ActivatedRoute } from "@angular/router";
3
+import { FormBuilder, Validators, FormGroup } from "@angular/forms";
4
+import { NzMessageService } from "ng-zorro-antd/message";
5
+
6
+import { MainService } from "../../services/main.service";
7
+import { OverlayScrollbarsComponent } from "overlayscrollbars-ngx";
8
+import { ToolService } from "../../services/tool.service";
9
+import { GenerateFloorComponent } from "src/app/share/generate-floor/generate-floor.component";
10
+
11
+@Component({
12
+  selector: "app-building-floor",
13
+  templateUrl: "./building-floor.component.html",
14
+  styleUrls: ["./building-floor.component.less"],
15
+})
16
+export class BuildingFloorComponent implements OnInit {
17
+  tableHeight;
18
+
19
+  constructor(
20
+    private fb: FormBuilder,
21
+    private route: ActivatedRoute,
22
+    private mainService: MainService,
23
+    private msg: NzMessageService,
24
+    private tool: ToolService
25
+  ) {}
26
+  @ViewChild("osComponentRef1", {
27
+    read: OverlayScrollbarsComponent,
28
+    static: false,
29
+  })
30
+  osComponentRef1: OverlayScrollbarsComponent;
31
+  @ViewChild(GenerateFloorComponent, { static: false })
32
+  generate1: GenerateFloorComponent;
33
+  ngOnInit() {
34
+    this.coopBtns = this.tool.initCoopBtns(this.route);
35
+    console.log(this.coopBtns);
36
+    this.initForm();
37
+    this.initFormFloor();
38
+    this.getHospitalList();
39
+    this.getBuildingList();
40
+    this.tableHeight = document.body.clientHeight - 267;
41
+  }
42
+  isAllDisplayDataChecked = false;
43
+  isIndeterminate = false;
44
+  listOfDisplayData: any[] = [];
45
+  allFloorList: any[] = []; //当前选中的楼栋包含的所有楼层
46
+  mapOfCheckedId: { [key: string]: boolean } = {};
47
+  checkedBuilding: any = {}; //选中楼栋
48
+  buildingList: Array<any> = []; //楼栋信息
49
+  hospitalList: Array<any> = []; //院区列表
50
+  hosId: any; //当前选择的院区id
51
+
52
+  promptContent: string; //操作提示框提示信息
53
+  ifSuccess: boolean; //操作成功/失败
54
+  promptInfo: string; //操作结果提示信息
55
+  promptModalShow: boolean; //是否展示提示框
56
+
57
+  btnLoading: boolean = false; //确认按钮loading状态
58
+  saveLoading: boolean = false; //批量打印按钮loading状态
59
+
60
+  // 初始化增删改按钮
61
+  coopBtns: any = {};
62
+
63
+  // 分组列表
64
+  loading1 = false;
65
+  getBuildingList() {
66
+    let postData = {
67
+      idx: 0,
68
+      sum: 9999,
69
+      building: { hosId: this.hosId },
70
+    };
71
+    this.loading1 = true;
72
+    this.mainService
73
+      .getFetchDataList("simple/data", "building", postData)
74
+      .subscribe((result) => {
75
+        this.loading1 = false;
76
+        if (result.status == 200) {
77
+          this.buildingList = result.list;
78
+          if (Object.keys(this.checkedBuilding).length) {
79
+            result.list.forEach((item) => {
80
+              if (item.id == this.checkedBuilding.id) {
81
+                this.checkGroup(item);
82
+              }
83
+            });
84
+          } else {
85
+            this.checkGroup(result.list[0]);
86
+          }
87
+        }
88
+      });
89
+  }
90
+
91
+  // 获取选中楼栋下楼层列表
92
+  loading2 = false;
93
+  allUsers = [];
94
+  getAllFloor() {
95
+    // 初始化的时候搜索一次,然后前端过滤
96
+    let postData = {
97
+      idx: 0,
98
+      sum: 9999,
99
+      floor: { hosId: this.hosId, buildId: this.checkedBuilding.id },
100
+    };
101
+    this.loading2 = true;
102
+    this.mainService
103
+      .getFetchDataList("simple/data", "floor", postData)
104
+      .subscribe((result) => {
105
+        this.loading2 = false;
106
+        if (result.status == 200) {
107
+          this.allFloorList = result.list;
108
+          this.allUsers = JSON.parse(JSON.stringify(result.list));
109
+          this.refreshStatus(true);
110
+        }
111
+      });
112
+  }
113
+
114
+  // 院区列表
115
+  getHospitalList() {
116
+    this.hosId = this.tool.getCurrentHospital().id;
117
+    this.hospitalList = [this.tool.getCurrentHospital()];
118
+  }
119
+  // 选中分组
120
+  positionY = 0; //记录其他建单Y轴滚动距离
121
+  checkGroup(data) {
122
+    this.positionY = this.osComponentRef1.osInstance().scroll().position.y; //内容滚动的距离
123
+    this.checkedBuilding = data;
124
+    this.mapOfCheckedId = {};
125
+    this.getAllFloor();
126
+  }
127
+  selectedUser(data) {
128
+    this.mapOfCheckedId[data.id] = !this.mapOfCheckedId[data.id];
129
+    this.refreshStatus();
130
+  }
131
+  // 选中列表中当前分组用户
132
+  usersArr = [];
133
+  refreshStatus(first?): void {
134
+    let arr = [];
135
+    for (var m in this.mapOfCheckedId) {
136
+      if (this.mapOfCheckedId[m]) {
137
+        arr.push({ id: m });
138
+      }
139
+    }
140
+    this.usersArr = arr;
141
+  }
142
+
143
+  // 新增/编辑楼栋模态框
144
+  coopModal: boolean = false; //模态框是否展示
145
+  add: boolean = true; //true:新增;false:编辑
146
+  showCoopModal(type) {
147
+    this.coopModal = true;
148
+    this.add = type == "add";
149
+    if (type == "edit") {
150
+      this.validateForm.controls.buildingName.setValue(
151
+        this.checkedBuilding["buildingName"]
152
+      );
153
+    } else {
154
+      this.validateForm.controls.buildingName.setValue(null);
155
+    }
156
+  }
157
+  // 新增/编辑楼层模态框
158
+  floorModal: boolean = false; //模态框是否展示
159
+  addFloor: boolean = true; //true:新增;false:编辑
160
+  floorDataEdit; //正在编辑的楼层
161
+  showFloorModal(e, type, data?) {
162
+    this.floorModal = true;
163
+    this.addFloor = type == "add";
164
+    if (type == "edit") {
165
+      this.floorDataEdit = data;
166
+      this.validateFloorForm.controls.buildId.setValue(data.buildId);
167
+      this.validateFloorForm.controls.floorName.setValue(data.floorName);
168
+    } else {
169
+      this.validateFloorForm.controls.buildId.setValue(this.checkedBuilding.id);
170
+      this.validateFloorForm.controls.floorName.setValue(null);
171
+    }
172
+    e.stopPropagation();
173
+  }
174
+  // 隐藏楼栋模态框
175
+  hideCoopModal() {
176
+    this.coopModal = false;
177
+  }
178
+  // 隐藏楼层模态框
179
+  hideFloorModal() {
180
+    this.floorModal = false;
181
+  }
182
+
183
+  // 初始化新增form表单
184
+  initForm() {
185
+    this.validateForm = this.fb.group({
186
+      buildingName: [null, [Validators.required]],
187
+    });
188
+  }
189
+  // 初始化新增form表单floor
190
+  validateFloorForm: FormGroup;
191
+  initFormFloor() {
192
+    this.validateFloorForm = this.fb.group({
193
+      buildId: [null, [Validators.required]],
194
+      floorName: [null, [Validators.required]],
195
+    });
196
+  }
197
+
198
+  // 新增/编辑楼栋提交
199
+  validateForm: FormGroup;
200
+  submitForm(): void {
201
+    for (const i in this.validateForm.controls) {
202
+      this.validateForm.controls[i].markAsDirty();
203
+      this.validateForm.controls[i].updateValueAndValidity();
204
+    }
205
+    if (this.validateForm.invalid) return;
206
+    this.btnLoading = true;
207
+    let postData;
208
+    if (this.add) {
209
+      let arr = this.buildingList.filter(
210
+        (item) => item.buildingName == this.validateForm.value.buildingName
211
+      );
212
+      //有重复名称
213
+      if (arr.length > 0) {
214
+        this.btnLoading = false;
215
+        this.showPromptModal(
216
+          "新增",
217
+          false,
218
+          `存在重复的楼栋名称【${this.validateForm.value.buildingName}】请修改后再保存!`
219
+        );
220
+        return;
221
+      }
222
+      postData = {
223
+        buildingName: this.validateForm.value.buildingName,
224
+        deleted: false,
225
+        hosId: this.hosId,
226
+      };
227
+    } else {
228
+      postData = {
229
+        buildingName: this.validateForm.value.buildingName,
230
+        deleted: false,
231
+        hosId: this.hosId,
232
+        id: this.checkedBuilding.id,
233
+      };
234
+    }
235
+    this.mainService
236
+      .simplePost("addData", "building", postData)
237
+      .subscribe((result) => {
238
+        this.hideCoopModal();
239
+        this.btnLoading = false;
240
+        if (result["status"] == 200) {
241
+          this.showPromptModal(this.add ? "新增" : "编辑", true, "");
242
+        } else {
243
+          this.showPromptModal(
244
+            this.add ? "新增" : "编辑",
245
+            false,
246
+            result["msg"]
247
+          );
248
+        }
249
+      });
250
+  }
251
+  // 新增/编辑楼层提交
252
+  submitFormFloor(): void {
253
+    for (const i in this.validateFloorForm.controls) {
254
+      this.validateFloorForm.controls[i].markAsDirty();
255
+      this.validateFloorForm.controls[i].updateValueAndValidity();
256
+    }
257
+    if (this.validateFloorForm.invalid) return;
258
+    this.btnLoading = true;
259
+    let postData;
260
+    if (this.addFloor) {
261
+      let arr = this.allFloorList.filter(
262
+        (item) => item.floorName == this.validateFloorForm.value.floorName
263
+      );
264
+      //有重复名称
265
+      if (arr.length > 0) {
266
+        this.btnLoading = false;
267
+        this.showPromptModal(
268
+          "新增",
269
+          false,
270
+          `同一个楼栋存在重复的楼层名称【${this.validateFloorForm.value.floorName}】请修改后再保存!`
271
+        );
272
+        return;
273
+      }
274
+      postData = {
275
+        buildId: this.validateFloorForm.value.buildId,
276
+        floorName: this.validateFloorForm.value.floorName,
277
+        deleted: false,
278
+        hosId: this.hosId,
279
+      };
280
+    } else {
281
+      postData = {
282
+        buildId: this.validateFloorForm.value.buildId,
283
+        floorName: this.validateFloorForm.value.floorName,
284
+        deleted: false,
285
+        hosId: this.hosId,
286
+        id: this.floorDataEdit.id,
287
+      };
288
+    }
289
+    this.addFloorHandler(postData, false);
290
+  }
291
+  //新增楼层
292
+  addFloorHandler(postData, flag) {
293
+    this.mainService
294
+      .simplePost(flag ? "addListData" : "addData", "floor", postData)
295
+      .subscribe((result) => {
296
+        this.hideFloorModal();
297
+        this.btnLoading = false;
298
+        if (result["status"] == 200) {
299
+          this.showPromptModal(this.addFloor ? "新增" : "编辑", true, "");
300
+        } else {
301
+          this.showPromptModal(
302
+            this.addFloor ? "新增" : "编辑",
303
+            false,
304
+            result["msg"]
305
+          );
306
+        }
307
+      });
308
+  }
309
+
310
+  //删除楼栋
311
+  delModal: boolean = false;
312
+  showDelModal() {
313
+    this.delModal = true;
314
+  }
315
+  hideDelModal() {
316
+    this.delModal = false;
317
+  }
318
+  // 确认删除
319
+  confirmDel() {
320
+    this.btnLoading = true;
321
+    let postData = [this.checkedBuilding["id"]];
322
+    this.mainService.delBuildingList(postData).subscribe((result) => {
323
+      this.hideDelModal();
324
+      this.btnLoading = false;
325
+      if (result["status"] == 200 && !result["data"][0].msg) {
326
+        this.showPromptModal("删除", true, "");
327
+      } else {
328
+        this.showPromptModal("删除", false, result["data"][0].msg);
329
+      }
330
+    });
331
+  }
332
+  /**
333
+   * 删除楼层
334
+   * @param e 事件对象
335
+   * @param data 有值就是单个删除,无值就是批量删除
336
+   */
337
+  delFloorModal: boolean = false;
338
+  isDelSingle: boolean = false; //是否单个删除
339
+  showDelFloorModal(e, data?) {
340
+    if (data) {
341
+      this.isDelSingle = true;
342
+      this.floorDataEdit = data;
343
+    } else {
344
+      this.isDelSingle = false;
345
+    }
346
+    this.delFloorModal = true;
347
+    e.stopPropagation();
348
+  }
349
+  hideDelFloorModal() {
350
+    this.delFloorModal = false;
351
+  }
352
+  // 确认删除
353
+  confirmFloorDel() {
354
+    this.btnLoading = true;
355
+    let ids = Object.keys(this.mapOfCheckedId); //批量删除选中的楼层
356
+    let postData = this.isDelSingle ? [this.floorDataEdit.id] : ids;
357
+    this.mainService.delFloorList(postData).subscribe((result) => {
358
+      this.hideDelFloorModal();
359
+      this.btnLoading = false;
360
+      if (result["status"] == 200 && !result["data"][0].msg) {
361
+        this.showPromptModal("删除", true, "");
362
+      } else {
363
+        this.showPromptModal("删除", false, result["data"][0].msg);
364
+      }
365
+    });
366
+  }
367
+
368
+  // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
369
+  showPromptModal(con, success, promptInfo) {
370
+    this.promptModalShow = false;
371
+    this.promptContent = con;
372
+    this.ifSuccess = success;
373
+    this.promptInfo = promptInfo;
374
+    this.osComponentRef1.osInstance().scroll({ x: 0, y: this.positionY });
375
+    setTimeout(() => {
376
+      this.promptModalShow = true;
377
+      this.getBuildingList();
378
+    }, 100);
379
+  }
380
+  // 生成楼层
381
+  generateModal: boolean = false;
382
+  generate() {
383
+    this.generateModal = true;
384
+  }
385
+  // 隐藏楼层模态框
386
+  hideGenerateModal() {
387
+    this.generateModal = false;
388
+  }
389
+  // 确认生成
390
+  confirmGenerate(e) {
391
+    console.log(e);
392
+    let arr = []; //生成的楼层
393
+    for (let i = e[1]; i <= e[2]; i++) {
394
+      arr.push({
395
+        buildId: e[0].id,
396
+        floorName: i + "",
397
+        deleted: false,
398
+        hosId: this.hosId,
399
+      });
400
+    }
401
+    // 去重
402
+    this.allFloorList.forEach((item1) => {
403
+      arr = arr.filter(
404
+        (item2) =>
405
+          !(
406
+            item1.buildId == item2.buildId && item1.floorName == item2.floorName
407
+          )
408
+      );
409
+    });
410
+    this.btnLoading = true;
411
+    this.generate1.delModal = false;
412
+    this.hideGenerateModal();
413
+    this.addFloorHandler(arr, true);
414
+  }
415
+}

+ 19 - 0
src/app/views/building-floor/building-floor.module.ts

@@ -0,0 +1,19 @@
1
+import { NgModule } from '@angular/core';
2
+import { CommonModule } from '@angular/common';
3
+
4
+import { BuildingFloorRoutingModule } from './building-floor-routing.module';
5
+import { ShareModule } from 'src/app/share/share.module';
6
+import { BuildingFloorComponent } from './building-floor.component';
7
+
8
+
9
+@NgModule({
10
+  declarations: [
11
+    BuildingFloorComponent
12
+  ],
13
+  imports: [
14
+    CommonModule,
15
+    BuildingFloorRoutingModule,
16
+    ShareModule
17
+  ]
18
+})
19
+export class BuildingFloorModule { }

+ 8 - 0
src/app/views/main/main-routing.module.ts

@@ -265,6 +265,14 @@ const routes: Routes = [
265 265
             (m) => m.BuildingDistanceModule
266 266
           ),
267 267
       },
268
+      {
269
+        // 楼栋楼层
270
+        path: "buildingFloor",
271
+        loadChildren: () =>
272
+          import("../building-floor/building-floor.module").then(
273
+            (m) => m.BuildingFloorModule
274
+          ),
275
+      },
268 276
     ],
269 277
   },
270 278
 ];