<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ page isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
    String basePath = request.getContextPath();
%>
<div class="table-responsive">
    <table class="table table-striped table-bordered table-hover " >
        <thead>
        <tr>
            <th>角色名称</th>
            <th>角色代码</th>
            <th>创建时间</th>
            <th class="hidden-print">操 作</th>
        </tr>
        </thead>
        <tbody>
        <c:choose>
            <c:when test="${list!=null}">
                <c:set var="index" value="0" scope="request" /><!-- 自增序号，注意scope-->
                <c:set var="level" value="0" scope="request" /><!-- 记录树的层次，注意scope-->
                <c:set var="treeList" value="${list}" scope="request" />
                <c:import url="recursive.jsp" />
            </c:when>
            <c:otherwise>
                <tr>
                    <td colspan="4">无数据</td>
                </tr>
            </c:otherwise>
        </c:choose>
        </tbody>
    </table>
</div>
<script type="text/javascript">
    $("#divGrid table tbody tr td:last-child")
        .on("click", "button[name='btnEdit']", function () {
            var id = $(this).parent().children("input[type='hidden'][name='id']").val();
            $.popBsPartial({ url: "<%=basePath%>/admin/role_mgr/edit.htm/" + id });
        })
        .on("click", "button[name='btnAuth']", function() {
            var id = $(this).parent().children("input[type='hidden'][name='id']").val();
            $.popBsPartial({ url: "<%=basePath%>/admin/role_mgr/auth.htm/" + id });
        })
        .on("click", "button[name='btnDelete']", function() {
            var id = $(this).parent().children("input[type='hidden'][name='id']").val();
            $.delWithConfirm({ func: $.ajaxGetRefresh, funcArgs: { ajaxGetOptions: { url: "<%=basePath%>/admin/role_mgr/delete.action/" + id } } });
        });

    $('table').treegrid({
        expanderExpandedClass: 'glyphicon glyphicon-minus',
        expanderCollapsedClass: 'glyphicon glyphicon-plus'
    });
</script>