index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <script setup lang="ts">
  2. import { ref } from 'vue'
  3. import dayjs from 'dayjs'
  4. import { DICT_TYPE } from '@/utils/dict'
  5. import { useTable } from '@/hooks/web/useTable'
  6. import { useI18n } from '@/hooks/web/useI18n'
  7. import type { ApiErrorLogVO } from '@/api/infra/apiErrorLog/types'
  8. import { allSchemas } from './apiErrorLog.data'
  9. import * as ApiErrorLogApi from '@/api/infra/apiErrorLog'
  10. import { InfraApiErrorLogProcessStatusEnum } from '@/utils/constants'
  11. import { useMessage } from '@/hooks/web/useMessage'
  12. const message = useMessage()
  13. const { t } = useI18n() // 国际化
  14. // ========== 列表相关 ==========
  15. const { register, tableObject, methods } = useTable<ApiErrorLogVO>({
  16. getListApi: ApiErrorLogApi.getApiErrorLogPageApi,
  17. exportListApi: ApiErrorLogApi.exportApiErrorLogApi
  18. })
  19. const { getList, setSearchParams, exportList } = methods
  20. // ========== 详情相关 ==========
  21. const detailRef = ref() // 详情 Ref
  22. const dialogVisible = ref(false) // 是否显示弹出层
  23. const dialogTitle = ref('') // 弹出层标题
  24. // 详情操作
  25. const handleDetail = (row: ApiErrorLogVO) => {
  26. // 设置数据
  27. detailRef.value = row
  28. dialogTitle.value = t('action.detail')
  29. dialogVisible.value = true
  30. }
  31. // 异常处理操作
  32. const handleProcessClick = (row: ApiErrorLogVO, processSttatus: number, type: string) => {
  33. message
  34. .confirm('确认标记为' + type + '?', t('common.reminder'))
  35. .then(async () => {
  36. ApiErrorLogApi.updateApiErrorLogPageApi(row.id, processSttatus).then(() => {
  37. message.success(t('common.updateSuccess'))
  38. getList()
  39. })
  40. })
  41. .catch(() => {})
  42. }
  43. // ========== 初始化 ==========
  44. getList()
  45. </script>
  46. <template>
  47. <!-- 搜索工作区 -->
  48. <ContentWrap>
  49. <Search :schema="allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />
  50. </ContentWrap>
  51. <ContentWrap>
  52. <el-button v-hasPermi="['infra:api-error-log:export']" @click="exportList('错误数据.xls')">
  53. <Icon icon="ep:download" class="mr-5px" /> {{ t('action.export') }}
  54. </el-button>
  55. <!-- 列表 -->
  56. <Table
  57. :columns="allSchemas.tableColumns"
  58. :selection="false"
  59. :data="tableObject.tableList"
  60. :loading="tableObject.loading"
  61. :pagination="{
  62. total: tableObject.total
  63. }"
  64. v-model:pageSize="tableObject.pageSize"
  65. v-model:currentPage="tableObject.currentPage"
  66. @register="register"
  67. >
  68. <template #userType="{ row }">
  69. <DictTag :type="DICT_TYPE.USER_TYPE" :value="row.userType" />
  70. </template>
  71. <template #processStatus="{ row }">
  72. <DictTag :type="DICT_TYPE.INFRA_API_ERROR_LOG_PROCESS_STATUS" :value="row.processStatus" />
  73. </template>
  74. <template #exceptionTime="{ row }">
  75. <span>{{ dayjs(row.exceptionTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
  76. </template>
  77. <template #processTime="{ row }">
  78. <span v-if="row.processTime">{{
  79. dayjs(row.processTime).format('YYYY-MM-DD HH:mm:ss')
  80. }}</span>
  81. </template>
  82. <template #action="{ row }">
  83. <el-button
  84. link
  85. type="primary"
  86. v-hasPermi="['infra:api-error-log:export']"
  87. @click="handleDetail(row)"
  88. >
  89. <Icon icon="ep:view" class="mr-1px" /> {{ t('action.detail') }}
  90. </el-button>
  91. <el-button
  92. link
  93. type="primary"
  94. v-if="row.processStatus === InfraApiErrorLogProcessStatusEnum.INIT"
  95. v-hasPermi="['infra:api-error-log:update-status']"
  96. @click="handleProcessClick(row, InfraApiErrorLogProcessStatusEnum.DONE, '已处理')"
  97. >
  98. <Icon icon="ep:cpu" class="mr-1px" /> 已处理
  99. </el-button>
  100. <el-button
  101. link
  102. type="primary"
  103. v-if="row.processStatus === InfraApiErrorLogProcessStatusEnum.INIT"
  104. v-hasPermi="['infra:api-error-log:update-status']"
  105. @click="handleProcessClick(row, InfraApiErrorLogProcessStatusEnum.IGNORE, '已忽略')"
  106. >
  107. <Icon icon="ep:mute-notification" class="mr-1px" /> 已忽略
  108. </el-button>
  109. </template>
  110. </Table>
  111. </ContentWrap>
  112. <XModal v-model="dialogVisible" :title="dialogTitle">
  113. <!-- 对话框(详情) -->
  114. <Descriptions :schema="allSchemas.detailSchema" :data="detailRef">
  115. <template #userType="{ row }">
  116. <DictTag :type="DICT_TYPE.USER_TYPE" :value="row.userType" />
  117. </template>
  118. <template #processStatus="{ row }">
  119. <DictTag :type="DICT_TYPE.INFRA_API_ERROR_LOG_PROCESS_STATUS" :value="row.processStatus" />
  120. </template>
  121. <template #exceptionTime="{ row }">
  122. <span>{{ dayjs(row.exceptionTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
  123. </template>
  124. </Descriptions>
  125. <!-- 操作按钮 -->
  126. <template #footer>
  127. <el-button @click="dialogVisible = false">{{ t('dialog.close') }}</el-button>
  128. </template>
  129. </XModal>
  130. </template>