问题1:左侧菜单栏数据是在哪里获取的?

答案1:

项目根目录的Views/Home/Index文件为平台首页

打开Index.cshtml文件,有一个framework-clientdata.js引入此页面

打开framework-clientdata.js文件,有一个ajax请求,该请求时"获取客户端数据",该"获取客户端数据"返回值有authorizeMenu和authorizeButton,并将返回值返回到Index页面(clients)

打开ClientsDataController/GetClientsDataJson()方法,果然是获取菜单和按钮的(具体的获取就不再细说)

问题2:DoMes平台在创建菜单页面上设置,若是父节点则value值是0,但保存时又将ParentId由0改为了null,这样的结果是修改菜单时无法回显"父节点",如何让它回显父节点?

答案2:

分析:要想在修改时回显父节点,只需要保存的时候保存为0即可,不要转换为null值保存,那么问题是保存了ParentId为0,如何让所获取菜单的地方正确显示的?

1.打开Form修改页面,查看ParentId下拉框的数据源是/SystemManage/Module/GetTreeSelectJson

2.查看/SystemManage/Module/GetTreeSelectJson方法,此方法最主要的地方是treeList.TreeSelectJson()

3.查看treeList.TreeSelectJson(),此方法有两处之前均为null值(花圈处),全部改为字符串0

至此,修改页面的上级下拉框的值就可以正常获取并显示ParentId值为0的数据了

问题3:虽然修改页面正确显示了,但是菜单管理页面并没有正确显示ParentId为0的,而依旧是显示ParentId为null的数据,怎么做?

答案3:

1.打开系统菜单Index页面,找到获取数据的路径/SystemManage/Module/GetTreeGridJson

2.打开此路径/SystemManage/Module/GetTreeGridJson,此方法最主要的地方是treeList.TreeGridJson()

3.打开treeList.TreeGridJson()方法,此方法有一处给ParentId赋值null,并依据此值判断查询,将此处的Null值改为字符串0

至此,系统菜单页面可以正常获取ParentId为0的数据并显示了

问题4:更改完以上内容后,刷新项目,发现左侧菜单一个也不显示了?怎么回事?

答案4:首先回到答案1的结尾,继续跟踪是如何获取菜单内容的

1.进入GetMenuList()方法内,此方法最主要的还是this.ToMenuJson(menuList, "0");语句,将此方法的第二个参数null改为字符串0,因为ToMenuJson(List<Sys_Module> data, string parentId)方法内有根据ParentId进行判断查询

2.进入GetMenuButtonList()方法,此方法并没有根据ParentId进行判断的地方也没有对返回值进行处理,没有需要更改的地方

3.更改完上述操作后再次刷新页面发现还是没有菜单数据!!!

4.接着分析发现:ClientsDataController/GetClientsDataJson()方法执行完仅仅是"<script src="~/Content/js/framework-clientdata.js"></script>"执行完,而Home/Index页面末尾还有几个js引入进来,其中有一个index.js文件

5.打开index.js文件,有一个GetLoadNav()方法,此方法正好是调用了framework-clientdata.js执行完返回的数据clients并进行循环判断,其中就有根据ParentId是否为Null的判断,将null改为字符串0

6.最后重新编译解决方案,并且清空浏览器的缓存,再次登陆项目,发现可以正确显示菜单了!!!

问题5:ParentId不存Null改为存储字符串0,会不会对角色授权部分有影响?

答案5:

1.打开新增修改角色权限的页面,找到数据源标签及数据访问地址/SystemManage/RoleAuthorize/GetPermissionTree?roleId=

2.打开此地址“/SystemManage/RoleAuthorize/GetPermissionTree?roleId=”对应的方法,此方法较长截图其中一部分,其余代码另行附上,其中最主要的还是返回值的处理上TreeHelper.ConvertToJson(treeList)

  /// <summary>
