<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"
|
@keyup.enter.native="getOperationLog(1)"
|
>
|
<span class="icon iconfont icon_clear" @click="clearSearch" slot="append" v-if="fuzzySearch">
|

|
</span>
|
<span class="icon iconfont icon_search" @click="getOperationLog(1)" slot="append">
|

|
</span>
|
|
<!-- <el-button
|
slot="append"
|
icon="el-icon-search"
|
@click="getOperationLog(1)"
|
></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" value-key="proc_name">
|
<el-option label="全部" :value="''"> </el-option>
|
<el-option v-for="(item, i) in moduleOptions" :key="i" :label="item.name_zh" :value="item"> </el-option>
|
</el-select>
|
</div>
|
<div class="bar">
|
<div class="name">操作功能:</div>
|
<el-select
|
v-model="gongneng"
|
placeholder="请选择"
|
size="small"
|
:disabled="curModule == ''"
|
@change="getOperationLog(1)"
|
>
|
<!-- :disabled="gongnengOptions.length==0" -->
|
<el-option v-for="(item, i) in gongnengOptions" :key="i" :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(1)">
|
<el-option v-for="(item, i) in resultOptions" :key="i" :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"
|
:header-cell-style="{ background: '#f8f8f8', color: '#222222' }"
|
style="width: 100%"
|
border
|
>
|
<template slot="empty">
|
<img :src="png" class="empty_img" alt="" />
|
</template>
|
<el-table-column :align="'center'" label="序号" type="index" width="50"> </el-table-column>
|
<el-table-column
|
:align="'center'"
|
sortable
|
min-width="150px"
|
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="function" 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>
|
|
<el-pagination
|
@size-change="handleSizeChange"
|
@current-change="handleCurrentChange"
|
:current-page="page"
|
:page-sizes="[15, 30, 50, 100]"
|
:page-size="15"
|
layout="total, sizes, prev, pager, next, jumper"
|
:total="total"
|
>
|
</el-pagination>
|
</div>
|
</template>
|
|
<script>
|
import { deleteDate } from "@/api/system"
|
import { pad0 } from "@/api/utils"
|
import { queryOperationLog, getOperations, getModules } from "@/api/log"
|
|
export default {
|
name: "operationLog",
|
data() {
|
return {
|
png: require("../../../../public/images/syslog/没数据.png"),
|
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()
|
this.getOperationLog()
|
this.getOptions()
|
},
|
methods: {
|
handleSizeChange(val) {
|
this.pageSize = val
|
this.getOperationLog()
|
},
|
handleCurrentChange(val) {
|
this.page = val
|
this.getOperationLog()
|
},
|
moduleChange(val) {
|
this.getOperationLog(1)
|
this.gongneng = ""
|
getOperations({
|
module: val.proc_name
|
}).then((res) => {
|
this.gongnengOptions = res.data
|
})
|
},
|
getOptions() {
|
getModules().then((res) => {
|
const indexArr = []
|
res.data.forEach((item, index) => {
|
if (item.proc_name == "") {
|
indexArr.push(index)
|
}
|
})
|
if (indexArr.length != 0) {
|
indexArr.forEach((i) => {
|
res.data.splice(i)
|
})
|
}
|
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(1)
|
this.activeDateChoise = i
|
},
|
getOperationLog(typ) {
|
if (typ == 1) {
|
this.page = 1
|
}
|
queryOperationLog({
|
timeStart: this.timeStart,
|
timeEnd: this.timeEnd,
|
page: this.page,
|
pageSize: this.pageSize,
|
module: this.curModule.name_zh,
|
function: this.gongneng,
|
result: this.result,
|
fuzzySearch: this.fuzzySearch
|
}).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()) //日
|
return `${date.getFullYear()}-${month}-${day}`
|
},
|
getTimeRange(gap) {
|
var date = new Date()
|
var preDay = new Date(new Date().getTime() - gap + 24 * 60 * 60 * 1000)
|
this.timeStart = this.getTimeStr(preDay) + " 00:00:00"
|
this.timeEnd = this.getTimeStr(date) + " 23:59:59"
|
},
|
clearSearch() {
|
this.fuzzySearch = ""
|
this.getOperationLog(1)
|
}
|
}
|
}
|
</script>
|
<style lang="scss">
|
.op-log {
|
margin: 0 auto;
|
padding: 0px 8px 10px 5px;
|
border-top: 1px solid #e1e0e6;
|
background-color: rgba(242, 242, 247, 1);
|
width: 100%;
|
display: flex;
|
flex-direction: column;
|
overflow: auto;
|
.top {
|
height: 132px;
|
background: #fff;
|
border-radius: 5px;
|
.first {
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
height: 45px;
|
padding: 20px 20px 0 20px;
|
.time-option {
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
.title {
|
margin-right: 10px;
|
min-width: fit-content;
|
font-weight: bold;
|
font-size: 12px;
|
}
|
.opts {
|
display: flex;
|
justify-content: space-between;
|
.opt {
|
box-sizing: border-box;
|
border: 2px solid #efeff6;
|
min-width: fit-content;
|
width: 100px;
|
height: 36px;
|
padding: 0 15px;
|
border-radius: 4px;
|
cursor: pointer;
|
margin-right: 2px;
|
line-height: 32px;
|
font-size: 12px;
|
color: #333;
|
}
|
.opt:hover {
|
border-color: #4e94ff;
|
}
|
.opt-active {
|
color: #fff;
|
background-color: #4e94ff;
|
border-color: #4e94ff;
|
}
|
}
|
}
|
.search {
|
width: 280px;
|
height: 36px;
|
display: flex;
|
align-items: center;
|
|
.icon_clear:hover {
|
color: #4e94ff;
|
}
|
|
.input-with-select {
|
width: 100%;
|
height: 100%;
|
|
input {
|
height: 100%;
|
border-radius: 18px 0 0 18px;
|
border: 2px solid #f2f2f7;
|
border-right: none;
|
|
&:focus,
|
&:focus + .el-input-group__append {
|
border-color: #409eff;
|
}
|
}
|
|
.el-input-group__append {
|
transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
|
background-color: #fff;
|
border: 2px solid #f2f2f7;
|
border-radius: 0 18px 18px 0;
|
border-left: none;
|
}
|
}
|
|
span {
|
cursor: pointer;
|
color: rgb(47, 45, 61);
|
font-weight: 700;
|
font-size: 19px;
|
}
|
}
|
}
|
.second {
|
display: flex;
|
margin: 15px 0 20px 0;
|
padding: 0 20px;
|
.bar {
|
display: flex;
|
align-items: baseline;
|
width: fit-content;
|
margin-right: 30px;
|
min-width: 120px;
|
|
.el-select {
|
width: 200px;
|
height: 36px;
|
|
.el-input {
|
width: 100%;
|
height: 100%;
|
|
input {
|
width: 100%;
|
height: 100%;
|
border: 2px solid #f2f2f7;
|
border-radius: 20px;
|
}
|
}
|
}
|
.name {
|
margin-right: 15px;
|
min-width: fit-content;
|
font-weight: bold;
|
font-size: 12px;
|
}
|
}
|
}
|
}
|
.table {
|
margin-top: 16px;
|
border-radius: 5px;
|
padding: 12px;
|
background-color: white;
|
.empty_img {
|
margin: 80px auto;
|
width: 164px;
|
}
|
.tableBox {
|
border: none;
|
&::before,
|
&::after {
|
display: none;
|
}
|
tr {
|
td:first-child {
|
border-radius: 4px 0 0 4px;
|
}
|
td:last-child {
|
border-radius: 0 4px 4px 0;
|
}
|
&.current-row td {
|
background-color: #4e94ff !important;
|
color: #fff;
|
}
|
&:hover td {
|
background-color: rgb(242, 242, 247);
|
}
|
}
|
th {
|
padding: 0 !important;
|
height: 40px;
|
line-height: 40px;
|
border-color: #fff !important;
|
border-right: 2px solid #fff;
|
border-radius: 4px;
|
font-size: 12px;
|
background: #f2f2f7;
|
}
|
td {
|
padding: 0 !important;
|
height: 34px;
|
line-height: 34px;
|
border: none;
|
font-size: 12px;
|
}
|
}
|
}
|
.el-pagination {
|
padding: 20px 5px;
|
height: 100%;
|
box-sizing: border-box;
|
background-color: white;
|
}
|
}
|
</style>
|