index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <ContentWrap>
  3. <!-- 列表 -->
  4. <vxe-grid ref="xGrid" v-bind="gridOptions" class="xtable-scrollbar">
  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. </vxe-grid>
  44. </ContentWrap>
  45. <XModal v-model="dialogVisible" :title="dialogTitle">
  46. <!-- 对话框(详情) -->
  47. <Descriptions :schema="allSchemas.detailSchema" :data="detailRef" />
  48. <!-- 操作按钮 -->
  49. <template #footer>
  50. <el-button @click="dialogVisible = false">{{ t('dialog.close') }}</el-button>
  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 { useVxeGrid } from '@/hooks/web/useVxeGrid'
  58. import { VxeGridInstance } from 'vxe-table'
  59. import { allSchemas } from './apiErrorLog.data'
  60. import * as ApiErrorLogApi from '@/api/infra/apiErrorLog'
  61. import { InfraApiErrorLogProcessStatusEnum } from '@/utils/constants'
  62. import { useMessage } from '@/hooks/web/useMessage'
  63. const message = useMessage()
  64. const { t } = useI18n() // 国际化
  65. // ========== 列表相关 ==========
  66. const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
  67. const { gridOptions, getList, exportList } = useVxeGrid<ApiErrorLogApi.ApiErrorLogVO>({
  68. allSchemas: allSchemas,
  69. getListApi: ApiErrorLogApi.getApiErrorLogPageApi,
  70. exportListApi: ApiErrorLogApi.exportApiErrorLogApi
  71. })
  72. // ========== 详情相关 ==========
  73. const detailRef = ref() // 详情 Ref
  74. const dialogVisible = ref(false) // 是否显示弹出层
  75. const dialogTitle = ref('') // 弹出层标题
  76. // 详情操作
  77. const handleDetail = (row: ApiErrorLogApi.ApiErrorLogVO) => {
  78. // 设置数据
  79. detailRef.value = row
  80. dialogTitle.value = t('action.detail')
  81. dialogVisible.value = true
  82. }
  83. // 导出
  84. const handleExport = async () => {
  85. await exportList(xGrid, '错误数据.xls')
  86. }
  87. // 异常处理操作
  88. const handleProcessClick = (
  89. row: ApiErrorLogApi.ApiErrorLogVO,
  90. processSttatus: number,
  91. type: string
  92. ) => {
  93. message
  94. .confirm('确认标记为' + type + '?', t('common.reminder'))
  95. .then(async () => {
  96. ApiErrorLogApi.updateApiErrorLogPageApi(row.id, processSttatus).then(() => {
  97. message.success(t('common.updateSuccess'))
  98. })
  99. })
  100. .finally(async () => {
  101. // 刷新列表
  102. await getList(xGrid)
  103. })
  104. .catch(() => {})
  105. }
  106. </script>