7 changed files with 461 additions and 331 deletions
-
5src/components/audit/History.vue
-
140src/components/audit/OperationRecord.vue
-
21src/stores/auditStore.ts
-
4src/stores/settingStore.ts
-
202src/views/audit/index.vue
-
4src/views/setting/index.vue
@ -0,0 +1,140 @@ |
|||
<script lang="ts" setup> |
|||
import { sendCmd, syncSendCmd } from 'apis/system' |
|||
import type { TableColumnCtx } from 'element-plus' |
|||
import { onMounted, ref } from 'vue' |
|||
|
|||
import { FtMessage } from '@/libs/message' |
|||
|
|||
/** |
|||
* 操作记录组件 |
|||
*/ |
|||
|
|||
// 分页控制 |
|||
const pageNum = ref(1) // 当前页码 |
|||
const pageSize = ref(10) // 每页显示数量 |
|||
const totle = ref(0) // 总记录数 |
|||
|
|||
// 表格数据 |
|||
const tableData = ref<Audit.AuditItem[]>([]) // 审计日志表格数据 |
|||
|
|||
/** |
|||
* @hook 生命周期钩子 - 组件挂载完成时执行 |
|||
* @description 初始化加载审计日志列表 |
|||
*/ |
|||
onMounted(() => { |
|||
getAuditList() |
|||
}) |
|||
|
|||
/** |
|||
* @function 获取审计日志列表 |
|||
* @desc 从服务端获取分页后的审计日志数据 |
|||
*/ |
|||
const getAuditList = async () => { |
|||
const params = { |
|||
className: 'AuditMgrService', |
|||
fnName: 'getRecords', |
|||
params: { |
|||
page: pageNum.value, |
|||
pageSize: pageSize.value, |
|||
}, |
|||
} |
|||
try { |
|||
const res = await sendCmd(params) |
|||
tableData.value = res.items || [] |
|||
totle.value = res.total || 0 |
|||
} |
|||
catch (error) { |
|||
FtMessage.error('获取日志列表失败') |
|||
console.error('获取审计日志失败:', error) |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* @function 导出全部审计记录 |
|||
* @desc 导出单条审计记录,需先选择一条记录 |
|||
*/ |
|||
const onExportRecord = () => { |
|||
// if (selectedUserList.value.length !== 1) { |
|||
// FtMessage.warning('请选择一条数据进行导出') |
|||
// return |
|||
// } |
|||
const params = { |
|||
className: 'AuditMgrService', |
|||
fnName: 'exportData', |
|||
} |
|||
syncSendCmd(params) |
|||
.then((res) => { |
|||
if (res.ackcode === 0) { |
|||
FtMessage.success('导出成功') |
|||
} |
|||
}) |
|||
.catch((error) => { |
|||
console.error('导出审计记录失败:', error) |
|||
}) |
|||
} |
|||
|
|||
/** |
|||
* @function 页码变更处理 |
|||
* @param {number} page - 新的页码 |
|||
* @desc 更新页码并重新加载数据 |
|||
*/ |
|||
const handleCurrentChange = (page: number) => { |
|||
pageNum.value = page |
|||
getAuditList() |
|||
} |
|||
|
|||
const formatIndex = ( |
|||
_row: unknown, |
|||
_column: TableColumnCtx<unknown>, |
|||
_cellValue: unknown, |
|||
index: number, |
|||
): number => { |
|||
return (pageNum.value - 1) * pageSize.value + index + 1 |
|||
} |
|||
</script> |
|||
|
|||
<template> |
|||
<div class="dashboard-container"> |
|||
<main class="main-content"> |
|||
<div class="audit-export"> |
|||
<bt-button type="primary" button-text="全部导出" @click="onExportRecord" /> |
|||
</div> |
|||
<div class="audit-table"> |
|||
<el-table :data="tableData" style="width: 100%" height="100%"> |
|||
<el-table-column label="序号" width="100" :formatter="formatIndex" /> |
|||
<el-table-column prop="usrName" label="操作人" width="250" /> |
|||
<el-table-column prop="behaviorinfo" label="操作内容" /> |
|||
<el-table-column prop="date" label="操作时间" width="250" /> |
|||
</el-table> |
|||
</div> |
|||
<div class="audit-pagination"> |
|||
<el-pagination layout="prev, pager, next" :total="totle" @current-change="handleCurrentChange" /> |
|||
</div> |
|||
</main> |
|||
</div> |
|||
</template> |
|||
|
|||
<style lang="scss" scoped> |
|||
.main-content { |
|||
height: $main-container-height; |
|||
overflow: hidden; |
|||
background: $gradient-color; |
|||
box-shadow: 0px 1px 5px 0px rgba(9, 39, 62, 0.15); |
|||
.audit-export { |
|||
height: 50px; |
|||
padding: 0 10px; |
|||
display: flex; |
|||
align-items: center; |
|||
} |
|||
.audit-table { |
|||
overflow: auto; |
|||
height: calc(100% - 100px); |
|||
} |
|||
.audit-pagination { |
|||
height: 50px; |
|||
display: flex; |
|||
align-items: center; |
|||
float: right; |
|||
} |
|||
} |
|||
</style> |
@ -0,0 +1,21 @@ |
|||
import { defineStore } from 'pinia' |
|||
/** |
|||
* 审计模块 |
|||
*/ |
|||
export const useAuditStore = defineStore('audit', () => { |
|||
// 设置菜单配置
|
|||
const auditMenus = [{ |
|||
name: '操作记录', |
|||
code: 'history', |
|||
roleType: 'admin', |
|||
}, { |
|||
name: '消毒记录', |
|||
code: 'operationRecord', |
|||
roleType: 'admin,maintainer', |
|||
}] |
|||
const historyList: Record<string, string>[] = [] |
|||
return { |
|||
auditMenus, |
|||
historyList, |
|||
} |
|||
}) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue