index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <ContentWrap>
  3. <!-- 搜索工作栏 -->
  4. <el-form
  5. class="-mb-15px"
  6. :model="queryParams"
  7. ref="queryFormRef"
  8. :inline="true"
  9. label-width="68px"
  10. >
  11. <el-form-item label="用户编号" prop="userId">
  12. <el-input
  13. v-model="queryParams.userId"
  14. placeholder="请输入用户编号"
  15. clearable
  16. @keyup.enter="handleQuery"
  17. class="!w-240px"
  18. />
  19. </el-form-item>
  20. <el-form-item label="用户类型" prop="userType">
  21. <el-select
  22. v-model="queryParams.userType"
  23. placeholder="请选择用户类型"
  24. clearable
  25. class="!w-240px"
  26. >
  27. <el-option
  28. v-for="dict in getIntDictOptions(DICT_TYPE.USER_TYPE)"
  29. :key="dict.value"
  30. :label="dict.label"
  31. :value="dict.value"
  32. />
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item label="应用名" prop="applicationName">
  36. <el-input
  37. v-model="queryParams.applicationName"
  38. placeholder="请输入应用名"
  39. clearable
  40. @keyup.enter="handleQuery"
  41. class="!w-240px"
  42. />
  43. </el-form-item>
  44. <el-form-item label="异常时间" prop="exceptionTime">
  45. <el-date-picker
  46. v-model="queryParams.exceptionTime"
  47. value-format="yyyy-MM-dd HH:mm:ss"
  48. type="daterange"
  49. start-placeholder="开始日期"
  50. end-placeholder="结束日期"
  51. :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
  52. class="!w-240px"
  53. />
  54. </el-form-item>
  55. <el-form-item label="处理状态" prop="processStatus">
  56. <el-select
  57. v-model="queryParams.processStatus"
  58. placeholder="请选择处理状态"
  59. clearable
  60. class="!w-240px"
  61. >
  62. <el-option
  63. v-for="dict in getIntDictOptions(DICT_TYPE.INFRA_API_ERROR_LOG_PROCESS_STATUS)"
  64. :key="dict.value"
  65. :label="dict.label"
  66. :value="dict.value"
  67. />
  68. </el-select>
  69. </el-form-item>
  70. <el-form-item>
  71. <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
  72. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
  73. <el-button
  74. type="success"
  75. plain
  76. @click="handleExport"
  77. :loading="exportLoading"
  78. v-hasPermi="['infra:api-error-log:export']"
  79. >
  80. <Icon icon="ep:download" class="mr-5px" /> 导出
  81. </el-button>
  82. </el-form-item>
  83. </el-form>
  84. </ContentWrap>
  85. <!-- 列表 -->
  86. <ContentWrap>
  87. <el-table v-loading="loading" :data="list">
  88. <el-table-column label="日志编号" align="center" prop="id" />
  89. <el-table-column label="用户编号" align="center" prop="userId" />
  90. <el-table-column label="用户类型" align="center" prop="userType">
  91. <template #default="scope">
  92. <dict-tag :type="DICT_TYPE.USER_TYPE" :value="scope.row.userType" />
  93. </template>
  94. </el-table-column>
  95. <el-table-column label="应用名" align="center" prop="applicationName" width="200" />
  96. <el-table-column label="请求方法" align="center" prop="requestMethod" width="80" />
  97. <el-table-column label="请求地址" align="center" prop="requestUrl" width="180" />
  98. <el-table-column
  99. label="异常发生时间"
  100. align="center"
  101. prop="exceptionTime"
  102. width="180"
  103. :formatter="dateFormatter"
  104. />
  105. <el-table-column label="异常名" align="center" prop="exceptionName" width="180" />
  106. <el-table-column label="处理状态" align="center" prop="processStatus">
  107. <template #default="scope">
  108. <dict-tag
  109. :type="DICT_TYPE.INFRA_API_ERROR_LOG_PROCESS_STATUS"
  110. :value="scope.row.processStatus"
  111. />
  112. </template>
  113. </el-table-column>
  114. <el-table-column label="操作" align="center" width="200">
  115. <template #default="scope">
  116. <el-button
  117. link
  118. type="primary"
  119. @click="openDetail(scope.row)"
  120. v-hasPermi="['infra:api-error-log:query']"
  121. >
  122. 详细
  123. </el-button>
  124. <el-button
  125. link
  126. type="primary"
  127. v-if="scope.row.processStatus === InfraApiErrorLogProcessStatusEnum.INIT"
  128. @click="handleProcess(scope.row.id, InfraApiErrorLogProcessStatusEnum.DONE)"
  129. v-hasPermi="['infra:api-error-log:update-status']"
  130. >
  131. 已处理
  132. </el-button>
  133. <el-button
  134. link
  135. type="primary"
  136. v-if="scope.row.processStatus === InfraApiErrorLogProcessStatusEnum.INIT"
  137. @click="handleProcess(scope.row.id, InfraApiErrorLogProcessStatusEnum.IGNORE)"
  138. v-hasPermi="['infra:api-error-log:update-status']"
  139. >
  140. 已忽略
  141. </el-button>
  142. </template>
  143. </el-table-column>
  144. </el-table>
  145. <!-- 分页组件 -->
  146. <Pagination
  147. :total="total"
  148. v-model:page="queryParams.pageNo"
  149. v-model:limit="queryParams.pageSize"
  150. @pagination="getList"
  151. />
  152. </ContentWrap>
  153. <!-- 表单弹窗:详情 -->
  154. <ApiErrorLogDetail ref="detailRef" />
  155. </template>
  156. <script setup lang="ts" name="ApiErrorLog">
  157. import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
  158. import { dateFormatter } from '@/utils/formatTime'
  159. import download from '@/utils/download'
  160. import * as ApiErrorLogApi from '@/api/infra/apiErrorLog'
  161. import ApiErrorLogDetail from './ApiErrorLogDetail.vue'
  162. import { InfraApiErrorLogProcessStatusEnum } from '@/utils/constants'
  163. const message = useMessage() // 消息弹窗
  164. const loading = ref(true) // 列表的加载中
  165. const total = ref(0) // 列表的总页数
  166. const list = ref([]) // 列表的数据
  167. const queryParams = reactive({
  168. pageNo: 1,
  169. pageSize: 10,
  170. userId: null,
  171. userType: null,
  172. applicationName: null,
  173. requestUrl: null,
  174. processStatus: null,
  175. exceptionTime: []
  176. })
  177. const queryFormRef = ref() // 搜索的表单
  178. const exportLoading = ref(false) // 导出的加载中
  179. /** 查询参数列表 */
  180. const getList = async () => {
  181. loading.value = true
  182. try {
  183. const data = await ApiErrorLogApi.getApiErrorLogPage(queryParams)
  184. list.value = data.list
  185. total.value = data.total
  186. } finally {
  187. loading.value = false
  188. }
  189. }
  190. /** 搜索按钮操作 */
  191. const handleQuery = () => {
  192. queryParams.pageNo = 1
  193. getList()
  194. }
  195. /** 重置按钮操作 */
  196. const resetQuery = () => {
  197. queryFormRef.value.resetFields()
  198. handleQuery()
  199. }
  200. /** 详情操作 */
  201. const detailRef = ref()
  202. const openDetail = (data: ApiErrorLogApi.ApiErrorLogVO) => {
  203. detailRef.value.open(data)
  204. }
  205. /** 处理已处理 / 已忽略的操作 **/
  206. const handleProcess = async (id: number, processStatus: number) => {
  207. try {
  208. // 操作的二次确认
  209. const type = processStatus === InfraApiErrorLogProcessStatusEnum.DONE ? '已处理' : '已忽略'
  210. await message.confirm('确认标记为' + type + '?')
  211. // 执行操作
  212. await ApiErrorLogApi.updateApiErrorLogPage(id, processStatus)
  213. await message.success(type)
  214. // 刷新列表
  215. await getList()
  216. } catch {}
  217. }
  218. /** 导出按钮操作 */
  219. const handleExport = async () => {
  220. try {
  221. // 导出的二次确认
  222. await message.exportConfirm()
  223. // 发起导出
  224. exportLoading.value = true
  225. const data = await ApiErrorLogApi.exportApiErrorLog(queryParams)
  226. download.excel(data, '异常日志.xls')
  227. } catch {
  228. } finally {
  229. exportLoading.value = false
  230. }
  231. }
  232. /** 初始化 **/
  233. onMounted(() => {
  234. getList()
  235. })
  236. </script>