/// 根据角色Id获取已经授权的权限
/// </summary>
/// <param name="roleId">角色Id</param>
/// <returns></returns>
public ActionResult GetPermissionTree(string roleId)
{
var IsAdmin = this.CurrentSession.IsAdmin;
var LoginroleId = this.CurrentSession.RoleId;//值为NULL,何时不为NULL
//获取所有的菜单列表:64个菜单
List<Sys_Module> AllModuleList = this.CreateService<IRoleAuthorizeAppService>().GetMenuList(LoginroleId, IsAdmin);
//获取所有的按钮列表:150个按钮
List<Sys_ModuleButton> AllButtonList = (this.CreateService<IModuleButtonAppService>() as ModuleButtonAppService).GetModelList<Sys_ModuleButton>(null);
//获取角色Id为roleId,已配置权限的菜单权限列表
List<Sys_RoleAuthorize> Authorizedata = this.CreateService<IRoleAuthorizeAppService>().GetList(roleId);//该角色的按钮权限有11个
if (string.IsNullOrEmpty(roleId))
{
List<TreeViewModel> treeList = new List<TreeViewModel>();
foreach (Sys_Module module in AllModuleList)
{
TreeViewModel tree = new TreeViewModel();
bool hasChildren = AllModuleList.Any(a => a.ParentId == module.Id);
tree.Id = module.Id;
tree.Text = module.Name;
tree.Value = module.EnCode;
tree.ParentId = module.ParentId;
tree.Isexpand = true;
tree.Complete = true;
tree.Showcheck = true;
tree.Checkstate = AllButtonList.Count(t => t.ModuleId == module.Id);
tree.HasChildren = true;
tree.Img = module.Icon == "" ? "" : module.Icon;
treeList.Add(tree);
}
foreach (Sys_ModuleButton moduleButton in AllButtonList)
{
TreeViewModel tree = new TreeViewModel();
bool hasChildren = AllModuleList.Any(a => a.ParentId == moduleButton.Id);
tree.Id = moduleButton.Id;
tree.Text = moduleButton.FullName;
tree.Value = moduleButton.EnCode;
tree.ParentId = moduleButton.ModuleId;
tree.Isexpand = true;
tree.Complete = true;
tree.Showcheck = true;
tree.Checkstate = AllButtonList.Count(t => t.ModuleId == moduleButton.Id);
tree.HasChildren = hasChildren;
tree.Img = moduleButton.Icon == "" ? "" : moduleButton.Icon;
treeList.Add(tree);
}
return Content(TreeHelper.ConvertToJson(treeList));
}
else
{
List<TreeViewModel> treeList = new List<TreeViewModel>();
foreach (Sys_Module module in AllModuleList)
{
TreeViewModel tree = new TreeViewModel();
bool hasChildren = AllModuleList.Any(a => a.ParentId == module.Id);
tree.Id = module.Id;
tree.Text = module.Name;//显示内容
tree.Value = module.EnCode;
tree.ParentId = module.ParentId;
tree.Isexpand = true;
tree.Complete = true;
tree.Showcheck = true;
tree.Checkstate = Authorizedata.Count(t => t.ModuleId == module.Id);//复选框的状态应该有是否配置权限决定
tree.HasChildren = true;
tree.Img = module.Icon == "" ? "" : module.Icon;
treeList.Add(tree);
}
foreach (Sys_ModuleButton moduleButton in AllButtonList)
{
TreeViewModel tree = new TreeViewModel();
//bool hasChildren = AllModuleList.Any(a => a.ParentId == moduleButton.Id);
tree.Id = moduleButton.Id;
tree.Text = moduleButton.FullName;
tree.Value = moduleButton.EnCode;
tree.ParentId = moduleButton.ModuleId;
tree.Isexpand = true;
tree.Complete = true;
tree.Showcheck = true;
tree.Checkstate = Authorizedata.Count(t => t.ModuleId == moduleButton.Id);
//tree.HasChildren = hasChildren;
tree.Img = moduleButton.Icon == "" ? "" : moduleButton.Icon;
treeList.Add(tree);
}
return Content(TreeHelper.ConvertToJson(treeList,""));
} }

