index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <ContentWrap>
  3. <!-- 列表 -->
  4. <XTable @register="registerTable">
  5. <!-- 操作:导出 -->
  6. <template #toolbar_buttons>
  7. <XButton
  8. type="warning"
  9. preIcon="ep:download"
  10. :title="t('action.export')"
  11. @click="handleExport()"
  12. />
  13. </template>
  14. <template #duration_default="{ row }">
  15. <span>{{ row.duration + 'ms' }}</span>
  16. </template>
  17. <template #resultCode_default="{ row }">
  18. <span>{{ row.resultCode === 0 ? '成功' : '失败(' + row.resultMsg + ')' }}</span>
  19. </template>
  20. <template #actionbtns_default="{ row }">
  21. <!-- 操作:详情 -->
  22. <XTextButton
  23. preIcon="ep:view"
  24. :title="t('action.detail')"
  25. v-hasPermi="['infra:api-access-log:query']"
  26. @click="handleDetail(row)"
  27. />
  28. <XTextButton
  29. preIcon="ep:cpu"
  30. title="已处理"
  31. v-if="row.processStatus === InfraApiErrorLogProcessStatusEnum.INIT"
  32. v-hasPermi="['infra:api-error-log:update-status']"
  33. @click="handleProcessClick(row, InfraApiErrorLogProcessStatusEnum.DONE, '已处理')"
  34. />
  35. <XTextButton
  36. preIcon="ep:mute-notification"
  37. title="已忽略"
  38. v-if="row.processStatus === InfraApiErrorLogProcessStatusEnum.INIT"
  39. v-hasPermi="['infra:api-error-log:update-status']"
  40. @click="handleProcessClick(row, InfraApiErrorLogProcessStatusEnum.IGNORE, '已忽略')"
  41. />
  42. </template>
  43. </XTable>
  44. </ContentWrap>
  45. <XModal v-model="dialogVisible" :title="dialogTitle">
  46. <!-- 对话框(详情) -->
  47. <Descriptions :schema="allSchemas.detailSchema" :data="detailData" />
  48. <!-- 操作按钮 -->
  49. <template #footer>
  50. <XButton :title="t('dialog.close')" @click="dialogVisible = false" />
  51. </template>
  52. </XModal>
  53. </template>
  54. <script setup lang="ts" name="ApiErrorLog">
  55. import { ref } from 'vue'
  56. import { useI18n } from '@/hooks/web/useI18n'
  57. import { useXTable } from '@/hooks/web/useXTable'
  58. import { allSchemas } from './apiErrorLog.data'
  59. import * as ApiErrorLogApi from '@/api/infra/apiErrorLog'
  60. import { InfraApiErrorLogProcessStatusEnum } from '@/utils/constants'
  61. import { useMessage } from '@/hooks/web/useMessage'
  62. const { t } = useI18n() // 国际化
  63. const message = useMessage()
  64. // ========== 列表相关 ==========
  65. const [registerTable, { reload, exportList }] = useXTable({
  66. allSchemas: allSchemas,
  67. getListApi: ApiErrorLogApi.getApiErrorLogPageApi,
  68. exportListApi: ApiErrorLogApi.exportApiErrorLogApi
  69. })
  70. // ========== 详情相关 ==========
  71. const detailData = ref() // 详情 Ref
  72. const dialogVisible = ref(false) // 是否显示弹出层
  73. const dialogTitle = ref('') // 弹出层标题
  74. // 详情操作
  75. const handleDetail = (row: ApiErrorLogApi.ApiErrorLogVO) => {
  76. // 设置数据
  77. detailData.value = row
  78. dialogTitle.value = t('action.detail')
  79. dialogVisible.value = true
  80. }
  81. // 导出
  82. const handleExport = async () => {
  83. await exportList('错误数据.xls')
  84. }
  85. // 异常处理操作
  86. const handleProcessClick = (
  87. row: ApiErrorLogApi.ApiErrorLogVO,
  88. processSttatus: number,
  89. type: string
  90. ) => {
  91. message
  92. .confirm('确认标记为' + type + '?', t('common.reminder'))
  93. .then(async () => {
  94. await ApiErrorLogApi.updateApiErrorLogPageApi(row.id, processSttatus)
  95. message.success(t('common.updateSuccess'))
  96. })
  97. .finally(async () => {
  98. // 刷新列表
  99. await reload()
  100. })
  101. .catch(() => {})
  102. }
  103. </script>