index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <div class="app-container">
  3. <!-- 搜索工作栏 -->
  4. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  5. <el-form-item label="用户编号" prop="userId">
  6. <el-input v-model="queryParams.userId" placeholder="请输入用户编号" clearable size="small" @keyup.enter.native="handleQuery"/>
  7. </el-form-item>
  8. <el-form-item label="用户类型" prop="userType">
  9. <el-select v-model="queryParams.userType" placeholder="请选择用户类型" clearable size="small">
  10. <el-option v-for="dict in this.getDictDatas(DICT_TYPE.USER_TYPE)"
  11. :key="dict.value" :label="dict.label" :value="dict.value"/>
  12. </el-select>
  13. </el-form-item>
  14. <el-form-item label="应用名" prop="applicationName">
  15. <el-input v-model="queryParams.applicationName" placeholder="请输入应用名" clearable size="small" @keyup.enter.native="handleQuery"/>
  16. </el-form-item>
  17. <el-form-item label="请求地址" prop="requestUrl">
  18. <el-input v-model="queryParams.requestUrl" placeholder="请输入请求地址" clearable size="small" @keyup.enter.native="handleQuery"/>
  19. </el-form-item>
  20. <el-form-item label="异常时间">
  21. <el-date-picker v-model="dateRangeExceptionTime" size="small" style="width: 240px" value-format="yyyy-MM-dd"
  22. type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
  23. </el-form-item>
  24. <el-form-item label="处理状态" prop="processStatus">
  25. <el-select v-model="queryParams.processStatus" placeholder="请选择处理状态" clearable size="small">
  26. <el-option v-for="dict in this.getDictDatas(DICT_TYPE.INF_API_ERROR_LOG_PROCESS_STATUS)"
  27. :key="dict.value" :label="dict.label" :value="dict.value"/>
  28. </el-select>
  29. </el-form-item>
  30. <el-form-item>
  31. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  32. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  33. </el-form-item>
  34. </el-form>
  35. <!-- 操作工具栏 -->
  36. <el-row :gutter="10" class="mb8">
  37. <el-col :span="1.5">
  38. <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
  39. v-hasPermi="['infra:api-error-log:export']">导出</el-button>
  40. </el-col>
  41. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  42. </el-row>
  43. <!-- 列表 -->
  44. <el-table v-loading="loading" :data="list">
  45. <el-table-column label="日志编号" align="center" prop="id" />
  46. <el-table-column label="用户编号" align="center" prop="userId" />
  47. <el-table-column label="用户类型" align="center" prop="userType">
  48. <template slot-scope="scope">
  49. <span>{{ getDictDataLabel(DICT_TYPE.USER_TYPE, scope.row.userType) }}</span>
  50. </template>
  51. </el-table-column>>
  52. <el-table-column label="应用名" align="center" prop="applicationName" />
  53. <el-table-column label="请求方法名" align="center" prop="requestMethod" />
  54. <el-table-column label="请求地址" align="center" prop="requestUrl" width="250" />
  55. <el-table-column label="异常发生时间" align="center" prop="exceptionTime" width="180">
  56. <template slot-scope="scope">
  57. <span>{{ parseTime(scope.row.exceptionTime) }}</span>
  58. </template>
  59. </el-table-column>
  60. <el-table-column label="异常名" align="center" prop="exceptionName" width="250" />
  61. <el-table-column label="处理状态" align="center" prop="processStatus">
  62. <template slot-scope="scope">
  63. <span>{{ getDictDataLabel(DICT_TYPE.INF_API_ERROR_LOG_PROCESS_STATUS, scope.row.processStatus) }}</span>
  64. </template>
  65. </el-table-column>
  66. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  67. <template slot-scope="scope">
  68. <el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row,scope.index)"
  69. v-hasPermi="['infra:api-access-log:query']">详细</el-button>
  70. <el-button type="text" size="mini" icon="el-icon-check"
  71. v-if="scope.row.processStatus === InfApiErrorLogProcessStatusEnum.INIT" v-hasPermi="['infra:api-error-log:update-status']"
  72. @click="handleProcessClick(scope.row, InfApiErrorLogProcessStatusEnum.DONE)">已处理</el-button>
  73. <el-button type="text" size="mini" icon="el-icon-check"
  74. v-if="scope.row.processStatus === InfApiErrorLogProcessStatusEnum.INIT" v-hasPermi="['infra:api-error-log:update-status']"
  75. @click="handleProcessClick(scope.row, InfApiErrorLogProcessStatusEnum.IGNORE)">已忽略</el-button>
  76. </template>
  77. </el-table-column>
  78. </el-table>
  79. <!-- 分页组件 -->
  80. <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
  81. @pagination="getList"/>
  82. <!-- 查看明细 -->
  83. <el-dialog title="API 异常日志详细" :visible.sync="open" width="1280px" append-to-body>
  84. <el-form ref="form" :model="form" label-width="100px" size="mini">
  85. <el-row>
  86. <el-col :span="24">
  87. <el-form-item label="日志主键:">{{ form.id }}</el-form-item>
  88. <el-form-item label="链路追踪:">{{ form.traceId }}</el-form-item>
  89. <el-form-item label="应用名:">{{ form.applicationName }}</el-form-item>
  90. <el-form-item label="用户信息:">
  91. {{ form.userId }} | {{ getDictDataLabel(DICT_TYPE.USER_TYPE, form.userType) }} | {{ form.userIp }} | {{ form.userAgent}}
  92. </el-form-item>
  93. <el-form-item label="请求信息:">{{ form.requestMethod }} | {{ form.requestUrl }} </el-form-item>
  94. <el-form-item label="请求参数:">{{ form.requestParams }}</el-form-item>
  95. <el-form-item label="异常时间:">{{ parseTime(form.exceptionTime) }}</el-form-item>
  96. <el-form-item label="异常名">{{ form.exceptionName }}</el-form-item>
  97. <el-form-item label="异常名">
  98. <el-input type="textarea" :readonly="true" :autosize="{ maxRows: 20}" v-model="form.exceptionStackTrace"></el-input>
  99. </el-form-item>
  100. <el-form-item label="处理状态">
  101. {{ getDictDataLabel(DICT_TYPE.INF_API_ERROR_LOG_PROCESS_STATUS, form.processStatus) }}
  102. </el-form-item>
  103. <el-form-item label="处理人">{{ form.processUserId }}</el-form-item>
  104. <el-form-item label="处理时间">{{ parseTime(form.processTime) }}</el-form-item>
  105. </el-col>
  106. </el-row>
  107. </el-form>
  108. <div slot="footer" class="dialog-footer">
  109. <el-button @click="open = false">关 闭</el-button>
  110. </div>
  111. </el-dialog>
  112. </div>
  113. </template>
  114. <script>
  115. import { updateApiErrorLogProcess, getApiErrorLogPage, exportApiErrorLogExcel } from "@/api/infra/apiErrorLog";
  116. import { InfApiErrorLogProcessStatusEnum } from '@/utils/constants'
  117. export default {
  118. name: "ApiErrorLog",
  119. components: {
  120. },
  121. data() {
  122. return {
  123. // 遮罩层
  124. loading: true,
  125. // 显示搜索条件
  126. showSearch: true,
  127. // 总条数
  128. total: 0,
  129. // API 错误日志列表
  130. list: [],
  131. // 弹出层标题
  132. title: "",
  133. // 是否显示弹出层
  134. open: false,
  135. dateRangeExceptionTime: [],
  136. // 查询参数
  137. queryParams: {
  138. pageNo: 1,
  139. pageSize: 10,
  140. userId: null,
  141. userType: null,
  142. applicationName: null,
  143. requestUrl: null,
  144. processStatus: null,
  145. },
  146. // 表单参数
  147. form: {},
  148. // 枚举
  149. InfApiErrorLogProcessStatusEnum: InfApiErrorLogProcessStatusEnum,
  150. };
  151. },
  152. created() {
  153. this.getList();
  154. },
  155. methods: {
  156. /** 查询列表 */
  157. getList() {
  158. this.loading = true;
  159. // 处理查询参数
  160. let params = {...this.queryParams};
  161. this.addBeginAndEndTime(params, this.dateRangeExceptionTime, 'exceptionTime');
  162. // 执行查询
  163. getApiErrorLogPage(params).then(response => {
  164. this.list = response.data.list;
  165. this.total = response.data.total;
  166. this.loading = false;
  167. });
  168. },
  169. /** 取消按钮 */
  170. cancel() {
  171. this.open = false;
  172. this.reset();
  173. },
  174. /** 表单重置 */
  175. reset() {
  176. this.form = {};
  177. this.resetForm("form");
  178. },
  179. /** 搜索按钮操作 */
  180. handleQuery() {
  181. this.queryParams.pageNo = 1;
  182. this.getList();
  183. },
  184. /** 重置按钮操作 */
  185. resetQuery() {
  186. this.dateRangeExceptionTime = [];
  187. this.resetForm("queryForm");
  188. this.handleQuery();
  189. },
  190. /** 详细按钮操作 */
  191. handleView(row) {
  192. this.open = true;
  193. this.form = row;
  194. },
  195. /** 处理已处理 / 已忽略的操作 **/
  196. handleProcessClick(row, processStatus) {
  197. const processStatusText = this.getDictDataLabel(this.DICT_TYPE.INF_API_ERROR_LOG_PROCESS_STATUS, processStatus)
  198. this.$confirm('确认标记为' + processStatusText, '提示', {
  199. type: 'warning',
  200. confirmButtonText: '确定',
  201. cancelButtonText: '取消'
  202. }).then(() => {
  203. updateApiErrorLogProcess(row.id, processStatus).then(() => {
  204. this.msgSuccess("修改成功");
  205. this.getList();
  206. });
  207. })
  208. },
  209. /** 导出按钮操作 */
  210. handleExport() {
  211. // 处理查询参数
  212. let params = {...this.queryParams};
  213. params.pageNo = undefined;
  214. params.pageSize = undefined;
  215. this.addBeginAndEndTime(params, this.dateRangeExceptionTime, 'exceptionTime');
  216. // 执行导出
  217. this.$confirm('是否确认导出所有API 错误日志数据项?', "警告", {
  218. confirmButtonText: "确定",
  219. cancelButtonText: "取消",
  220. type: "warning"
  221. }).then(function() {
  222. return exportApiErrorLogExcel(params);
  223. }).then(response => {
  224. this.downloadExcel(response, 'API 错误日志.xls');
  225. })
  226. }
  227. }
  228. };
  229. </script>