add:日志清除按钮

This commit is contained in:
zhangzhiqiang
2023-03-01 14:36:30 +08:00
parent 0e177b00a7
commit 83424bb995
5 changed files with 94 additions and 1 deletions

View File

@@ -15,4 +15,12 @@ export function labelsValues(type) {
})
}
export default { getLogData, labelsValues }
export function clearLogs(param) {
return request({
url: '/api/esLog/clearLogs',
method: 'delete',
data: param
})
}
export default { getLogData, labelsValues, clearLogs }

View File

@@ -118,6 +118,14 @@
:step="1"
/>
</el-form-item>
<el-form-item label="总条数">
<el-input
v-model="total"
size="small"
disabled
style="width: 110px"
/>
</el-form-item>
<el-form-item>
<el-dropdown split-button type="primary" size="mini" @click="queryData">
查询
@@ -126,6 +134,9 @@
</el-dropdown-menu>
</el-dropdown>
</el-form-item>
<el-form-item>
<el-button @click="clearLogs">清空日志</el-button>
</el-form-item>
</el-form>
</div>
<!-- <div style="margin: 3px; min-height: 80vh;">
@@ -180,6 +191,7 @@ let queryParam = {
filterSql: true,
isRequest: true,
page: null,
total: 0,
size: 20
}
export default {
@@ -308,6 +320,7 @@ export default {
logOperation.getLogData(queryParam).then(res => {
this.showEmpty = false
this.total = res.total
// 清空
this.logs = []
for (const j in res.records) { // 用push的方式将所有日志数组添加进去
@@ -315,6 +328,50 @@ export default {
}
})
},
clearLogs() {
var message = '您确定要清空'
if (this.system !== '' && this.system !== null) {
message += '标签为:' + this.system + ' '
}
message += '10天前的日志吗 ?'
this.$confirm(message, '确认信息', {
distinguishCancelAndClose: true,
confirmButtonText: '确定',
cancelButtonText: '取消'
})
.then(() => {
// 清空查询数据
this.clearParam()
queryParam.logLevel = this.logLevelValue
const time = new Date()
if (this.timeZoneValue !== '') {
queryParam.startTime = new Date(((time.getTime() - this.timeZoneValue)))
}
if (this.timeRange !== '' && this.timeRange.length > 0) {
queryParam.startTime = this.timeRange[0]
queryParam.endTime = this.timeRange[1]
}
queryParam.message = this.message.replace(/^\s*|\s*$/g, '')
queryParam.traceId = this.traceId
queryParam.system = this.system
logOperation.clearLogs(queryParam).then(res => {
this.queryData()
this.$message({
type: 'info',
message: '清除成功'
})
})
})
.catch(action => {
this.$message({
type: 'info',
message: action === 'cancel'
? '已取消'
: '已取消'
})
})
},
changetype() {
},