<div class="panel-content">
    <div class="panel-title fluid">
        <div class="title-main">
            <% for (let menu of userMenu) { %>
            <% if (menu.title === secondMenu[action].title) { %>
            <%= menu.title %>
            <% } else { %>
            <a href="<%= menu.url %>" class="btn btn-primary btn-link" style="margin-left: 0;margin-right: 12px"><%= menu.title %></a>
            <% } %>
            <% } %>
            <a href="#news-add" data-toggle="modal" data-target="#news-add" class="btn btn-primary btn-sm pull-right">添加用户</a></h2>
            <a href="javascript:void(0)" id="add-allCldUser" class="btn btn-warning btn-sm pull-right">一键增加所有CLD员工用户</a></h2>
        </div>
    </div>
    <div class="content-wrap">
        <div class="c-header">
            <form class="form-inline" method="get" action="" id="searchUser">
                <!--结果-->
                <div class="btn-group">
                    &nbsp;共 <%= total %> 条结果
                </div>
                <!--搜索-->
                <div class="btn-group">
                    <div class="input-group">
                        <input type="text" name="keyword" class="form-control input-sm" value="<%= filter.keyword === undefined ? '' : filter.keyword %>" placeholder="手机/邮箱/姓名/公司">
                        <span class="input-group-btn">
                        <button class="btn btn-default btn-sm" type="submit">
                            <i class="glyphicon glyphicon-search"></i>
                        </button>
                    </span>
                    </div>
                </div>
            </form>
        </div>
        <div class="c-body">
            <table class="table">
                <thead>
                <tr>
                    <th width="350">注册手机/QQ</th>
                    <th>姓名</th>
                    <th>企业名称</th>
                    <th>最近使用 </th>
                    <th width="180">最近登录</th>
                    <th>详细</th>
                </tr>
                </thead>
                <tbody>
                <% userList.forEach(function (user){ %>
                <tr>
                    <td><%= user.mobile %><br><%= user.qq %></td>
                    <td><%= user.real_name %></td>
                    <td><%= user.company %></td>
                    <td><%= compilationMap[user.latest_used]?compilationMap[user.latest_used].name:""%></td>
                    <td><%= user.latest_login?moment(user.latest_login).tz("Asia/Shanghai").format('YYYY-MM-DD HH:mm:ss'):"" %></td>
                    <td><a role="button" data-toggle="modal" data-target="#view" onclick='getUserInfo("<%= user._id.toString()%>")'>详细</a></td>
                </tr>
                <% }) %>
                </tbody>
            </table>
            <nav aria-label="Page navigation">
                <%include ../layout/page.html %>
            </nav>
        </div>
    </div>
</div>


<!-- 弹窗查看用户详情-->
<div class="modal fade" id="view" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" >用户信息</h4>
            </div>
            <div class="modal-body">
                <table class="table table-bordered">
                    <tbody id="userInfoTable">
                    </tbody>
                </table>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-danger" id="remove-cldUser" data-uid="">移除该账号</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>

<!-- 弹窗添加-->
<div class="modal fade" id="news-add" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" >添加剔除用户</h4>
            </div>
            <div class="modal-body">
                <form class="input-group" method="get" action="/user/search" onsubmit="searchUser(); return false;" style="margin-bottom:10px">
                    <input class="form-control input-sm" placeholder="手机/邮箱/姓名" type="text" name="keyword" id="search_keyword">
                    <span class="input-group-btn">
			        <button class="btn btn-default btn-sm" type="submit"><i class="glyphicon glyphicon-search"></i></button>
			      </span>
                </form>
                <table class="table table-sm table-bordered">
                    <tr><th>姓名</th><th>邮箱</th><th>手机</th><th>添加</th></tr>
                    <tbody id="search_user_list">
                    </tbody>
                </table>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    let compilationList = JSON.parse('<%- compilationString %>');
    let adminName = '<%- adminName %>';
</script>
<script type="text/javascript" src="/web/users/js/user.js"></script>
