2021-12-26 19:28:11 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="app-container">
|
2022-01-22 00:50:13 +08:00
|
|
|
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="70px">
|
2021-12-26 19:28:11 +08:00
|
|
|
|
<el-form-item label="接口名称" prop="apiName">
|
2022-01-22 00:50:13 +08:00
|
|
|
|
<el-select
|
2021-12-26 19:28:11 +08:00
|
|
|
|
v-model="queryParams.apiName"
|
2022-01-22 00:50:13 +08:00
|
|
|
|
placeholder="请输入"
|
|
|
|
|
|
clearable
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
style="width: 150px">
|
|
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="index in apiName"
|
|
|
|
|
|
:key="index"
|
|
|
|
|
|
:label="index"
|
|
|
|
|
|
:value="index"/>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
<el-form-item label="请求URL" prop="url">
|
|
|
|
|
|
<el-input
|
|
|
|
|
|
v-model="queryParams.url"
|
|
|
|
|
|
placeholder="请输入请求URL"
|
|
|
|
|
|
clearable
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
@keyup.enter.native="handleQuery"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
<el-form-item label="请求参数" prop="request">
|
|
|
|
|
|
<el-input
|
|
|
|
|
|
v-model="queryParams.request"
|
|
|
|
|
|
placeholder="请输入请求参数"
|
|
|
|
|
|
clearable
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
@keyup.enter.native="handleQuery"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
<el-form-item label="响应参数" prop="response">
|
|
|
|
|
|
<el-input
|
|
|
|
|
|
v-model="queryParams.response"
|
|
|
|
|
|
placeholder="请输入响应参数"
|
2021-12-26 19:28:11 +08:00
|
|
|
|
clearable
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
@keyup.enter.native="handleQuery"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-form-item>
|
2021-12-26 22:52:28 +08:00
|
|
|
|
|
2022-01-22 00:50:13 +08:00
|
|
|
|
<el-form-item label="是否成功" prop="isSuccess">
|
|
|
|
|
|
<el-select
|
|
|
|
|
|
v-model="queryParams.isSuccess"
|
|
|
|
|
|
placeholder="请输入"
|
|
|
|
|
|
clearable
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
style="width: 150px">
|
|
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="dict in dict.type.request_status"
|
|
|
|
|
|
:key="dict.value"
|
|
|
|
|
|
:label="dict.label"
|
|
|
|
|
|
:value="dict.value"/>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
<el-form-item label="请求方法" prop="method">
|
|
|
|
|
|
<el-select
|
|
|
|
|
|
v-model="queryParams.method"
|
|
|
|
|
|
placeholder="请输入"
|
|
|
|
|
|
clearable
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
style="width: 150px">
|
|
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="dict in dict.type.request_method"
|
|
|
|
|
|
:key="dict.value"
|
|
|
|
|
|
:label="dict.label"
|
|
|
|
|
|
:value="dict.value"/>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<el-form-item label="创建时间">
|
|
|
|
|
|
<el-date-picker
|
|
|
|
|
|
v-model="daterangeCreateTime"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
style="width: 240px"
|
|
|
|
|
|
value-format="yyyy-MM-dd"
|
|
|
|
|
|
type="daterange"
|
|
|
|
|
|
range-separator="-"
|
|
|
|
|
|
start-placeholder="开始日期"
|
|
|
|
|
|
end-placeholder="结束日期"
|
|
|
|
|
|
></el-date-picker>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-12-26 19:28:11 +08:00
|
|
|
|
<el-form-item>
|
|
|
|
|
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
|
|
|
|
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-form>
|
|
|
|
|
|
|
|
|
|
|
|
<el-row :gutter="10" class="mb8">
|
|
|
|
|
|
<el-col :span="1.5">
|
|
|
|
|
|
<el-button
|
|
|
|
|
|
type="danger"
|
|
|
|
|
|
plain
|
|
|
|
|
|
icon="el-icon-delete"
|
|
|
|
|
|
size="mini"
|
|
|
|
|
|
:disabled="multiple"
|
|
|
|
|
|
@click="handleDelete"
|
2022-01-13 11:41:29 +08:00
|
|
|
|
v-hasPermi="['log:apilog:remove']"
|
2021-12-27 17:04:56 +08:00
|
|
|
|
>删除
|
|
|
|
|
|
</el-button>
|
2021-12-26 19:28:11 +08:00
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="1.5">
|
|
|
|
|
|
<el-button
|
|
|
|
|
|
type="warning"
|
|
|
|
|
|
plain
|
|
|
|
|
|
icon="el-icon-download"
|
|
|
|
|
|
size="mini"
|
|
|
|
|
|
@click="handleExport"
|
2022-01-13 11:41:29 +08:00
|
|
|
|
v-hasPermi="['log:apilog:export']"
|
2021-12-27 17:04:56 +08:00
|
|
|
|
>导出
|
|
|
|
|
|
</el-button>
|
2021-12-26 19:28:11 +08:00
|
|
|
|
</el-col>
|
|
|
|
|
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
|
2022-02-18 11:57:01 +08:00
|
|
|
|
<el-table v-loading="loading" :data="logList" border height="585" @selection-change="handleSelectionChange">
|
2021-12-27 17:04:56 +08:00
|
|
|
|
<el-table-column type="selection" width="55" align="center"/>
|
2021-12-26 22:52:28 +08:00
|
|
|
|
<el-table-column label="接口名称" align="center" prop="apiName" :show-overflow-tooltip="true"/>
|
2021-12-27 17:04:56 +08:00
|
|
|
|
<el-table-column label="请求URL" align="center" prop="url" :show-overflow-tooltip="true"/>
|
2021-12-26 22:52:28 +08:00
|
|
|
|
<el-table-column label="请求方法" align="center" prop="method" :show-overflow-tooltip="true"/>
|
2022-02-17 09:57:14 +08:00
|
|
|
|
<el-table-column label="请求参数" align="center" prop="request" :show-overflow-tooltip="true">
|
|
|
|
|
|
<template slot-scope="scope">
|
2022-02-17 21:28:23 +08:00
|
|
|
|
<span>{{ scope.row.request !== "" ? scope.row.request : "-" }}</span>
|
2022-02-17 09:57:14 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
2021-12-27 10:09:39 +08:00
|
|
|
|
<el-table-column label="响应参数" align="center" prop="response" :show-overflow-tooltip="true"/>
|
2021-12-27 20:29:04 +08:00
|
|
|
|
<el-table-column label="创建时间" align="center" prop="createTime" :show-overflow-tooltip="true"/>
|
2022-01-08 02:34:57 +08:00
|
|
|
|
<el-table-column label="是否请求成功" align="center" prop="isSuccess" :show-overflow-tooltip="true">
|
|
|
|
|
|
<template slot-scope="scope">
|
2022-01-13 16:42:37 +08:00
|
|
|
|
<el-tag :type="scope.row.isSuccess=== 1 ?'success':'danger'" size="small">
|
|
|
|
|
|
{{ scope.row.isSuccess === 1 ? '成功' : '失败' }}
|
|
|
|
|
|
</el-tag>
|
2022-01-08 02:34:57 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
2021-12-26 19:28:11 +08:00
|
|
|
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
|
|
|
|
<template slot-scope="scope">
|
2022-01-08 22:49:21 +08:00
|
|
|
|
<el-tooltip class="item" effect="dark" content="点击查看json格式" placement="top-start">
|
2022-01-08 02:34:57 +08:00
|
|
|
|
<el-button circle
|
|
|
|
|
|
type=""
|
|
|
|
|
|
icon="el-icon-view"
|
|
|
|
|
|
@click="handleView(scope.row,scope.index)"
|
2022-01-13 11:41:29 +08:00
|
|
|
|
v-hasPermi="['log:apilog:query']"
|
2022-01-08 02:34:57 +08:00
|
|
|
|
></el-button>
|
|
|
|
|
|
</el-tooltip>
|
2021-12-26 19:28:11 +08:00
|
|
|
|
<el-button
|
2021-12-29 00:17:21 +08:00
|
|
|
|
circle
|
|
|
|
|
|
type="danger"
|
2021-12-26 19:28:11 +08:00
|
|
|
|
icon="el-icon-delete"
|
|
|
|
|
|
@click="handleDelete(scope.row)"
|
2022-01-13 11:41:29 +08:00
|
|
|
|
v-hasPermi="['log:apilog:remove']"
|
2021-12-29 00:17:21 +08:00
|
|
|
|
>
|
2021-12-27 17:04:56 +08:00
|
|
|
|
</el-button>
|
2021-12-26 19:28:11 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
</el-table>
|
2021-12-26 22:52:28 +08:00
|
|
|
|
|
2022-01-08 02:34:57 +08:00
|
|
|
|
|
|
|
|
|
|
<el-dialog title="内容详细" :visible.sync="open" width="700px" append-to-body>
|
|
|
|
|
|
<el-row>
|
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
|
请求参数:
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
|
<json-viewer :value=request
|
|
|
|
|
|
:expand-depth=5
|
|
|
|
|
|
copyable
|
|
|
|
|
|
boxed
|
|
|
|
|
|
sort></json-viewer>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
|
响应参数:
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
|
<json-viewer :value="response"
|
|
|
|
|
|
:expand-depth=5
|
|
|
|
|
|
copyable
|
|
|
|
|
|
boxed
|
|
|
|
|
|
sort></json-viewer>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
|
|
|
<el-button @click="open = false">关 闭</el-button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-dialog>
|
|
|
|
|
|
|
2021-12-26 19:28:11 +08:00
|
|
|
|
<pagination
|
|
|
|
|
|
v-show="total>0"
|
|
|
|
|
|
:total="total"
|
|
|
|
|
|
:page.sync="queryParams.pageNum"
|
|
|
|
|
|
:limit.sync="queryParams.pageSize"
|
|
|
|
|
|
@pagination="getList"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2022-02-17 21:28:23 +08:00
|
|
|
|
import {listLog, delLog, getApiName} from "@/api/business/log/apilog";
|
2021-12-26 19:28:11 +08:00
|
|
|
|
|
|
|
|
|
|
export default {
|
2022-01-19 09:07:47 +08:00
|
|
|
|
name: "Apilog",
|
2022-02-17 09:57:14 +08:00
|
|
|
|
dicts: ['request_status', 'request_method'],
|
2021-12-26 19:28:11 +08:00
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
|
|
|
|
|
// 遮罩层
|
|
|
|
|
|
loading: true,
|
|
|
|
|
|
// 选中数组
|
|
|
|
|
|
ids: [],
|
|
|
|
|
|
// 非单个禁用
|
|
|
|
|
|
single: true,
|
|
|
|
|
|
// 非多个禁用
|
|
|
|
|
|
multiple: true,
|
|
|
|
|
|
// 显示搜索条件
|
|
|
|
|
|
showSearch: true,
|
|
|
|
|
|
// 总条数
|
|
|
|
|
|
total: 0,
|
|
|
|
|
|
// 日志表格数据
|
|
|
|
|
|
logList: [],
|
|
|
|
|
|
// 弹出层标题
|
|
|
|
|
|
title: "",
|
|
|
|
|
|
// 是否显示弹出层
|
|
|
|
|
|
open: false,
|
2022-02-17 21:28:23 +08:00
|
|
|
|
// 查询参数 需要给一个null值,否则input框等无法输入
|
2021-12-26 19:28:11 +08:00
|
|
|
|
queryParams: {
|
|
|
|
|
|
pageNum: 1,
|
|
|
|
|
|
pageSize: 10,
|
2022-02-17 21:28:23 +08:00
|
|
|
|
apiName: null,
|
|
|
|
|
|
url:null,
|
|
|
|
|
|
request:null,
|
|
|
|
|
|
response:null,
|
|
|
|
|
|
isSuccess:null,
|
|
|
|
|
|
method:null,
|
2021-12-26 19:28:11 +08:00
|
|
|
|
},
|
|
|
|
|
|
// 表单参数
|
|
|
|
|
|
form: {},
|
2022-01-08 02:34:57 +08:00
|
|
|
|
|
|
|
|
|
|
//json格式数据
|
|
|
|
|
|
request: {},
|
|
|
|
|
|
response: {},
|
|
|
|
|
|
|
2021-12-26 19:28:11 +08:00
|
|
|
|
// 表单校验
|
2022-01-22 00:50:13 +08:00
|
|
|
|
rules: {},
|
|
|
|
|
|
|
|
|
|
|
|
//检查查询范围
|
|
|
|
|
|
daterangeCreateTime: [],
|
|
|
|
|
|
|
|
|
|
|
|
//api名称
|
2022-02-17 09:57:14 +08:00
|
|
|
|
apiName: [],
|
2021-12-26 19:28:11 +08:00
|
|
|
|
};
|
|
|
|
|
|
},
|
|
|
|
|
|
created() {
|
|
|
|
|
|
this.getList();
|
2022-01-22 00:50:13 +08:00
|
|
|
|
this.getApiName()
|
2021-12-26 19:28:11 +08:00
|
|
|
|
},
|
2022-02-17 21:28:23 +08:00
|
|
|
|
|
2021-12-26 19:28:11 +08:00
|
|
|
|
methods: {
|
2022-01-22 00:50:13 +08:00
|
|
|
|
//获取所有api名称
|
|
|
|
|
|
getApiName() {
|
2022-02-17 09:57:14 +08:00
|
|
|
|
getApiName().then(res => {
|
|
|
|
|
|
this.apiName = res.data
|
2022-01-22 00:50:13 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2021-12-26 19:28:11 +08:00
|
|
|
|
/** 查询日志列表 */
|
|
|
|
|
|
getList() {
|
|
|
|
|
|
this.loading = true;
|
2022-01-22 00:50:13 +08:00
|
|
|
|
if (null != this.daterangeCreateTime && '' != this.daterangeCreateTime) {
|
|
|
|
|
|
this.queryParams.createTime = this.daterangeCreateTime[0];
|
|
|
|
|
|
this.queryParams.endCreateTime = this.daterangeCreateTime[1];
|
|
|
|
|
|
}
|
2021-12-26 19:28:11 +08:00
|
|
|
|
listLog(this.queryParams).then(response => {
|
|
|
|
|
|
this.logList = response.rows;
|
|
|
|
|
|
this.total = response.total;
|
|
|
|
|
|
this.loading = false;
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
2022-02-17 21:28:23 +08:00
|
|
|
|
|
2021-12-26 19:28:11 +08:00
|
|
|
|
/** 搜索按钮操作 */
|
|
|
|
|
|
handleQuery() {
|
|
|
|
|
|
this.queryParams.pageNum = 1;
|
|
|
|
|
|
this.getList();
|
|
|
|
|
|
},
|
2022-01-08 02:34:57 +08:00
|
|
|
|
/** 详细按钮操作 */
|
|
|
|
|
|
handleView(row) {
|
|
|
|
|
|
this.open = true;
|
|
|
|
|
|
this.form = row;
|
2022-01-08 13:35:33 +08:00
|
|
|
|
try {
|
|
|
|
|
|
this.request = JSON.parse(this.form.request)
|
2022-01-13 16:42:37 +08:00
|
|
|
|
this.response = JSON.parse(this.form.response)
|
|
|
|
|
|
} catch (err) {
|
2022-01-08 13:35:33 +08:00
|
|
|
|
this.open = false;
|
|
|
|
|
|
this.$notify({
|
|
|
|
|
|
title: '警告',
|
|
|
|
|
|
message: '参数不是json格式!!!',
|
|
|
|
|
|
type: 'warning'
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-01-08 02:34:57 +08:00
|
|
|
|
},
|
2021-12-26 19:28:11 +08:00
|
|
|
|
/** 重置按钮操作 */
|
|
|
|
|
|
resetQuery() {
|
2022-01-22 00:50:13 +08:00
|
|
|
|
this.daterangeCreateTime = [];
|
2022-02-17 09:57:14 +08:00
|
|
|
|
this.queryParams.createTime = null
|
|
|
|
|
|
this.queryParams.endCreateTime = null
|
2021-12-26 19:28:11 +08:00
|
|
|
|
this.resetForm("queryForm");
|
|
|
|
|
|
this.handleQuery();
|
|
|
|
|
|
},
|
|
|
|
|
|
// 多选框选中数据
|
|
|
|
|
|
handleSelectionChange(selection) {
|
|
|
|
|
|
this.ids = selection.map(item => item.id)
|
2021-12-27 17:04:56 +08:00
|
|
|
|
this.single = selection.length !== 1
|
2021-12-26 19:28:11 +08:00
|
|
|
|
this.multiple = !selection.length
|
|
|
|
|
|
},
|
2022-02-17 21:28:23 +08:00
|
|
|
|
|
2021-12-26 19:28:11 +08:00
|
|
|
|
/** 删除按钮操作 */
|
|
|
|
|
|
handleDelete(row) {
|
|
|
|
|
|
const ids = row.id || this.ids;
|
2021-12-27 17:04:56 +08:00
|
|
|
|
this.$modal.confirm('是否确认删除日志编号为"' + ids + '"的数据项?').then(function () {
|
2021-12-26 19:28:11 +08:00
|
|
|
|
return delLog(ids);
|
|
|
|
|
|
}).then(() => {
|
|
|
|
|
|
this.getList();
|
|
|
|
|
|
this.$modal.msgSuccess("删除成功");
|
2021-12-27 17:04:56 +08:00
|
|
|
|
}).catch(() => {
|
|
|
|
|
|
});
|
2021-12-26 19:28:11 +08:00
|
|
|
|
},
|
|
|
|
|
|
/** 导出按钮操作 */
|
|
|
|
|
|
handleExport() {
|
2022-02-12 22:32:00 +08:00
|
|
|
|
this.download('log/apilog/export', {
|
2021-12-26 19:28:11 +08:00
|
|
|
|
...this.queryParams
|
|
|
|
|
|
}, `log_${new Date().getTime()}.xlsx`)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
2021-12-26 22:52:28 +08:00
|
|
|
|
</script>
|