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.

222 lines
5.5 KiB

2 months ago
2 months ago
2 months ago
  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="90"/>
  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: 1,
  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/market"
  105. });
  106. };
  107. // 分页方法
  108. const handleSizeChange = (val) => {
  109. pageSize.value = val;
  110. logTableData(targetId.value);
  111. console.log(`每页 ${val}`);
  112. };
  113. const handleCurrentChange = (val) => {
  114. currentPage.value = val;
  115. logTableData(targetId.value);
  116. console.log(`当前页: ${val}`);
  117. };
  118. // 排序事件
  119. const handleSortChange = (sort) => {
  120. const { prop, order } = sort;
  121. if (!['created_at', 'expire_time'].includes(prop)) return;
  122. // 覆盖排序状态(实现二选一)
  123. sortProp.value = prop; // 保存当前排序字段
  124. sortOrder.value = order; // 保存当前排序方式
  125. logTableData(targetId.value);
  126. };
  127. </script>
  128. <style scoped>
  129. /* 父容器 */
  130. .page-container {
  131. position: relative;
  132. min-height: 600px;
  133. }
  134. /* 按钮组 */
  135. .button-group {
  136. display: flex;
  137. align-items: center;
  138. gap: 10px;
  139. margin-bottom: 20px;
  140. }
  141. /* 按钮样式 */
  142. .button-group .el-button {
  143. padding: 6px 10px !important;
  144. font-size: 14px !important;
  145. height: 36px !important;
  146. }
  147. /* 表格样式 */
  148. .table-rounded {
  149. border-radius: 12px !important;
  150. overflow: hidden !important;
  151. border: 1px solid #e4e7ed !important;
  152. min-height: 800px;
  153. }
  154. .table-header {
  155. text-align: center !important;
  156. font-weight: 800 !important;
  157. font-size: 15px !important;
  158. color: #333 !important;
  159. background-color: #f8f9fa !important;
  160. }
  161. .el-table__cell {
  162. border-right: none !important;
  163. border-bottom: 1px solid #e4e7ed !important;
  164. }
  165. .el-table__header th.el-table__cell {
  166. border-right: none !important;
  167. border-bottom: 1px solid #e4e7ed !important;
  168. }
  169. .el-table__row:hover .el-table__cell {
  170. background-color: #fafafa !important;
  171. }
  172. /* 备注 */
  173. .note-ellipsis {
  174. display: inline-block;
  175. width: 100%;
  176. white-space: nowrap;
  177. overflow: hidden;
  178. text-overflow: ellipsis;
  179. padding: 0 4px;
  180. }
  181. /* 分页组件 */
  182. .demo-pagination-block {
  183. display: flex;
  184. width: 100%;
  185. height: 44px;
  186. padding: 0 16px;
  187. align-items: center;
  188. gap: 16px;
  189. margin-top: 10px;
  190. border-radius: 0 0 3px 3px;
  191. border-top: 1px solid #EAEAEA;
  192. background: #FEFBFB;
  193. box-sizing: border-box;
  194. }
  195. </style>