96 lines
3.5 KiB
Vue
96 lines
3.5 KiB
Vue
<template>
|
|||
|
|
<div class="page-container">
|
||
|
|
<el-card shadow="never">
|
||
|
|
<template #header>
|
||
|
|
<div class="card-header">
|
||
|
|
<span>审计日志</span>
|
||
|
|
<el-radio-group v-model="resourceFilter" size="small" @change="loadData">
|
||
|
|
<el-radio-button label="">全部</el-radio-button>
|
||
|
|
<el-radio-button label="user">用户</el-radio-button>
|
||
|
|
<el-radio-button label="operator">Operator</el-radio-button>
|
||
|
|
<el-radio-button label="report">举报</el-radio-button>
|
||
|
|
<el-radio-button label="appeal">申诉</el-radio-button>
|
||
|
|
<el-radio-button label="activity">活动</el-radio-button>
|
||
|
|
</el-radio-group>
|
||
|
|
</div>
|
||
|
|
</template>
|
||
|
|
|
||
|
|
<el-table :data="tableData" v-loading="loading" border stripe>
|
||
|
|
<el-table-column prop="operatorId" label="操作人ID" width="140" />
|
||
|
|
<el-table-column prop="action" label="操作" width="160">
|
||
|
|
<template #default="{row}">{{ actionText(row.action) }}</template>
|
||
|
|
</el-table-column>
|
||
|
|
<el-table-column prop="resourceType" label="资源类型" width="120">
|
||
|
|
<template #default="{row}">{{ row.resourceType }}</template>
|
||
|
|
</el-table-column>
|
||
|
|
<el-table-column prop="resourceId" label="资源ID" width="140" show-overflow-tooltip />
|
||
|
|
<el-table-column prop="ip" label="IP地址" width="140" />
|
||
|
|
<el-table-column prop="createdAt" label="时间" width="180">
|
||
|
|
<template #default="{row}">{{ formatTime(row.createdAt) }}</template>
|
||
|
|
</el-table-column>
|
||
|
|
</el-table>
|
||
|
|
|
||
|
|
<el-pagination v-if="total > 0" style="margin-top:16px;text-align:right"
|
||
|
|
layout="total, prev, pager, next" :total="total" :page-size="pageSize"
|
||
|
|
:current-page="page" @current-change="handlePageChange" />
|
||
|
|
</el-card>
|
||
|
|
</div>
|
||
|
|
</template>
|
||
|
|
|
||
|
|
<script setup lang="ts">
|
||
|
|
import { ref, onMounted } from 'vue'
|
||
|
|
import { get } from '@/api/client'
|
||
|
|
|
||
|
|
const loading = ref(false)
|
||
|
|
const tableData = ref<any[]>([])
|
||
|
|
const total = ref(0)
|
||
|
|
const page = ref(0)
|
||
|
|
const pageSize = ref(20)
|
||
|
|
const resourceFilter = ref('')
|
||
|
|
|
||
|
|
const ACTION_TEXT: Record<string, string> = {
|
||
|
|
CREATE_OPERATOR: '创建操作员',
|
||
|
|
DISABLE_OPERATOR: '停用操作员',
|
||
|
|
ENABLE_OPERATOR: '启用操作员',
|
||
|
|
RESET_PASSWORD: '重置密码',
|
||
|
|
VIEW_USER_DETAIL: '查看用户详情',
|
||
|
|
UPDATE_USER_STATUS: '修改用户状态',
|
||
|
|
SUBMIT_REPORT: '提交举报',
|
||
|
|
PROCESS_REPORT: '处理举报',
|
||
|
|
SUBMIT_APPEAL: '提交申诉',
|
||
|
|
PROCESS_APPEAL: '处理申诉',
|
||
|
|
CREATE_ORGANIZATION: '创建机构',
|
||
|
|
DISABLE_ORGANIZATION: '停用机构',
|
||
|
|
ENABLE_ORGANIZATION: '启用机构',
|
||
|
|
CREATE_ACTIVITY: '创建活动',
|
||
|
|
APPROVE_REGISTRATION: '审核报名',
|
||
|
|
REJECT_REGISTRATION: '拒绝报名'
|
||
|
|
}
|
||
|
|
|
||
|
|
async function loadData() {
|
||
|
|
loading.value = true
|
||
|
|
try {
|
||
|
|
const token = localStorage.getItem('accessToken')
|
||
|
|
const res: any = await get('/operator/audit/logs', {
|
||
|
|
resourceType: resourceFilter.value || undefined,
|
||
|
|
page: page.value,
|
||
|
|
pageSize: pageSize.value
|
||
|
|
}, { Authorization: `Bearer ${token}` })
|
||
|
|
tableData.value = res.list || []
|
||
|
|
total.value = res.total || 0
|
||
|
|
} catch (e) { console.error(e) }
|
||
|
|
finally { loading.value = false }
|
||
|
|
}
|
||
|
|
|
||
|
|
function handlePageChange(p: number) { page.value = p - 1; loadData() }
|
||
|
|
function actionText(a: string) { return ACTION_TEXT[a] || a }
|
||
|
|
function formatTime(t?: string) { return t ? new Date(t).toLocaleString('zh-CN') : '-' }
|
||
|
|
|
||
|
|
onMounted(loadData)
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<style scoped>
|
||
|
|
.page-container { padding: 24px; }
|
||
|
|
.card-header { display: flex; justify-content: space-between; align-items: center; }
|
||
|
|
</style>
|