index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <ContentWrap>
  3. <!-- 列表 -->
  4. <vxe-grid ref="xGrid" v-bind="gridOptions" class="xtable-scrollbar">
  5. <template #duration_default="{ row }">
  6. <span>{{ row.duration + 'ms' }}</span>
  7. </template>
  8. <template #resultCode_default="{ row }">
  9. <span>{{ row.resultCode === 0 ? '成功' : '失败(' + row.resultMsg + ')' }}</span>
  10. </template>
  11. <template #actionbtns_default="{ row }">
  12. <!-- 操作:详情 -->
  13. <XTextButton
  14. preIcon="ep:view"
  15. :title="t('action.detail')"
  16. v-hasPermi="['infra:api-access-log:query']"
  17. @click="handleDetail(row)"
  18. />
  19. </template>
  20. </vxe-grid>
  21. </ContentWrap>
  22. <XModal v-model="dialogVisible" :title="dialogTitle">
  23. <!-- 对话框(详情) -->
  24. <Descriptions :schema="allSchemas.detailSchema" :data="detailRef">
  25. <template #duration="{ row }">
  26. <span>{{ row.duration + 'ms' }}</span>
  27. </template>
  28. <template #resultCode="{ row }">
  29. <span>{{ row.resultCode === 0 ? '成功' : '失败(' + row.resultMsg + ')' }}</span>
  30. </template>
  31. </Descriptions>
  32. <!-- 操作按钮 -->
  33. <template #footer>
  34. <XButton :title="t('dialog.close')" @click="dialogVisible = false" />
  35. </template>
  36. </XModal>
  37. </template>
  38. <script setup lang="ts" name="ApiAccessLog">
  39. import { ref } from 'vue'
  40. import { useI18n } from '@/hooks/web/useI18n'
  41. import { useVxeGrid } from '@/hooks/web/useVxeGrid'
  42. import { VxeGridInstance } from 'vxe-table'
  43. import { allSchemas } from './apiAccessLog.data'
  44. import * as ApiAccessLogApi from '@/api/infra/apiAccessLog'
  45. const { t } = useI18n() // 国际化
  46. // 列表相关的变量
  47. const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
  48. const { gridOptions } = useVxeGrid<ApiAccessLogApi.ApiAccessLogVO>({
  49. allSchemas: allSchemas,
  50. topActionSlots: false,
  51. getListApi: ApiAccessLogApi.getApiAccessLogPageApi
  52. })
  53. // ========== 详情相关 ==========
  54. const detailRef = ref() // 详情 Ref
  55. const dialogVisible = ref(false) // 是否显示弹出层
  56. const dialogTitle = ref('') // 弹出层标题
  57. // 详情操作
  58. const handleDetail = (row: ApiAccessLogApi.ApiAccessLogVO) => {
  59. // 设置数据
  60. detailRef.value = row
  61. dialogTitle.value = t('action.detail')
  62. dialogVisible.value = true
  63. }
  64. </script>