admin_list.html 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>绑定列表</title>
  6. <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
  7. </head>
  8. <body class="p-3">
  9. <div class="container">
  10. <h1>绑定列表</h1>
  11. <table class="table table-bordered">
  12. <thead>
  13. <tr>
  14. <th>ID</th>
  15. <th>UUID</th>
  16. <th>简历ID</th>
  17. <th>状态</th>
  18. <th>创建时间</th>
  19. <th>绑定时间</th>
  20. <th>操作人</th>
  21. <th>操作</th>
  22. </tr>
  23. </thead>
  24. <tbody>
  25. {{range .Bindings}}
  26. <tr>
  27. <td>{{.ID}}</td>
  28. <td>{{.UUID}}</td>
  29. <td>{{.ResumeID}}</td>
  30. <td>{{.Status}}</td>
  31. <td>{{.CreatedAt}}</td>
  32. <td>{{.BoundAt}}</td>
  33. <td>{{.Operator}}</td>
  34. <td>
  35. <form class="unbindForm" method="post" action="/admin/unbind">
  36. <input type="hidden" name="id" value="{{.ID}}">
  37. <input type="hidden" name="resume_id" value="{{.ResumeID}}">
  38. <button type="submit" class="btn btn-danger btn-sm">解绑</button>
  39. </form>
  40. </td>
  41. </tr>
  42. {{end}}
  43. </tbody>
  44. </table>
  45. <!-- 分页导航 start -->
  46. <nav aria-label="Page navigation">
  47. <ul class="pagination">
  48. <!-- 上一页 -->
  49. <li class="page-item {{if eq .CurrPage 1}}disabled{{end}}">
  50. <a class="page-link" href="/admin/list?page={{dec .CurrPage}}" aria-label="Previous">
  51. <span aria-hidden="true">&laquo;</span>
  52. </a>
  53. </li>
  54. {{/* 使用自定义模板函数 dec 和 inc 来计算当前页的前后页码 */}}
  55. {{range $i := seq 1 .TotalPage}}
  56. <li class="page-item {{if eq $.CurrPage $i}}active{{end}}">
  57. <a class="page-link" href="/admin/list?page={{$i}}">{{$i}}</a>
  58. </li>
  59. {{end}}
  60. <!-- 下一页 -->
  61. <li class="page-item {{if eq .CurrPage .TotalPage}}disabled{{end}}">
  62. <a class="page-link" href="/admin/list?page={{inc .CurrPage}}" aria-label="Next">
  63. <span aria-hidden="true">&raquo;</span>
  64. </a>
  65. </li>
  66. </ul>
  67. </nav>
  68. <!-- 分页导航 end -->
  69. <a href="/admin/search" class="btn btn-secondary">返回搜索页</a>
  70. </div>
  71. <script>
  72. document.querySelectorAll('.unbindForm').forEach(form => {
  73. form.addEventListener('submit', function(e) {
  74. e.preventDefault();
  75. if(confirm("确定解绑吗?")) {
  76. var formData = new FormData(this);
  77. fetch("/admin/unbind", {
  78. method: "POST",
  79. body: formData
  80. })
  81. .then(response => response.json())
  82. .then(data => {
  83. if(data.error) {
  84. alert(data.error);
  85. } else {
  86. alert(data.message);
  87. location.reload();
  88. }
  89. })
  90. .catch(err => {
  91. console.error(err);
  92. });
  93. }
  94. });
  95. });
  96. </script>
  97. </body>
  98. </html>