审计列表页提交

This commit is contained in:
stt
2025-10-11 14:37:58 +08:00
parent 0bb7577a92
commit a7e3cebb6f
3 changed files with 335 additions and 96 deletions

View File

@@ -1,10 +1,16 @@
<template> <template>
<div class="default-main"> <div class="default-main">
<div v-show="flg">
<TableHeader datePicker showExport :showReset="false" ref="TableHeaderRef"> <TableHeader datePicker showExport :showReset="false" ref="TableHeaderRef">
<template v-slot:select> <template v-slot:select>
<el-form :inline="true" :model="formData" label-width="90px" class=""> <el-form :inline="true" label-width="90px" class="">
<el-form-item label="用户名:"> <el-form-item label="用户名:">
<el-select v-model="formData.loginName" placeholder="用户名" clearable filterable> <el-select
v-model="tableStore.table.params.loginName"
placeholder="用户名"
clearable
filterable
>
<el-option <el-option
v-for="item in userName" v-for="item in userName"
:key="item.id" :key="item.id"
@@ -14,7 +20,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="事件类型:"> <el-form-item label="事件类型:">
<el-select v-model="formData.type" placeholder="事件类型" clearable> <el-select v-model="tableStore.table.params.type" placeholder="事件类型" clearable>
<el-option <el-option
v-for="item in eventType" v-for="item in eventType"
:key="item.id" :key="item.id"
@@ -24,7 +30,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="操作类型:"> <el-form-item label="操作类型:">
<el-select v-model="formData.operateType" placeholder="操作类型" clearable> <el-select v-model="tableStore.table.params.operateType" placeholder="操作类型" clearable>
<el-option <el-option
v-for="item in operationType" v-for="item in operationType"
:key="item.value" :key="item.value"
@@ -34,7 +40,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="操作结果:"> <el-form-item label="操作结果:">
<el-select v-model="formData.result" placeholder="操作结果" clearable> <el-select v-model="tableStore.table.params.result" placeholder="操作结果" clearable>
<el-option <el-option
v-for="item in resultList" v-for="item in resultList"
:key="item.id" :key="item.id"
@@ -46,11 +52,60 @@
</el-form> </el-form>
</template> </template>
<template #operation> <template #operation>
<!-- <el-button type="primary" @click="backups">文件备份</el-button> <el-button type="primary" @click="backups">文件备份</el-button>
<el-button type="primary" @click="details">统计</el-button> --> <el-button type="primary" @click="details">统计</el-button>
</template> </template>
</TableHeader> </TableHeader>
<Table ref="tableRef" /> <Table ref="tableRef" @sort-change="handleSortChange" />
</div>
<div v-if="!flg">
<Statistics @back="onSubmit" ref="statistics" />
<!-- <TableHeader datePicker showExport :showReset="false" ref="TableHeaderRef">
<template v-slot:select>
<el-form :inline="true" label-width="90px" class="">
<el-form-item label="用户名:">
<el-select
v-model="tableStore.table.params.loginName"
placeholder="用户名"
clearable
filterable
>
<el-option
v-for="item in userName"
:key="item.id"
:label="item.loginName"
:value="item.loginName"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="事件类型:">
<el-select v-model="tableStore.table.params.type" placeholder="事件类型" clearable>
<el-option
v-for="item in eventType"
:key="item.id"
:label="item.label"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="操作类型:">
<el-select v-model="tableStore.table.params.operateType" placeholder="操作类型" clearable>
<el-option
v-for="item in operationType"
:key="item.value"
:label="item.value"
:value="item.value"
></el-option>
</el-select>
</el-form-item>
</el-form>
</template>
<template #operation>
<el-button type="primary" @click="back">返回</el-button>
</template>
</TableHeader>
<Table ref="tableRef_1" /> -->
</div>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@@ -66,8 +121,9 @@ import {
recoverLogFile, recoverLogFile,
getMemoInfo, getMemoInfo,
getSysConfig getSysConfig
} from '/@/api/auditManage/auditList' } from '@/api/auditManage/auditList'
// import { ElMessage } from 'element-ui' import { ElMessage } from 'element-plus'
import Statistics from './statistics.vue'
defineOptions({ defineOptions({
name: 'admin/BusinessAdministrator/Audit/Operations/Management' name: 'admin/BusinessAdministrator/Audit/Operations/Management'
@@ -80,51 +136,20 @@ interface UserInfo {
const userName = ref<UserInfo[]>([]) const userName = ref<UserInfo[]>([])
const TableHeaderRef = ref() const TableHeaderRef = ref()
// 响应式数据定义
const formData = reactive({
loginName: '', //用户名
type: '', //事件类型
operateType: '', //操作类型
result: null,
searchBeginTime: '', //开始
searchEndTime: '', //结束
sortBy: '',
sortName: '',
orderBy: '',
pageNum: 1,
pageSize: 100
})
const formLine = reactive({
loginName: '', //用户名
type: '', //事件类型
operateType: '', //操作类型
searchBeginTime: '', //开始
searchEndTime: '', //结束
sortBy: '',
sortName: '',
orderBy: '',
pageNum: 1,
pageSize: 20
})
// 其他响应式数据 // 其他响应式数据
const loading = ref(false) const loading = ref(false)
const loading1 = ref(false) const statistics = ref()
const view = ref(false)
const view1 = ref(false)
const flg = ref(true) const flg = ref(true)
const showMqtt = ref(false) const showMqtt = ref(false)
const zoom = ref('') //图表焦点校验 const zoom = ref('') //图表焦点校验
const vh = ref(undefined)
const item = ref(['', ''])
const item1 = ref(['', ''])
const resultList = ref([ const resultList = ref([
{ id: 1, label: '成功' }, { id: 1, label: '成功' },
{ id: 0, label: '失败' } { id: 0, label: '失败' }
]) ])
const datamock = ref([])
const statisticsData = ref([])
const eventType = ref([ const eventType = ref([
{ {
id: 0, id: 0,
@@ -146,35 +171,113 @@ const operationType = ref([
{ id: 8, value: '下载' }, { id: 8, value: '下载' },
{ id: 9, value: '越权访问' } { id: 9, value: '越权访问' }
]) //操作类型 ]) //操作类型
const timeFlag = ref('')
const total = ref(undefined)
const statisticsTotal = ref(undefined) const statisticsTotal = ref(undefined)
const tableStore: any = new TableStore({ const tableStore: any = new TableStore({
url: '/system-boot/audit/getAuditLog', url: '/system-boot/audit/getAuditLog',
method: 'POST', method: 'POST',
column: [ column: [
{ field: 'userName', title: '登录用户' }, { field: 'time', title: '操作时间', sortable: true },
{ field: 'ip', title: '登录ip' }, { field: 'userName', title: '操作人员' },
{ field: 'time', title: '登录时间' } { field: 'operate', title: '操作类型', sortable: true },
{ field: 'describe', title: '事件描述' },
{ field: 'type', title: '事件类型', sortable: true },
{ field: 'result', title: '操作结果', sortable: true },
{ field: 'ip', title: '操作IP' },
{ field: 'level', title: '事件等级', sortable: true }
] ]
}) })
tableStore.table.params.loginName = '' tableStore.table.params.loginName = ''
tableStore.table.params.type = '' tableStore.table.params.type = ''
tableStore.table.params.operateType = '' tableStore.table.params.operateType = ''
tableStore.table.params.result = '' tableStore.table.params.result = null
tableStore.table.params.sortBy = ''
tableStore.table.params.sortName = ''
tableStore.table.params.orderBy = ''
tableStore.table.params.pageSize = 100
provide('tableStore', tableStore) provide('tableStore', tableStore)
onMounted(() => { onMounted(() => {
tableStore.index() // tableStore.index()
search() search()
onSubmit()
}) })
// 排序
const handleSortChange = ({ column, order }: { column: TableColumn; order: 'asc' | 'desc' | null }) => {
tableStore.table.params.sortName = column?.title
tableStore.table.params.sortBy =
column?.property == 'operate' ? 'operate_type' : column?.property == 'time' ? 'create_time' : column?.property
tableStore.table.params.orderBy = order
tableStore.table.params.pageNum = 1
// tableStore.index()
onSubmit()
}
//下拉框查询 //下拉框查询
const search = () => { const search = () => {
getAllUserList().then(res => { getAllUserList().then(res => {
userName.value = res.data userName.value = res.data
}) })
} }
// 统计
const details = () => {
flg.value = false
nextTick(() => {
statistics.value.tableStore.index()
})
}
// 查询
const onSubmit = async () => {
flg.value = true
await tableStore.index()
getLogSize()
}
// 查询日志大小
const getLogSize = () => {
getMemoInfo({}).then(res => {
getSysConfig().then(re => {
if (res.data > re.data.logSize) {
ElMessage({
showClose: true,
duration: 0,
message: '日志表存储空间已超过' + re.data.logSize + '(M)请及时备份清理!',
type: 'warning'
})
}
})
})
}
// 备份
const backups = () => {
loading.value = true
logFileWriter({}).then(res => {})
setTimeout(() => {
ElMessage({
type: 'success',
message: '文件备份成功'
})
loading.value = false
}, 50000)
}
// 恢复
const restore = () => {
loading.value = true
recoverLogFile({}).then(res => {})
setTimeout(() => {
ElMessage({
type: 'success',
message: '文件恢复成功'
})
loading.value = false
}, 50000)
}
</script> </script>

View File

@@ -0,0 +1,135 @@
<template>
<TableHeader datePicker showExport :showReset="false" ref="TableHeaderRef">
<template v-slot:select>
<el-form :inline="true" label-width="90px" class="">
<el-form-item label="用户名:">
<el-select v-model="tableStore.table.params.loginName" placeholder="用户名" clearable filterable>
<el-option
v-for="item in userName"
:key="item.id"
:label="item.loginName"
:value="item.loginName"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="事件类型:">
<el-select v-model="tableStore.table.params.type" placeholder="事件类型" clearable>
<el-option
v-for="item in eventType"
:key="item.id"
:label="item.label"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="操作类型:">
<el-select v-model="tableStore.table.params.operateType" placeholder="操作类型" clearable>
<el-option
v-for="item in operationType"
:key="item.value"
:label="item.value"
:value="item.value"
></el-option>
</el-select>
</el-form-item>
</el-form>
</template>
<template #operation>
<el-button type="primary" @click="back">返回</el-button>
</template>
</TableHeader>
<Table ref="tableRef_1" />
</template>
<script setup lang="ts">
import { ref, onMounted, provide, nextTick } from 'vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import TableHeader from '@/components/table/header/index.vue'
import {
getAllUserList,
} from '@/api/auditManage/auditList'
import { ElMessage } from 'element-plus'
defineOptions({
name: 'admin/BusinessAdministrator/Audit/Operations/Management'
})
interface UserInfo {
id: number | string
loginName: string
}
const emit = defineEmits(['back'])
const userName = ref<UserInfo[]>([])
const TableHeaderRef = ref()
// 其他响应式数据
const loading1 = ref(false)
const flg = ref(true)
const showMqtt = ref(false)
const zoom = ref('') //图表焦点校验
const eventType = ref([
{
id: 0,
label: '业务事件类型'
},
{
id: 1,
label: '系统事件类型'
}
]) //事件类型
const operationType = ref([
{ id: 1, value: '查询' },
{ id: 2, value: '新增' },
{ id: 3, value: '更新' },
{ id: 4, value: '删除' },
{ id: 5, value: '认证' },
{ id: 6, value: '注销' },
{ id: 7, value: '上传' },
{ id: 8, value: '下载' },
{ id: 9, value: '越权访问' }
]) //操作类型
const tableStore: any = new TableStore({
url: '/system-boot/audit/censusAuditLog',
method: 'POST',
column: [
// 根据实际统计表格的列来定义
{ field: 'loginName', title: '操作人员' },
{ field: 'operateType', title: '事件类型' },
{ field: 'count', title: '事件总数' }
]
})
tableStore.table.params.loginName = ''
tableStore.table.params.type = ''
tableStore.table.params.operateType = ''
tableStore.table.params.result = null
tableStore.table.params.sortBy = ''
tableStore.table.params.sortName = ''
tableStore.table.params.orderBy = ''
tableStore.table.params.pageSize = 100
provide('tableStore', tableStore)
onMounted(() => {
search()
tableStore.index()
})
//下拉框查询
const search = () => {
getAllUserList().then(res => {
userName.value = res.data
})
}
//返回
const back = () => {
flg.value = true
// 触发父组件的 onSubmit 方法
emit('back')
}
</script>

3
types/table.d.ts vendored
View File

@@ -82,7 +82,8 @@ declare global {
column: VxeColumnProps, column: VxeColumnProps,
index: number index: number
) => string ) => string
children?: TableColumn[] children?: TableColumn[],
property?:string
} }
/* 表格右侧操作按钮 */ /* 表格右侧操作按钮 */