<%@ page import="com.lightinit.hsdataplatformresdir.dictionary.DicUserAccountLockType" %>
<%@ 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>状态</th>
            <th>创建时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <c:choose>
            <c:when test="${list!=null}">
                <c:forEach items="${list}" var="item">
                    <tr>
                        <td>
                            <a href="#" onclick="adminView(${item.id})">${item.username}</a>
                        </td>
                        <td>${item.showname}</td>
                        <td>${item.salt}</td>
                        <td>
                            <c:if test="${item.accountlock==1}">
                                <%=DicUserAccountLockType.LOCKING%>
                            </c:if>
                            <c:if test="${item.accountlock!=1}">
                                <%=DicUserAccountLockType.NORMAL%>
                            </c:if>
                        </td>
                        <td>
                            <fmt:formatDate value="${item.createdAt}" pattern="yyyy-MM-dd"/>
                        </td>
                        <td>
                            <button  class="btn btn-sm btn-primary m-r-sm" onclick="editButton(${item.id})"><i class="fa fa-edit"></i>编辑</button>
                            <button name="btnAddRole" class="btn btn-sm btn-warning m-r-sm" onclick="addRoleClick(${item.id})"><i class="fa fa-thumbs-o-up"></i>角色授权</button>
                            <button  class="btn btn-sm btn-danger" onclick="deleteButton(${item.id})"><i class="fa fa-trash-o"></i>删除</button>
                        </td>
                    </tr>
                </c:forEach>
            </c:when>
            <c:otherwise>
                <tr>
                    <td colspan="4">无数据</td>
                </tr>
            </c:otherwise>
        </c:choose>
        </tbody>
    </table>
</div>
<jsp:include page="../../../common/admin/pager.jsp">
    <jsp:param name="pageNo" value="${pager.pageNo}"/>
    <jsp:param name="pageSize" value="${pager.pageSize}"/>
    <jsp:param name="total" value="${pager.total}"/>
</jsp:include>
<script type="text/javascript">
    function editButton(id) {
        $.popBsPartial({ url: "<%=basePath%>/admin/user/edit.htm/"+id});
    }

    function addRoleClick(id) {
        $.popBsPartial({ url: "<%=basePath%>/admin/user/add_role.htm/" + id});
    }

    function deleteButton(id) {
        $.delWithConfirm({ func: $.ajaxGetRefresh, funcArgs: { ajaxGetOptions: { url: "<%=basePath%>/admin/user/delete.action/" + id } } });
    }
    function adminView(id) {
        $.popBsPartial({ url: "<%=basePath%>/admin/user/view.htm/"+id});
    }
</script>