소스 검색

楼栋楼层全选

seimin 3 년 전
부모
커밋
428c8065f8

+ 2 - 2
src/app/services/tool.service.ts

@@ -4,7 +4,6 @@ import { Injectable } from "@angular/core";
4 4
   providedIn: "root",
5 5
 })
6 6
 export class ToolService {
7
-  menu: any = JSON.parse(localStorage.getItem("menu")) || []; //菜单
8 7
   constructor() {}
9 8
   // 获取权限中的院区
10 9
   getHospitalList() {
@@ -25,6 +24,7 @@ export class ToolService {
25 24
   //获取当前菜单的权限
26 25
   initCoopBtns(route) {
27 26
     let link;
27
+    let menu: any = JSON.parse(localStorage.getItem("menu")) || []; //菜单
28 28
     if (route === "dataDictionary") {
29 29
       link = route;
30 30
     } else {
@@ -33,7 +33,7 @@ export class ToolService {
33 33
     let secondMenus = []; // 二级菜单
34 34
     let jurisdiction = []; //当前菜单的权限列表
35 35
     let coopBtns: any = {}; // 初始化权限
36
-    this.menu.forEach((e) => {
36
+    menu.forEach((e) => {
37 37
       if (e.childrens) {
38 38
         e.childrens.forEach((el) => {
39 39
           secondMenus.push(el);

+ 13 - 5
src/app/views/building-floor/building-floor.component.html

@@ -27,20 +27,28 @@
27 27
         <span>已选择 {{selectedFloor.length}} 个楼层</span>
28 28
         <button class="btn default" *ngIf="coopBtns.add" nzType="primary" nz-button
29 29
           (click)="showFloorModal($event,'add')">新增</button>
30
-        <button class="btn default" *ngIf="coopBtns.del" nzType="primary" nz-button
31
-          (click)="showDelFloorModal($event)">批量删除</button>
30
+        <button class="btn default" *ngIf="coopBtns.del" nzType="primary" nz-button (click)="showDelFloorModal($event)"
31
+          [disabled]="allFloorList.length===0">批量删除</button>
32 32
         <button class="btn default" *ngIf="coopBtns.add" nzType="primary" nz-button (click)="generate()">生成楼层</button>
33 33
       </div>
34 34
     </div>
35 35
     <div class="table" *ngIf="!buildingsLoading">
36 36
       <nz-table class="groupManagementTable" #rowSelectionTable [nzPageSize]="9999" [nzData]="allFloorList"
37 37
         [nzShowPagination]="false" [nzScroll]="{ y: tableHeight+'px' }" [nzLoading]="floorsLoading">
38
+        <thead>
39
+          <tr class="thead">
40
+            <th nzWidth="5%" nzShowCheckbox [(nzChecked)]="isAllDisplayDataChecked"
41
+              (nzCheckedChange)="checkAll($event)"></th>
42
+            <th nzWidth="75%">楼层</th>
43
+            <th nzWidth="20%">操作</th>
44
+          </tr>
45
+        </thead>
38 46
         <tbody>
39 47
           <tr *ngFor="let data of rowSelectionTable.data" (click)="selectedUser(data)">
40
-            <td style="width:5%" nzShowCheckbox [(nzDisabled)]="!coopBtns.edit" [(nzChecked)]="mapOfCheckedId[data.id]"
48
+            <td nzShowCheckbox [(nzDisabled)]="!coopBtns.edit" [(nzChecked)]="mapOfCheckedId[data.id]"
41 49
               (nzCheckedChange)="refreshStatus()"></td>
42
-            <td style="width:75%">{{ data.floorName }}</td>
43
-            <td style="width:20%">
50
+            <td>{{ data.floorName }}</td>
51
+            <td>
44 52
               <button nz-button nzType="primary" nzSize="small" (click)="showFloorModal($event,'edit',data)">编辑</button>
45 53
               <button nz-button nzType="primary" nzSize="small" class="ml8"
46 54
                 (click)="showDelFloorModal($event,data)">删除</button>

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

@@ -133,6 +133,9 @@
133 133
         padding: 16px;
134 134
         background: #f9fafb;
135 135
         border: 1px solid #e5e9ed;
136
+        .thead th {
137
+          text-align: center;
138
+        }
136 139
 
137 140
         .ant-table-tbody {
138 141
           tr {

+ 19 - 3
src/app/views/building-floor/building-floor.component.ts

@@ -40,6 +40,7 @@ export class BuildingFloorComponent implements OnInit {
40 40
   delFloorModal: boolean = false; //删除楼层,模态框是否显示
41 41
   isDelSingle: boolean = false; //是否单个删除楼层
42 42
   generateModal: boolean = false; //生成楼层的模态框
43
+  isAllDisplayDataChecked = false; //当前页是否全选
43 44
 
44 45
   constructor(
45 46
     private fb: FormBuilder,
@@ -125,6 +126,14 @@ export class BuildingFloorComponent implements OnInit {
125 126
   // 选中列表中楼层
126 127
   refreshStatus(): void {
127 128
     let arr = [];
129
+    if (this.allFloorList.length) {
130
+      this.isAllDisplayDataChecked = this.allFloorList.every(
131
+        (item) => this.mapOfCheckedId[item.id]
132
+      );
133
+    } else {
134
+      this.isAllDisplayDataChecked = false;
135
+    }
136
+
128 137
     for (var m in this.mapOfCheckedId) {
129 138
       if (this.mapOfCheckedId[m]) {
130 139
         arr.push({ id: m });
@@ -344,9 +353,8 @@ export class BuildingFloorComponent implements OnInit {
344 353
   // 确认删除
345 354
   confirmFloorDel() {
346 355
     this.btnLoading = true;
347
-    let postData = this.isDelSingle
348
-      ? [this.floorDataEdit.id]
349
-      : this.selectedFloor;
356
+    let selectedFloor = this.selectedFloor.map((item) => item.id);
357
+    let postData = this.isDelSingle ? [this.floorDataEdit.id] : selectedFloor;
350 358
     this.mainService.delFloorList(postData).subscribe((result) => {
351 359
       this.hideDelFloorModal();
352 360
       this.btnLoading = false;
@@ -357,6 +365,14 @@ export class BuildingFloorComponent implements OnInit {
357 365
       }
358 366
     });
359 367
   }
368
+  // 全选
369
+  checkAll(value: boolean): void {
370
+    console.log(this.allFloorList);
371
+    this.allFloorList.forEach((item) => {
372
+      this.mapOfCheckedId[item.id] = value;
373
+    });
374
+    this.refreshStatus();
375
+  }
360 376
 
361 377
   // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
362 378
   showPromptModal(con, success, promptInfo) {