articleDelete.html 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>违规文章删除</title>
  7. <!-- 引入 Bootstrap 样式 -->
  8. <link href="https://gcore.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
  9. <script src="https://gcore.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
  10. </head>
  11. <style>
  12. /* 限制内容显示为省略号 */
  13. .ellipsis-container {
  14. position: relative;
  15. display: inline-block;
  16. max-width: 500px;
  17. }
  18. .text-ellipsis {
  19. display: inline-block;
  20. max-width: 200px;
  21. white-space: nowrap;
  22. overflow: hidden;
  23. text-overflow: ellipsis;
  24. }
  25. /* 悬浮显示完整内容 */
  26. .tooltip-content {
  27. display: none; /* 初始隐藏 */
  28. position: absolute;
  29. left: 0;
  30. top: 100%;
  31. z-index: 10;
  32. background-color: #fff;
  33. border: 1px solid #ddd;
  34. padding: 5px;
  35. box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
  36. white-space: normal;
  37. max-width: 500px;
  38. word-wrap: break-word;
  39. color: #000; /* 防止文字颜色被继承 */
  40. }
  41. .ellipsis-container:hover .tooltip-content {
  42. display: block; /* 悬停时显示完整内容 */
  43. }
  44. </style>
  45. <body>
  46. <div class="container mt-5">
  47. <!-- 查询部分 -->
  48. <div class="card">
  49. <div class="card-header bg-primary text-white">
  50. <h5>查询数据</h5>
  51. </div>
  52. <div class="card-body">
  53. <div class="row g-3 align-items-center">
  54. <div class="col-md-2">
  55. <label for="titleInput" class="form-label">标题</label>
  56. </div>
  57. <div class="col-md-8">
  58. <input type="text" class="form-control" id="titleInput" placeholder="请输入标题">
  59. </div>
  60. <div class="col-md-2">
  61. <button class="btn btn-success w-100" onclick="queryData(1)">查询</button>
  62. </div>
  63. </div>
  64. </div>
  65. </div>
  66. <!-- 数据展示表格 -->
  67. <div class="card mt-4">
  68. <div class="card-header bg-secondary text-white">
  69. <h5>数据列表</h5>
  70. </div>
  71. <div class="table-responsive">
  72. <table class="table table-bordered table-hover">
  73. <thead class="table-light">
  74. <tr>
  75. <th style="width: 10%; white-space: nowrap;">发布日期</th>
  76. <th style="width: 20%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">标题</th>
  77. <th style="width: 10%; white-space: nowrap;">账号名称</th>
  78. <th style="width: 17%; white-space: nowrap;">账号来源</th>
  79. <th style="width: 10%; white-space: nowrap;">操作计划类型</th>
  80. <th style="width: 5%; white-space: nowrap;">位置</th>
  81. <th style="width: 18%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">链接</th>
  82. <th style="width: 10%; white-space: nowrap;">操作</th>
  83. </tr>
  84. </thead>
  85. <tbody id="dataTableBody">
  86. <!-- 动态数据填充 -->
  87. </tbody>
  88. </table>
  89. <!-- 分页控件 -->
  90. <nav aria-label="Page navigation">
  91. <ul class="pagination justify-content-center" id="pagination">
  92. <!-- 分页按钮将在这里生成 -->
  93. </ul>
  94. </nav>
  95. </div>
  96. </div>
  97. </div>
  98. <!-- JavaScript 脚本 -->
  99. <script>
  100. let currentPage = 1; // 当前页码
  101. const pageSize = 50; // 每页显示的数据条数
  102. window.onload = function () {
  103. queryData(currentPage); // 页面加载后自动执行查询,查询第一页数据
  104. };
  105. // 查询数据:调用后端接口,支持分页
  106. function queryData(page) {
  107. currentPage = page; // 更新当前页码
  108. const title = document.getElementById('titleInput').value;
  109. // 调用后端查询接口
  110. fetch(`/articleAudit/articleDeleteList`, {
  111. method: 'POST',
  112. headers: {
  113. 'Content-Type': 'application/json',
  114. 'Access-Control-Allow-Origin': '*'
  115. },
  116. body: JSON.stringify({title: title, pageNum: currentPage, pageSize: pageSize})
  117. })
  118. .then(response => response.json())
  119. .then(data => {
  120. console.log('查询结果:', data);
  121. populateTable(data.data.objs); // 渲染数据表格
  122. totalPage = Math.ceil(data.data.totalSize / pageSize);
  123. renderPagination(totalPage); // 渲染分页控件
  124. })
  125. .catch(error => {
  126. console.error('查询失败:', error);
  127. alert('查询失败,请检查接口连接!');
  128. });
  129. }
  130. // 渲染数据到表格
  131. function populateTable(data) {
  132. const tableBody = document.getElementById('dataTableBody');
  133. tableBody.innerHTML = ''; // 清空旧数据
  134. data.forEach(item => {
  135. const row = `
  136. <tr>
  137. <td>${item.dateStr}</td>
  138. <td>
  139. <div class="ellipsis-container">
  140. <span class="text-ellipsis">${item.title}</span>
  141. <div class="tooltip-content">${item.title}</div>
  142. </div>
  143. </td>
  144. <td>${item.accountName}</td>
  145. <td>${item.accountSourceType}</td>
  146. <td>${item.planType}</td>
  147. <td>${item.index}</td>
  148. <td>
  149. <div class="ellipsis-container">
  150. <a href="${item.link}" target="_blank" rel="noopener noreferrer" class="text-ellipsis">${item.link}</a>
  151. <div class="tooltip-content">${item.link}</div>
  152. </div>
  153. </td>
  154. <td>
  155. <button class="btn btn-primary btn-sm text-nowrap" onclick="submitData('${item.title}')">标记违规</button>
  156. </td>
  157. </tr>
  158. `;
  159. tableBody.insertAdjacentHTML('beforeend', row);
  160. });
  161. }
  162. // 渲染分页控件
  163. function renderPagination(totalPages) {
  164. const pagination = document.getElementById('pagination');
  165. pagination.innerHTML = ''; // 清空旧分页
  166. const maxVisiblePages = 5; // 最多显示的页码按钮数量
  167. let startPage = Math.max(1, currentPage - Math.floor(maxVisiblePages / 2));
  168. let endPage = Math.min(totalPages, startPage + maxVisiblePages - 1);
  169. // 上一页按钮
  170. pagination.insertAdjacentHTML('beforeend', `
  171. <li class="page-item ${currentPage === 1 ? 'disabled' : ''}">
  172. <a class="page-link" href="#" onclick="queryData(${currentPage - 1})">上一页</a>
  173. </li>
  174. `);
  175. // 显示前面的省略号(如果有的话)
  176. if (startPage > 1) {
  177. pagination.insertAdjacentHTML('beforeend', `
  178. <li class="page-item">
  179. <a class="page-link" href="#" onclick="queryData(1)">1</a>
  180. </li>
  181. <li class="page-item disabled">
  182. <span class="page-link">...</span>
  183. </li>
  184. `);
  185. }
  186. // 数字页码按钮
  187. for (let i = startPage; i <= endPage; i++) {
  188. pagination.insertAdjacentHTML('beforeend', `
  189. <li class="page-item ${currentPage === i ? 'active' : ''}">
  190. <a class="page-link" href="#" onclick="queryData(${i})">${i}</a>
  191. </li>
  192. `);
  193. }
  194. // 显示后面的省略号(如果有的话)
  195. if (endPage < totalPages) {
  196. pagination.insertAdjacentHTML('beforeend', `
  197. <li class="page-item disabled">
  198. <span class="page-link">...</span>
  199. </li>
  200. <li class="page-item">
  201. <a class="page-link" href="#" onclick="queryData(${totalPages})">${totalPages}</a>
  202. </li>
  203. `);
  204. }
  205. // 下一页按钮
  206. pagination.insertAdjacentHTML('beforeend', `
  207. <li class="page-item ${currentPage === totalPages ? 'disabled' : ''}">
  208. <a class="page-link" href="#" onclick="queryData(${currentPage + 1})">下一页</a>
  209. </li>
  210. `);
  211. }
  212. // 提交删除:调用后端接口
  213. function submitData(title) {
  214. // 调用后端更新接口
  215. fetch('/articleAudit/titleDangerFindDelete', { // 替换为实际接口
  216. method: 'POST',
  217. headers: {
  218. 'Content-Type': 'application/json',
  219. 'Access-Control-Allow-Origin': '*'
  220. },
  221. body: JSON.stringify({title: title})
  222. })
  223. .then(response => response.json())
  224. .then(data => {
  225. console.log('删除结果:', data);
  226. alert('删除成功!');
  227. })
  228. .catch(error => {
  229. console.error('删除失败:', error);
  230. alert('删除失败,请检查接口连接!');
  231. });
  232. }
  233. </script>
  234. </body>
  235. </html>