index.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <ContentWrap>
  3. <!-- 列表 -->
  4. <XTable @register="registerTable">
  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. </XTable>
  21. </ContentWrap>
  22. <XModal v-model="dialogVisible" :title="dialogTitle">
  23. <!-- 对话框(详情) -->
  24. <Descriptions :schema="allSchemas.detailSchema" :data="detailData">
  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 { useXTable } from '@/hooks/web/useXTable'
  42. import { allSchemas } from './apiAccessLog.data'
  43. import * as ApiAccessLogApi from '@/api/infra/apiAccessLog'
  44. const { t } = useI18n() // 国际化
  45. // 列表相关的变量
  46. const [registerTable] = useXTable({
  47. allSchemas: allSchemas,
  48. topActionSlots: false,
  49. getListApi: ApiAccessLogApi.getApiAccessLogPageApi
  50. })
  51. // ========== 详情相关 ==========
  52. const detailData = ref() // 详情 Ref
  53. const dialogVisible = ref(false) // 是否显示弹出层
  54. const dialogTitle = ref('') // 弹出层标题
  55. // 详情操作
  56. const handleDetail = (row: ApiAccessLogApi.ApiAccessLogVO) => {
  57. // 设置数据
  58. detailData.value = row
  59. dialogTitle.value = t('action.detail')
  60. dialogVisible.value = true
  61. }
  62. </script>