longz
2026-04-28 bfa7d3b23e526809b04299d9c2719c3449aba3be
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<template>
  <div>
    <div class="page-head">
      <div class="page-title">运维日志</div>
      <div class="page-subtitle">展示管理后台写操作记录</div>
    </div>
 
    <el-table :data="rows" v-loading="loading" stripe>
      <el-table-column prop="opTime" label="操作时间" min-width="180" />
      <el-table-column prop="operatorName" label="操作人" min-width="120" />
      <el-table-column prop="module" label="模块" min-width="120" />
      <el-table-column prop="action" label="动作" min-width="140" />
      <el-table-column prop="resourceType" label="资源类型" min-width="140" show-overflow-tooltip />
      <el-table-column prop="resourceId" label="资源标识" min-width="220" show-overflow-tooltip />
      <el-table-column prop="traceId" label="TraceId" min-width="220" show-overflow-tooltip />
      <el-table-column label="详情" min-width="280">
        <template #default="{ row }">
          <span class="detail-text">{{ row.detailJson || "—" }}</span>
        </template>
      </el-table-column>
    </el-table>
 
    <div class="pager">
      <el-pagination
        background
        layout="total, prev, pager, next"
        :current-page="page"
        :page-size="size"
        :total="total"
        @current-change="handlePageChange"
      />
    </div>
  </div>
</template>
 
<script setup lang="ts">
import { onMounted, ref } from "vue";
import { ElMessage } from "element-plus";
import http from "../api/http";
 
type OpLogRow = {
  id: number;
  opTime?: string;
  operatorName?: string;
  module?: string;
  action?: string;
  resourceType?: string;
  resourceId?: string;
  traceId?: string;
  detailJson?: string;
};
 
const loading = ref(false);
const rows = ref<OpLogRow[]>([]);
const page = ref(1);
const size = ref(10);
const total = ref(0);
 
async function load() {
  loading.value = true;
  try {
    const { data } = await http.get("/op-logs", {
      params: {
        page: page.value,
        size: size.value,
        sourceType: "ADMIN",
      },
    });
    rows.value = data.result || [];
    total.value = data.total || 0;
  } catch (e: unknown) {
    ElMessage.error(e instanceof Error ? e.message : "加载失败");
  } finally {
    loading.value = false;
  }
}
 
function handlePageChange(nextPage: number) {
  page.value = nextPage;
  load();
}
 
onMounted(load);
</script>
 
<style scoped>
.page-head {
  margin-bottom: 16px;
}
 
.page-title {
  font-size: 18px;
  font-weight: 600;
  color: #1f2937;
}
 
.page-subtitle {
  margin-top: 4px;
  font-size: 13px;
  color: #6b7280;
}
 
.pager {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}
 
.detail-text {
  display: inline-block;
  max-width: 100%;
  color: #4b5563;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
</style>