Przeglądaj źródła

bug4086,4088,4089

luolei 5 lat temu
rodzic
commit
e69f92f92e
2 zmienionych plików z 37 dodań i 16 usunięć
  1. 14 13
      src/css/roleManager.less
  2. 23 3
      src/js/roleManager.js

+ 14 - 13
src/css/roleManager.less

@@ -10,23 +10,24 @@
         padding: 0 10px;
         height: 50px;
         line-height: 50px;
+        cursor: pointer;
         &:hover {
             background-color: #F0F5FF;
         }
     }
-    .editRole {
-        float: right;
-        width: 52px;
-        height: 30px;
-        line-height: 30px;
-        color: #5A8EEE;
-        border: 1px solid #5A8EEE;
-        border-radius: 4px;
-        text-align: center;
-        position: relative;
-        top: 10px;
-        cursor: pointer;
-    }
+    // .editRole {
+    //     float: right;
+    //     width: 52px;
+    //     height: 30px;
+    //     line-height: 30px;
+    //     color: #5A8EEE;
+    //     border: 1px solid #5A8EEE;
+    //     border-radius: 4px;
+    //     text-align: center;
+    //     position: relative;
+    //     top: 10px;
+    //     cursor: pointer;
+    // }
 }
 .rightMenu {
     position: absolute;

+ 23 - 3
src/js/roleManager.js

@@ -119,6 +119,7 @@ $(function(){
                     }
                     
                 }else if(permissionId){//第三层
+                    let tmpNum = 0
                     for(let i = 0;i < tmpDataLis.length;i++){
                         let num = 0
                         let tmpPer = tmpDataLis[i].sysPermissionDTOList
@@ -135,20 +136,38 @@ $(function(){
                         }else{
                             tmpDataLis[i].haveMenu = '1'
                         }
+                        //二层否有选中,有则第一层选中,否则第一层不选中
+                        if(tmpDataLis[i].haveMenu == 0){
+                            ++tmpNum
+                        }
+                    }
+                    if(tmpNum == tmpDataLis.length){//二层都是取消状态,一层选中取消掉否则选中
+                        tmpData.haveMenu = 0
+                    }else{
+                        tmpData.haveMenu = 1
                     }
                 }else{//第二层,内层全选反选
+                    let tmpNum = 0
                     for(let i = 0;i < tmpDataLis.length;i++){
                         let tmpPer = tmpDataLis[i].sysPermissionDTOList
                         if(menuId&&menuId == tmpDataLis[i].menuId){//第二层,里面的全部选中或者全部取消
                             tmpSelectData = tmpDataLis[i]
-                            // console.log(tmpDataLis[i],788787878)
                             tmpDataLis[i].haveMenu = haveMenu==0?'1':'0'
                             for(let m = 0;m < tmpPer.length;m++){//所有相同id联动
                                 tmpPer[m].havePermission = haveMenu==0?'1':'0'
                             }
                         }
+                        //二层否有选中,有则第一层选中,否则第一层不选中
+                        if(tmpDataLis[i].haveMenu == 0){
+                            ++tmpNum
+                        }
+                    }
+                    if(tmpNum == tmpDataLis.length){//二层都是取消状态,一层选中取消掉否则选中
+                        tmpData.haveMenu = 0
+                    }else{
+                        tmpData.haveMenu = 1
                     }
-                    //麻烦,全选后遍历统计数据中有相同id的也要选中,三级自动选中后二级要判断是取消还是选中
+                    //全选后遍历统计数据中有相同id的也要选中,三级自动选中后二级要判断是取消还是选中
                     for(let i = 0;i < tmpDataLis.length;i++){//二级循环
                         let num = 0
                         if(menuId&&menuId != tmpDataLis[i].menuId){//第二层,没有点击,自动选中第三层相同id的
@@ -278,7 +297,7 @@ $(function(){
         let str = ''
         for(let i = 0;i < data.length;i++){
             str+=`
-                <li class="ellipsis">${data[i].name} <span class="editRole" data-id="${data[i].id}">编辑</span></li>
+                <li class="ellipsis editRole" style="background:${i == 0?'#F0F5FF':'#fff'}" data-id="${data[i].id}">${data[i].name}</li>
             `
         }
         $(".leftMenu ul").html(str)
@@ -289,6 +308,7 @@ $(function(){
             let id = $(this).attr("data-id")
             curId = id
             permissionIdLis=[],menuIdLis=[];
+            $(this).css({"background-color":"#F0F5FF"}).siblings().css("background-color","#fff")
             getRoleMenu(id)
         })
     }