1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<template>
<div class="container">
<direct-search
ref="form"
:label-position="'right'"
:forms="searchList"
:style="{ textAlign: 'left' }"
@handleSearch="handleFormSearch"
/>
<el-table-self
ref="table"
:table-data="tableData"
:columns="columns"
:list-loading="listLoading"
:current-page="pageIndex"
:total-count="total"
:page-sizes="pageSizes"
:page-size="pageSize"
:sortChange="sortChange"
@pageSizeChange="handleSizeChange"
@currentPageChange="handleCurrentChange"
/>
</div>
</template>
<script>
import { getLogPage } from "@/api/user";
import directSearch from "@/components/FormComponents/directSearch";
import elTableSelf from "@/components/TabComponents/index";
import paginationMixin from "@/components/TabComponents/mixin";
export default {
name: "Log",
mixins: [paginationMixin],
components: {
elTableSelf,
directSearch,
},
data() {
return {
formEdit: {},
title: "",
// 查询列表
searchList: [
{
label: "操作名称",
type: "input",
prop: "title",
placeholder: "请输入操作名称",
},
{
label: "请求方式",
type: "input",
prop: "method",
placeholder: "请输入请求方式",
},
{
label: "参数",
type: "input",
prop: "params",
placeholder: "请输入参数",
},
{
type: "button",
icon: "el-icon-search",
value: "查询",
},
],
tableData: [],
listLoading: false,
columns: [
{
label: "操作名称",
value: "title",
minWidth: 220,
},
{
label: "用户IP",
value: "remoteAddr",
minWidth: 180,
},
{
label: "操作人",
value: "createBy",
minWidth: 180,
},
{
label: "代理",
value: "userAgent",
minWidth: 220,
},
{
label: "请求路径",
value: "requestUri",
minWidth: 150,
},
{
label: "请求方式",
value: "method",
minWidth: 100,
},
{
label: "请求参数",
value: "params",
minWidth: 150,
},
{
label: "异常",
value: "exception",
minWidth: 150,
},
{
label: "操作时间",
value: "createTime",
minWidth: 150,
sortable: "custom",
},
],
cacheForm: {},
};
},
methods: {
sortChange({ prop, order }) {
const asc = order ? (order === "ascending" ? true : false) : "";
const column = order ? prop : "";
if (column) {
this.handleSearch({
"orders[0].asc": asc,
"orders[0].column": this.$handle.toUnderline(column),
});
} else {
delete this.cacheForm["orders[0].asc"];
delete this.cacheForm["orders[0].column"];
this.handleSearch();
}
},
// 查询
handleFormSearch(form) {
this.pageIndex = 1;
this.handleSearch(form);
},
// 数据page
handleSearch(form = {}) {
this.cacheForm = Object.assign(this.cacheForm, form);
this.listLoading = true;
const params = Object.assign({}, this.cacheForm);
for (let key in params) {
if (params[key] === "") {
delete params[key];
}
}
params.current = this.pageIndex;
params.size = this.pageSize;
getLogPage(params).then((res) => {
if (res.code === 1) {
const d = res.data;
let total = 0;
let result = [];
if (d && d.total > 0) {
result = d.records;
total = d.total;
}
this.tableData = result;
this.total = total;
this.listLoading = false;
}
});
},
},
mounted() {
this.handleFormSearch();
},
};
</script>
<style lang="scss"></style>