interfaceLog.vue
12 KB
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
<template>
<div class="interfacel">
<el-form
:model="queryConfig"
:rules="rules"
ref="queryConfig"
label-width="100px"
class="demo-queryConfig"
>
<el-row :gutter="10">
<el-col :span="4">
<el-form-item label="接口名:" prop="name">
<el-input v-model="queryConfig.interfaceName"></el-input>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="标志:" prop="">
<el-select v-model="queryConfig.flag" placeholder="请选择">
<el-option
v-for="item in optionsFlag"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="Url:" prop="">
<el-input v-model="queryConfig.url" />
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="请求方式:" prop="">
<el-input v-model="queryConfig.method" />
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="耗时:" prop="totalMilliseconds">
<el-input v-model="queryConfig.totalMilliseconds" />
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="请求:" prop="">
<el-input v-model="queryConfig.request" />
</el-form-item>
</el-col>
<el-col :span="3.5">
<el-form-item label="回复:" prop="">
<el-input v-model="queryConfig.response" />
</el-form-item>
</el-col>
<el-col :span="3.5">
<el-form-item label="开始时间:" prop="">
<el-date-picker
v-model="form.startTime"
type="datetime"
placeholder="选择日期时间"
/>
</el-form-item>
</el-col>
<el-col :span="4">
<el-form-item label="结束时间:" prop="">
<el-date-picker
v-model="form.endTime"
type="datetime"
placeholder="选择日期时间"
/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="" prop="">
<el-button
icon="el-icon-search"
class="T1"
@click="btnAction('queryConfig')"
type="primary"
>查询</el-button
>
<el-button class="T1" @click="details()">查询情况</el-button>
<!-- <el-button class="T1" @click="goodsTypeModify()" disabled
>导出</el-button
> -->
</el-form-item>
</el-col>
</el-row>
</el-form>
<div class="table">
<el-table
:data="tableData"
style="width: 100%"
height="700"
@selection-change="handleSelectionChange"
:header-cell-style="{ background: '#d9ebfe', color: '#000000' }"
>
<el-table-column
type="selection"
align="center"
width="55"
></el-table-column>
<el-table-column prop="id" label="内置ID" width="100">
</el-table-column>
<el-table-column
prop="interfaceName"
label="接口名"
width="180"
:show-overflow-tooltip="true"
>
</el-table-column>
<el-table-column
prop="url"
width="180"
label="URL"
:show-overflow-tooltip="true"
>
</el-table-column>
<el-table-column prop="method" label="请求方式"> </el-table-column>
<el-table-column prop="totalMilliseconds" label="耗时">
</el-table-column>
<el-table-column prop="request" label="请求"> </el-table-column>
<el-table-column
prop="response"
label="回复"
width="200"
:show-overflow-tooltip="true"
>
</el-table-column>
<el-table-column prop="flag" label="标志"> </el-table-column>
<el-table-column prop="requestIp" label="请求者IP"> </el-table-column>
<el-table-column prop="remark" label="备注"> </el-table-column>
<el-table-column prop="created" label="开始时间"> </el-table-column>
<el-table-column prop="createdBy" label="创建人"> </el-table-column>
</el-table>
<div class="pagination-container">
<el-pagination
background
layout="prev, pager, next"
:current-page="queryConfig.currentPage"
:page-size="queryConfig.pageSize"
:total="total"
@current-change="handleCurrentChange"
>
</el-pagination>
</div>
</div>
<el-dialog title="接口日志详情" :visible.sync="dialogFormVisible">
<div class="container" v-for="(item, index) in detailsData" :key="index">
<div class="box">
<div class="inner-left">内部id:</div>
<div class="inner-right">{{ item.id }}</div>
</div>
<div class="box">
<div class="inner-left">接口名:</div>
<div class="inner-right">{{ item.interfaceName }}</div>
</div>
<div class="box">
<div class="inner-left">耗时:</div>
<div class="inner-right">{{ item.totalMilliseconds }}</div>
</div>
<div class="box">
<div class="inner-left">标志:</div>
<div class="inner-right">{{ item.flag }}</div>
</div>
<div class="box">
<div class="inner-left">开始时间:</div>
<div class="inner-right">{{ item.created }}</div>
</div>
<div class="box">
<div class="inner-left">请求者IP:</div>
<div class="inner-right">{{ item.requestIp }}</div>
</div>
<div class="box1">
<div class="inner-left">请求:</div>
<div class="inner-right">
<el-input
type="textarea"
:autosize="{ minRows: 2, maxRows: 4 }"
placeholder="请输入内容"
v-model="item.request"
/>
</div>
</div>
<div class="box1">
<div class="inner-left">回复:</div>
<div class="inner-right">
<el-input
type="textarea"
:autosize="{ minRows: 2, maxRows: 4 }"
placeholder="请输入内容"
v-model="item.response"
/>
</div>
</div>
<div class="box1">
<div class="inner-left">内容:</div>
<div class="inner-right">
<el-input
type="textarea"
:autosize="{ minRows: 2, maxRows: 4 }"
placeholder="请输入内容"
v-model="item.content"
/>
</div>
</div>
<div class="box1">
<div class="inner-left">备注:</div>
<div class="inner-right">
<el-input
type="textarea"
:autosize="{ minRows: 2, maxRows: 4 }"
placeholder="请输入内容"
v-model="item.remark"
/>
</div>
</div>
</div>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = false">取 消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
GetDictWithDetailsLangs,
GetInterfaceLog,
GetInterfaceLogById,
} from "@/api/logManage/index";
export default {
data() {
return {
tableData: [],
queryConfig: {
currentPage: 1,
pageSize: 20,
interfaceName: "",
flag: "",
url: "",
method: "",
totalMilliseconds: 0,
request: "",
response: "",
},
rules: {
totalMilliseconds: [
{ required: true, message: "该字段不能为空", trigger: "blur" },
{ validator: this.validateNumber, trigger: "blur" },
],
},
total: 0,
form: {
startTime: this.$moment()
.subtract(3, "days")
.format("YYYY-MM-DD 00:00:00"),
endTime: this.$moment().add(1, "days").format("YYYY-MM-DD 23:59:59"),
},
optionsFlag: [
{
value: "",
label: "全部",
},
],
dialogFormVisible: false,
multipleSelection: [],
detailsData: [],
};
},
created() {
this.getFlag("LogLevelFlag");
this.getTableList();
},
methods: {
//查询按钮
btnAction(queryConfig) {
this.$refs[queryConfig].validate((valid) => {
if (valid) {
this.getTableList();
} else {
return false;
}
});
},
//类型校验
validateNumber(rule, value, callback) {
if (value !== "" && isNaN(value)) {
return callback(new Error("请输入有效的数字"));
}
callback(); // 验证通过
},
getFlag(data) {
let params = { Code: data };
GetDictWithDetailsLangs(params).then((response) => {
response.data.dictDetails.forEach((x) => {
this.optionsFlag.push({ value: x.code, label: x.name });
});
});
},
//表格数据
getTableList() {
const params = {
pageNumber: this.queryConfig.currentPage,
perPageCount: this.queryConfig.pageSize,
queryConfig: {
interfaceName: this.queryConfig.interfaceName,
url: this.queryConfig.url,
request: this.queryConfig.request,
response: this.queryConfig.response,
method: this.queryConfig.method,
flag: this.queryConfig.flag,
content: "",
totalMilliseconds: this.queryConfig.totalMilliseconds,
remark: "",
begin: this.form.startTime,
end: this.form.endTime,
},
};
this.listLoading = true;
GetInterfaceLog(params).then((response) => {
this.total = response.data.totalCount;
this.tableData = response.data.data;
this.listLoading = false;
});
},
// 详情
details() {
if (this.multipleSelection.length == 0) {
this.$alert("请选择一条数据!", "标题名称", {
confirmButtonText: "确定",
});
} else {
this.detailsData = [];
let params = {
id: this.multipleSelection[0].id,
};
GetInterfaceLogById(params).then((response) => {
this.detailsData.push(response.data);
});
this.dialogFormVisible = true;
}
},
//获取表格行数据
handleSelectionChange(val) {
this.multipleSelection = val;
},
//分页
handleCurrentChange(page) {
this.queryConfig.currentPage = page;
this.getTableList();
},
},
};
</script>
<style>
.interfacel {
width: 100%;
}
.table {
border: 1px solid #e5e9f2;
}
.pagination-container {
text-align: center; /* 使分页组件靠右 */
margin-top: 20px; /* 添加顶部间距 */
}
.container {
width: 100%; /* 大 div 宽度 */
display: flex; /* 使用 Flexbox 布局 */
flex-wrap: wrap; /* 允许换行 */
padding: 10px; /* 内边距 */
box-sizing: border-box; /* 包含内边距在内 */
}
.box {
width: 50%; /* 小 div 宽度为 50% */
height: 50px; /* 小 div 高度 */
margin: 5px 0; /* 上下外边距 */
display: flex; /* 嵌套使用 Flexbox */
}
.box1 {
width: 50%; /* 小 div 宽度为 50% */
height: 100px; /* 小 div 高度 */
margin: 5px 0; /* 上下外边距 */
display: flex; /* 嵌套使用 Flexbox */
}
.inner-left {
width: 40%; /* 内部左侧 div 宽度为 50% */
height: 100%; /* 高度为 100% */
display: flex; /* 使用 Flexbox */
justify-content: flex-end; /* 内容靠右 */
align-items: center; /* 垂直居中 */
padding-right: 5px; /* 右侧内边距 */
}
.inner-right {
width: 50%; /* 内部右侧 div 宽度为 50% */
height: 100%; /* 高度为 100% */
display: flex; /* 使用 Flexbox */
justify-content: flex-start; /* 内容靠左 */
align-items: center; /* 垂直居中 */
padding-left: 5px; /* 左侧内边距 */
}
.demo-ruleForm {
margin-top: 20px;
}
</style>