<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/9/11
  Time: 12:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    Vector v_list = null;
    try {
        conn = com.censoft.db.DBUtil.getConnection();
        StringBuffer sb = new StringBuffer();
        sb.append(" select distinct menu.* from t_book_role_menu_rel rel  ");
        sb.append(" join t_book_role role on role.id=rel.role_id ");
        sb.append(" join t_book_user_role_rel ur on ur.role_id=role.id ");
        sb.append(" join  zb_bgs_user ad on ad.id=ur.login_id ");
        sb.append(" join t_book_menu menu on menu.id=rel.menu_id ");
        sb.append(" where ad.id=?  and (menu.p_id ='' or menu.p_id is null) and (menu.sys_id='3' or menu.sys_id is null or menu.sys_id ='')  order by menu.menu_order asc");
        //System.out.println(sb.toString());
        v_list = cf.doQuery(conn, sb.toString(), null, new Object[]{s_id});
        if("admin".equals(s_id)){
           // sb = new StringBuffer("select * from t_book_menu menu where  (menu.p_id ='' or menu.p_id is null) order by  menu_order asc");
           // v_list = cf.doQuery(conn, sb.toString(), null, new Object[]{});
        }
        if (v_list == null) {
            out.println("查询角色出错");
            return;
        }
    } catch (Exception e) {
        out.println("查询角色信息异常" + e);
        return;
    } finally {
        if (conn != null) {
            try {
                conn.close();
            } catch (Exception e) {
            }
        }
    }
%>
<aside class="Hui-aside">
    <div class="menu_dropdown bk_2">
        <%
			String  menu_ids = "";
            if (v_list != null && v_list.size() > 0) {
                for (int i = 0; i < v_list.size(); i++) {
                    Hashtable ht = (Hashtable) v_list.get(i);
                    String menu_name = pub.trimNull((String) ht.get("menu_name"));
                    String menu_url = pub.trimNull((String) ht.get("menu_url"));
                    String id = pub.trimNull((String) ht.get("id"));
					menu_ids+=id+",";
                    if (!"#".equals(menu_url)) {
                        if (menu_url.indexOf("?") > 0) {
                            menu_url += "&menu_id=" + id;
                        } else {
                            menu_url += "?menu_id=" + id;
                        }
                    }
                    String menu_pic = pub.trimNull((String) ht.get("menu_pic"))+";";
                    if ("".equals(menu_pic)) menu_pic = "&#xe620;";
        %>
        <dl id="menu-<%=id%>">
            <%if (!"#".equals(menu_url)) {%>
            <dt style="font-size: 18px;"><i class="Hui-iconfont"><%=menu_pic%></i>
                <a data-href="<%=menu_url%>" data-title="<%=menu_name%>" href="javascript:void(0)"><%=menu_name%>
                </a>
            </dt>
            <%} else {%>
            <dt style="font-size: 18px;" onclick="getChildMenu('<%=id%>');"><i class="Hui-iconfont"><%=menu_pic%></i> <%=menu_name%><i class="Hui-iconfont menu_dropdown-arrow">&#xe6d5;</i></dt>
            <dd id="menu-child-<%=id%>">
            </dd>
            <%}%>
        </dl>
        <%
                }
            }
			session.setAttribute("menu_ids",menu_ids);
        %>

    </div>


</aside>
<script>
    function getChildMenu(id) {
        $.ajax({
            type: "post",
            url: "leftMenu_child_bgs.jsp?menu_id=" + id,
            success: function (msg) {
                $("#menu-child-" + id).html(msg);
            }
        });
    }
</script>