deepchart后台管理系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

223 lines
5.5 KiB

  1. <template>
  2. <div class="page-container">
  3. <!-- 头部 -->
  4. <div class="button-group">
  5. <el-button type="danger" @click="goback">返回上一页</el-button>
  6. </div>
  7. <!-- 数据表格 -->
  8. <el-table
  9. :data="tableData"
  10. style="width: 100%; margin-top: 20px;"
  11. header-cell-class-name="table-header"
  12. @sort-change="handleSortChange"
  13. :default-sort="{ prop: null, order: null }"
  14. class="table-rounded"
  15. :loading="tableLoading"
  16. >
  17. <el-table-column prop="id" label="序号" align="center" header-align="center" width="80">
  18. <template #default="scope">
  19. {{ (currentPage - 1) * pageSize + scope.$index + 1 }}
  20. </template>
  21. </el-table-column>
  22. <el-table-column prop="dccode" label="账号" align="center" header-align="center" width="120"/>
  23. <el-table-column prop="name" label="姓名" align="center" header-align="center" width="150"/>
  24. <el-table-column prop="module_name" label="模块名称" align="center" header-align="center" width="100"/>
  25. <el-table-column prop="created_at" label="操作时间" align="center" header-align="center" sortable="custom" width="200"/>
  26. <el-table-column prop="expire_time" label="到期时间" align="center" header-align="center" sortable="custom" width="200"/>
  27. <el-table-column prop="remark" label="备注" align="center" header-align="center">
  28. <template #default="scope">
  29. <el-tooltip :content="scope.row.remark" placement="top">
  30. <span class="note-ellipsis">
  31. {{ scope.row.remark }}
  32. </span>
  33. </el-tooltip>
  34. </template>
  35. </el-table-column>
  36. </el-table>
  37. <!-- 分页组件 -->
  38. <div class="demo-pagination-block">
  39. <el-pagination
  40. @size-change="handleSizeChange"
  41. @current-change="handleCurrentChange"
  42. :current-page="currentPage"
  43. :page-sizes="[10, 20, 50, 100]"
  44. :page-size="pageSize"
  45. layout="total, sizes, prev, pager, next, jumper"
  46. :total="datatotal"
  47. />
  48. </div>
  49. </div>
  50. </template>
  51. <script setup>
  52. import { ref, onMounted } from 'vue';
  53. import { logMListApi } from '../../api/userPermissions'
  54. import { useRoute, useRouter } from 'vue-router';
  55. // token
  56. const token = localStorage.getItem('token')
  57. //获取路由实例
  58. const route = useRoute();
  59. const router = useRouter();
  60. // 全局账号
  61. const targetId = ref('');
  62. // 排序参数
  63. const sortProp = ref(null);
  64. const sortOrder = ref(null);
  65. // 表格数据
  66. const tableData = ref([]);
  67. const tableLoading = ref(false);
  68. const datatotal = ref(0);
  69. // 分页参数
  70. const currentPage = ref(1);
  71. const pageSize = ref(10);
  72. // 获取表格数据
  73. const logTableData = async (dccode) => {
  74. try {
  75. tableLoading.value = true;
  76. const requestParams = {
  77. token: token,
  78. dccode: dccode,
  79. type: 3,
  80. sort_field: sortProp.value,
  81. sort_order: sortOrder.value,
  82. page: currentPage.value,
  83. page_size: pageSize.value
  84. };
  85. const data = await logMListApi(requestParams);
  86. tableData.value = data.list
  87. datatotal.value = data.total
  88. } catch (error) {
  89. console.error('获取表格数据失败:', error);
  90. tableData.value = [];
  91. datatotal.value = 0;
  92. } finally {
  93. tableLoading.value = false;
  94. }
  95. };
  96. // 组件挂载时
  97. onMounted(() => {
  98. targetId.value = route.query.dccode;
  99. logTableData(targetId.value)
  100. });
  101. // 返回按钮
  102. const goback = () => {
  103. router.push({
  104. path: "/userPermissions/module",
  105. query: { taber: "DeepExplore" }
  106. });
  107. };
  108. // 分页方法
  109. const handleSizeChange = (val) => {
  110. pageSize.value = val;
  111. logTableData(targetId.value);
  112. console.log(`每页 ${val}`);
  113. };
  114. const handleCurrentChange = (val) => {
  115. currentPage.value = val;
  116. logTableData(targetId.value);
  117. console.log(`当前页: ${val}`);
  118. };
  119. // 排序事件
  120. const handleSortChange = (sort) => {
  121. const { prop, order } = sort;
  122. if (!['created_at', 'expire_time'].includes(prop)) return;
  123. // 覆盖排序状态(实现二选一)
  124. sortProp.value = prop; // 保存当前排序字段
  125. sortOrder.value = order; // 保存当前排序方式
  126. logTableData(targetId.value);
  127. };
  128. </script>
  129. <style scoped>
  130. /* 父容器 */
  131. .page-container {
  132. position: relative;
  133. min-height: 600px;
  134. }
  135. /* 按钮组 */
  136. .button-group {
  137. display: flex;
  138. align-items: center;
  139. gap: 10px;
  140. margin-bottom: 20px;
  141. }
  142. /* 按钮样式 */
  143. .button-group .el-button {
  144. padding: 6px 10px !important;
  145. font-size: 14px !important;
  146. height: 36px !important;
  147. }
  148. /* 表格样式 */
  149. .table-rounded {
  150. border-radius: 12px !important;
  151. overflow: hidden !important;
  152. border: 1px solid #e4e7ed !important;
  153. min-height: 800px;
  154. }
  155. .table-header {
  156. text-align: center !important;
  157. font-weight: 800 !important;
  158. font-size: 15px !important;
  159. color: #333 !important;
  160. background-color: #f8f9fa !important;
  161. }
  162. .el-table__cell {
  163. border-right: none !important;
  164. border-bottom: 1px solid #e4e7ed !important;
  165. }
  166. .el-table__header th.el-table__cell {
  167. border-right: none !important;
  168. border-bottom: 1px solid #e4e7ed !important;
  169. }
  170. .el-table__row:hover .el-table__cell {
  171. background-color: #fafafa !important;
  172. }
  173. /* 备注 */
  174. .note-ellipsis {
  175. display: inline-block;
  176. width: 100%;
  177. white-space: nowrap;
  178. overflow: hidden;
  179. text-overflow: ellipsis;
  180. padding: 0 4px;
  181. }
  182. /* 分页组件 */
  183. .demo-pagination-block {
  184. display: flex;
  185. width: 100%;
  186. height: 44px;
  187. padding: 0 16px;
  188. align-items: center;
  189. gap: 16px;
  190. margin-top: 10px;
  191. border-radius: 0 0 3px 3px;
  192. border-top: 1px solid #EAEAEA;
  193. background: #FEFBFB;
  194. box-sizing: border-box;
  195. }
  196. </style>