list-page.html

张创琦

  1. <!DOCTYPE html>
  2. <html lang="en" xmlns:th="http://www.thymeleaf.org">
  3. <head>
  4. <meta charset="UTF-8"/>
  5. <title>userList</title>
  6. <link rel="stylesheet" th:href="@{/css/bootstrap.css}"></link>
  7. <script type="text/javascript" th:src="@{/js/My97DatePicker/WdatePicker.js}"></script>
  8. <script type="text/javascript" src="/js/My97DatePicker/lang/zh-cn.js"></script>
  9. <script type="text/javascript" th:src="@{/js/jquery/jquery-1.10.2.min.js}"></script>
  10. </head>
  11. <body class="container">
  12. <br/>
  13. <h1>账单列表</h1>
  14. <br/><br/>
  15. <div class="with:80%">
  16. <form class="form-inline" id="qf" th:action="@{/bill/list-page}" method="post">
  17. <!-- TODO 分页相关参数-->
  18. <input type="hidden" name="pageNum" id="pageNum" th:value="${page.pageNum}"/>
  19. <input type="hidden" name="pageSize" id="pageSize" th:value="${page.pageSize}"/>
  20. <div class="form-group">
  21. <label for="typeId" class="control-label">类型</label>
  22. <select name="typeId" id="typeId" class="form-control">
  23. <option value="">全部</option>
  24. <option th:each="t:${types}" th:value="${t.id}" th:text="${t.name}" th:selected="(${bill.typeId} == ${t.id})"></option>
  25. </select>
  26. </div>
  27. <div class="form-group">
  28. <label for="date1" class="control-label" >开始时间</label>
  29. <input type="text" class="form-control" name="date1" id="date1" placeholder="开始时间" th:value="${bill.date1} ? ${#dates.format(bill.date1, 'yyyy-MM-dd')}" onclick="WdatePicker()"/>
  30. </div>
  31. <div class="form-group">
  32. <label for="date2" class="control-label">结束时间</label>
  33. <input type="text" class="form-control" name="date2" id="date2" placeholder="结束时间" th:value="${bill.date2} ? ${#dates.format(bill.date2, 'yyyy-MM-dd')}" onclick="WdatePicker()"/>
  34. </div>
  35. <div class="form-group">
  36. <input type="submit" value="查询" class="btn btn-info" />
  37. &nbsp; &nbsp;
  38. <input type="reset" value="重置" class="btn btn-info" />
  39. &nbsp; &nbsp;
  40. <a href="/bill/toAdd" th:href="@{/bill/toAdd}" class="btn btn-info">添加</a>
  41. </div>
  42. </form>
  43. </div>
  44. <br/>
  45. <div class="with:80%">
  46. <table class="table table-striped table-bordered">
  47. <thead>
  48. <tr>
  49. <th>#</th>
  50. <th>标题</th>
  51. <th>时间</th>
  52. <th>金额</th>
  53. <th>类别</th>
  54. <th>说明</th>
  55. <th>操作</th>
  56. </tr>
  57. </thead>
  58. <tbody>
  59. <!-- TODO 页面循环-->
  60. <tr th:each="b, bstatus : ${page.list}" th:style="${bstatus.odd} ? 'background-color: #A3C6C8'">
  61. <th scope="row" th:text="${bill.id}">id</th>
  62. <td th:text="${b.title}">name</td>
  63. <td th:text="${b.billTime} ? ${#dates.format(b.billTime, 'yyyy-MM-dd')}">time</td>
  64. <td th:text="${b.price}">price</td>
  65. <td th:text="${b.typeName}">typeName</td>
  66. <td th:text="${b.explain}">explain</td>
  67. <td>
  68. <a th:href="|/bill/toUpdate/${b.id}|">修改</a>
  69. <a th:href="|/bill/download/${b.id}|">下载</a>
  70. </td>
  71. </tr>
  72. </tbody>
  73. </table>
  74. </div>
  75. <!-- TODO 分页工具类-->
  76. <ul class="pagination">
  77. <li><button class="btn btn-default" id="first">第一页</button></li>
  78. <li><button class="btn btn-default" id="prev">上一页</button></li>
  79. <li th:each="p:${page.navigatepageNums}">
  80. <button class="btn btn-default" name="pn" th:text="${p}" th:disabled="(${p} == ${page.pageNum})"></button>
  81. </li>
  82. <li><button class="btn btn-default" id="next">下一页</button></li>
  83. <li><button class="btn btn-default" id="last">最后页</button></li>
  84. </ul>
  85. <!-- TODO 分页的js代码-->
  86. <script th:inline="javascript">
  87. /*<![CDATA[*/
  88. $(function(){
  89. //初始化变量
  90. var pageNum = [[${page.pageNum}]]; //当前页var pageCount = [[${page.pages}]];//最后页
  91. var hasNextPage = [[${page.hasNextPage}]];//还有下一页
  92. var hasPreviousPage = [[${page.hasPreviousPage}]];//还有上一页
  93. $("#next").click(function(){
  94. $("#pageNum").val(pageNum + 1);
  95. $("#qf").submit();
  96. });
  97. $("#prev").click(function(){
  98. $("#pageNum").val(pageNum - 1);
  99. $("#qf").submit();
  100. });
  101. $("#first").click(function(){
  102. $("#pageNum").val(1);
  103. $("#qf").submit();
  104. });
  105. $("#last").click(function(){
  106. $("#pageNum").val(pageCount);
  107. $("#qf").submit();
  108. });
  109. //没有上一页
  110. if (!hasPreviousPage) {
  111. $("#prev").prop("disabled", true);
  112. $("#first").prop("disabled", true);
  113. };
  114. //没有下一页
  115. if (!hasNextPage) {
  116. $("#next").prop("disabled", true);
  117. $("#last").prop("disabled", true);
  118. };
  119. $("button[name='pn']").click(function(){
  120. $("#pageNum").val($(this).html());
  121. $("#qf").submit();
  122. });
  123. });
  124. /*]]>*/
  125. </script>
  126. </body>
  127. </html>