3.打开TreeHelper类,有三个ConvertToJson()方法,其中前两个是调用者的roleId为空时执行的,后面一个方法是调用者的roleId不为空时执行的,绿色圈起来的地方均是由null改为了字符串0

public static string ConvertToJson(this List<TreeViewModel> data, string parentId = "")
{
StringBuilder strJson = new StringBuilder();
List<TreeViewModel> item = data.FindAll(t => t.ParentId == parentId);
strJson.Append("[");
if (item.Count > )
{
foreach (TreeViewModel entity in item)
{
strJson.Append("{");
strJson.Append("\"id\":\"" + entity.Id + "\",");
strJson.Append("\"text\":\"" + entity.Text.Replace("&nbsp;", "") + "\",");
strJson.Append("\"value\":\"" + entity.Value + "\",");
if (entity.Title != null && !string.IsNullOrEmpty(entity.Title.Replace("&nbsp;", "")))
{
strJson.Append("\"title\":\"" + entity.Title.Replace("&nbsp;", "") + "\",");
}
if (entity.Img != null && !string.IsNullOrEmpty(entity.Img.Replace("&nbsp;", "")))
{
strJson.Append("\"img\":\"" + entity.Img.Replace("&nbsp;", "") + "\",");
}
if (entity.Checkstate != null)
{
strJson.Append("\"checkstate\":" + entity.Checkstate + ",");
}
if (entity.ParentId != null)
{
strJson.Append("\"parentnodes\":\"" + entity.ParentId + "\",");
}
strJson.Append("\"showcheck\":" + entity.Showcheck.ToString().ToLower() + ",");
strJson.Append("\"isexpand\":" + entity.Isexpand.ToString().ToLower() + ",");
if (entity.Complete == true)
{
strJson.Append("\"complete\":" + entity.Complete.ToString().ToLower() + ",");
}
strJson.Append("\"hasChildren\":" + entity.HasChildren.ToString().ToLower() + ",");
strJson.Append("\"ChildNodes\":" + ConvertToJson(data, entity.Id) + "");
strJson.Append("},");
}
strJson = strJson.Remove(strJson.Length - , );
}
strJson.Append("]");
return strJson.ToString();
}

4.至此角色权限的配置就可以正常使用了。

