<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ page isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<c:forEach var="item" items="${treeList}" varStatus="vs">
    <c:set var="index" value="${index + 1}" scope="request" /><!-- 每一次循环，index+1 -->
    <tr class="treegrid-${item.id} ${item.parentid == null ? "" : "treegrid-parent-"}${item.parentid == null ? "" : item.parentid}">
        <td>${item.rolename}</td>
        <td>${item.rolecode}</td>
        <td><fmt:formatDate value="${item.addtiime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
        <td class="btn-table hidden-print">
            <input type="hidden" name="id" value="${item.id}" />
            <button name="btnEdit" class="btn btn-sm btn-primary m-r-sm"><i class="fa fa-edit"></i>编辑</button>
            <button name="btnAuth" class="btn btn-sm btn-warning m-r-sm"><i class="fa fa-thumbs-o-up"></i>授权</button>
            <button name="btnDelete" class="btn btn-sm btn-danger"><i class="fa fa-trash-o"></i>删除</button>
        </td>
    </tr>
    <c:if test="${fn:length(item.children) > 0}"><!-- 如果有childen -->
        <c:set var="level" value="${level + 1}" scope="request" /><!-- 循环一次子列表，level+1 -->
        <c:set var="treeList" value="${item.children}" scope="request" /><!-- 注意此处，子列表覆盖list，在request作用域 -->
        <c:import url="recursive.jsp" /><!-- 递归import自身 -->
    </c:if>
</c:forEach>
<c:set var="level" value="${level - 1}" scope="request" /><!-- 退出时，level-1 -->