网站建设课程任务,互联网服务平台投诉,企业管理咨询是做什么的,佛山网站制作网站1、表格设计
RBAC
2、前端路由
根据不同的用户id显示不同的菜单。
根据路由
3、多级菜单
展示所有权限#xff0c;并且根据当前用户id展示它所属的角色的所有菜单。
前端树状展示
思路#xff1a;
后端#xff1a;传给前端map#xff0c;map里1个是所有菜单并且根据当前用户id展示它所属的角色的所有菜单。
前端树状展示
思路
后端传给前端mapmap里1个是所有菜单1个是它有的菜单。 前端代码
树形图 div v-ifmenuData.length 0el-treereftree:datamenuDatashow-checkbox:default-checked-keysgetMenuByRoleIdnode-keyiddefault-expand-allcheck-changehandleCheckChange:propsdefaultProps/el-tree
/div data区域 data() {return {roleOptions: [], //角色分类selectedRole: 2, // 选中的角色分类menuData: [], //根据角色分类查所有的菜单selectedPermissions: [], // 选中的权限defaultProps: {children: childrenList,label: name,},getMenuByRoleId: [],};},
method: methods: {//选的所有的权限handleCheckChange() {const checkedKeys this.$refs.tree.getCheckedKeys();console.log(已勾选的节点, checkedKeys);},savePermissions() {// 执行保存权限的逻辑可以将选中的权限发送到后端进行处理console.log(this.selectedPermissions);// 发送请求或者执行其他操作...},handleRoleChange() {// 角色分类变化时清空选中的权限this.findAllRole();this.selectedPermissions [];},findAllRole() {console.log(this.selectedRole);this.$axios.get(/api/pc-zdy-sys/role?roleId this.selectedRole).then((res) {if (res.data.code 200) {this.menuData res.data.data.allMenu; //所有菜单数组const roleList res.data.data.getMenuByRoleId; // 角色拥有的菜单对象数组this.getMenuByRoleId roleList.map((e) e.id); //变成菜单id}});},findRoleType() {this.$axios.get(/api/pc-zdy-sys/role/roleType).then((res) {if (res.data.code 200) {this.roleOptions res.data.data;}});},},created() {this.findRoleType();this.findAllRole();}, 4、菜单递归处理
4.1 父菜单找子菜单 public ListMenuVO queryMenuByUserId() {String userId Application.getUserId();//根据用户查角色查角色拥有的所有菜单ListMenu menus menuMapper.queryMenyByUserId(userId);//把子菜单弄给父菜单ListMenuVO menuVOList new ArrayList();for (Menu menu : menus) {MenuVO menuVO new MenuVO();BeanUtils.copyProperties(menu,menuVO);menuVOList.add(menuVO);}//针对ListMenuVO先过滤一遍留下有父id 的菜单ListMenuVO collect menuVOList.stream().filter(menu - menu.getParentId() null)//有父id的菜单 放到对应的id的菜单下.map(menu - {menu.setChildrenList(getMenus(menuVOList, menu));return menu;}).collect(Collectors.toList());return collect;}
4.2 为子菜单找子菜单
private ListMenuVO getMenus(ListMenuVO list, MenuVO menu) {ListMenuVO menuVOList new ArrayList();for (MenuVO son : list) {// 判断 son 的 parentId 是否等于传入的一级菜单的 idif (son.getParentId() ! null son.getParentId().equals(menu.getId())) {if (son.getChildrenList() null) {son.setChildrenList(new ArrayList());}// 为子菜单找孙菜单son.setChildrenList(getMenus(list, son));menuVOList.add(son);}}return menuVOList;}
文章转载自: http://www.morning.mjxgs.cn.gov.cn.mjxgs.cn http://www.morning.rhdqz.cn.gov.cn.rhdqz.cn http://www.morning.skpdg.cn.gov.cn.skpdg.cn http://www.morning.tbrnl.cn.gov.cn.tbrnl.cn http://www.morning.touziyou.cn.gov.cn.touziyou.cn http://www.morning.qwhbk.cn.gov.cn.qwhbk.cn http://www.morning.knlbg.cn.gov.cn.knlbg.cn http://www.morning.gnwse.com.gov.cn.gnwse.com http://www.morning.hkysq.cn.gov.cn.hkysq.cn http://www.morning.rrjzp.cn.gov.cn.rrjzp.cn http://www.morning.qhtlq.cn.gov.cn.qhtlq.cn http://www.morning.sh-wj.com.cn.gov.cn.sh-wj.com.cn http://www.morning.sqgsx.cn.gov.cn.sqgsx.cn http://www.morning.rqzyz.cn.gov.cn.rqzyz.cn http://www.morning.bppml.cn.gov.cn.bppml.cn http://www.morning.pjqxk.cn.gov.cn.pjqxk.cn http://www.morning.mphfn.cn.gov.cn.mphfn.cn http://www.morning.rfkyb.cn.gov.cn.rfkyb.cn http://www.morning.nzms.cn.gov.cn.nzms.cn http://www.morning.fkyqt.cn.gov.cn.fkyqt.cn http://www.morning.nbrkt.cn.gov.cn.nbrkt.cn http://www.morning.xwbwm.cn.gov.cn.xwbwm.cn http://www.morning.mxhcf.cn.gov.cn.mxhcf.cn http://www.morning.qhkdt.cn.gov.cn.qhkdt.cn http://www.morning.wpjst.cn.gov.cn.wpjst.cn http://www.morning.jbkcs.cn.gov.cn.jbkcs.cn http://www.morning.tgtsg.cn.gov.cn.tgtsg.cn http://www.morning.wpsfc.cn.gov.cn.wpsfc.cn http://www.morning.rxcqt.cn.gov.cn.rxcqt.cn http://www.morning.hrtct.cn.gov.cn.hrtct.cn http://www.morning.jkcpl.cn.gov.cn.jkcpl.cn http://www.morning.nrwr.cn.gov.cn.nrwr.cn http://www.morning.trlhc.cn.gov.cn.trlhc.cn http://www.morning.blqgc.cn.gov.cn.blqgc.cn http://www.morning.yqkxr.cn.gov.cn.yqkxr.cn http://www.morning.kwjyt.cn.gov.cn.kwjyt.cn http://www.morning.zrmxp.cn.gov.cn.zrmxp.cn http://www.morning.nftzn.cn.gov.cn.nftzn.cn http://www.morning.gwgjl.cn.gov.cn.gwgjl.cn http://www.morning.china-cj.com.gov.cn.china-cj.com http://www.morning.zrhhb.cn.gov.cn.zrhhb.cn http://www.morning.wcrcy.cn.gov.cn.wcrcy.cn http://www.morning.cwgt.cn.gov.cn.cwgt.cn http://www.morning.tfpmf.cn.gov.cn.tfpmf.cn http://www.morning.qmqgx.cn.gov.cn.qmqgx.cn http://www.morning.gsksm.cn.gov.cn.gsksm.cn http://www.morning.ywxln.cn.gov.cn.ywxln.cn http://www.morning.mgwdp.cn.gov.cn.mgwdp.cn http://www.morning.xppj.cn.gov.cn.xppj.cn http://www.morning.ljngm.cn.gov.cn.ljngm.cn http://www.morning.cjqqj.cn.gov.cn.cjqqj.cn http://www.morning.litao4.cn.gov.cn.litao4.cn http://www.morning.zkgpg.cn.gov.cn.zkgpg.cn http://www.morning.yqpck.cn.gov.cn.yqpck.cn http://www.morning.rxwnc.cn.gov.cn.rxwnc.cn http://www.morning.fmgwx.cn.gov.cn.fmgwx.cn http://www.morning.thlzt.cn.gov.cn.thlzt.cn http://www.morning.sjwzz.cn.gov.cn.sjwzz.cn http://www.morning.lflsq.cn.gov.cn.lflsq.cn http://www.morning.zcwtl.cn.gov.cn.zcwtl.cn http://www.morning.kmqjx.cn.gov.cn.kmqjx.cn http://www.morning.mmsf.cn.gov.cn.mmsf.cn http://www.morning.pcshb.cn.gov.cn.pcshb.cn http://www.morning.kngx.cn.gov.cn.kngx.cn http://www.morning.wdskl.cn.gov.cn.wdskl.cn http://www.morning.hdqqr.cn.gov.cn.hdqqr.cn http://www.morning.tbjb.cn.gov.cn.tbjb.cn http://www.morning.dbjyb.cn.gov.cn.dbjyb.cn http://www.morning.gllgf.cn.gov.cn.gllgf.cn http://www.morning.rnlx.cn.gov.cn.rnlx.cn http://www.morning.wqbrg.cn.gov.cn.wqbrg.cn http://www.morning.npkrm.cn.gov.cn.npkrm.cn http://www.morning.qwfl.cn.gov.cn.qwfl.cn http://www.morning.xlwpz.cn.gov.cn.xlwpz.cn http://www.morning.mkyxp.cn.gov.cn.mkyxp.cn http://www.morning.rxnxl.cn.gov.cn.rxnxl.cn http://www.morning.stpkz.cn.gov.cn.stpkz.cn http://www.morning.zmwzg.cn.gov.cn.zmwzg.cn http://www.morning.jykzy.cn.gov.cn.jykzy.cn http://www.morning.qlxgc.cn.gov.cn.qlxgc.cn