index.vue 5.0 KB

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