let data ={
"entityDisplayName": "admin",
"groups": [
{
"name": "AbpIdentity",
"displayName": "系统管理模块",
"permissions": [
{
"name": "AbpIdentity.Roles",
"displayName": "角色管理",
"parentName": null,
"isGranted": true,
"allowedProviders": [],
"grantedProviders": [
{
"providerName": "R",
"providerKey": "admin"
}
]
},
{
"name": "AbpIdentity.Roles.Create",
"displayName": "创建",
"parentName": "AbpIdentity.Roles",
"isGranted": true,
"allowedProviders": [],
"grantedProviders": [
{
"providerName": "R",
"providerKey": "admin"
}
]
},
{
"name": "AbpIdentity.Roles.Update",
"displayName": "编辑",
"parentName": "AbpIdentity.Roles",
"isGranted": true,
"allowedProviders": [],
"grantedProviders": [
{
"providerName": "R",
"providerKey": "admin"
}
]
},
{
"name": "AbpIdentity.Roles.Delete",
"displayName": "删除",
"parentName": "AbpIdentity.Roles",
"isGranted": true,
"allowedProviders": [],
"grantedProviders": [
{
"providerName": "R",
"providerKey": "admin"
}
]
},
{
"name": "AbpIdentity.Roles.ManagePermissions",
"displayName": "更改权限",
"parentName": "AbpIdentity.Roles",
"isGranted": true,
"allowedProviders": [],
"grantedProviders": [
{
"providerName": "R",
"providerKey": "admin"
}
]
},
{
"name": "AbpIdentity.Roles.ManageOrganizationUnits",
"displayName": "管理部门",
"parentName": "AbpIdentity.Roles",
"isGranted": true,
"allowedProviders": [],
"grantedProviders": [
{
"providerName": "R",
"providerKey": "admin"
}
]
},
{
"name": "AbpIdentity.Users",
"displayName": "用户管理",
"parentName": null,
"isGranted": true,
"allowedProviders": [],
"grantedProviders": [
{
"providerName": "R",
"providerKey": "admin"
}
]
},
{
"name": "AbpIdentity.Users.Create",
"displayName": "创建",
"parentName": "AbpIdentity.Users",
"isGranted": true,
"allowedProviders": [],
"grantedProviders": [
{
"providerName": "R",
"providerKey": "admin"
}
]
},
{
"name": "AbpIdentity.Users.Update",
"displayName": "编辑",
"parentName": "AbpIdentity.Users",
"isGranted": true,
"allowedProviders": [],
"grantedProviders": [
{
"providerName": "R",
"providerKey": "admin"
}
]
},
{
"name": "AbpIdentity.Users.Delete",
"displayName": "删除",
"parentName": "AbpIdentity.Users",
"isGranted": true,
"allowedProviders": [],
"grantedProviders": [
{
"providerName": "R",
"providerKey": "admin"
}
]
},
{
"name": "AbpIdentity.Users.ManagePermissions",
"displayName": "更改权限",
"parentName": "AbpIdentity.Users",
"isGranted": true,
"allowedProviders": [],
"grantedProviders": [
{
"providerName": "R",
"providerKey": "admin"
}
]
},
{
"name": "AbpIdentity.Users.ManageOrganizationUnits",
"displayName": "管理部门",
"parentName": "AbpIdentity.Users",
"isGranted": true,
"allowedProviders": [],
"grantedProviders": [
{
"providerName": "R",
"providerKey": "admin"
}
]
},
{
"name": "AbpIdentity.OrganizationUnits",
"displayName": "部门管理",
"parentName": null,
"isGranted": true,
"allowedProviders": [],
"grantedProviders": [
{
"providerName": "R",
"providerKey": "admin"
}
]
},
{
"name": "AbpIdentity.OrganizationUnits.Create",
"displayName": "创建",
"parentName": "AbpIdentity.OrganizationUnits",
"isGranted": true,
"allowedProviders": [],
"grantedProviders": [
{
"providerName": "R",
"providerKey": "admin"
}
]
},
{
"name": "AbpIdentity.OrganizationUnits.Update",
"displayName": "编辑",
"parentName": "AbpIdentity.OrganizationUnits",
"isGranted": true,
"allowedProviders": [],
"grantedProviders": [
{
"providerName": "R",
"providerKey": "admin"
}
]
},
{
"name": "AbpIdentity.OrganizationUnits.Delete",
"displayName": "删除",
"parentName": "AbpIdentity.OrganizationUnits",
"isGranted": true,
"allowedProviders": [],
"grantedProviders": [
{
"providerName": "R",
"providerKey": "admin"
}
]
},
{
"name": "AbpIdentity.OrganizationUnits.ManageRoles",
"displayName": "Permission:ChangeRoles",
"parentName": "AbpIdentity.OrganizationUnits",
"isGranted": true,
"allowedProviders": [],
"grantedProviders": [
{
"providerName": "R",
"providerKey": "admin"
}
]
},
{
"name": "AbpIdentity.OrganizationUnits.ManageUsers",
"displayName": "Permission:ChangeUsers",
"parentName": "AbpIdentity.OrganizationUnits",
"isGranted": true,
"allowedProviders": [],
"grantedProviders": [
{
"providerName": "R",
"providerKey": "admin"
}
]
},
{
"name": "AbpIdentity.UserLookup",
"displayName": "用户查询",
"parentName": null,
"isGranted": true,
"allowedProviders": [],
"grantedProviders": [
{
"providerName": "R",
"providerKey": "admin"
}
]
},
{
"name": "AbpIdentity.AuditLogging",
"displayName": "系统日志",
"parentName": null,
"isGranted": false,
"allowedProviders": [],
"grantedProviders": []
},
{
"name": "OnlineEduManagement.Member",
"displayName": "学员管理",
"parentName": null,
"isGranted": false,
"allowedProviders": [],
"grantedProviders": []
},
{
"name": "OnlineEduManagement.Member.Create",
"displayName": "创建",
"parentName": "OnlineEduManagement.Member",
"isGranted": false,
"allowedProviders": [],
"grantedProviders": []
},
{
"name": "OnlineEduManagement.Member.Update",
"displayName": "编辑",
"parentName": "OnlineEduManagement.Member",
"isGranted": true,
"allowedProviders": [],
"grantedProviders": [
{
"providerName": "R",
"providerKey": "admin"
}
]
},
{
"name": "OnlineEduManagement.Member.Delete",
"displayName": "删除",
"parentName": "OnlineEduManagement.Member",
"isGranted": true,
"allowedProviders": [],
"grantedProviders": [
{
"providerName": "R",
"providerKey": "admin"
}
]
},
{
"name": "OnlineEduManagement.Member.ChangePhone",
"displayName": "修改手机号",
"parentName": "OnlineEduManagement.Member",
"isGranted": false,
"allowedProviders": [],
"grantedProviders": []
},
{
"name": "OnlineEduManagement.Member.Import",
"displayName": "导入",
"parentName": "OnlineEduManagement.Member",
"isGranted": false,
"allowedProviders": [],
"grantedProviders": []
},
{
"name": "OnlineEduManagement.Member.Export",
"displayName": "导出",
"parentName": "OnlineEduManagement.Member",
"isGranted": false,
"allowedProviders": [],
"grantedProviders": []
}
]
},
{
"name": "OnlineEduManagement.SX",
"displayName": "实习管理模块",
"permissions": [
{
"name": "OnlineEduManagement.PracticeHospital",
"displayName": "PracticeHospital",
"parentName": null,
"isGranted": false,
"allowedProviders": [],
"grantedProviders": []
},
{
"name": "OnlineEduManagement.PracticeHospital.Create",
"displayName": "创建",
"parentName": "OnlineEduManagement.PracticeHospital",
"isGranted": false,
"allowedProviders": [],
"grantedProviders": []
},
{
"name": "OnlineEduManagement.PracticeHospital.Update",
"displayName": "编辑",
"parentName": "OnlineEduManagement.PracticeHospital",
"isGranted": false,
"allowedProviders": [],
"grantedProviders": []
},
{
"name": "OnlineEduManagement.PracticeHospital.Delete",
"displayName": "删除",
"parentName": "OnlineEduManagement.PracticeHospital",
"isGranted": false,
"allowedProviders": [],
"grantedProviders": []
}
]
},
{
"name": "AbpTenantManagement",
"displayName": "租户管理",
"permissions": [
{
"name": "AbpTenantManagement.Tenants",
"displayName": "租户管理",
"parentName": null,
"isGranted": true,
"allowedProviders": [],
"grantedProviders": [
{
"providerName": "R",
"providerKey": "admin"
}
]
},
{
"name": "AbpTenantManagement.Tenants.Create",
"displayName": "创建",
"parentName": "AbpTenantManagement.Tenants",
"isGranted": true,
"allowedProviders": [],
"grantedProviders": [
{
"providerName": "R",
"providerKey": "admin"
}
]
},
{
"name": "AbpTenantManagement.Tenants.Update",
"displayName": "编辑",
"parentName": "AbpTenantManagement.Tenants",
"isGranted": true,
"allowedProviders": [],
"grantedProviders": [
{
"providerName": "R",
"providerKey": "admin"
}
]
},
{
"name": "AbpTenantManagement.Tenants.Delete",
"displayName": "删除",
"parentName": "AbpTenantManagement.Tenants",
"isGranted": true,
"allowedProviders": [],
"grantedProviders": [
{
"providerName": "R",
"providerKey": "admin"
}
]
},
{
"name": "AbpTenantManagement.Tenants.ManageFeatures",
"displayName": "管理功能",
"parentName": "AbpTenantManagement.Tenants",
"isGranted": false,
"allowedProviders": [],
"grantedProviders": []
},
{
"name": "AbpTenantManagement.Tenants.ManageConnectionStrings",
"displayName": "管理连接字符串",
"parentName": "AbpTenantManagement.Tenants",
"isGranted": false,
"allowedProviders": [],
"grantedProviders": []
}
]
}
]
};
function treeDataTranslate(arr,id='id',pid='pid'){
let tree =[];
const map=[];
for(let item of arr){
let newItem = map[item[id]] = {
name:item.name,
displayName:item.displayName,
children:[]
}
if(map[item[pid]]){
let parent = map[item[pid]];
parent.children.push(newItem);
} else {
tree.push(newItem);
}
}
return tree;
}
let treeData = [];
let grantedNames = [];
for(let gitem of data.groups){
var item = {
name:gitem.name,
displayName:gitem.displayName
};
item.children = treeDataTranslate(gitem.permissions,'name','parentName');
treeData.push(item);
grantedNames.push.apply(grantedNames,_.compact(_.map(gitem.permissions,function(el){
if(el.isGranted)
return el.name;
})))
}
//console.log(treeData);
console.log(grantedNames);
console