indexUser.html 4.9 KB
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <title>员工列表</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" type="image/x-icon" href="/power/img/favicon.ico">
    <!-- 引入 Bootstrap -->
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">

</head>
<body>
<div class="container">
    <div class="row clearfix">
        <div class="col-md-12 column">
            <div class="page-header">
                <h1>
                    欢迎 <span th:if="${session.user!=null}" th:text="${session.user.userName}"></span>
                </h1>
                <div><a th:href="@{/user/logout}">退出登录</a></div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-md-4 column">
            <a class="btn btn-primary" th:href="@{/user/addUser}">添加员工</a>
<!--            <a class="btn btn-primary" th:href="@{/employee/queryAllEmployees}">显示全部员工</a>-->
        </div>
        <div class="col-md-4 column"></div>
        <div class="col-md-4 column">

            <form class="form-inline" th:action="@{/user/page}" method="post" style="float: right">
            <span style="color:red;font-weight: bold">
            </span>
                <input type="text" name="searchName" class="form-control" th:value="${searchName}"
                       placeholder="登录名/姓名/手机号">
                <input type="submit" value="查询" class="btn btn-primary">
            </form>
        </div>

    </div>

    <div class="row clearfix">
        <div class="col-md-12 column">
            <table class="table table-hover table-striped">
                <thead>
                <tr>
                    <th>登录名</th>
                    <th>姓名</th>
                    <th>手机号</th>
                    <th>头像</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>

                <tr th:each="user,state:${list}">
                    <td><span th:text="${user.loginName}"></span></td>
                    <td><span th:text="${user.userName}"></span></td>
                    <td><span th:text="${user.mobile}"></span></td>
<!--                    <td><img th:src="@{/photo/}+${user.photo}" width="30px"></td>-->
                    <!--                    <td><span th:text="${#dates.format(emp.birthday,'yyyy-MM-dd')}"></span></td>-->
                    <td>
                        <a th:if="${(session != null && session.user != null) && (user.userName == session.user.userName || session.user.loginName == 'admin')}" th:href="@{/user/toUpdateUser/} + ${user.userId}">编辑</a>
                        <a th:if="${user.loginName != 'admin' && (session != null && session.user != null) && session.user.loginName == 'admin'}" href="javascript:;" th:onclick="confirmDelete([[${user.userId}]])"> | 删除</a>
                        <a th:if="${(session != null && session.user != null) && (user.userName == session.user.userName || session.user.loginName == 'admin')}" th:href="@{/user/toUpdatePasswd/} + ${user.userId}"> | 修改密码</a>
                        <a th:if="${(session != null && session.user != null) && (user.userName == session.user.userName || session.user.loginName == 'admin')}" href="javascript:;" th:onclick="resertPasswd([[${user.userId}]])"> | 重置密码</a>
                    </td>
                </tr>
                </c:forEach>
                <script>
                    function confirmDelete(userId) {
                        // alert(userId);
                        if (window.confirm("确定要删除该人员吗?")) {
                            location.href = "[[@{/user/deleteUser/}]]" + userId;
                        }
                    }

                    function resertPasswd(userId) {
                        // alert(userId);
                        if (window.confirm("确定要重置密码吗?重置后密码为\"hczd\"")) {
                            location.href = "[[@{/user/resertPasswd/}]]" + userId;
                            alert("重置成功");
                        }
                    }
                </script>
                </tbody>
            </table>
            <p>
                <a th:href="@{page(pageNo=1, searchName=${searchName})}">首页&nbsp;&nbsp;</a>
                <a th:if="${current} != 1" th:href="@{page(pageNo=${current}-1, searchName=${searchName})}">上一页&nbsp;&nbsp;</a>
                <a th:if="${current} != ${pages}" th:href="@{page(pageNo=${current}+1, searchName=${searchName})}">下一页&nbsp;&nbsp;</a>
                <a th:href="@{page(pageNo=${pages}, searchName=${searchName})}">末页&nbsp;&nbsp;</a>
<span th:text="${current}"></span>&nbsp;&nbsp;
                总数:<span th:text="${total}"></span>
            </p>
        </div>
    </div>
</div>
</body>
</html>