修复操作人异常显示

This commit is contained in:
Cheng Zhou
2025-12-23 21:48:43 +08:00
parent c9d1535428
commit 9e9404d273
3 changed files with 17 additions and 9 deletions
+2 -2
View File
@@ -4,8 +4,8 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>CTMS</title>
<script type="module" crossorigin src="/assets/index-CLgelUhv.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-CpYJ-5eT.css">
<script type="module" crossorigin src="/assets/index-Cs6sO1fk.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-BX8Ho7fh.css">
</head>
<body>
<div id="app"></div>
+2 -1
View File
@@ -185,8 +185,9 @@ const subjectMap = computed(() =>
const verifierMap = computed(() =>
members.value.reduce<Record<string, string>>((acc, cur) => {
const username = cur?.user?.display_name || cur?.user?.username || cur?.username;
const username = cur?.user?.display_name || cur?.user?.full_name || cur?.user?.username || cur?.username;
if (cur?.user_id) acc[cur.user_id] = username || cur.user_id;
if (cur?.id) acc[cur.id] = username || cur.id;
return acc;
}, {})
);
+11 -4
View File
@@ -93,6 +93,7 @@ import { useRouter } from "vue-router";
import { ElMessage, ElMessageBox } from "element-plus";
import { fetchAuditLogs } from "../../api/auditLogs";
import { fetchUsers } from "../../api/users";
import { listMembers } from "../../api/members";
import { auditDict, normalizeAuditEvent } from "../../audit";
import { useStudyStore } from "../../store/study";
import { useAuthStore } from "../../store/auth";
@@ -155,13 +156,19 @@ const ensureAccess = () => {
};
const loadUsers = async () => {
if (auth.user?.role !== "ADMIN") {
users.value = [];
return;
}
try {
if (auth.user?.role === "ADMIN") {
const { data } = await fetchUsers({ limit: 500 });
users.value = (data as any).items || data || [];
} else if (study.currentStudy) {
// 非管理员,尝试加载项目成员作为备选
const { data } = await listMembers(study.currentStudy.id, { limit: 500 });
const items = Array.isArray(data) ? data : (data as any).items || [];
users.value = items.map((m: any) => ({
id: m.user_id,
username: m.user?.display_name || m.user?.full_name || m.user?.username || m.username,
}));
}
} catch {
users.value = [];
}