operationLog.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <div class="operation-log-container">
  3. <!-- 返回按钮和标题 -->
  4. <div class="header-section">
  5. <el-button :icon="ArrowLeft" @click="handleBack"> 返回 </el-button>
  6. </div>
  7. <!-- 标签页 -->
  8. <el-tabs v-model="activeTab" @tab-change="handleTabChange" class="operation-tabs">
  9. <el-tab-pane label="账号操作记录" name="ACCOUNT" />
  10. <el-tab-pane label="角色操作记录" name="ROLE" />
  11. </el-tabs>
  12. <!-- 表格 -->
  13. <ProTable
  14. ref="proTable"
  15. :columns="columns"
  16. :request-api="getTableList"
  17. :init-param="initParam"
  18. :data-callback="dataCallback"
  19. row-key="id"
  20. :pagination="true"
  21. />
  22. </div>
  23. </template>
  24. <script setup lang="tsx" name="operationLog">
  25. import { ref, reactive, computed, watch } from "vue";
  26. import { useRouter } from "vue-router";
  27. import { ArrowLeft } from "@element-plus/icons-vue";
  28. import ProTable from "@/components/ProTable/index.vue";
  29. import { ColumnProps, ProTableInstance } from "@/components/ProTable/interface";
  30. import { operationLog, type OperationLogItem } from "@/api/modules/accountRoleManagement";
  31. // 路由
  32. const router = useRouter();
  33. // ProTable 实例
  34. const proTable = ref<ProTableInstance>();
  35. // 当前激活的标签页
  36. const activeTab = ref<"ACCOUNT" | "ROLE">("ACCOUNT");
  37. // 初始化参数
  38. const initParam = reactive({
  39. page: 1,
  40. size: 10,
  41. module: activeTab.value
  42. });
  43. // 数据回调处理
  44. const dataCallback = (data: any) => {
  45. // 如果返回的是分页对象
  46. if (data.records) {
  47. return {
  48. list: data.records || [],
  49. total: data.total || 0
  50. };
  51. }
  52. // 默认返回
  53. return {
  54. list: [],
  55. total: 0
  56. };
  57. };
  58. // 请求接口
  59. const getTableList = (params: any) => {
  60. return operationLog({
  61. page: params.pageNum || params.page || 1,
  62. size: params.pageSize || params.size || 10,
  63. account: params.account || "",
  64. endTime: params.endTime || "",
  65. module: activeTab.value,
  66. startTime: params.startTime || ""
  67. });
  68. };
  69. // 表格列配置
  70. const columns = reactive<ColumnProps<OperationLogItem>[]>([
  71. {
  72. prop: "operationType",
  73. label: "操作记录",
  74. minWidth: 150
  75. },
  76. {
  77. prop: "operationTime",
  78. label: "操作时间",
  79. minWidth: 180
  80. },
  81. {
  82. prop: "operatorAccount",
  83. label: "操作账号",
  84. minWidth: 150,
  85. render: (scope: { row: OperationLogItem }) => {
  86. return scope.row.operatorAccount || "--";
  87. }
  88. },
  89. {
  90. prop: "operationContent",
  91. label: "操作记录详情",
  92. minWidth: 300
  93. }
  94. ]);
  95. // 标签页切换
  96. const handleTabChange = (tabName: string) => {
  97. activeTab.value = tabName as "ACCOUNT" | "ROLE";
  98. // 更新初始化参数
  99. initParam.module = activeTab.value;
  100. // 刷新表格
  101. proTable.value?.reset();
  102. proTable.value?.getTableList();
  103. };
  104. // 返回
  105. const handleBack = () => {
  106. router.back();
  107. };
  108. // 监听标签页变化,更新初始化参数
  109. watch(
  110. () => activeTab.value,
  111. newTab => {
  112. initParam.module = newTab;
  113. }
  114. );
  115. </script>
  116. <style lang="scss" scoped>
  117. .operation-log-container {
  118. min-height: calc(100vh - 84px);
  119. padding: 20px;
  120. background: #ffffff;
  121. }
  122. .header-section {
  123. display: flex;
  124. gap: 16px;
  125. align-items: center;
  126. margin-bottom: 20px;
  127. .page-title {
  128. margin: 0;
  129. font-size: 20px;
  130. font-weight: 500;
  131. color: var(--el-text-color-primary);
  132. }
  133. }
  134. .operation-tabs {
  135. margin-bottom: 20px;
  136. :deep(.el-tabs__header) {
  137. margin-bottom: 0;
  138. }
  139. :deep(.el-tabs__item.is-active) {
  140. font-weight: 500;
  141. color: var(--el-color-primary);
  142. }
  143. :deep(.el-tabs__active-bar) {
  144. background-color: var(--el-color-primary);
  145. }
  146. }
  147. </style>