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.

218 lines
5.3 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"/>
  23. <el-table-column prop="name" label="姓名" align="center" header-align="center"/>
  24. <el-table-column prop="module_name" label="模块名称" align="center" header-align="center"/>
  25. <el-table-column prop="token_change_num" label="token数量" align="center" header-align="center"/>
  26. <el-table-column prop="created_at" label="操作时间" align="center" header-align="center" sortable="custom"/>
  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. onMounted(() => {
  59. targetId.value = route.query.dccode;
  60. logTableData(targetId.value)
  61. });
  62. // 获取路由实例
  63. const route = useRoute();
  64. const router = useRouter();
  65. // 全局账号
  66. const targetId = ref('');
  67. // 排序参数
  68. const sortProp = ref(null);
  69. const sortOrder = ref(null);
  70. // 表格数据
  71. const tableData = ref([]);
  72. const tableLoading = ref(false);
  73. const datatotal = ref(0);
  74. // 分页参数
  75. const currentPage = ref(1);
  76. const pageSize = ref(10);
  77. // 获取表格数据
  78. const logTableData = async (dccode) => {
  79. try {
  80. tableLoading.value = true;
  81. const requestParams = {
  82. token: token,
  83. dccode: dccode,
  84. type: 2,
  85. sort_field: sortProp.value,
  86. sort_order: sortOrder.value,
  87. page: currentPage.value,
  88. page_size: pageSize.value
  89. };
  90. const data = await logMListApi(requestParams);
  91. tableData.value = data.list
  92. datatotal.value = data.total
  93. } catch (error) {
  94. console.error('获取表格数据失败:', error);
  95. tableData.value = [];
  96. datatotal.value = 0;
  97. } finally {
  98. tableLoading.value = false;
  99. }
  100. };
  101. // 返回按钮
  102. const goback = () => {
  103. router.push({
  104. path: "/userPermissions/module",
  105. query: { taber: "DeepMate" }
  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. sortProp.value = prop;
  123. sortOrder.value = order;
  124. logTableData(targetId.value);
  125. };
  126. </script>
  127. <style scoped>
  128. /* 父容器 */
  129. .page-container {
  130. position: relative;
  131. min-height: 600px;
  132. }
  133. /* 按钮组 */
  134. .button-group {
  135. display: flex;
  136. align-items: center;
  137. gap: 10px;
  138. margin-bottom: 20px;
  139. }
  140. /* 按钮样式 */
  141. .button-group .el-button {
  142. padding: 6px 10px !important;
  143. font-size: 14px !important;
  144. height: 36px !important;
  145. }
  146. /* 表格样式 */
  147. .table-rounded {
  148. border-radius: 12px !important;
  149. overflow: hidden !important;
  150. border: 1px solid #e4e7ed !important;
  151. min-height: 800px;
  152. }
  153. .table-header {
  154. text-align: center !important;
  155. font-weight: 800 !important;
  156. font-size: 15px !important;
  157. color: #333 !important;
  158. background-color: #f8f9fa !important;
  159. }
  160. .el-table__cell {
  161. border-right: none !important;
  162. border-bottom: 1px solid #e4e7ed !important;
  163. }
  164. .el-table__header th.el-table__cell {
  165. border-right: none !important;
  166. border-bottom: 1px solid #e4e7ed !important;
  167. }
  168. .el-table__row:hover .el-table__cell {
  169. background-color: #fafafa !important;
  170. }
  171. /* 备注 */
  172. .note-ellipsis {
  173. display: inline-block;
  174. width: 100%;
  175. white-space: nowrap;
  176. overflow: hidden;
  177. text-overflow: ellipsis;
  178. padding: 0 4px;
  179. }
  180. /* 分页组件 */
  181. .demo-pagination-block {
  182. display: flex;
  183. width: 100%;
  184. height: 44px;
  185. padding: 0 16px;
  186. align-items: center;
  187. gap: 16px;
  188. margin-top: 10px;
  189. border-radius: 0 0 3px 3px;
  190. border-top: 1px solid #EAEAEA;
  191. background: #FEFBFB;
  192. box-sizing: border-box;
  193. }
  194. </style>