<template>
|
<div class="op-log" v-loading="loading" :element-loading-text="loadingText">
|
<div class="top">
|
<div class="first">
|
<div class="time-option">
|
<div class="title">周期:</div>
|
|
<div class="opts">
|
<div
|
:class="activeDateChoise == i ? 'opt-active' : ''"
|
class="opt"
|
v-for="(item, i) in dateArr"
|
:key="i"
|
@click="choseRange(item, i)"
|
>
|
{{ item }}
|
</div>
|
</div>
|
</div>
|
<div class="search">
|
<el-input
|
placeholder="搜索"
|
v-model="fuzzySearch"
|
size="small"
|
class="input-with-select"
|
>
|
<el-button slot="append" icon="el-icon-search" @click="getOperationLog"></el-button>
|
</el-input>
|
</div>
|
</div>
|
<div class="second">
|
<div class="bar">
|
<div class="name">操作模块:</div>
|
|
<el-select
|
v-model="curModule"
|
placeholder="请选择"
|
size="small"
|
@change="moduleChange"
|
>
|
<el-option
|
label="全部"
|
:value="''"
|
>
|
</el-option>
|
<el-option
|
v-for="item in moduleOptions"
|
:key="item.proc_name"
|
:label="item.proc_name"
|
:value="item.proc_name"
|
>
|
</el-option>
|
</el-select>
|
</div>
|
<div class="bar">
|
<div class="name">操作功能:</div>
|
<el-select
|
v-model="gongneng"
|
placeholder="请选择"
|
size="small"
|
@change="getOperationLog"
|
>
|
<!-- :disabled="gongnengOptions.length==0" -->
|
<el-option
|
v-for="item in gongnengOptions"
|
:key="item.name"
|
:label="item.name"
|
:value="item.name"
|
>
|
</el-option>
|
</el-select>
|
</div>
|
<div class="bar">
|
<div class="name">操作结果:</div>
|
|
<el-select
|
v-model="result"
|
placeholder="请选择"
|
size="small"
|
@change="getOperationLog"
|
>
|
<el-option
|
v-for="item in resultOptions"
|
:key="item.value"
|
:label="item.label"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
</div>
|
</div>
|
</div>
|
<div class="table">
|
<el-table
|
class="tableBox"
|
ref="multipleTable"
|
highlight-current-row
|
:data="tableData"
|
style="width: 100%"
|
:header-cell-style="{ background: '#f8f8f8', color: '#222222' }"
|
@selection-change="handleSelectionChange"
|
>
|
<el-table-column :align="'center'" label="序号" type="index" width="50">
|
</el-table-column>
|
<el-table-column
|
:align="'center'"
|
sortable
|
min-width="98px"
|
prop="add_time"
|
label="操作时间"
|
></el-table-column>
|
<el-table-column
|
sortable
|
:align="'center'"
|
prop="userName"
|
label="用户名"
|
></el-table-column>
|
<el-table-column
|
:align="'center'"
|
sortable
|
prop="module"
|
label="操作模块"
|
></el-table-column>
|
<el-table-column
|
:align="'center'"
|
prop="procName"
|
label="操作功能"
|
></el-table-column>
|
<el-table-column
|
:align="'center'"
|
sortable
|
prop="result"
|
label="操作结果"
|
></el-table-column>
|
<el-table-column
|
:align="'center'"
|
prop="msg"
|
min-width="100px"
|
label="详细信息"
|
></el-table-column>
|
<el-table-column
|
:align="'center'"
|
sortable
|
prop="ip"
|
label="IP"
|
></el-table-column>
|
</el-table>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
import { deleteDate } from "@/api/system";
|
import { queryOperationLog, getOperations, getModules } from "@/api/log";
|
|
function pad0(i) {
|
if (i >= 0 && i <= 9) {
|
return "0" + i;
|
} else {
|
return i;
|
}
|
}
|
export default {
|
data() {
|
return {
|
loading: false,
|
loadingText: "",
|
input3: "",
|
tableData: [],
|
dateArr: ["今日", "近三天", "近七天", "近一个月", "近六个月"],
|
moduleOptions: [],
|
gongnengOptions: [],
|
resultOptions: [
|
{
|
value: "",
|
label: "全部",
|
},
|
{
|
value: "成功",
|
label: "成功",
|
},
|
{
|
value: "失败",
|
label: "失败",
|
},
|
],
|
value: "",
|
page: 1,
|
pageSize: 15,
|
activeDateChoise: 0,
|
gongneng: "",
|
result: "",
|
curModule: "",
|
timeStart: "",
|
timeEnd: "",
|
fuzzySearch: "",
|
total:0,
|
};
|
},
|
mounted() {
|
this.getTimeRange(24 * 60 * 60 * 1000);
|
this.getOperationLog();
|
this.getOptions();
|
},
|
methods: {
|
gongnengChange(val) {},
|
moduleChange(val) {
|
this.getOperationLog()
|
this.gongneng=""
|
getOperations({
|
module: this.curModule,
|
}).then((res) => {
|
this.gongnengOptions = res.data;
|
});
|
},
|
getOptions() {
|
getModules().then((res) => {
|
this.moduleOptions = res.data;
|
});
|
},
|
choseRange(item, i) {
|
switch (item) {
|
case "今日":
|
this.getTimeRange(24 * 60 * 60 * 1000);
|
break;
|
case "近三天":
|
this.getTimeRange(24 * 60 * 60 * 1000 * 3);
|
break;
|
case "近七天":
|
this.getTimeRange(24 * 60 * 60 * 1000 * 7);
|
break;
|
case "近一个月":
|
this.getTimeRange(24 * 60 * 60 * 1000 * 30);
|
break;
|
case "近六个月":
|
this.getTimeRange(24 * 60 * 60 * 1000 * 30 * 6);
|
break;
|
default:
|
break;
|
}
|
this.getOperationLog();
|
this.activeDateChoise = i;
|
},
|
getOperationLog(timeStart, timeEnd) {
|
const data= {
|
timeStart: this.timeStart,
|
timeEnd: this.timeEnd,
|
page: this.page,
|
pageSize: this.pageSize,
|
module: this.curModule,
|
function: this.gongneng,
|
result: this.result,
|
fuzzySearch: this.fuzzySearch,
|
}
|
queryOperationLog(data).then((res) => {
|
this.tableData = res.data.logs;
|
this.total = res.data.total
|
});
|
},
|
getTimeStr(date) {
|
var month = pad0(date.getMonth() + 1); //月
|
var day = pad0(date.getDate()); //日
|
var hour = pad0(date.getHours()); //时
|
var minute = pad0(date.getMinutes()); //分
|
var second = pad0(date.getSeconds()); //秒
|
return `${date.getFullYear()}-${month}-${day} ${hour}:${minute}:${second}`;
|
},
|
getTimeRange(gap) {
|
var date = new Date(); //当前时间
|
var preDay = new Date(new Date().getTime() - gap);
|
this.timeStart = this.getTimeStr(preDay)
|
this.timeEnd = this.getTimeStr(date)
|
},
|
},
|
};
|
</script>
|
<style lang="scss">
|
.op-log {
|
margin: 0 auto;
|
padding: 10px 8px 10px 5px;
|
|
background-color: rgba(248, 248, 248, 1);
|
width: 100%;
|
display: flex;
|
flex-direction: column;
|
.top {
|
height: 100px;
|
background: #fff;
|
border-radius: 5px;
|
.first {
|
display: flex;
|
justify-content: space-between;
|
height: 45px;
|
padding: 0 20px;
|
.time-option {
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
// padding-left: 20px;
|
.title {
|
margin-right: 20px;
|
}
|
.opts {
|
display: flex;
|
justify-content: space-between;
|
.opt {
|
width: fit-content;
|
height: 32px;
|
padding: 0 15px;
|
// background: aquamarine;
|
border-radius: 4px;
|
cursor: pointer;
|
margin-right: 20px;
|
line-height: 32px;
|
font-size: 14px;
|
}
|
.opt:hover {
|
background-color: rgba(61, 104, 225, 1);
|
color: #fff;
|
}
|
.opt-active {
|
color: #fff;
|
background-color: rgba(61, 104, 225, 1);
|
}
|
}
|
}
|
.search {
|
display: flex;
|
align-items: center;
|
}
|
}
|
.second {
|
display: flex;
|
margin: 10px 0;
|
.bar {
|
display: flex;
|
align-items: baseline;
|
width: fit-content;
|
padding-left: 20px;
|
.name {
|
margin-right: 5px;
|
}
|
}
|
}
|
}
|
.table {
|
margin-top: 16px;
|
border-radius: 5px;
|
padding: 12px;
|
background-color: white;
|
.tableBox {
|
th {
|
padding: 0 !important;
|
height: 40px;
|
line-height: 40px;
|
}
|
td {
|
padding: 0 !important;
|
height: 34px;
|
line-height: 34px;
|
}
|
}
|
}
|
}
|
</style>
|