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.

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