index.vue 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <ContentWrap>
  3. <!-- 列表 -->
  4. <vxe-grid ref="xGrid" v-bind="gridOptions" class="xtable-scrollbar">
  5. <template #toolbar_buttons>
  6. <!-- 操作:新增 -->
  7. <XButton
  8. type="warning"
  9. preIcon="ep:download"
  10. :title="t('action.export')"
  11. v-hasPermi="['system:operate-log:export']"
  12. @click="handleExport()"
  13. />
  14. </template>
  15. <template #duration="{ row }">
  16. <span>{{ row.duration + 'ms' }}</span>
  17. </template>
  18. <template #resultCode="{ row }">
  19. <span>{{ row.resultCode === 0 ? '成功' : '失败' }}</span>
  20. </template>
  21. <template #actionbtns_default="{ row }">
  22. <!-- 操作:详情 -->
  23. <XTextButton preIcon="ep:view" :title="t('action.detail')" @click="handleDetail(row)" />
  24. </template>
  25. </vxe-grid>
  26. </ContentWrap>
  27. <!-- 弹窗 -->
  28. <XModal id="postModel" v-model="dialogVisible" :title="dialogTitle">
  29. <!-- 对话框(详情) -->
  30. <Descriptions :schema="allSchemas.detailSchema" :data="detailRef">
  31. <template #resultCode="{ row }">
  32. <span>{{ row.resultCode === 0 ? '成功' : '失败' }}</span>
  33. </template>
  34. <template #duration="{ row }">
  35. <span>{{ row.duration + 'ms' }}</span>
  36. </template>
  37. </Descriptions>
  38. <template #footer>
  39. <!-- 按钮:关闭 -->
  40. <XButton :loading="actionLoading" :title="t('dialog.close')" @click="dialogVisible = false" />
  41. </template>
  42. </XModal>
  43. </template>
  44. <script setup lang="ts">
  45. // 全局相关的 import
  46. import { ref } from 'vue'
  47. import { useI18n } from '@/hooks/web/useI18n'
  48. import { useVxeGrid } from '@/hooks/web/useVxeGrid'
  49. import { VxeGridInstance } from 'vxe-table'
  50. // 业务相关的 import
  51. import * as OperateLogApi from '@/api/system/operatelog'
  52. import { allSchemas } from './operatelog.data'
  53. const { t } = useI18n() // 国际化
  54. // 列表相关的变量
  55. const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
  56. const { gridOptions, exportList } = useVxeGrid<OperateLogApi.OperateLogVO>({
  57. allSchemas: allSchemas,
  58. getListApi: OperateLogApi.getOperateLogPageApi,
  59. exportListApi: OperateLogApi.exportOperateLogApi
  60. })
  61. // 弹窗相关的变量
  62. const dialogVisible = ref(false) // 是否显示弹出层
  63. const dialogTitle = ref('edit') // 弹出层标题
  64. const actionLoading = ref(false) // 按钮 Loading
  65. const detailRef = ref() // 详情 Ref
  66. // 详情
  67. const handleDetail = (row: OperateLogApi.OperateLogVO) => {
  68. // 设置数据
  69. detailRef.value = row
  70. dialogVisible.value = true
  71. }
  72. // 导出操作
  73. const handleExport = async () => {
  74. // TODO 星语:缺少 await 噢
  75. exportList(xGrid, '岗位列表.xls')
  76. }
  77. </script>