消毒机设备
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

143 lines
3.6 KiB

  1. <script lang="ts" setup>
  2. import { sendCmd, syncSendCmd } from 'apis/system'
  3. import type { TableColumnCtx } from 'element-plus'
  4. import { ElLoading } from 'element-plus'
  5. import { onMounted, ref } from 'vue'
  6. import { FtMessage } from '@/libs/message'
  7. /**
  8. * 操作记录组件
  9. */
  10. // 分页控制
  11. const pageNum = ref(1) // 当前页码
  12. const pageSize = ref(10) // 每页显示数量
  13. const totle = ref(0) // 总记录数
  14. // 表格数据
  15. const tableData = ref<Audit.AuditItem[]>([]) // 审计日志表格数据
  16. /**
  17. * @hook 生命周期钩子 - 组件挂载完成时执行
  18. * @description 初始化加载审计日志列表
  19. */
  20. onMounted(() => {
  21. getAuditList()
  22. })
  23. /**
  24. * @function 获取审计日志列表
  25. * @desc 从服务端获取分页后的审计日志数据
  26. */
  27. const getAuditList = async () => {
  28. const params = {
  29. className: 'AuditMgrService',
  30. fnName: 'getRecords',
  31. params: {
  32. page: pageNum.value,
  33. pageSize: pageSize.value,
  34. },
  35. }
  36. try {
  37. const res = await sendCmd(params)
  38. tableData.value = res.items || []
  39. totle.value = res.total || 0
  40. }
  41. catch (error) {
  42. FtMessage.error('获取日志列表失败')
  43. console.error('获取审计日志失败:', error)
  44. }
  45. }
  46. /**
  47. * @function 导出全部审计记录
  48. * @desc 导出单条审计记录需先选择一条记录
  49. */
  50. const onExportRecord = () => {
  51. // if (selectedUserList.value.length !== 1) {
  52. // FtMessage.warning('请选择一条数据进行导出')
  53. // return
  54. // }
  55. const loading = ElLoading.service({
  56. lock: true,
  57. text: '正在导出',
  58. background: 'rgba(255, 255, 255, 0.8)',
  59. })
  60. const params = {
  61. className: 'AuditMgrService',
  62. fnName: 'exportData',
  63. }
  64. syncSendCmd(params)
  65. .then((res) => {
  66. if (res.ackcode === 0) {
  67. FtMessage.success('导出成功')
  68. }
  69. })
  70. .catch((error) => {
  71. console.error('导出审计记录失败:', error)
  72. })
  73. .finally(() => {
  74. loading.close()
  75. })
  76. }
  77. /**
  78. * @function 页码变更处理
  79. * @param {number} page - 新的页码
  80. * @desc 更新页码并重新加载数据
  81. */
  82. const handleCurrentChange = (page: number) => {
  83. pageNum.value = page
  84. getAuditList()
  85. }
  86. const formatIndex = (_row: unknown, _column: TableColumnCtx<unknown>, _cellValue: unknown, index: number): number => {
  87. return (pageNum.value - 1) * pageSize.value + index + 1
  88. }
  89. </script>
  90. <template>
  91. <div class="dashboard-container">
  92. <main class="main-content">
  93. <div class="audit-export">
  94. <bt-button type="primary" button-text="全部导出" @click="onExportRecord" />
  95. </div>
  96. <div class="audit-table">
  97. <el-table :data="tableData" style="width: 100%" height="100%">
  98. <el-table-column label="序号" width="100" :formatter="formatIndex" />
  99. <el-table-column prop="usrName" label="操作人" width="120" />
  100. <el-table-column prop="behaviorinfo" label="操作内容" />
  101. <el-table-column prop="date" label="操作时间" width="250" />
  102. </el-table>
  103. </div>
  104. <div class="audit-pagination">
  105. <el-pagination layout="prev, pager, next" :total="totle" @current-change="handleCurrentChange" />
  106. </div>
  107. </main>
  108. </div>
  109. </template>
  110. <style lang="scss" scoped>
  111. .main-content {
  112. height: $main-container-height;
  113. overflow: hidden;
  114. background: $gradient-color;
  115. .audit-export {
  116. height: 50px;
  117. //padding: 0 10px;
  118. display: flex;
  119. align-items: center;
  120. }
  121. .audit-table {
  122. overflow: auto;
  123. height: calc(100% - 110px);
  124. }
  125. .audit-pagination {
  126. height: 50px;
  127. display: flex;
  128. align-items: center;
  129. float: right;
  130. }
  131. }
  132. </style>