统一项目角色展示与预设文案
This commit is contained in:
@@ -243,10 +243,12 @@ import type { UserInfo } from "../../types/api";
|
||||
import { useAuthStore } from "../../store/auth";
|
||||
import { TEXT } from "../../locales";
|
||||
import { displayEnum, displayText, getUserDisplayName } from "../../utils/display";
|
||||
import { useRoleTemplateMeta } from "../../composables/useRoleTemplateMeta";
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const auth = useAuthStore();
|
||||
const { roleLabel, loadRoleTemplates } = useRoleTemplateMeta();
|
||||
const documentId = computed(() => route.params.id as string);
|
||||
|
||||
const loading = ref(false);
|
||||
@@ -365,17 +367,16 @@ const roleOptions = computed(() => {
|
||||
const values = roles.size ? Array.from(roles) : fallbackRoles;
|
||||
return values.map((value) => ({
|
||||
value,
|
||||
label: displayEnum(TEXT.enums.userRole, value),
|
||||
label: roleLabel(value),
|
||||
}));
|
||||
});
|
||||
|
||||
const memberOptions = computed(() =>
|
||||
members.value.map((m) => {
|
||||
const name = getUserDisplayName((m as any).user) || (m as any).user?.email || m.user_id;
|
||||
const roleLabel = displayEnum(TEXT.enums.userRole, m.role_in_study);
|
||||
return {
|
||||
value: m.user_id,
|
||||
label: `${name}(${roleLabel})`,
|
||||
label: `${name}(${roleLabel(m.role_in_study)})`,
|
||||
role: m.role_in_study,
|
||||
};
|
||||
})
|
||||
@@ -383,7 +384,7 @@ const memberOptions = computed(() =>
|
||||
|
||||
const displayTarget = (row: Distribution) => {
|
||||
if (row.target_type === "ROLE") {
|
||||
return displayEnum(TEXT.enums.userRole, row.target_id);
|
||||
return roleLabel(row.target_id);
|
||||
}
|
||||
if (row.target_type === "USER") {
|
||||
const hit = memberOptions.value.find((m) => m.value === row.target_id);
|
||||
@@ -658,6 +659,7 @@ const formatDateOnly = (value?: string | null) => {
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
await loadRoleTemplates();
|
||||
await loadDetail();
|
||||
await loadDistributions();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user