R84 R86 收口用户开通界面与自动化回归
这个提交包含在:
@@ -49,7 +49,12 @@ export function UserManagementPage() {
|
||||
const [q, setQ] = useState("");
|
||||
const [page, setPage] = useState(1);
|
||||
const [error, setError] = useState("");
|
||||
const [resetResult, setResetResult] = useState<{ userId: string; password: string } | null>(null);
|
||||
const [credentialResult, setCredentialResult] = useState<{
|
||||
mode: "create" | "reset";
|
||||
userId: string;
|
||||
employeeNo?: string;
|
||||
password: string;
|
||||
} | null>(null);
|
||||
|
||||
const [createOpen, setCreateOpen] = useState(false);
|
||||
const [importOpen, setImportOpen] = useState(false);
|
||||
@@ -74,10 +79,16 @@ export function UserManagementPage() {
|
||||
|
||||
const createMutation = useMutation({
|
||||
mutationFn: (payload: CreateUserFormData) => createUser(payload),
|
||||
onSuccess: async () => {
|
||||
onSuccess: async (data) => {
|
||||
await queryClient.invalidateQueries({ queryKey: ["users"] });
|
||||
setCreateOpen(false);
|
||||
setError("");
|
||||
setCredentialResult({
|
||||
mode: "create",
|
||||
userId: data.id,
|
||||
employeeNo: data.employeeNo,
|
||||
password: data.oneTimePassword,
|
||||
});
|
||||
toast.success("用户已创建");
|
||||
},
|
||||
onError: (err) => {
|
||||
@@ -109,7 +120,7 @@ export function UserManagementPage() {
|
||||
const resetMutation = useMutation({
|
||||
mutationFn: async (item: UserSummary) => resetUserPassword(item.id),
|
||||
onSuccess: async (data) => {
|
||||
setResetResult({ userId: data.id, password: data.oneTimePassword });
|
||||
setCredentialResult({ mode: "reset", userId: data.id, password: data.oneTimePassword });
|
||||
await queryClient.invalidateQueries({ queryKey: ["users"] });
|
||||
setError("");
|
||||
toast.success("密码已重置");
|
||||
@@ -142,7 +153,7 @@ export function UserManagementPage() {
|
||||
<div className="space-y-6">
|
||||
<PageHeader
|
||||
title="系统用户管理"
|
||||
subtitle="创建/启用/禁用账号,重置密码并分配角色(仅试运行最小运营)。"
|
||||
subtitle="创建/启用/禁用账号,系统自动生成工号并展示一次性口令,管理员只负责最小开通与角色分配。"
|
||||
actions={
|
||||
<div className="flex gap-2">
|
||||
<UserImportDialog
|
||||
@@ -184,9 +195,21 @@ export function UserManagementPage() {
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
{resetResult ? (
|
||||
{credentialResult ? (
|
||||
<p className="rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-800" data-testid="users-reset-result">
|
||||
已重置密码(user={resetResult.userId}),一次性口令:<span className="font-mono">{resetResult.password}</span>
|
||||
{credentialResult.mode === "create"
|
||||
? (
|
||||
<>
|
||||
已创建用户(user={credentialResult.userId}
|
||||
{credentialResult.employeeNo ? `,工号=${credentialResult.employeeNo}` : ""}
|
||||
),一次性口令:<span className="font-mono">{credentialResult.password}</span>
|
||||
</>
|
||||
)
|
||||
: (
|
||||
<>
|
||||
已重置密码(user={credentialResult.userId}),一次性口令:<span className="font-mono">{credentialResult.password}</span>
|
||||
</>
|
||||
)}
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
|
||||
在新工单中引用
屏蔽一个用户