app-xiangsonghua/app-saas-src/script/menu-privilege.js
2024-12-26 17:00:06 +08:00

51 lines
1.4 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var privilegeModule = {
menuList: {}, // 菜单列表
getMenuList: {}, // 获取登录用户可以查看的菜单列表[ems中设置权限]
}
privilegeModule.getMenuList = function(callback) {
var cusId = $api.getStorage('cusId');
var cusRoleType = $api.getStorage('cusRoleType');
var url = '/ems/rest/menu/list/by/customer';
var data = {
menuBelong: 1, // 1为app2为edp
customerId: cusId, // 客户id
roleId: cusRoleType, // 客户角色id 如董事长,项目经理,项目负责人
isSelected: true
}
$api.get(url,data,function(data, error){
if(data && data.code == 200 ){
if(data.body && data.body.length){
privilegeModule.menuList = data.body; // 获取到菜单列表
callback && callback();
return;
}
api.toast({
msg: '请先联系工作站站长设置权限',
duration: 3000,
locaiton: 'top'
});
}else{
api.toast({
msg: '网络错误,请稍后再试...',
duration: 3000,
locaiton: 'top'
});
}
})
}
privilegeModule.hasMenu = function(name) {
var list = privilegeModule.menuList;
var menuName = $api.trim(name);
var flag = false;
for(var i = 0; i < list.length;i++){
var itemName = $api.trim(list[i]['menuName']);
if(itemName == menuName) {
flag = true;
return true;
}
}
return false;
}