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

128 lines
2.9 KiB
Vue
Raw Normal View History

2024-10-22 13:19:13 +08:00
<template>
<div class='table-box'>
<ProTable
ref='proTable'
:columns='columns'
:data='logData'
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'
2024-11-18 09:02:57 +08:00
import { type Sys_Log_Audit } from '@/api/system/interface/log'
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-11-18 09:02:57 +08:00
import logDataList from '@/api/system/log/logData'
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'
2024-10-30 15:19:47 +08:00
import { useDictStore } from '@/stores/modules/dict'
2025-01-15 09:35:36 +08:00
defineOptions({
name: 'log'
})
2024-10-22 14:47:25 +08:00
let multipleSelection = ref<string[]>([])
2024-10-22 13:19:13 +08:00
const logData = logDataList
2024-10-30 15:19:47 +08:00
const dictStore = useDictStore()
2024-10-23 19:30:11 +08:00
// 定义包含和排除的单位
2024-10-28 08:39:09 +08:00
const includedUnits = ['日', '周', '月', '自定义']; // 可以根据需要包含的单位
const excludedUnits = ['季度','年']; // 要排除的单位
const defaultUnits = '日'; // 默认的单位
2024-10-22 13:19:13 +08:00
// ProTable 实例
const proTable = ref<ProTableInstance>()
2025-01-15 09:35:36 +08:00
2024-10-22 13:19:13 +08:00
// 表格配置项
2024-10-30 15:19:47 +08:00
const columns = reactive<ColumnProps<Sys_Log_Audit.Audit_LogList>[]>([
2024-10-28 08:39:09 +08:00
{ type: 'selection', fixed: 'left', width: 70 },
2024-10-22 13:19:13 +08:00
{
2024-10-24 12:28:12 +08:00
prop: 'id',
label: '序号',
2024-10-28 08:39:09 +08:00
width: 70,
2024-10-22 13:19:13 +08:00
},
{
2024-10-30 15:19:47 +08:00
prop: 'create_By',
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
{
2024-10-30 15:19:47 +08:00
prop: 'create_Time',
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: {
span: 2,
2024-10-29 11:17:04 +08:00
render: () => {
2024-10-22 14:47:25 +08:00
return (
<div class='flx-flex-start'>
2024-10-28 08:39:09 +08:00
<TimeControl
include={includedUnits}
exclude={excludedUnits}
default={defaultUnits}
/>
2024-10-22 14:47:25 +08:00
</div>
)
},
},
},
2024-10-24 12:28:12 +08:00
{
2024-10-30 15:19:47 +08:00
prop: 'remark',
label: '事件描述',
minWidth: 400,
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 (
<el-tag type={scope.row.warn ? 'danger' : 'success'}>{scope.row.warn ? '告警' : '未告警'}</el-tag>
)
},
},
{
prop: 'operate_Type',
label: '日志类型',
width: 100,
2024-10-24 12:28:12 +08:00
search: { el: 'select', props: { filterable: true } },
},
2024-10-22 13:19:13 +08:00
])
//选中
// 处理选择变化
2024-10-30 15:19:47 +08:00
const handleSelectionChange = (selection: Sys_Log_Audit.Audit_LogList[]) => {
2024-10-22 14:47:25 +08:00
multipleSelection.value = selection.map(row => row.id) // 更新选中的行
2024-10-29 11:17:04 +08:00
2024-10-22 14:47:25 +08:00
}
2024-10-23 19:30:11 +08:00
2024-10-22 13:19:13 +08:00
</script>
<style scoped>
</style>