From ccc3ea689499643e78988190e1e4fff844a66eb5 Mon Sep 17 00:00:00 2001 From: thinkgem Date: Mon, 22 Jul 2024 15:39:33 +0800 Subject: [PATCH] open beetl functions menu --- .../resources/views/functions/menu/tree.html | 116 ++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 modules/core/src/main/resources/views/functions/menu/tree.html diff --git a/modules/core/src/main/resources/views/functions/menu/tree.html b/modules/core/src/main/resources/views/functions/menu/tree.html new file mode 100644 index 00000000..43b0ec3b --- /dev/null +++ b/modules/core/src/main/resources/views/functions/menu/tree.html @@ -0,0 +1,116 @@ +<%/* Copyright (c) 2013-Now http://jeesite.com All rights reserved. + * No deletion without permission, or be held responsible to law. */ + +/** + * 侧边栏菜单 + * @author ThinkGem + * @version 2017-3-5 + */ +var p = para0; p.html = ''; +p.loadType = p.loadType!'2'; +p.parentCode = p.parentCode!'0'; +p.paddingLeft = p.paddingLeft!14; +p.paddingInitLeft = p.paddingInitLeft!(@Global.getConfig('sys.index.menuStyle', '1') == '2' ? 0 : p.paddingLeft); +if (p.loadType == '1'){ + p.menuList = @UserUtils.getMenuListByParentCode(p.parentCode); +}else if (p.loadType == '2'){ + if (p.children!false){ + p.menuList = p.childList![]; + }else{ + if (p.children!true){ + if (p.parentCode == '0'){ + p.parentCode = '0,'; + }else{ + p.parentCode = '0,' + p.parentCode + ','; + } + } + p.menuList = @UserUtils.getMenuTreeByParentCode(p.parentCode); + } +} +for (var menu in p.menuList![]){ + if ((p.loadType == '2' || p.parentCode == menu.parentCode) + && menu.isMenu && menu.isShow == @Global.YES){ + var attrs = ' ', style = '', menuIcon; + if (isBlank(menu.menuTarget)){ + attrs = attrs + 'href="javascript:" data-'; + } + if (isNotBlank(menu.menuUrl)){ + var href = menu.menuUrl; + if (@StringUtils.startsWith(href, "///")){ + href = @StringUtils.substring(href, 2); + } else if (@StringUtils.startsWith(href, "//")){ + href = @Global.getCtxPath() + @StringUtils.substring(href, 1); + } else if (@StringUtils.startsWith(href, "/")){ + href = @Global.getCtxPath() + @Global.getAdminPath() + href; + } + attrs = attrs + 'href="' + href + '"'; + }else{ + attrs = attrs + 'href="blank"'; + } + if (isNotBlank(menu.menuTarget)){ + attrs = attrs + ' target="' + menu.menuTarget + '"'; + } + if (isBlank(menu.menuTarget)){ + attrs = attrs + ' class="addTabPage"'; + } + if (isNotBlank(menu.menuColor)){ + style = style + 'color:' + menu.menuColor + ';'; + } + if (menu.treeLevel > 1) { + style = style + 'padding-left:' + (toInteger(menu.treeLevel) * p.paddingLeft + p.paddingInitLeft) + 'px;'; + } + if (style != '') { + attrs = attrs + ' style="' + style + '"'; + } + if (isNotBlank(menu.menuTitle)){ + attrs = attrs + ' title="' + menu.menuTitle + '"'; + }else{ + attrs = attrs + ' title="' + menu.menuName + '"'; + } + attrs = attrs + ' data-code="' + menu.menuCode + '"'; + if (isNotBlank(menu.menuIcon)){ + if (@StringUtils.contains(menu.menuIcon, '://')){ + menuIcon = ''; + }else if (@StringUtils.startsWith(menu.menuIcon, '/')){ + menuIcon = ''; + }else{ + menuIcon = ''; + } + }else{ + menuIcon = ''; + } + var h = { +%> +
  • <% + %>${menuIcon} ${menu.menuName}<% + // 输出子节点(递归调用) + var p2 = null; + if (p.loadType == '1'){ + p2 = {loadType: '1', children: !menu.isTreeLeaf, parentCode: menu.menuCode, + paddingLeft: p.paddingLeft, paddingInitLeft: p.paddingInitLeft}; + }else if (p.loadType == '2'){ + p2 = {loadType: '2', children: isNotBlank(menu.childList), childList: menu.childList, + paddingLeft: p.paddingLeft, paddingInitLeft: p.paddingInitLeft}; + } + if (p2 != null && p2.children && p.children!true){ + menu.tree(p2); + if (isNotBlank(p2.html)){ + %> + <% + } + } + %><% + if (isNotBlank(p2.html)){ + %>
      + + <% print(p2.html); + %>
    <% + } +%>
  • + +<% + }; + p.html = p.html + h; + } +} +%> \ No newline at end of file