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

97 lines
2.3 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-23 19:30:11 +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>
</div>
</template>
<script setup lang='tsx' name='useProTable'>
2024-10-22 14:47:25 +08:00
// 根据实际路径调整
import TimeControl from '@/components/TimeControl/index.vue'
import { type Log } from '@/api/log/interface'
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 logDataList from '@/api/log/logData'
import type { ColumnProps, ProTableInstance } from '@/components/ProTable/interface'
2024-10-23 19:30:11 +08:00
import { reactive,ref } from 'vue'
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-23 19:30:11 +08:00
// 定义包含和排除的单位
const includedUnits = ['日', '周', '月', '季度']; // 可以根据需要包含的单位
const excludedUnits = ['年']; // 要排除的单位
2024-10-22 13:19:13 +08:00
// ProTable 实例
const proTable = ref<ProTableInstance>()
// 表格配置项
const columns = reactive<ColumnProps<Log.LogList>[]>([
{ type: 'selection', fixed: 'left', width: 50 },
{
2024-10-24 12:28:12 +08:00
prop: 'id',
label: '序号',
width: 100,
2024-10-22 13:19:13 +08:00
},
{
prop: 'user',
label: '操作用户',
search: { el: 'select', props: { filterable: true } },
2024-10-24 12:28:12 +08:00
width: 150,
2024-10-22 13:19:13 +08:00
},
2024-10-22 14:47:25 +08:00
{
prop: 'record_Time',
label: '记录时间',
2024-10-24 12:28:12 +08:00
width: 200,
2024-10-22 14:47:25 +08:00
search: {
span: 2,
render: ({ searchParam }) => {
return (
<div class='flx-flex-start'>
2024-10-23 19:30:11 +08:00
<TimeControl/>
2024-10-22 14:47:25 +08:00
</div>
)
},
},
},
2024-10-24 12:28:12 +08:00
{
prop: 'content',
label: '内容',
},
{
prop: 'type',
label: '日志类型',
width: 200,
search: { el: 'select', props: { filterable: true } },
},
{
prop: 'level',
label: '日志等级',
width: 200,
search: { el: 'select', props: { filterable: true } },
},
2024-10-22 13:19:13 +08:00
])
//选中
// 处理选择变化
2024-10-22 14:47:25 +08:00
const handleSelectionChange = (selection: Log.LogList[]) => {
multipleSelection.value = selection.map(row => row.id) // 更新选中的行
}
2024-10-23 19:30:11 +08:00
2024-10-22 13:19:13 +08:00
</script>
<style scoped>
</style>