Files
pqs-9100_client/frontend/src/views/log/index.vue

126 lines
3.0 KiB
Vue
Raw Normal View History

2024-10-22 13:19:13 +08:00
<template>
<div class='table-box'>
<ProTable
ref='proTable'
:columns='columns'
2025-02-13 15:40:13 +08:00
:request-api='getTableList'
2024-10-22 14:47:25 +08:00
@selection-change='handleSelectionChange'
type='selection'
2024-10-22 13:19:13 +08:00
>
2024-10-22 14:47:25 +08:00
<!-- 表格 header 按钮 -->
<template #tableHeader>
2024-10-28 08:39:09 +08:00
<el-button type='primary' :icon='DataAnalysis' >分析</el-button>
2024-10-22 14:47:25 +08:00
<el-button type='primary' :icon='Upload'>导出csv</el-button>
</template>
2024-10-22 13:19:13 +08:00
</ProTable>
2024-10-29 11:17:04 +08:00
2024-10-22 13:19:13 +08:00
</div>
</template>
<script setup lang='tsx' name='useProTable'>
2024-10-22 14:47:25 +08:00
// 根据实际路径调整
import TimeControl from '@/components/TimeControl/index.vue'
2025-02-13 15:40:13 +08:00
import { type AuditLog} from '@/api/system/log/interface/log.ts'
2024-10-22 13:19:13 +08:00
import ProTable from '@/components/ProTable/index.vue'
2024-10-23 19:30:11 +08:00
import { Upload ,DataAnalysis} from '@element-plus/icons-vue'
2024-10-22 13:19:13 +08:00
import type { ColumnProps, ProTableInstance } from '@/components/ProTable/interface'
2024-10-29 11:17:04 +08:00
import { reactive,ref,watch } from 'vue'
2025-02-13 15:40:13 +08:00
import {
getAuditLog,
} from '@/api/system/log/index.ts'
2025-01-15 09:35:36 +08:00
2025-02-13 15:40:13 +08:00
// defineOptions({
// name: 'log'
// })
const startDate = ref('')
const endDate = ref('')
2024-10-22 13:19:13 +08:00
// ProTable 实例
const proTable = ref<ProTableInstance>()
2025-01-15 09:35:36 +08:00
2025-02-13 15:40:13 +08:00
const getTableList = async (params: any) => {
let newParams = JSON.parse(JSON.stringify(params))
newParams.searchEndTime = endDate.value
newParams.searchBeginTime = startDate.value
return getAuditLog(newParams)
}
2025-01-15 09:35:36 +08:00
2024-10-22 13:19:13 +08:00
// 表格配置项
2025-02-13 15:40:13 +08:00
const columns = reactive<ColumnProps<AuditLog.ReqAuditLogParams>[]>([
2024-10-28 08:39:09 +08:00
{ type: 'selection', fixed: 'left', width: 70 },
2025-02-13 15:40:13 +08:00
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
2024-10-22 13:19:13 +08:00
{
2025-04-11 14:34:56 +08:00
prop: 'userName',
2024-10-22 13:19:13 +08:00
label: '操作用户',
2024-10-30 15:19:47 +08:00
search: { el: 'input' },
minWidth: 100,
},
{
prop: 'ip',
label: 'IP',
minWidth: 120,
2024-10-22 13:19:13 +08:00
},
2024-10-22 14:47:25 +08:00
{
2025-04-11 14:34:56 +08:00
prop: 'logTime',
2024-10-22 14:47:25 +08:00
label: '记录时间',
2024-10-30 15:19:47 +08:00
minWidth: 180,
2024-10-22 14:47:25 +08:00
search: {
2024-10-29 11:17:04 +08:00
render: () => {
2024-10-22 14:47:25 +08:00
return (
2025-02-13 15:40:13 +08:00
<div class='flx-flex-start'>
<TimeControl
include={['日', '周', '月', '自定义']}
default={'月'}
onUpdate-dates={handleDateChange}
/>
</div>
2024-10-22 14:47:25 +08:00
)
},
},
},
2024-10-24 12:28:12 +08:00
{
2024-10-30 15:19:47 +08:00
label: '事件描述',
2025-04-11 14:34:56 +08:00
minWidth: 450,
render: (scope) => {
return (scope.row.userName + '在' + scope.row.logTime + '执行了' + scope.row.operateType +scope.row.operate + '操作,结果为' + scope.row.result + '。')
}
2024-10-24 12:28:12 +08:00
},
{
2024-10-30 15:19:47 +08:00
prop: 'result',
label: '事件结果',
minWidth: 120,
2024-10-24 12:28:12 +08:00
},
{
2024-10-30 15:19:47 +08:00
prop: 'warn',
label: '告警标志',
minWidth: 100,
render: scope => {
return (
2025-04-11 14:34:56 +08:00
<el-tag type={scope.row.warn==1 ? 'danger' : 'success'}>{scope.row.warn==1 ? '已告警' : '未告警'}</el-tag>
2024-10-30 15:19:47 +08:00
)
},
},
{
2025-02-14 10:39:00 +08:00
prop: 'operateType',
2024-10-30 15:19:47 +08:00
label: '日志类型',
width: 100,
2024-10-24 12:28:12 +08:00
},
2024-10-22 13:19:13 +08:00
])
2025-02-13 15:40:13 +08:00
// 处理日期变化的回调函数
const handleDateChange = (startDateTemp: string, endDateTemp: string) => {
startDate.value = startDateTemp
endDate.value = endDateTemp
2024-10-22 14:47:25 +08:00
}
2024-10-23 19:30:11 +08:00
2025-02-13 15:40:13 +08:00
2024-10-22 13:19:13 +08:00
</script>
<style scoped>
</style>