三级菜单生成成功,但有问题。。。
生成的菜单脚本脚本如下:
<divtitle="数据中心" iconCls="folder"><ul><li><divtitle="地址管理"iconCls="pictures"> <span class="icon pictures" > </span> <span class="nav" >地址管理</span><ul><li><divtitle="测试三级菜单" url="demoController.do?demoIframe" iconCls="back"> <a class="测试三级菜单" href="#" > <span class="icon back" > </span> <span class="nav" >测试三级菜单</span></a></div></li></ul></div></li></ul></div><divtitle="统计查询" iconCls="folder"><ul><li><divtitle="用户分析"iconCls="pencil"onclick="addTab('用户分析','logController.do?statisticTabs','pencil')"url="logController.do?statisticTabs"> <a class="用户分析" href="#" > <span class="icon pencil" > </span> <span class="nav" >用户分析</span></a></div></li></ul></div><divtitle="系统管理" iconCls="group_add"><ul><li><divtitle="用户管理"iconCls="pictures"onclick="addTab('用户管理','userController.do?user','pictures')"url="userController.do?user"> <a class="用户管理" href="#" > <span class="icon pictures" > </span> <span class="nav" >用户管理</span></a></div></li><li><divtitle="角色管理"iconCls="pictures"onclick="addTab('角色管理','roleController.do?role','pictures')"url="roleController.do?role"> <a class="角色管理" href="#" > <span class="icon pictures" > </span> <span class="nav" >角色管理</span></a></div></li><li><divtitle="菜单管理"iconCls="pictures"onclick="addTab('菜单管理','functionController.do?function','pictures')"url="functionController.do?function"> <a class="菜单管理" href="#" > <span class="icon pictures" > </span> <span class="nav" >菜单管理</span></a></div></li><li><divtitle="图标管理"iconCls="pictures"onclick="addTab('图标管理','iconController.do?icon','pictures')"url="iconController.do?icon"> <a class="图标管理" href="#" > <span class="icon pictures" > </span> <span class="nav" >图标管理</span></a></div></li><li><divtitle="部门管理"iconCls="pictures"onclick="addTab('部门管理','departController.do?depart','pictures')"url="departController.do?depart"> <a class="部门管理" href="#" > <span class="icon pictures" > </span> <span class="nav" >部门管理</span></a></div></li></ul></div><divtitle="常用插件" iconCls="pictures"><ul><li><divtitle="表单验证"iconCls="pictures"onclick="addTab('表单验证','demoController.do?formTabs','pictures')"url="demoController.do?formTabs"> <a class="表单验证" href="#" > <span class="icon pictures" > </span> <span class="nav" >表单验证</span></a></div></li><li><divtitle="上传下载"iconCls="pictures"onclick="addTab('上传下载','demoController.do?uploadTabs','pictures')"url="demoController.do?uploadTabs"> <a class="上传下载" href="#" > <span class="icon pictures" > </span> <span class="nav" >上传下载</span></a></div></li><li><divtitle="开发DEMO"iconCls="pictures"onclick="addTab('开发DEMO','haivenceDemoController.do?haivenceDemo','pictures')"url="haivenceDemoController.do?haivenceDemo"> <a class="开发DEMO" href="#" > <span class="icon pictures" > </span> <span class="nav" >开发DEMO</span></a></div></li><li><divtitle="DEMO维护"iconCls="pictures"onclick="addTab('DEMO维护','demoController.do?demoList','pictures')"url="demoController.do?demoList"> <a class="DEMO维护" href="#" > <span class="icon pictures" > </span> <span class="nav" >DEMO维护</span></a></div></li><li><divtitle="DEMO分类"iconCls="pictures"onclick="addTab('DEMO分类','demoController.do?demoIframe','pictures')"url="demoController.do?demoIframe"> <a class="DEMO分类" href="#" > <span class="icon pictures" > </span> <span class="nav" >DEMO分类</span></a></div></li><li><divtitle="单表模型"iconCls="pictures"onclick="addTab('单表模型','haivenceNoteController.do?haivenceNote','pictures')"url="haivenceNoteController.do?haivenceNote"> <a class="单表模型" href="#" > <span class="icon pictures" > </span> <span class="nav" >单表模型</span></a></div></li><li><divtitle="一对多实例"iconCls="pictures"onclick="addTab('一对多实例','haivenceOrderMainController.do?haivenceOrderMain','pictures')"url="haivenceOrderMainController.do?haivenceOrderMain"> <a class="一对多实例" href="#" > <span class="icon pictures" > </span> <span class="nav" >一对多实例</span></a></div></li><li><divtitle="Excel导出列表"iconCls="pictures"onclick="addTab('Excel导出列表','jpPersonController.do?jpPerson','pictures')"url="jpPersonController.do?jpPerson"> <a class="Excel导出列表" href="#" > <span class="icon pictures" > </span> <span class="nav" >Excel导出列表</span></a></div></li><li><divtitle="Excel导入"iconCls="pictures"onclick="addTab('Excel导入','jpPersonController.do?goImplXls','pictures')"url="jpPersonController.do?goImplXls"> <a class="Excel导入" href="#" > <span class="icon pictures" > </span> <span class="nav" >Excel导入</span></a></div></li></ul></div><divtitle="系统监控" iconCls="pictures"><ul><li><divtitle="数据监控"iconCls="pencil"onclick="addTab('数据监控','dataSourceController.do?goDruid&isiframe','pencil')"url="dataSourceController.do?goDruid&isiframe"> <a class="数据监控" href="#" > <span class="icon pencil" > </span> <span class="nav" >数据监控</span></a></div></li><li><divtitle="系统日志"iconCls="pictures"onclick="addTab('系统日志','logController.do?log','pictures')"url="logController.do?log"> <a class="系统日志" href="#" > <span class="icon pictures" > </span> <span class="nav" >系统日志</span></a></div></li></ul></div>
有3级的2级菜单,点击后,会出现进度条,且一直不消失,谁能帮忙解决一下?
目前系统默认只支持二级菜单 解决了,已扩展到三级:lol hi,能否截图一张,我看看3及菜单的图片? 上边的脚本拿下来就是三级菜单,效果见附件 westlake 发表于 2013-5-20 17:30 static/image/common/back.gif
上边的脚本拿下来就是三级菜单,效果见附件
分享一下吧 呵呵,还不完善,想加上手风琴组件,把3级菜单收起来,
/**
* 菜单跳转
*
* @return
*/
@RequestMapping(params = "left")
public ModelAndView left(HttpServletRequest request) {
TSUser user = ResourceUtil.getSessionUserName();
String roles = "";
// 登陆者的权限
Set<TSFunction> loginActionlist = new HashSet<TSFunction>();// 已有权限菜单
//update-begin--Author:chenxuDate:20130322 for:左侧菜单信息放入到session中
List<TSRoleUser> rUsers = systemService.findByProperty(TSRoleUser.class, "TSUser.id", user.getId());
for (TSRoleUser ru : rUsers) {
TSRole role = ru.getTSRole();
roles += role.getRoleName() + ",";
List<TSRoleFunction> roleFunctionList = ResourceUtil.getSessionTSRoleFunction(role.getId());
if (roleFunctionList == null) {
HttpSession session = ContextHolderUtils.getSession();
session.setMaxInactiveInterval(60 * 30);
roleFunctionList = systemService.findByProperty(TSRoleFunction.class, "TSRole.id", role.getId());
session.setAttribute(role.getId(), roleFunctionList);
}
for (TSRoleFunction roleFunction : roleFunctionList) {
TSFunction function = (TSFunction) roleFunction.getTSFunction();
loginActionlist.add(function);
}
}
//update-end--Author:chenxuDate:20130322 for:左侧菜单信息放入到session中
List<TSFunction> bigActionlist = new ArrayList<TSFunction>();// 一级权限菜单
List<TSFunction> smailActionlist = new ArrayList<TSFunction>();// 二级权限菜单
List<TSFunction> smailActionlist1 = new ArrayList<TSFunction>();// 三级权限菜单
if (loginActionlist.size() > 0) {
for (TSFunction function : loginActionlist) {
//System.out.println("function.getFunctionLevel()===="+function.getFunctionLevel());
if (function.getFunctionLevel() == 0) {
bigActionlist.add(function);
} else if (function.getFunctionLevel() == 1) {
smailActionlist.add(function);
}else if (function.getFunctionLevel() == 2) {
smailActionlist1.add(function);
}
}
}
// 菜单栏排序
Collections.sort(bigActionlist, new NumberComparator());
Collections.sort(smailActionlist, new NumberComparator());
Collections.sort(smailActionlist1, new NumberComparator());
String logString = ListtoMenu.getEasyuiMenu(bigActionlist, smailActionlist,smailActionlist1);
//String logString1 =ListtoMenu.getEasyuiMenu(smailActionlist, smailActionlist1);
request.setAttribute("loginMenu", logString);
//request.setAttribute("loginMenu1", logString1);
request.setAttribute("parentFun", bigActionlist);
request.setAttribute("roleName", roles);
request.setAttribute("userName", user.getRealName());
request.setAttribute("childFun", smailActionlist);
request.setAttribute("childFun1", smailActionlist1);
request.setAttribute("userName", user.getRealName());
List<TSConfig> configs = userService.loadAll(TSConfig.class);
for (TSConfig tsConfig : configs) {
request.setAttribute(tsConfig.getCode(), tsConfig.getContents());
}
return new ModelAndView("main/left");
}
/**
* 拼装EASYUI菜单 3级 菜单扩展
* @param pFunctions 一级菜单
* @param functions 二级菜单
* @param functions1 三级菜单
* @return
*/
public static String getEasyuiMenu(List<TSFunction> pFunctions, List<TSFunction> functions, List<TSFunction> functions1) {
StringBuffer menuString=new StringBuffer();
for (TSFunction pFunction : pFunctions) {
menuString.append("<divtitle=\""+pFunction.getFunctionName()+"\" iconCls=\""+pFunction.getTSIcon().getIconClas()+"\">");
int submenusize=pFunction.getTSFunctions().size();//一级菜单数量
if(submenusize==0)
{
menuString.append("</div>");
}
if(submenusize>0)
{
menuString.append("<ul>");
}
for (TSFunction function : functions) {
if(function.getTSFunction().getId().equals(pFunction.getId()))//有二级菜单
{
String icon="folder";
if(function.getTSIcon()!=null)
{
icon=function.getTSIcon().getIconClas();
}
//menuString.append("<li><div> <a class=\""+function.getFunctionName()+"\" iconCls=\""+icon+"\" target=\"tabiframe\"href=\""+function.getFunctionUrl()+"\"> <span class=\"icon "+icon+"\" > </span> <span class=\"nav\">"+function.getFunctionName()+"</span></a></div></li>");
if(function.getTSFunctions().size()>0)//有三级子菜单
{
menuString.append("<li><div> <a class=\""+function.getFunctionName()+"\" href=\"#\" > <span class=\"icon "+icon+"\" > </span> <span class=\"nav\" >"+function.getFunctionName()+"</span></a>");//增加二级菜单标签
menuString.append("<ul>");//三级菜单开始
for(TSFunction function2 : function.getTSFunctions())//循环列出二级菜单的三级子菜单
{
String icon1="folder";
if(function2.getTSIcon()!=null)//有新设置的图标
{
icon1=function2.getTSIcon().getIconClas();
}
menuString.append("<li><div onclick=\"addTab(\'"+function2.getFunctionName()+"\',\'"+function2.getFunctionUrl()+"\',\'"+icon1+"\')\"title=\""+function2.getFunctionName()+"\" url=\""+function2.getFunctionUrl()+"\" iconCls=\""+icon1+"\"> <a class=\""+function2.getFunctionName()+"\" href=\"#\" > <span class=\"icon "+icon1+"\" > </span> <span class=\"nav\" >"+function2.getFunctionName()+"</span></a></div></li>");
}
menuString.append("</ul>");//三级菜单结束
menuString.append("</div></li>");//二级菜单结束
}
else//没有三级子菜单
{ //显示二级菜单
menuString.append("<li><divtitle=\""+function.getFunctionName()+"\"iconCls=\""+icon+"\"onclick=\"addTab(\'"+function.getFunctionName()+"\',\'"+function.getFunctionUrl()+"\',\'"+icon+"\')\"url=\""+function.getFunctionUrl()+"\"> <a class=\""+function.getFunctionName()+"\" href=\"#\" > <span class=\"icon "+icon+"\" > </span> <span class=\"nav\" >"+function.getFunctionName()+"</span></a></div></li>");
}
}
}
if(submenusize>0)
{
menuString.append("</ul></div>");
}
}
return menuString.toString();
} westlake 发表于 2013-5-21 15:25 static/image/common/back.gif
呵呵,还不完善,想加上手风琴组件,把3级菜单收起来,
/**
求分享啊 代码不全,鉴定完毕! 完善后的效果,加了折叠效果
页:
[1]
2