DoMes平台首页菜单栏的更多相关文章

  1. Jquery实现挂号平台首页源码2

    第二个版本:点击预约挂号可跳转到排班表,获取之后7个星期的排班 先放图 首先是index.html <!DOCTYPE html> <html lang="en" ...

  2. Jquery实现挂号平台首页源码

    带二级导航.轮播海报.二级联动.搜索功能.Tab选项卡 按照国际惯例先放图 index.html <!DOCTYPE html> <html lang="zh-cn&quo ...

  3. 挂号平台首页开发(UI组件部分)

    JQ插件模式开发UI组件 JQ插件开发方法: 1.$.extend() 扩展JQ(比较简单,功能略显不足) $.extend({ sayHello:function(){ console.log(&q ...

  4. PAAS平台的web应用性能测试与分析

    引言 为什么我会写这一篇博客,因为最近很多京东云擎jae的用户反应一个问题就是他们部署在jae上面的应用访问很慢,有极少数应用甚至经常出现504超时现象,当然大家首先想到的是jae性能太差,这也是人之 ...

  5. 2013年5月~2013年11月份(转接关于ns51服务平台项目)相关资料:

    <1> [平台首页] 界面截图:(网络游客所看到的界面首页) <2>[注册] 有需求则注册会员(略...) <3>[个人空间] 注册成功后进入个人空间(有深层次的需 ...

  6. 开源视频平台:MediaCore(MediaDrop)

    MediaCore 是一个多媒体的建站系统,主要的功能包括视频.音频.YouTube集成.播客和 iTunes RSS 生成,用户可以提交各种多媒体内容. <开源中国>网站上说它是一个开源 ...

  7. 基于SpringBoot+Mybatis+AntDesign快速开发平台,Jeecg-Boot 1.1 版本发布

    Jeecg-Boot 1.1 版本发布,初成长稳定版本 导读     平台首页UI升级,精美的首页支持多模式 提供4套代码生成器模板(支持单表.一对多) 集成Excel简易工具类,支持单表.一对多导入 ...

  8. Python爬虫实例(二)使用selenium抓取斗鱼直播平台数据

    程序说明:抓取斗鱼直播平台的直播房间号及其观众人数,最后统计出某一时刻的总直播人数和总观众人数. 过程分析: 一.进入斗鱼首页http://www.douyu.com/directory/all 进入 ...

  9. 【数据售卖平台】—— Vue2.0入门学习项目爬坑

    前言:这个项目是我从零学习Vue2.0时用于练习基础知识的入门项目,包含了Vue2.0几乎所有项目都会用到的基础功能,是新手用来练手的好项目,这里温故知新对功能点做一个总结.github地址:http ...

随机推荐

  1. Java面向对象封装优化1_this(Python中的self)

    1. 类 package cn.itcast.day06.demo03; /* 问题描述:定义Person的年龄时,无法阻止不合理的数值被设置进来. 解决方案:用private关键字将需要保护的成员变 ...

  2. 《JavaScript高级程序设计》读书笔记(五)引用类型

    内容---使用对象---创建并操作数组---理解基本的JavaScript类型---使用基本类型和基本包装类型 引用类型--引用类型的值(对象)是引用类型的一个实例--在ECMAScript中,引用类 ...

  3. 使用SQL计算宝宝每次吃奶的时间间隔(数据保障篇)

    目前程序从功能上其实已经完全满足客户(当然我这里的客户都是指媳妇儿^_^)需求,具体可参考: 使用SQL计算宝宝每次吃奶的时间间隔 使用SQL计算宝宝每次吃奶的时间间隔(续) 那么本篇 使用SQL计算 ...

  4. 操作系统OS - 阻塞(Blocking)非阻塞(Non-Blocking)与同步(Synchronous)异步(Asynchronous)

    参考: http://blog.jobbole.com/103290/ https://www.zhihu.com/question/19732473/answer/23434554 http://b ...

  5. linux(centos6.10)下去掉mysql的强密码验证

    vim /etc/my.cnf shift + G      光标移到最下方: o    进入插入模式,同时换行: 添加一行语句:  validate_password=OFF 保存退出. servi ...

  6. ApacheBench(ab)压力测试工具

    服务器负载太大而影响程序效率也是很常见的,Apache服务器自带有一个叫AB(ApacheBench)的工具,可以对服务器进行负载测试 基本用法: ab  -n 全部请求数 -c 并发数测试url 注 ...

  7. ZooKeeper 相关知识

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明.本文链接:https://blog.csdn.net/zhang123456456/articl ...

  8. Spring中@MapperScan注解

    之前是,直接在Mapper类上面添加注解@Mapper,这种方式要求每一个mapper类都需要添加此注解,麻烦. 通过使用@MapperScan可以指定要扫描的Mapper类的包的路径,比如: @Sp ...

  9. JDBC笔记一

    连接池原理 数据库连接池:1.提前创建好多个连接对象,放到缓存中(集合),客户端用时直接从缓存中获取连接 ,用完连接后一定要还回来. 目的:提高数据库访问效率.  模拟代码: package com. ...

  10. python 基础之文件读操作

    创建一个名为‘尘曦’的文件内容如下 Hadoop是一个由Apache基金会所开发的分布式系统基础架构. 用户可以在不了解分布式底层细节的情况下,开发分布式程序.充分利用集群的威力进行高速运算和存储. ...