feat(security): 审计日志增强前端页面
- auditlog-enhanced/api.js: 审计日志增强API接口 - auditlog-enhanced/index.vue: 审计日志管理页面(支持风险级别/业务类型筛选/统计面板)
This commit is contained in:
19
healthlink-his-ui/src/views/auditlog-enhanced/api.js
Normal file
19
healthlink-his-ui/src/views/auditlog-enhanced/api.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 增强审计日志查询
|
||||
export function getEnhancedLogs(params) {
|
||||
return request({
|
||||
url: '/audit/enhanced/logs',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
// 审计日志统计
|
||||
export function getAuditStats(params) {
|
||||
return request({
|
||||
url: '/audit/enhanced/stats',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
}
|
||||
254
healthlink-his-ui/src/views/auditlog-enhanced/index.vue
Normal file
254
healthlink-his-ui/src/views/auditlog-enhanced/index.vue
Normal file
@@ -0,0 +1,254 @@
|
||||
<template>
|
||||
<div style="padding:16px">
|
||||
<div style="margin-bottom:16px;display:flex;justify-content:space-between;align-items:center">
|
||||
<span style="font-size:18px;font-weight:bold">审计日志管理</span>
|
||||
<el-button @click="showStats = !showStats">
|
||||
{{ showStats ? '隐藏统计' : '查看统计' }}
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<!-- 统计面板 -->
|
||||
<el-card v-if="showStats" style="margin-bottom:16px">
|
||||
<template #header>
|
||||
<span>审计统计</span>
|
||||
</template>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="8">
|
||||
<div style="text-align:center">
|
||||
<div style="font-size:24px;font-weight:bold;color:#409eff">{{ stats.totalCount || 0 }}</div>
|
||||
<div style="color:#909399">总日志数</div>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<div style="text-align:center">
|
||||
<div style="font-size:24px;font-weight:bold;color:#e6a23c">{{ stats.highRiskCount || 0 }}</div>
|
||||
<div style="color:#909399">高风险操作</div>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<div style="text-align:center">
|
||||
<div style="font-size:24px;font-weight:bold;color:#f56c6c">{{ stats.criticalCount || 0 }}</div>
|
||||
<div style="color:#909399">严重风险</div>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-divider />
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<div style="font-weight:bold;margin-bottom:8px">按模块分布</div>
|
||||
<div v-for="item in stats.moduleStats" :key="item.module" style="display:flex;justify-content:space-between;margin-bottom:4px">
|
||||
<span>{{ item.module || '未知' }}</span>
|
||||
<el-tag size="small">{{ item.count }}</el-tag>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<div style="font-weight:bold;margin-bottom:8px">按风险级别分布</div>
|
||||
<div v-for="item in stats.riskStats" :key="item.risk_level" style="display:flex;justify-content:space-between;margin-bottom:4px">
|
||||
<span>{{ getRiskLabel(item.risk_level) }}</span>
|
||||
<el-tag :type="getRiskType(item.risk_level)" size="small">{{ item.count }}</el-tag>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-card>
|
||||
|
||||
<!-- 查询条件 -->
|
||||
<div style="margin-bottom:12px;display:flex;gap:8px;flex-wrap:wrap">
|
||||
<el-input
|
||||
v-model="q.userName"
|
||||
placeholder="用户名"
|
||||
clearable
|
||||
style="width:120px"
|
||||
/>
|
||||
<el-input
|
||||
v-model="q.module"
|
||||
placeholder="模块"
|
||||
clearable
|
||||
style="width:120px"
|
||||
/>
|
||||
<el-input
|
||||
v-model="q.action"
|
||||
placeholder="操作"
|
||||
clearable
|
||||
style="width:120px"
|
||||
/>
|
||||
<el-select
|
||||
v-model="q.riskLevel"
|
||||
placeholder="风险级别"
|
||||
clearable
|
||||
style="width:120px"
|
||||
>
|
||||
<el-option label="低" value="LOW" />
|
||||
<el-option label="中" value="MEDIUM" />
|
||||
<el-option label="高" value="HIGH" />
|
||||
<el-option label="严重" value="CRITICAL" />
|
||||
</el-select>
|
||||
<el-select
|
||||
v-model="q.businessType"
|
||||
placeholder="业务类型"
|
||||
clearable
|
||||
style="width:120px"
|
||||
>
|
||||
<el-option label="登录" value="login" />
|
||||
<el-option label="登出" value="logout" />
|
||||
<el-option label="查询" value="query" />
|
||||
<el-option label="新增" value="insert" />
|
||||
<el-option label="修改" value="update" />
|
||||
<el-option label="删除" value="delete" />
|
||||
<el-option label="导出" value="export" />
|
||||
</el-select>
|
||||
<el-date-picker
|
||||
v-model="dateRange"
|
||||
type="daterange"
|
||||
range-separator="至"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
value-format="YYYY-MM-DD"
|
||||
style="width:240px"
|
||||
/>
|
||||
<el-button type="primary" @click="loadData">查询</el-button>
|
||||
<el-button @click="resetQuery">重置</el-button>
|
||||
</div>
|
||||
|
||||
<!-- 数据表格 -->
|
||||
<el-table :data="tableData" border stripe>
|
||||
<el-table-column prop="userName" label="用户" width="100" />
|
||||
<el-table-column prop="module" label="模块" width="120" />
|
||||
<el-table-column prop="action" label="操作" width="100" />
|
||||
<el-table-column prop="businessType" label="业务类型" width="100">
|
||||
<template #default="{row}">
|
||||
<el-tag size="small">{{ getBusinessLabel(row.businessType) }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="riskLevel" label="风险级别" width="100">
|
||||
<template #default="{row}">
|
||||
<el-tag :type="getRiskType(row.riskLevel)" size="small">
|
||||
{{ getRiskLabel(row.riskLevel) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="method" label="方法" width="70" align="center" />
|
||||
<el-table-column prop="url" label="URL" min-width="200" show-overflow-tooltip />
|
||||
<el-table-column prop="clientIp" label="IP" width="120" />
|
||||
<el-table-column prop="result" label="结果" width="80" align="center">
|
||||
<template #default="{row}">
|
||||
<el-tag v-if="row.result==='SUCCESS'" type="success" size="small">成功</el-tag>
|
||||
<el-tag v-else type="danger" size="small">失败</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="responseTimeMs" label="耗时ms" width="80" align="center" />
|
||||
<el-table-column prop="createTime" label="时间" width="170" />
|
||||
<el-table-column label="操作" width="80">
|
||||
<template #default="{row}">
|
||||
<el-button type="primary" link size="small" @click="showDetail(row)">详情</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<el-pagination
|
||||
v-model:current-page="q.pageNo"
|
||||
v-model:page-size="q.pageSize"
|
||||
style="margin-top:12px;justify-content:flex-end"
|
||||
:total="total"
|
||||
layout="total,prev,pager,next"
|
||||
@current-change="loadData"
|
||||
/>
|
||||
|
||||
<!-- 详情弹窗 -->
|
||||
<el-dialog v-model="detailVisible" title="审计日志详情" width="700px">
|
||||
<el-descriptions :column="2" border>
|
||||
<el-descriptions-item label="用户">{{ detail.userName }}</el-descriptions-item>
|
||||
<el-descriptions-item label="模块">{{ detail.module }}</el-descriptions-item>
|
||||
<el-descriptions-item label="操作">{{ detail.action }}</el-descriptions-item>
|
||||
<el-descriptions-item label="业务类型">{{ getBusinessLabel(detail.businessType) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="风险级别">
|
||||
<el-tag :type="getRiskType(detail.riskLevel)">{{ getRiskLabel(detail.riskLevel) }}</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="方法">{{ detail.method }}</el-descriptions-item>
|
||||
<el-descriptions-item label="URL" :span="2">{{ detail.url }}</el-descriptions-item>
|
||||
<el-descriptions-item label="IP">{{ detail.clientIp }}</el-descriptions-item>
|
||||
<el-descriptions-item label="耗时">{{ detail.responseTimeMs }}ms</el-descriptions-item>
|
||||
<el-descriptions-item label="租户">{{ detail.tenantName }}</el-descriptions-item>
|
||||
<el-descriptions-item label="科室">{{ detail.orgName }}</el-descriptions-item>
|
||||
<el-descriptions-item label="参数" :span="2">{{ detail.params }}</el-descriptions-item>
|
||||
<el-descriptions-item label="错误" :span="2">{{ detail.errorMsg }}</el-descriptions-item>
|
||||
<el-descriptions-item label="用户代理" :span="2">{{ detail.userAgent }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { getEnhancedLogs, getAuditStats } from './api'
|
||||
|
||||
const tableData = ref([])
|
||||
const total = ref(0)
|
||||
const q = ref({
|
||||
pageNo: 1,
|
||||
pageSize: 20,
|
||||
userName: '',
|
||||
module: '',
|
||||
action: '',
|
||||
riskLevel: '',
|
||||
businessType: ''
|
||||
})
|
||||
const dateRange = ref(null)
|
||||
const showStats = ref(false)
|
||||
const stats = ref({})
|
||||
const detailVisible = ref(false)
|
||||
const detail = ref({})
|
||||
|
||||
const loadData = async () => {
|
||||
const params = { ...q.value }
|
||||
if (dateRange.value && dateRange.value.length === 2) {
|
||||
params.startDate = dateRange.value[0]
|
||||
params.endDate = dateRange.value[1]
|
||||
}
|
||||
const r = await getEnhancedLogs(params)
|
||||
tableData.value = r.data?.records || []
|
||||
total.value = r.data?.total || 0
|
||||
}
|
||||
|
||||
const loadStats = async () => {
|
||||
const params = {}
|
||||
if (dateRange.value && dateRange.value.length === 2) {
|
||||
params.startDate = dateRange.value[0]
|
||||
params.endDate = dateRange.value[1]
|
||||
}
|
||||
const r = await getAuditStats(params)
|
||||
stats.value = r.data || {}
|
||||
}
|
||||
|
||||
const resetQuery = () => {
|
||||
q.value = { pageNo: 1, pageSize: 20, userName: '', module: '', action: '', riskLevel: '', businessType: '' }
|
||||
dateRange.value = null
|
||||
loadData()
|
||||
}
|
||||
|
||||
const showDetail = (row) => {
|
||||
detail.value = row
|
||||
detailVisible.value = true
|
||||
}
|
||||
|
||||
const getRiskLabel = (level) => {
|
||||
const map = { LOW: '低', MEDIUM: '中', HIGH: '高', CRITICAL: '严重' }
|
||||
return map[level] || level || '未知'
|
||||
}
|
||||
|
||||
const getRiskType = (level) => {
|
||||
const map = { LOW: 'info', MEDIUM: 'warning', HIGH: 'danger', CRITICAL: 'danger' }
|
||||
return map[level] || 'info'
|
||||
}
|
||||
|
||||
const getBusinessLabel = (type) => {
|
||||
const map = { login: '登录', logout: '登出', query: '查询', insert: '新增', update: '修改', delete: '删除', export: '导出' }
|
||||
return map[type] || type || '未知'
|
||||
}
|
||||
|
||||
watch(showStats, (val) => {
|
||||
if (val) loadStats()
|
||||
})
|
||||
|
||||
onMounted(() => loadData())
|
||||
</script>
|
||||
Reference in New Issue
Block a user