From ce77aa9e5d218b5a045dfee4cd0c8aa4bcdf179f Mon Sep 17 00:00:00 2001 From: "tao.chen" <93983997+taochen-ct@users.noreply.github.com> Date: Wed, 26 Aug 2026 09:55:11 +0800 Subject: [PATCH] update: role_code --- .../app/features/admin/UserManagementPage.tsx | 37 +++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/frontend/app/features/admin/UserManagementPage.tsx b/frontend/app/features/admin/UserManagementPage.tsx index 3716a59..58df878 100644 --- a/frontend/app/features/admin/UserManagementPage.tsx +++ b/frontend/app/features/admin/UserManagementPage.tsx @@ -1,6 +1,6 @@ import { useEffect, useState } from "react"; -import { ApiRequestError, type Employee } from "../../services/api"; +import { ApiRequestError, type Employee, type Role } from "../../services/api"; import { useApi, useAuth } from "../../context/AuthContext"; import Icon from "../../components/common/Icon"; import { @@ -39,6 +39,7 @@ export function UserManagementPage({ const api = useApi(); const { user } = useAuth(); const [employees, setEmployees] = useState([]); + const [roles, setRoles] = useState([]); const [loading, setLoading] = useState(true); const [saving, setSaving] = useState(false); const [editing, setEditing] = useState(null); @@ -51,7 +52,12 @@ export function UserManagementPage({ const load = async (): Promise => { setLoading(true); try { - setEmployees(await api.listPlatformEmployees()); + const [employeeList, roleList] = await Promise.all([ + api.listPlatformEmployees(), + api.listPlatformRoles(), + ]); + setEmployees(employeeList); + setRoles(roleList); onConnectionChange(true); } catch (error) { onConnectionChange(false); @@ -95,7 +101,7 @@ export function UserManagementPage({ onNotify({ tone: "error", message: "请输入密码" }); return; } - // 编辑自身或管理员时,前端二次拦截禁用 status / role_code 的修改 + // 编辑自身时,前端二次拦截禁用 status / role_code 的修改;管理员账号禁止停用/锁定 if (editing) { const editingSelf = editing.user_id === user?.user_id; const targetIsAdmin = editing.role_code === "admin"; @@ -107,10 +113,6 @@ export function UserManagementPage({ onNotify({ tone: "error", message: "不能停用或锁定管理员账号" }); return; } - if (targetIsAdmin && form.role_code !== editing.role_code) { - onNotify({ tone: "error", message: "不能降级管理员账号" }); - return; - } if (editingSelf && form.role_code !== editing.role_code) { onNotify({ tone: "error", message: "不能降级自身管理员角色" }); return; @@ -286,6 +288,27 @@ export function UserManagementPage({ placeholder="请输入邮箱(可选)" /> + {editing && ( + + )} {editing && (