From c2861157afcf93433e6e2c84898d19163d1f2e30 Mon Sep 17 00:00:00 2001 From: zzh <1368735060@qq.com> Date: Fri, 30 Oct 2026 17:51:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=A2=E6=88=B7=E5=85=AC=E5=BC=80?= =?UTF-8?q?=E6=B3=A8=E5=86=8C=E9=BB=98=E8=AE=A4=E7=8A=B6=E6=80=81=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=20Normal=EF=BC=8C=E9=81=BF=E5=85=8D=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E5=90=8E=E6=97=A0=E6=B3=95=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原先 create 默认 status=1 实为 Disabled;并透出登录业务错误文案。 Co-authored-by: Cursor --- src/api/customer/index.ts | 9 ++++++--- src/store/modules/rbac-user.ts | 6 +++++- src/views/login/components/pwd-login/index.vue | 18 +++++++++++++----- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/api/customer/index.ts b/src/api/customer/index.ts index 43b44e9..6cd2dd8 100644 --- a/src/api/customer/index.ts +++ b/src/api/customer/index.ts @@ -3,8 +3,10 @@ */ import { axiosInstance } from '@/api/rbac' import { assertBusinessOk, omsUrl, parseListPayload, unwrapData } from '@/api/oms/common' +import { CUSTOMER_STATUS } from '@/utils/customerStatus' -export type CustomerStatus = 0 | 1 | 2 +/** 与后端 CustomerStatus 对齐:0=None,1=Disabled,2=Normal,3=Frozen */ +export type CustomerStatus = 0 | 1 | 2 | 3 export type CustomerGroup = 0 | 1 | 2 | 3 | 4 | 5 @@ -154,7 +156,7 @@ export const CustomerService = { balance: data.accountBalance ?? data.balance ?? 0, totalQuota: data.totalQuota ?? 0, usedQuota: data.usedQuota ?? 0, - status: data.status ?? 1, + status: data.status ?? CUSTOMER_STATUS.normal, remark: data.remark, salesman: data.salesman ?? data.salesPerson, customerService: data.customerService, @@ -186,7 +188,8 @@ export const CustomerService = { balance: data.accountBalance ?? data.balance, totalQuota: data.totalQuota, usedQuota: data.usedQuota, - status: data.status ?? 1, + // 后端:1=Disabled,2=Normal;勿默认 1,否则公开注册账号无法登录 + status: data.status ?? CUSTOMER_STATUS.normal, role: data.role, remark: data.remark, salesman: data.salesman ?? data.salesPerson, diff --git a/src/store/modules/rbac-user.ts b/src/store/modules/rbac-user.ts index 352a528..605196c 100644 --- a/src/store/modules/rbac-user.ts +++ b/src/store/modules/rbac-user.ts @@ -318,7 +318,11 @@ export const useRbacUserStore = defineStore('rbacUser', () => { enableKeepAlive() await hydrateUserAfterLogin(result) return true - } catch { + } catch (error: unknown) { + // 交给登录页展示业务文案(如「客户已禁用」),勿一律当成账号密码错误 + const anyErr = error as { body?: { message?: string }; message?: string } + const msg = String(anyErr?.body?.message || anyErr?.message || '').trim() + if (msg) throw new Error(msg) return false } } diff --git a/src/views/login/components/pwd-login/index.vue b/src/views/login/components/pwd-login/index.vue index 3d5bdf1..f554177 100644 --- a/src/views/login/components/pwd-login/index.vue +++ b/src/views/login/components/pwd-login/index.vue @@ -350,11 +350,19 @@ async function handleSubmit() { loading.value = true; errorBox.value = ''; - const success = await rbacUserStore.login( - loginForm.account, - loginForm.password, - props.loginType, - ); + let success = false; + try { + success = await rbacUserStore.login( + loginForm.account, + loginForm.password, + props.loginType, + ); + } catch (loginErr: unknown) { + const msg = loginErr instanceof Error ? loginErr.message.trim() : ''; + errorBox.value = msg || t('login.form.login.failed'); + loginCharacters.value?.onLoginFailed(); + return; + } if (success && rbacUserStore.userInfo) { const userInfoData = rbacUserStore.userInfo;