|
@@ -12,13 +12,22 @@ const arrowLeft= require("./../images/arrow_left.png")
|
|
|
const arrowRight = require("./../images/arrow_right.png")
|
|
|
|
|
|
$(function(){
|
|
|
- let curId="",curData="",curTreeData=[];
|
|
|
+ let curId="",curData="",curTreeData=[],permissionIdLis=[],menuIdLis=[];
|
|
|
$(window).resize(function(){
|
|
|
$(".role .leftMenu").css("height",$(window).height()-128+'px')
|
|
|
$(".role .rightMenu").css({"height":$(window).height()-88+'px',"width":$(".filterBox").width()-400+'px'})
|
|
|
})
|
|
|
$(".role .leftMenu").css("height",$(window).height()-128+'px')
|
|
|
$(".role .rightMenu").css({"height":$(window).height()-88+'px',"width":$(".filterBox").width()-400+'px'})
|
|
|
+ $(".saveRoleSet").click(function(){//保存角色设置
|
|
|
+ $.alerModal({type:"loading"});
|
|
|
+ let params = {
|
|
|
+ "roleId": curId,
|
|
|
+ "sysMenuSaveVOList": menuIdLis,
|
|
|
+ "sysPermissionSaveVOList": permissionIdLis
|
|
|
+ }
|
|
|
+ saveRoleMenu(params)
|
|
|
+ })
|
|
|
'/sys/role/getRoleMenu'//获取角色菜权限单等数据
|
|
|
'/sys/role/list' //获取角色列表信息
|
|
|
'/sys/role/listForUser'//获取角色下拉列表信息
|
|
@@ -53,11 +62,14 @@ $(function(){
|
|
|
function saveRoleMenu(params){
|
|
|
post('/sys/role/saveRoleMenu',params).then(res =>{
|
|
|
let data = res.data;
|
|
|
+ $(".loading").remove()
|
|
|
if(data.code == '0'){
|
|
|
-
|
|
|
- }else{}
|
|
|
+ $.alerModal({type:"tip",message:"保存成功"});
|
|
|
+ }else{
|
|
|
+
|
|
|
+ }
|
|
|
}).catch((e) =>{
|
|
|
-
|
|
|
+ $(".loading").remove()
|
|
|
})
|
|
|
}
|
|
|
function roleSetLis(data){
|
|
@@ -95,8 +107,17 @@ $(function(){
|
|
|
// console.log(curData[grandIndex])
|
|
|
let tmpData = curData[grandIndex];
|
|
|
let tmpDataLis = curData[grandIndex].sonMenuDTOList;
|
|
|
- if(parentId == -1&&menuId&&menuId == tmpData.menuId) {//第一层,全选反选
|
|
|
+ if(parentId == -1&&menuId&&menuId == tmpData.menuId) {//第一层,全选反选,
|
|
|
tmpData.haveMenu = haveMenu==0?'1':'0'
|
|
|
+ for(let i = 0;i < tmpDataLis.length;i++){
|
|
|
+ let num = 0
|
|
|
+ let tmpPer = tmpDataLis[i].sysPermissionDTOList
|
|
|
+ tmpDataLis[i].haveMenu = haveMenu==0?'1':'0'
|
|
|
+ for(let m = 0;m < tmpPer.length;m++){//所有相同id联动
|
|
|
+ tmpPer[m].havePermission = haveMenu==0?'1':'0'
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}else if(permissionId){//第三层
|
|
|
for(let i = 0;i < tmpDataLis.length;i++){
|
|
|
let num = 0
|
|
@@ -183,22 +204,42 @@ $(function(){
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- // getParams()
|
|
|
- // let params = {
|
|
|
- // "roleId": curId,
|
|
|
- // "sysMenuSaveVOList": menuIdLis,
|
|
|
- // "sysPermissionSaveVOList": permissionIdLis
|
|
|
- // }
|
|
|
-
|
|
|
roleSetLis(curData)
|
|
|
+ getParams()
|
|
|
})
|
|
|
}
|
|
|
- function getParams(){//type=0删除,1添加
|
|
|
- console.log(curData)
|
|
|
- let permissionIdLis=[],menuIdLis=[];
|
|
|
- for(let i = 0;i < curData.length;i++){
|
|
|
+ function getParams(){//type=0删除,1添加,共三层
|
|
|
+ permissionIdLis=[],menuIdLis=[];
|
|
|
+ for(let i = 0;i < curData.length;i++){//最外层的
|
|
|
let tmpData = curData[i]
|
|
|
+ if(tmpData.haveMenu == 1){//第一层选中了,继续遍历第二层
|
|
|
+ menuIdLis.push({menuId:tmpData.menuId})
|
|
|
+ if(tmpData.sonMenuDTOList&&tmpData.sonMenuDTOList.length > 0){//说明有第三层
|
|
|
+ let tmpSon = tmpData.sonMenuDTOList
|
|
|
+ for(let m = 0;m < tmpSon.length;m++){
|
|
|
+ let tmpSym = tmpSon[m]
|
|
|
+ if(tmpSym.haveMenu == 1){//有选中,遍历第三层
|
|
|
+ menuIdLis.push({menuId:tmpSym.menuId})
|
|
|
+ for(let n =0;n < tmpSym.sysPermissionDTOList.length;n++){
|
|
|
+ if(tmpSym.sysPermissionDTOList[n].havePermission == 1){
|
|
|
+ permissionIdLis.push({permissionId:tmpSym.sysPermissionDTOList[n].permissionId})
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{//只有两层
|
|
|
+ if(tmpData.haveMenu == 1){
|
|
|
+ for(let j = 0;j < tmpData.sysPermissionDTOList.length;j++){
|
|
|
+ let tmpS = tmpData.sysPermissionDTOList[j]
|
|
|
+ if(tmpS.havePermission == 1){
|
|
|
+ permissionIdLis.push({permissionId:tmpS.permissionId})
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ // console.log(permissionIdLis,menuIdLis)
|
|
|
}
|
|
|
function getOneLis(data){
|
|
|
let tmpstr = ''
|
|
@@ -237,9 +278,18 @@ $(function(){
|
|
|
let str = ''
|
|
|
for(let i = 0;i < data.length;i++){
|
|
|
str+=`
|
|
|
- <li class="ellipsis" data-id="${data[i].id}">${data[i].name} <span class="editRole">编辑</span></li>
|
|
|
+ <li class="ellipsis">${data[i].name} <span class="editRole" data-id="${data[i].id}">编辑</span></li>
|
|
|
`
|
|
|
}
|
|
|
$(".leftMenu ul").html(str)
|
|
|
+ changeRole()
|
|
|
+ }
|
|
|
+ function changeRole(){
|
|
|
+ $(".editRole").click(function(){
|
|
|
+ let id = $(this).attr("data-id")
|
|
|
+ curId = id
|
|
|
+ permissionIdLis=[],menuIdLis=[];
|
|
|
+ getRoleMenu(id)
|
|
|
+ })
|
|
|
}
|
|
|
})
|