index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <template>
  2. <content-wrap>
  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 getDictOptions(DICT_TYPE.USER_TYPE)"
  29. :key="parseInt(dict.value)"
  30. :label="dict.label"
  31. :value="parseInt(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 v-model="queryParams.processStatus" placeholder="请选择处理状态" clearable>
  57. <el-option
  58. v-for="dict in getDictOptions(DICT_TYPE.INFRA_API_ERROR_LOG_PROCESS_STATUS)"
  59. :key="parseInt(dict.value)"
  60. :label="dict.label"
  61. :value="parseInt(dict.value)"
  62. />
  63. </el-select>
  64. </el-form-item>
  65. <el-form-item>
  66. <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
  67. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
  68. <el-button
  69. type="success"
  70. plain
  71. @click="handleExport"
  72. :loading="exportLoading"
  73. v-hasPermi="['infra:api-error-log:export']"
  74. >
  75. <Icon icon="ep:download" class="mr-5px" /> 导出
  76. </el-button>
  77. </el-form-item>
  78. </el-form>
  79. </content-wrap>
  80. <!-- 列表 -->
  81. <content-wrap>
  82. <el-table v-loading="loading" :data="list">
  83. <el-table-column label="日志编号" align="center" prop="id" />
  84. <el-table-column label="用户编号" align="center" prop="userId" />
  85. <el-table-column label="用户类型" align="center" prop="userType">
  86. <template #default="scope">
  87. <dict-tag :type="DICT_TYPE.USER_TYPE" :value="scope.row.userType" />
  88. </template>
  89. </el-table-column>
  90. <el-table-column label="应用名" align="center" prop="applicationName" />
  91. <el-table-column label="请求方法名" align="center" prop="requestMethod" />
  92. <el-table-column label="请求地址" align="center" prop="requestUrl" width="250" />
  93. <el-table-column label="异常发生时间" align="center" prop="exceptionTime" width="180">
  94. <template #default="scope">
  95. <span>{{ scope.row.exceptionTime }}</span>
  96. </template>
  97. </el-table-column>
  98. <el-table-column label="异常名" align="center" prop="exceptionName" width="250" />
  99. <el-table-column label="处理状态" align="center" prop="processStatus">
  100. <template #default="scope">
  101. <dict-tag
  102. :type="DICT_TYPE.INFRA_API_ERROR_LOG_PROCESS_STATUS"
  103. :value="scope.row.processStatus"
  104. />
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="操作" align="center">
  108. <template #default="scope">
  109. <el-button
  110. link
  111. type="primary"
  112. @click="openModal(scope.row)"
  113. v-hasPermi="['infra:api-access-log:query']"
  114. >
  115. 详细
  116. </el-button>
  117. <el-button
  118. link
  119. type="primary"
  120. v-if="scope.row.processStatus === InfraApiErrorLogProcessStatusEnum.INIT"
  121. @click="
  122. handleProcessClick(InfraApiErrorLogProcessStatusEnum.DONE, '已处理', scope.row.id)
  123. "
  124. v-hasPermi="['infra:api-error-log:update-status']"
  125. >
  126. 已处理
  127. </el-button>
  128. <el-button
  129. link
  130. type="primary"
  131. icon="el-icon-check"
  132. v-if="scope.row.processStatus === InfraApiErrorLogProcessStatusEnum.INIT"
  133. @click="
  134. handleProcessClick(InfraApiErrorLogProcessStatusEnum.IGNORE, '已忽略', scope.row.id)
  135. "
  136. v-hasPermi="['infra:api-error-log:update-status']"
  137. >
  138. 已忽略
  139. </el-button>
  140. </template>
  141. </el-table-column>
  142. </el-table>
  143. <!-- 分页组件 -->
  144. <Pagination
  145. :total="total"
  146. v-model:page="queryParams.pageNo"
  147. v-model:limit="queryParams.pageSize"
  148. @pagination="getList"
  149. />
  150. </content-wrap>
  151. <!-- 表单弹窗:详情 -->
  152. <api-error-log-detail ref="modalRef" />
  153. </template>
  154. <script setup lang="ts" name="ApiErrorLog">
  155. import { DICT_TYPE, getDictOptions } from '@/utils/dict'
  156. import download from '@/utils/download'
  157. import * as ApiErrorLogApi from '@/api/infra/apiErrorLog'
  158. import ApiErrorLogDetail from './detail.vue'
  159. import { InfraApiErrorLogProcessStatusEnum } from '@/utils/constants'
  160. const message = useMessage() // 消息弹窗
  161. const loading = ref(true) // 列表的加载中
  162. const total = ref(0) // 列表的总页数
  163. const list = ref([]) // 列表的数据
  164. const queryParams = reactive({
  165. pageNo: 1,
  166. pageSize: 10,
  167. userId: null,
  168. userType: null,
  169. applicationName: null,
  170. requestUrl: null,
  171. processStatus: null,
  172. exceptionTime: []
  173. })
  174. const queryFormRef = ref() // 搜索的表单
  175. const exportLoading = ref(false) // 导出的加载中
  176. /** 查询参数列表 */
  177. const getList = async () => {
  178. loading.value = true
  179. try {
  180. const data = await ApiErrorLogApi.getApiErrorLogPageApi(queryParams)
  181. list.value = data.list
  182. total.value = data.total
  183. } finally {
  184. loading.value = false
  185. }
  186. }
  187. /** 搜索按钮操作 */
  188. const handleQuery = () => {
  189. queryParams.pageNo = 1
  190. getList()
  191. }
  192. /** 重置按钮操作 */
  193. const resetQuery = () => {
  194. queryFormRef.value.resetFields()
  195. handleQuery()
  196. }
  197. /** 详情操作 */
  198. const modalRef = ref()
  199. const openModal = (data: ApiErrorLogApi.ApiErrorLogVO) => {
  200. modalRef.value.openModal(data)
  201. }
  202. /** 处理已处理 / 已忽略的操作 **/
  203. const handleProcessClick = async (processStatus: number, type: string, id: number) => {
  204. try {
  205. // 操作的二次确认
  206. await message.confirm('确认标记为' + type + '?')
  207. // 执行操作
  208. await ApiErrorLogApi.updateApiErrorLogPageApi(id, processStatus)
  209. await message.success(type)
  210. // 刷新列表
  211. await getList()
  212. } catch {}
  213. }
  214. /** 导出按钮操作 */
  215. const handleExport = async () => {
  216. try {
  217. // 导出的二次确认
  218. await message.exportConfirm()
  219. // 发起导出
  220. exportLoading.value = true
  221. const data = await ApiErrorLogApi.exportApiErrorLogApi(queryParams)
  222. download.excel(data, '操作日志.xls')
  223. } catch {
  224. } finally {
  225. exportLoading.value = false
  226. }
  227. }
  228. /** 初始化 **/
  229. onMounted(() => {
  230. getList()
  231. })
  232. </script>