index.vue 7.6 KB

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