index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <script setup lang="ts">
  2. import dayjs from 'dayjs'
  3. import { useTable } from '@/hooks/web/useTable'
  4. import { allSchemas } from './operatelog.data'
  5. import { DICT_TYPE } from '@/utils/dict'
  6. import { useI18n } from '@/hooks/web/useI18n'
  7. import type { OperateLogVO } from '@/api/system/operatelog/types'
  8. import * as OperateLogApi from '@/api/system/operatelog'
  9. import { ref } from 'vue'
  10. const { t } = useI18n() // 国际化
  11. // ========== 列表相关 ==========
  12. const { register, tableObject, methods } = useTable<OperateLogVO>({
  13. getListApi: OperateLogApi.getOperateLogPageApi,
  14. exportListApi: OperateLogApi.exportOperateLogApi
  15. })
  16. // ========== 详情相关 ==========
  17. const detailRef = ref() // 详情 Ref
  18. const dialogVisible = ref(false) // 是否显示弹出层
  19. const dialogTitle = ref(t('action.detail')) // 弹出层标题
  20. const { getList, setSearchParams, exportList } = methods
  21. // 导出操作
  22. const handleExport = async () => {
  23. await exportList('操作日志.xls')
  24. }
  25. // 详情
  26. const handleDetail = (row: OperateLogVO) => {
  27. // 设置数据
  28. detailRef.value = row
  29. dialogVisible.value = true
  30. }
  31. getList()
  32. </script>
  33. <template>
  34. <ContentWrap>
  35. <Search :schema="allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />
  36. </ContentWrap>
  37. <ContentWrap>
  38. <!-- 操作工具栏 -->
  39. <div class="mb-10px">
  40. <el-button
  41. type="warning"
  42. v-hasPermi="['system:operate-log:export']"
  43. :loading="tableObject.exportLoading"
  44. @click="handleExport"
  45. >
  46. <Icon icon="ep:download" class="mr-5px" /> {{ t('action.export') }}
  47. </el-button>
  48. </div>
  49. <Table
  50. :columns="allSchemas.tableColumns"
  51. :selection="false"
  52. :data="tableObject.tableList"
  53. :loading="tableObject.loading"
  54. :pagination="{
  55. total: tableObject.total
  56. }"
  57. v-model:pageSize="tableObject.pageSize"
  58. v-model:currentPage="tableObject.currentPage"
  59. @register="register"
  60. >
  61. <template #type="{ row }">
  62. <DictTag :type="DICT_TYPE.SYSTEM_OPERATE_TYPE" :value="row.type" />
  63. </template>
  64. <template #duration="{ row }">
  65. <span>{{ row.duration + 'ms' }}</span>
  66. </template>
  67. <template #resultCode="{ row }">
  68. <span>{{ row.resultCode === 0 ? '成功' : '失败' }}</span>
  69. </template>
  70. <template #startTime="{ row }">
  71. <span>{{ dayjs(row.startTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
  72. </template>
  73. <template #action="{ row }">
  74. <el-button link type="primary" @click="handleDetail(row)">
  75. <Icon icon="ep:view" class="mr-1px" /> {{ t('action.detail') }}
  76. </el-button>
  77. </template>
  78. </Table>
  79. </ContentWrap>
  80. <Dialog v-model="dialogVisible" :title="dialogTitle">
  81. <!-- 对话框(详情) -->
  82. <Descriptions :schema="allSchemas.detailSchema" :data="detailRef">
  83. <template #resultCode="{ row }">
  84. <span>{{ row.resultCode === 0 ? '成功' : '失败' }}</span>
  85. </template>
  86. <template #type="{ row }">
  87. <DictTag :type="DICT_TYPE.SYSTEM_OPERATE_TYPE" :value="row.type" />
  88. </template>
  89. <template #duration="{ row }">
  90. <span>{{ row.duration + 'ms' }}</span>
  91. </template>
  92. <template #startTime="{ row }">
  93. <span>{{ dayjs(row.startTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
  94. </template>
  95. </Descriptions>
  96. <!-- 操作按钮 -->
  97. <template #footer>
  98. <el-button @click="dialogVisible = false">{{ t('dialog.close') }}</el-button>
  99. </template>
  100. </Dialog>
  101. </template>