index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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 lang="ts" setup>
  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. defineOptions({ name: 'InfraApiErrorLog' })
  165. const message = useMessage() // 消息弹窗
  166. const loading = ref(true) // 列表的加载中
  167. const total = ref(0) // 列表的总页数
  168. const list = ref([]) // 列表的数据
  169. const queryParams = reactive({
  170. pageNo: 1,
  171. pageSize: 10,
  172. userId: null,
  173. userType: null,
  174. applicationName: null,
  175. requestUrl: null,
  176. processStatus: null,
  177. exceptionTime: []
  178. })
  179. const queryFormRef = ref() // 搜索的表单
  180. const exportLoading = ref(false) // 导出的加载中
  181. /** 查询列表 */
  182. const getList = async () => {
  183. loading.value = true
  184. try {
  185. const data = await ApiErrorLogApi.getApiErrorLogPage(queryParams)
  186. list.value = data.list
  187. total.value = data.total
  188. } finally {
  189. loading.value = false
  190. }
  191. }
  192. /** 搜索按钮操作 */
  193. const handleQuery = () => {
  194. queryParams.pageNo = 1
  195. getList()
  196. }
  197. /** 重置按钮操作 */
  198. const resetQuery = () => {
  199. queryFormRef.value.resetFields()
  200. handleQuery()
  201. }
  202. /** 详情操作 */
  203. const detailRef = ref()
  204. const openDetail = (data: ApiErrorLogApi.ApiErrorLogVO) => {
  205. detailRef.value.open(data)
  206. }
  207. /** 处理已处理 / 已忽略的操作 **/
  208. const handleProcess = async (id: number, processStatus: number) => {
  209. try {
  210. // 操作的二次确认
  211. const type = processStatus === InfraApiErrorLogProcessStatusEnum.DONE ? '已处理' : '已忽略'
  212. await message.confirm('确认标记为' + type + '?')
  213. // 执行操作
  214. await ApiErrorLogApi.updateApiErrorLogPage(id, processStatus)
  215. await message.success(type)
  216. // 刷新列表
  217. await getList()
  218. } catch {}
  219. }
  220. /** 导出按钮操作 */
  221. const handleExport = async () => {
  222. try {
  223. // 导出的二次确认
  224. await message.exportConfirm()
  225. // 发起导出
  226. exportLoading.value = true
  227. const data = await ApiErrorLogApi.exportApiErrorLog(queryParams)
  228. download.excel(data, '异常日志.xls')
  229. } catch {
  230. } finally {
  231. exportLoading.value = false
  232. }
  233. }
  234. /** 初始化 **/
  235. onMounted(() => {
  236. getList()
  237. })
  238. </script>