修复重复弹msg的bug
deploy-userbase-front / build-and-deploy (push) Successful in 2m27s

This commit is contained in:
chenxing
2026-08-18 23:31:27 +08:00
parent 8fd5a21fcc
commit 02f1fd2b14
32 changed files with 4843 additions and 2530 deletions
@@ -42,8 +42,8 @@ onSuccess(() => {
onSuccessCallback?.();
});
onError((event) => {
const msg = event?.error?.message || '编辑失败';
Message.error(normalizeAccountError(msg, form.value.account));
// 错误提示已由全局 alova 拦截器统一弹出,这里仅记录日志避免二次弹窗
console.warn('[EditUserContainer] 编辑失败:', event?.error?.message || '编辑失败');
});
/* ---------- 打开编辑弹窗 ---------- */
@@ -100,7 +100,8 @@ async function open(row: any, groups: any[], curGroupId?: number | null, onSucce
roleOptions.value = list.map((r: any) => ({ id: r.id, name: r.name }));
roleOptionsLoaded.value = true;
} catch (e: any) {
Message.error('加载角色列表失败:' + (e?.message || '未知错误'));
// 全局拦截器已弹窗,这里仅记录日志避免二次弹窗
console.warn('[EditUserContainer] 加载角色列表失败:', e?.message || '未知错误');
}
// 3) 已绑定角色 -> appRoles 回填(相互独立)
@@ -118,7 +119,8 @@ async function open(row: any, groups: any[], curGroupId?: number | null, onSucce
} catch (e: any) {
// 已绑定角色加载失败:仍回填其它字段,但标记未加载成功(提交时不回写,避免误清空)
detailData.value = buildInitForm(row, [], defaultGroupId);
Message.error('加载用户已绑定角色失败:' + (e?.message || '未知错误'));
// 全局拦截器已弹窗,这里仅记录日志避免二次弹窗
console.warn('[EditUserContainer] 加载用户已绑定角色失败:', e?.message || '未知错误');
}
}
@@ -159,7 +161,8 @@ async function handleSubmit(formData: Record<string, any>) {
try {
await Apis.AppRole.saveUserRoles({ data: { userId: currentId.value as number, roleIds: appRolesToSave } });
} catch (e: any) {
Message.error('用户已更新,但角色属性保存失败:' + (e?.message || '未知错误'));
// 全局拦截器已弹窗,这里仅记录日志避免二次弹窗
console.warn('[EditUserContainer] 用户已更新,但角色属性保存失败:', e?.message || '未知错误');
}
}
}
@@ -190,13 +193,5 @@ function buildPayload(formData: Record<string, any>, id: number) {
return payload;
}
/* ---------- 工具:账号重复提示标准化 ---------- */
function normalizeAccountError(msg: string, account: string): string {
if (account && /账号/.test(msg) && /(已存在|重复|已被其他用户使用)/.test(msg)) {
return `账号${account}已存在`;
}
return msg;
}
defineExpose({ open, visible });
</script>