吴雨瞳添加了注释

master
wyt 4 months ago
parent 2e46ec9740
commit 19ef61e09c

@ -1,33 +1,46 @@
<template>
<!-- 操作日志日志主卡片容器 -->
<el-card class="main-card">
<!-- 页面标题使用当前路由名称 -->
<div class="title">{{ this.$route.name }}</div>
<!-- 操作按钮区域 -->
<div class="operation-container">
<!-- 批量删除删除按钮当没有选中日志时禁用 -->
<el-button
type="danger"
size="small"
icon="el-icon-delete"
:disabled="this.logIds.length == 0"
@click="isDelete = true">
type="danger"
size="small"
icon="el-icon-delete"
:disabled="this.logIds.length == 0"
@click="isDelete = true">
批量删除
</el-button>
<!-- 搜索区域居右显示 -->
<div style="margin-left: auto">
<!-- 搜索输入框支持回车搜索 -->
<el-input
v-model="keywords"
prefix-icon="el-icon-search"
size="small"
placeholder="请输入模块名或描述"
style="width: 200px"
@keyup.enter.native="searchLogs" />
v-model="keywords"
prefix-icon="el-icon-search"
size="small"
placeholder="请输入模块名或描述"
style="width: 200px"
@keyup.enter.native="searchLogs" />
<!-- 搜索按钮 -->
<el-button type="primary" size="small" icon="el-icon-search" style="margin-left: 1rem" @click="searchLogs">
搜索
</el-button>
</div>
</div>
<!-- 操作日志表格加载时显示loading状态支持选择行 -->
<el-table @selection-change="selectionChange" v-loading="loading" :data="logs">
<!-- 选择列 -->
<el-table-column type="selection" width="55" align="center" />
<!-- 系统模块列 -->
<el-table-column prop="optModule" label="系统模块" align="center" width="120" />
<!-- 操作类型列 -->
<el-table-column width="100" prop="optType" label="操作类型" align="center" />
<!-- 操作描述列 -->
<el-table-column prop="optDesc" label="操作描述" align="center" width="150" />
<!-- 请求方式列使用标签显示不同类型 -->
<el-table-column prop="requetMethod" label="请求方式" align="center" width="100">
<template slot-scope="scope" v-if="scope.row.requestMethod">
<el-tag :type="tagType(scope.row.requestMethod)">
@ -35,36 +48,45 @@
</el-tag>
</template>
</el-table-column>
<!-- 操作人员列 -->
<el-table-column prop="nickname" label="操作人员" align="center" />
<!-- 登录IP列 -->
<el-table-column prop="ipAddress" label="登录ip" align="center" width="130" />
<!-- 登录地址列 -->
<el-table-column prop="ipSource" label="登录地址" align="center" width="150" />
<!-- 操作日期列使用时间格式化过滤器 -->
<el-table-column prop="createTime" label="操作日期" align="center" width="190">
<template slot-scope="scope">
<i class="el-icon-time" style="margin-right: 5px" />
{{ scope.row.createTime | dateTime }}
</template>
</el-table-column>
<!-- 操作列查看和删除 -->
<el-table-column label="操作" align="center" width="150">
<template slot-scope="scope">
<!-- 查看按钮 -->
<el-button size="mini" type="text" slot="reference" @click="check(scope.row)">
<i class="el-icon-view" /> 查看
</el-button>
<!-- 删除确认按钮 -->
<el-popconfirm title="确定删除吗?" style="margin-left: 10px" @confirm="deleteLog(scope.row.id)">
<el-button size="mini" type="text" slot="reference"> <i class="el-icon-delete" /> 删除 </el-button>
</el-popconfirm>
</template>
</el-table-column>
</el-table>
<!-- 分页组件 -->
<el-pagination
class="pagination-container"
background
@size-change="sizeChange"
@current-change="currentChange"
:current-page="current"
:page-size="size"
:total="count"
:page-sizes="[10, 20]"
layout="total, sizes, prev, pager, next, jumper" />
class="pagination-container"
background
@size-change="sizeChange"
@current-change="currentChange"
:current-page="current"
:page-size="size"
:total="count"
:page-sizes="[10, 20]"
layout="total, sizes, prev, pager, next, jumper" />
<!-- 查看详情对话框 -->
<el-dialog :visible.sync="isCheck" width="40%">
<div class="dialog-title-container" slot="title"><i class="el-icon-more" />详细信息</div>
<el-form ref="form" :model="optLog" label-width="100px" size="mini">
@ -93,6 +115,7 @@
</el-form-item>
</el-form>
</el-dialog>
<!-- 批量删除确认对话框 -->
<el-dialog :visible.sync="isDelete" width="30%">
<div class="dialog-title-container" slot="title"><i class="el-icon-warning" style="color: #ff9900" />提示</div>
<div style="font-size: 1rem">是否删除选中项</div>
@ -106,100 +129,121 @@
<script>
export default {
//
created() {
// store
this.current = this.$store.state.pageState.operationLog
//
this.listLogs()
},
data() {
return {
loading: true,
logs: [],
logIds: [],
keywords: null,
current: 1,
size: 10,
count: 0,
isCheck: false,
isDelete: false,
optLog: {}
loading: true, //
logs: [], //
logIds: [], // ID
keywords: null, //
current: 1, //
size: 10, //
count: 0, //
isCheck: false, //
isDelete: false, //
optLog: {} //
}
},
methods: {
// ID
selectionChange(logs) {
this.logIds = []
logs.forEach((item) => {
this.logIds.push(item.id)
})
},
// 1
searchLogs() {
this.current = 1
// store
this.$store.commit('updateOperationLogPageState', this.current)
//
this.listLogs()
},
//
sizeChange(size) {
this.size = size
this.listLogs()
},
// store
currentChange(current) {
this.current = current
this.$store.commit('updateOperationLogPageState', current)
this.listLogs()
},
//
listLogs() {
this.axios
.get('/api/admin/operation/logs', {
params: {
current: this.current,
size: this.size,
keywords: this.keywords
}
})
.then(({ data }) => {
this.logs = data.data.records
this.count = data.data.count
this.loading = false
})
.get('/api/admin/operation/logs', {
params: {
current: this.current,
size: this.size,
keywords: this.keywords
}
})
.then(({ data }) => {
this.logs = data.data.records //
this.count = data.data.count //
this.loading = false //
})
},
//
deleteLog(id) {
var param = {}
// ID
if (id != null) {
param = { data: [id] }
} else {
// ID
param = { data: this.logIds }
}
this.axios.delete('/api/admin/operation/logs', param).then(({ data }) => {
if (data.flag) {
//
this.$notify.success({
title: '成功',
message: data.message
})
//
this.listLogs()
} else {
//
this.$notify.error({
title: '失败',
message: data.message
})
}
//
this.isDelete = false
})
},
//
check(optLog) {
//
this.optLog = JSON.parse(JSON.stringify(optLog))
//
this.isCheck = true
}
},
computed: {
//
tagType() {
return function (type) {
switch (type) {
case 'GET':
return ''
return '' //
case 'POST':
return 'success'
return 'success' // 绿
case 'PUT':
return 'warning'
return 'warning' //
case 'DELETE':
return 'danger'
return 'danger' //
}
}
}
@ -211,4 +255,4 @@ export default {
label {
font-weight: bold !important;
}
</style>
</style>
Loading…
Cancel
Save