You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.4 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

function getRoleButtons() {
var role = window.sessionStorage.getItem('role');
var allButtons = ["新增", "修改", "查看", "删除", "发布", "取件", "完成", "报表", "寄件", "接单", "发布订单"];
for (var i = 0; i < menus.length; i++) {
// 找到当前登录角色的菜单
if (menus[i].roleName == role) {
//后台菜单
var backMenu = menus[i].backMenu;
for (var j = 0; j < backMenu.length; j++) {
// 一级菜单
var menuChild = backMenu[j].child;
for (var k = 0; k < menuChild.length; k++) {
// 二级菜单
if (tableName == menuChild[k].tableName) {
var buttons = menuChild[k].buttons;
//console.log("you can see: "+buttons);
//将allButtons剔除能看到的按钮剩下的就是不能看到的按钮
if(buttons && buttons.length>0){
for(var l=0;l<buttons.length;l++){
if(allButtons.includes(buttons[l])){
var index = allButtons.indexOf(buttons[l]);
allButtons.splice(index,1);
//console.log("l="+l+","+allButtons);
}
}
}
//console.log("you can't see: "+allButtons);
for (var m=0; m<allButtons.length; m++) {
var elements = document.getElementsByClassName(allButtons[m]);
for (var n = elements.length - 1; n >= 0; n--) {
elements[n].parentNode.removeChild(elements[n]);
}
}
}
}
}
}
}
}