浏览代码

楼栋楼层全选

seimin 3 年之前
父节点
当前提交
428c8065f8

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

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

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

@@ -27,20 +27,28 @@
27
         <span>已选择 {{selectedFloor.length}} 个楼层</span>
27
         <span>已选择 {{selectedFloor.length}} 个楼层</span>
28
         <button class="btn default" *ngIf="coopBtns.add" nzType="primary" nz-button
28
         <button class="btn default" *ngIf="coopBtns.add" nzType="primary" nz-button
29
           (click)="showFloorModal($event,'add')">新增</button>
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
         <button class="btn default" *ngIf="coopBtns.add" nzType="primary" nz-button (click)="generate()">生成楼层</button>
32
         <button class="btn default" *ngIf="coopBtns.add" nzType="primary" nz-button (click)="generate()">生成楼层</button>
33
       </div>
33
       </div>
34
     </div>
34
     </div>
35
     <div class="table" *ngIf="!buildingsLoading">
35
     <div class="table" *ngIf="!buildingsLoading">
36
       <nz-table class="groupManagementTable" #rowSelectionTable [nzPageSize]="9999" [nzData]="allFloorList"
36
       <nz-table class="groupManagementTable" #rowSelectionTable [nzPageSize]="9999" [nzData]="allFloorList"
37
         [nzShowPagination]="false" [nzScroll]="{ y: tableHeight+'px' }" [nzLoading]="floorsLoading">
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
         <tbody>
46
         <tbody>
39
           <tr *ngFor="let data of rowSelectionTable.data" (click)="selectedUser(data)">
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
               (nzCheckedChange)="refreshStatus()"></td>
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
               <button nz-button nzType="primary" nzSize="small" (click)="showFloorModal($event,'edit',data)">编辑</button>
52
               <button nz-button nzType="primary" nzSize="small" (click)="showFloorModal($event,'edit',data)">编辑</button>
45
               <button nz-button nzType="primary" nzSize="small" class="ml8"
53
               <button nz-button nzType="primary" nzSize="small" class="ml8"
46
                 (click)="showDelFloorModal($event,data)">删除</button>
54
                 (click)="showDelFloorModal($event,data)">删除</button>

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

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

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

@@ -40,6 +40,7 @@ export class BuildingFloorComponent implements OnInit {
40
   delFloorModal: boolean = false; //删除楼层,模态框是否显示
40
   delFloorModal: boolean = false; //删除楼层,模态框是否显示
41
   isDelSingle: boolean = false; //是否单个删除楼层
41
   isDelSingle: boolean = false; //是否单个删除楼层
42
   generateModal: boolean = false; //生成楼层的模态框
42
   generateModal: boolean = false; //生成楼层的模态框
43
+  isAllDisplayDataChecked = false; //当前页是否全选
43
 
44
 
44
   constructor(
45
   constructor(
45
     private fb: FormBuilder,
46
     private fb: FormBuilder,
@@ -125,6 +126,14 @@ export class BuildingFloorComponent implements OnInit {
125
   // 选中列表中楼层
126
   // 选中列表中楼层
126
   refreshStatus(): void {
127
   refreshStatus(): void {
127
     let arr = [];
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
     for (var m in this.mapOfCheckedId) {
137
     for (var m in this.mapOfCheckedId) {
129
       if (this.mapOfCheckedId[m]) {
138
       if (this.mapOfCheckedId[m]) {
130
         arr.push({ id: m });
139
         arr.push({ id: m });
@@ -344,9 +353,8 @@ export class BuildingFloorComponent implements OnInit {
344
   // 确认删除
353
   // 确认删除
345
   confirmFloorDel() {
354
   confirmFloorDel() {
346
     this.btnLoading = true;
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
     this.mainService.delFloorList(postData).subscribe((result) => {
358
     this.mainService.delFloorList(postData).subscribe((result) => {
351
       this.hideDelFloorModal();
359
       this.hideDelFloorModal();
352
       this.btnLoading = false;
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
   // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
377
   // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
362
   showPromptModal(con, success, promptInfo) {
378
   showPromptModal(con, success, promptInfo) {