全局中文化
This commit is contained in:
@@ -3,28 +3,28 @@
|
||||
<el-card>
|
||||
<div class="header">
|
||||
<div>
|
||||
<h3>账号治理(系统登录账号)</h3>
|
||||
<p class="sub">账号用于登录系统,本身不具备项目或角色权限</p>
|
||||
<h3>{{ TEXT.modules.adminUsers.title }}</h3>
|
||||
<p class="sub">{{ TEXT.modules.adminUsers.subtitle }}</p>
|
||||
</div>
|
||||
<el-button type="primary" @click="openCreate">新建用户</el-button>
|
||||
<el-button type="primary" @click="openCreate">{{ TEXT.common.actions.add }}{{ TEXT.modules.adminUsers.userLabel }}</el-button>
|
||||
</div>
|
||||
<el-table :data="users" stripe v-loading="loading" style="width: 100%">
|
||||
<el-table-column prop="email" label="邮箱" min-width="200" />
|
||||
<el-table-column prop="full_name" label="姓名" min-width="140" />
|
||||
<el-table-column prop="department" label="部门" min-width="140" />
|
||||
<el-table-column label="状态" width="140">
|
||||
<el-table-column prop="email" :label="TEXT.common.fields.email" min-width="200" />
|
||||
<el-table-column prop="full_name" :label="TEXT.common.fields.name" min-width="140" />
|
||||
<el-table-column prop="department" :label="TEXT.common.fields.department" min-width="140" />
|
||||
<el-table-column :label="TEXT.common.fields.status" width="140">
|
||||
<template #default="scope">
|
||||
<el-tag :type="statusType(scope.row.status)">
|
||||
{{ statusLabel(scope.row.status) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="created_at" label="创建时间" width="200">
|
||||
<el-table-column prop="created_at" :label="TEXT.modules.adminUsers.createdAt" width="200">
|
||||
<template #default="scope">{{ displayDateTime(scope.row.created_at) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="320" fixed="right">
|
||||
<el-table-column :label="TEXT.common.labels.actions" width="320" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button link type="primary" size="small" @click="openEdit(scope.row)">编辑</el-button>
|
||||
<el-button link type="primary" size="small" @click="openEdit(scope.row)">{{ TEXT.common.actions.edit }}</el-button>
|
||||
<el-button
|
||||
link
|
||||
:type="scope.row.status === 'ACTIVE' ? 'danger' : 'primary'"
|
||||
@@ -32,9 +32,9 @@
|
||||
:disabled="isLastAdmin(scope.row)"
|
||||
@click="toggleStatus(scope.row)"
|
||||
>
|
||||
{{ scope.row.status === 'ACTIVE' ? "禁用" : "启用" }}
|
||||
{{ scope.row.status === 'ACTIVE' ? TEXT.common.actions.disable : TEXT.common.actions.enable }}
|
||||
</el-button>
|
||||
<el-button link type="danger" size="small" @click="openReset(scope.row)">重置密码</el-button>
|
||||
<el-button link type="danger" size="small" @click="openReset(scope.row)">{{ TEXT.modules.adminUsers.resetPassword }}</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="danger"
|
||||
@@ -42,7 +42,7 @@
|
||||
:disabled="scope.row.id === auth.user?.id"
|
||||
@click="onDelete(scope.row)"
|
||||
>
|
||||
删除
|
||||
{{ TEXT.common.actions.delete }}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -72,6 +72,7 @@ import UserForm from "./UserForm.vue";
|
||||
import UserResetPassword from "./UserResetPassword.vue";
|
||||
import { useAuthStore } from "../../store/auth";
|
||||
import { displayDateTime } from "../../utils/display";
|
||||
import { TEXT } from "../../locales";
|
||||
|
||||
const users = ref<UserInfo[]>([]);
|
||||
const total = ref(0);
|
||||
@@ -98,7 +99,7 @@ const loadUsers = async () => {
|
||||
total.value = (data as any).total || items.length;
|
||||
activeAdminCount.value = allItems.filter((u: UserInfo) => u.role === "ADMIN" && u.status === "ACTIVE").length;
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.response?.data?.message || "用户列表加载失败");
|
||||
ElMessage.error(e?.response?.data?.message || TEXT.modules.adminUsers.loadFailed);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
@@ -116,26 +117,26 @@ const openEdit = (row: UserInfo) => {
|
||||
|
||||
const toggleStatus = async (row: UserInfo) => {
|
||||
if (isLastAdmin(row)) {
|
||||
ElMessage.warning("至少保留一个管理员账号,不能禁用该账号");
|
||||
ElMessage.warning(TEXT.modules.adminUsers.keepAdminWarning);
|
||||
return;
|
||||
}
|
||||
const disable = row.status === "ACTIVE";
|
||||
const ok = await ElMessageBox.confirm(
|
||||
disable ? "该操作将影响用户账号,请确认是否继续" : "确认启用该用户账号?",
|
||||
disable ? "禁用账号" : "启用账号",
|
||||
disable ? TEXT.modules.adminUsers.disableConfirm : TEXT.modules.adminUsers.enableConfirm,
|
||||
disable ? TEXT.modules.adminUsers.disableTitle : TEXT.modules.adminUsers.enableTitle,
|
||||
{
|
||||
type: disable ? "warning" : "info",
|
||||
confirmButtonText: "确认",
|
||||
cancelButtonText: "取消",
|
||||
confirmButtonText: TEXT.common.actions.confirm,
|
||||
cancelButtonText: TEXT.common.actions.cancel,
|
||||
}
|
||||
).catch(() => null);
|
||||
if (!ok) return;
|
||||
try {
|
||||
await updateUser(row.id, { status: disable ? "DISABLED" : "ACTIVE", is_active: !disable });
|
||||
ElMessage.success(disable ? "已禁用" : "已启用");
|
||||
ElMessage.success(disable ? TEXT.modules.adminUsers.disableSuccess : TEXT.modules.adminUsers.enableSuccess);
|
||||
loadUsers();
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.response?.data?.message || "操作失败");
|
||||
ElMessage.error(e?.response?.data?.message || TEXT.common.messages.actionFailed);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -146,28 +147,28 @@ const openReset = (row: UserInfo) => {
|
||||
|
||||
const onDelete = async (row: UserInfo) => {
|
||||
const { value, action } = await ElMessageBox.prompt(
|
||||
"删除后账号将无法登录且无法恢复,需先在各项目成员配置中移除该账号。请输入当前管理员密码确认删除。",
|
||||
"危险操作:删除账号",
|
||||
TEXT.modules.adminUsers.deleteConfirm,
|
||||
TEXT.modules.adminUsers.deleteTitle,
|
||||
{
|
||||
inputType: "password",
|
||||
inputPlaceholder: "请输入 admin 密码",
|
||||
confirmButtonText: "确认删除",
|
||||
inputPlaceholder: TEXT.modules.adminUsers.deletePasswordPlaceholder,
|
||||
confirmButtonText: TEXT.modules.adminUsers.deleteConfirmButton,
|
||||
confirmButtonClass: "el-button--danger",
|
||||
cancelButtonText: "取消",
|
||||
cancelButtonText: TEXT.common.actions.cancel,
|
||||
}
|
||||
).catch(() => ({ action: "cancel", value: "" }));
|
||||
if (action !== "confirm" || !value) return;
|
||||
try {
|
||||
await deleteUser(row.id, { admin_password: value });
|
||||
ElMessage.success("账号已删除");
|
||||
ElMessage.success(TEXT.modules.adminUsers.deleteSuccess);
|
||||
loadUsers();
|
||||
} catch (e: any) {
|
||||
const detail = e?.response?.data?.detail || e?.response?.data?.message;
|
||||
if (detail && detail.includes("项目成员")) {
|
||||
if (detail && detail.includes(TEXT.modules.adminProjectMembers.memberLabel)) {
|
||||
ElMessage.closeAll();
|
||||
ElMessage.error(detail);
|
||||
} else {
|
||||
ElMessage.error(detail || "删除失败");
|
||||
ElMessage.error(detail || TEXT.modules.adminUsers.deleteFailed);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -192,15 +193,15 @@ const statusType = (status: string) => {
|
||||
const statusLabel = (status: string) => {
|
||||
switch (status) {
|
||||
case "ACTIVE":
|
||||
return "启用";
|
||||
return TEXT.enums.userStatus.ACTIVE;
|
||||
case "PENDING":
|
||||
return "待审核";
|
||||
return TEXT.enums.userStatus.PENDING;
|
||||
case "REJECTED":
|
||||
return "已拒绝";
|
||||
return TEXT.enums.userStatus.REJECTED;
|
||||
case "DISABLED":
|
||||
return "已停用";
|
||||
return TEXT.enums.userStatus.DISABLED;
|
||||
default:
|
||||
return status || "未知";
|
||||
return status || TEXT.common.fallback;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user