feat: 客户余额人工调整留痕,并修复 OMS 代登 SSO 链路
编辑客户余额改为只读;列表「调整余额」写账户流水。代登改为落到 /login,守卫优先消费 sso,避免官网首页吞掉 token。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
4ff22fed57
commit
50aed33e19
@ -88,7 +88,7 @@ function mapUpdateBody(id: string | number, data: Partial<CustomerDto>) {
|
|||||||
wechatNickname: data.wechatNickname,
|
wechatNickname: data.wechatNickname,
|
||||||
email: data.email,
|
email: data.email,
|
||||||
phone: data.phone,
|
phone: data.phone,
|
||||||
balance: data.accountBalance ?? data.balance,
|
// 余额不走 update,改用 adjustBalance 留痕
|
||||||
totalQuota: data.totalQuota,
|
totalQuota: data.totalQuota,
|
||||||
usedQuota: data.usedQuota,
|
usedQuota: data.usedQuota,
|
||||||
status: data.status,
|
status: data.status,
|
||||||
@ -212,6 +212,20 @@ export const CustomerService = {
|
|||||||
assertBusinessOk(r.data)
|
assertBusinessOk(r.data)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** 人工调整账户余额(差额可正可负),写入账户流水 */
|
||||||
|
async adjustBalance(
|
||||||
|
id: string | number,
|
||||||
|
amount: number,
|
||||||
|
remark: string,
|
||||||
|
): Promise<void> {
|
||||||
|
const r = await axiosInstance.post(omsUrl('/customer/adjust-balance'), {
|
||||||
|
id,
|
||||||
|
amount,
|
||||||
|
remark,
|
||||||
|
})
|
||||||
|
assertBusinessOk(r.data)
|
||||||
|
},
|
||||||
|
|
||||||
async delete(id: string | number): Promise<void> {
|
async delete(id: string | number): Promise<void> {
|
||||||
const r = await axiosInstance.post(omsUrl('/customer/delete'), { id })
|
const r = await axiosInstance.post(omsUrl('/customer/delete'), { id })
|
||||||
assertBusinessOk(r.data)
|
assertBusinessOk(r.data)
|
||||||
@ -270,7 +284,8 @@ export const CustomerService = {
|
|||||||
if (result.refreshToken) {
|
if (result.refreshToken) {
|
||||||
params.set('refreshToken', result.refreshToken)
|
params.set('refreshToken', result.refreshToken)
|
||||||
}
|
}
|
||||||
return `${window.location.origin}/?${params.toString()}`
|
// 必须落到登录路由,守卫才消费 sso;官网 `/` 不会代登
|
||||||
|
return `${window.location.origin}/login?${params.toString()}`
|
||||||
},
|
},
|
||||||
|
|
||||||
async getOpenApiCredential(): Promise<CustomerOpenApiCredentialDto> {
|
async getOpenApiCredential(): Promise<CustomerOpenApiCredentialDto> {
|
||||||
|
|||||||
@ -870,6 +870,7 @@ const CORE_GROUPS: PageButtonGroup[] = [
|
|||||||
{ code: 'Delete', name: '删除' },
|
{ code: 'Delete', name: '删除' },
|
||||||
{ code: 'Reset', name: '重置' },
|
{ code: 'Reset', name: '重置' },
|
||||||
{ code: 'ResetPassword', name: '重置密码' },
|
{ code: 'ResetPassword', name: '重置密码' },
|
||||||
|
{ code: 'AdjustBalance', name: '调整余额' },
|
||||||
{ code: 'OmsLogin', name: 'OMS登录' },
|
{ code: 'OmsLogin', name: 'OMS登录' },
|
||||||
{ code: 'ApiKey', name: '开放接口凭证' },
|
{ code: 'ApiKey', name: '开放接口凭证' },
|
||||||
{ code: 'ApiKeyReset', name: '重置开放接口密钥' },
|
{ code: 'ApiKeyReset', name: '重置开放接口密钥' },
|
||||||
|
|||||||
@ -4930,6 +4930,8 @@ export default {
|
|||||||
'user.accountFlow.search.actions.reset': 'Reset',
|
'user.accountFlow.search.actions.reset': 'Reset',
|
||||||
'user.accountFlow.bizType.recharge': 'Recharge credit',
|
'user.accountFlow.bizType.recharge': 'Recharge credit',
|
||||||
'user.accountFlow.bizType.orderPay': 'Order payment',
|
'user.accountFlow.bizType.orderPay': 'Order payment',
|
||||||
|
'user.accountFlow.bizType.pickupPay': 'Pickup payment',
|
||||||
|
'user.accountFlow.bizType.manualAdjust': 'Manual adjust',
|
||||||
'user.accountFlow.message.loadError': 'Failed to load account transactions',
|
'user.accountFlow.message.loadError': 'Failed to load account transactions',
|
||||||
'user.accountFlow.table.serialNumber': 'Serial no.',
|
'user.accountFlow.table.serialNumber': 'Serial no.',
|
||||||
'user.accountFlow.table.createTime': 'Time',
|
'user.accountFlow.table.createTime': 'Time',
|
||||||
@ -5153,6 +5155,7 @@ export default {
|
|||||||
'user.customer.actions.edit': 'Edit',
|
'user.customer.actions.edit': 'Edit',
|
||||||
'user.customer.actions.delete': 'Delete',
|
'user.customer.actions.delete': 'Delete',
|
||||||
'user.customer.actions.resetPassword': 'Reset Password',
|
'user.customer.actions.resetPassword': 'Reset Password',
|
||||||
|
'user.customer.actions.adjustBalance': 'Adjust Balance',
|
||||||
'user.customer.actions.omsLogin': 'OMS Login',
|
'user.customer.actions.omsLogin': 'OMS Login',
|
||||||
'user.customer.actions.openapi': 'Open API',
|
'user.customer.actions.openapi': 'Open API',
|
||||||
'user.customer.openapi.tip':
|
'user.customer.openapi.tip':
|
||||||
@ -5191,6 +5194,8 @@ export default {
|
|||||||
'user.customer.fields.phone': 'Phone',
|
'user.customer.fields.phone': 'Phone',
|
||||||
'user.customer.fields.password': 'Password',
|
'user.customer.fields.password': 'Password',
|
||||||
'user.customer.fields.accountBalance': 'Account Balance',
|
'user.customer.fields.accountBalance': 'Account Balance',
|
||||||
|
'user.customer.fields.adjustAmount': 'Adjustment Amount',
|
||||||
|
'user.customer.fields.adjustRemark': 'Reason',
|
||||||
'user.customer.fields.totalQuota': 'Total Quota',
|
'user.customer.fields.totalQuota': 'Total Quota',
|
||||||
'user.customer.fields.usedQuota': 'Used Quota',
|
'user.customer.fields.usedQuota': 'Used Quota',
|
||||||
'user.customer.fields.status': 'Status',
|
'user.customer.fields.status': 'Status',
|
||||||
@ -5233,6 +5238,8 @@ export default {
|
|||||||
'user.customer.placeholder.wechatNickname': 'Optional',
|
'user.customer.placeholder.wechatNickname': 'Optional',
|
||||||
'user.customer.placeholder.wechatAvatarUrl': 'Avatar image URL (optional)',
|
'user.customer.placeholder.wechatAvatarUrl': 'Avatar image URL (optional)',
|
||||||
'user.customer.placeholder.amount': 'Amount',
|
'user.customer.placeholder.amount': 'Amount',
|
||||||
|
'user.customer.placeholder.adjustAmount': 'Positive credit / negative debit; not zero',
|
||||||
|
'user.customer.placeholder.adjustRemark': 'Required reason for the adjustment',
|
||||||
'user.customer.placeholder.priceTierKey': 'Select or enter price tier',
|
'user.customer.placeholder.priceTierKey': 'Select or enter price tier',
|
||||||
'user.customer.placeholder.remark': 'Optional remark',
|
'user.customer.placeholder.remark': 'Optional remark',
|
||||||
'user.customer.section.basic': 'Basic Info',
|
'user.customer.section.basic': 'Basic Info',
|
||||||
@ -5243,7 +5250,8 @@ export default {
|
|||||||
'user.customer.tip.status': 'Disabled customers cannot sign in',
|
'user.customer.tip.status': 'Disabled customers cannot sign in',
|
||||||
'user.customer.tip.password': 'Password must contain both letters and digits',
|
'user.customer.tip.password': 'Password must contain both letters and digits',
|
||||||
'user.customer.tip.wechatAvatar': 'Accessible image URL for the avatar',
|
'user.customer.tip.wechatAvatar': 'Accessible image URL for the avatar',
|
||||||
'user.customer.tip.accountBalance': 'Available balance — adjust carefully',
|
'user.customer.tip.accountBalance': 'Read-only when editing; use Adjust Balance to leave a ledger entry',
|
||||||
|
'user.customer.tip.adjustBalance': 'Writes an account-flow entry (manual adjust). Check Account Flow to audit.',
|
||||||
'user.customer.tip.totalQuota': 'Credit limit',
|
'user.customer.tip.totalQuota': 'Credit limit',
|
||||||
'user.customer.tip.usedQuota': 'Used quota, usually accumulated by the system',
|
'user.customer.tip.usedQuota': 'Used quota, usually accumulated by the system',
|
||||||
'user.customer.tip.memberLevel': 'Auto-assigned from rolling 12-month paid base-freight points',
|
'user.customer.tip.memberLevel': 'Auto-assigned from rolling 12-month paid base-freight points',
|
||||||
@ -5256,6 +5264,8 @@ export default {
|
|||||||
'user.customer.rules.emailRequired': 'Please enter email',
|
'user.customer.rules.emailRequired': 'Please enter email',
|
||||||
'user.customer.rules.passwordRequired': 'Please enter password',
|
'user.customer.rules.passwordRequired': 'Please enter password',
|
||||||
'user.customer.rules.passwordLetterAndDigit': 'Password must contain both letters and numbers',
|
'user.customer.rules.passwordLetterAndDigit': 'Password must contain both letters and numbers',
|
||||||
|
'user.customer.rules.adjustAmountRequired': 'Enter a non-zero adjustment amount',
|
||||||
|
'user.customer.rules.adjustRemarkRequired': 'Enter a reason (at least 2 characters)',
|
||||||
'user.customer.hint.autoCustomerCode': 'Auto-generated on save (e.g. AF0A1, 1st customer in Jun 2026)',
|
'user.customer.hint.autoCustomerCode': 'Auto-generated on save (e.g. AF0A1, 1st customer in Jun 2026)',
|
||||||
'user.customer.message.loadFailed': 'Load failed',
|
'user.customer.message.loadFailed': 'Load failed',
|
||||||
'user.customer.message.createSuccess': 'Created successfully',
|
'user.customer.message.createSuccess': 'Created successfully',
|
||||||
@ -5265,6 +5275,9 @@ export default {
|
|||||||
'user.customer.message.saveFailed': 'Save failed',
|
'user.customer.message.saveFailed': 'Save failed',
|
||||||
'user.customer.message.resetPasswordSuccess': 'Password reset successfully',
|
'user.customer.message.resetPasswordSuccess': 'Password reset successfully',
|
||||||
'user.customer.message.resetPasswordFailed': 'Password reset failed',
|
'user.customer.message.resetPasswordFailed': 'Password reset failed',
|
||||||
|
'user.customer.message.adjustBalanceSuccess': 'Balance adjusted and recorded in account flow',
|
||||||
|
'user.customer.message.adjustBalanceFailed': 'Failed to adjust balance',
|
||||||
|
'user.customer.message.adjustBalanceIdMissing': 'Customer id missing',
|
||||||
'user.customer.pagination.total': 'Total {count} records',
|
'user.customer.pagination.total': 'Total {count} records',
|
||||||
'user.customer.pagination.prev': 'Prev',
|
'user.customer.pagination.prev': 'Prev',
|
||||||
'user.customer.pagination.next': 'Next',
|
'user.customer.pagination.next': 'Next',
|
||||||
|
|||||||
@ -4950,6 +4950,8 @@ export default {
|
|||||||
'user.accountFlow.search.actions.reset': '重置',
|
'user.accountFlow.search.actions.reset': '重置',
|
||||||
'user.accountFlow.bizType.recharge': '充值入账',
|
'user.accountFlow.bizType.recharge': '充值入账',
|
||||||
'user.accountFlow.bizType.orderPay': '订单支付',
|
'user.accountFlow.bizType.orderPay': '订单支付',
|
||||||
|
'user.accountFlow.bizType.pickupPay': '揽收支付',
|
||||||
|
'user.accountFlow.bizType.manualAdjust': '人工调整',
|
||||||
'user.accountFlow.message.loadError': '加载资金流水失败',
|
'user.accountFlow.message.loadError': '加载资金流水失败',
|
||||||
'user.accountFlow.table.serialNumber': '流水号',
|
'user.accountFlow.table.serialNumber': '流水号',
|
||||||
'user.accountFlow.table.createTime': '交易时间',
|
'user.accountFlow.table.createTime': '交易时间',
|
||||||
@ -5172,6 +5174,7 @@ export default {
|
|||||||
'user.customer.actions.edit': '编辑',
|
'user.customer.actions.edit': '编辑',
|
||||||
'user.customer.actions.delete': '删除',
|
'user.customer.actions.delete': '删除',
|
||||||
'user.customer.actions.resetPassword': '重置密码',
|
'user.customer.actions.resetPassword': '重置密码',
|
||||||
|
'user.customer.actions.adjustBalance': '调整余额',
|
||||||
'user.customer.actions.omsLogin': 'OMS登录',
|
'user.customer.actions.omsLogin': 'OMS登录',
|
||||||
'user.customer.actions.openapi': '开放接口',
|
'user.customer.actions.openapi': '开放接口',
|
||||||
'user.customer.openapi.tip':
|
'user.customer.openapi.tip':
|
||||||
@ -5209,6 +5212,8 @@ export default {
|
|||||||
'user.customer.fields.phone': '手机号',
|
'user.customer.fields.phone': '手机号',
|
||||||
'user.customer.fields.password': '登录密码',
|
'user.customer.fields.password': '登录密码',
|
||||||
'user.customer.fields.accountBalance': '账号余额',
|
'user.customer.fields.accountBalance': '账号余额',
|
||||||
|
'user.customer.fields.adjustAmount': '调整金额',
|
||||||
|
'user.customer.fields.adjustRemark': '调整原因',
|
||||||
'user.customer.fields.totalQuota': '总额度',
|
'user.customer.fields.totalQuota': '总额度',
|
||||||
'user.customer.fields.usedQuota': '已用额度',
|
'user.customer.fields.usedQuota': '已用额度',
|
||||||
'user.customer.fields.status': '状态',
|
'user.customer.fields.status': '状态',
|
||||||
@ -5251,6 +5256,8 @@ export default {
|
|||||||
'user.customer.placeholder.wechatNickname': '选填',
|
'user.customer.placeholder.wechatNickname': '选填',
|
||||||
'user.customer.placeholder.wechatAvatarUrl': '头像图片 URL,选填',
|
'user.customer.placeholder.wechatAvatarUrl': '头像图片 URL,选填',
|
||||||
'user.customer.placeholder.amount': '金额',
|
'user.customer.placeholder.amount': '金额',
|
||||||
|
'user.customer.placeholder.adjustAmount': '正数入账,负数扣减,不可为 0',
|
||||||
|
'user.customer.placeholder.adjustRemark': '请说明调整原因(必填)',
|
||||||
'user.customer.placeholder.priceTierKey': '选择或输入价区键',
|
'user.customer.placeholder.priceTierKey': '选择或输入价区键',
|
||||||
'user.customer.placeholder.remark': '选填备注',
|
'user.customer.placeholder.remark': '选填备注',
|
||||||
'user.customer.section.basic': '基础信息',
|
'user.customer.section.basic': '基础信息',
|
||||||
@ -5261,7 +5268,8 @@ export default {
|
|||||||
'user.customer.tip.status': '禁用后客户无法登录系统',
|
'user.customer.tip.status': '禁用后客户无法登录系统',
|
||||||
'user.customer.tip.password': '密码须同时包含字母和数字',
|
'user.customer.tip.password': '密码须同时包含字母和数字',
|
||||||
'user.customer.tip.wechatAvatar': '填写可访问的头像图片地址',
|
'user.customer.tip.wechatAvatar': '填写可访问的头像图片地址',
|
||||||
'user.customer.tip.accountBalance': '客户可用余额,谨慎手工调整',
|
'user.customer.tip.accountBalance': '编辑时只读;请用列表「调整余额」留痕',
|
||||||
|
'user.customer.tip.adjustBalance': '调整后写入账户流水(人工调整),可在账户流水页查询。',
|
||||||
'user.customer.tip.totalQuota': '信用总额度上限',
|
'user.customer.tip.totalQuota': '信用总额度上限',
|
||||||
'user.customer.tip.usedQuota': '已占用额度,通常由系统累计',
|
'user.customer.tip.usedQuota': '已占用额度,通常由系统累计',
|
||||||
'user.customer.tip.memberLevel': '由近 12 个月实付基础运费积分自动定级,可手工调整',
|
'user.customer.tip.memberLevel': '由近 12 个月实付基础运费积分自动定级,可手工调整',
|
||||||
@ -5274,6 +5282,8 @@ export default {
|
|||||||
'user.customer.rules.emailRequired': '请输入邮箱',
|
'user.customer.rules.emailRequired': '请输入邮箱',
|
||||||
'user.customer.rules.passwordRequired': '请输入登录密码',
|
'user.customer.rules.passwordRequired': '请输入登录密码',
|
||||||
'user.customer.rules.passwordLetterAndDigit': '密码须同时包含字母和数字',
|
'user.customer.rules.passwordLetterAndDigit': '密码须同时包含字母和数字',
|
||||||
|
'user.customer.rules.adjustAmountRequired': '请输入非 0 的调整金额',
|
||||||
|
'user.customer.rules.adjustRemarkRequired': '请填写至少 2 个字的调整原因',
|
||||||
'user.customer.hint.autoCustomerCode': '保存后系统自动生成(如 AF0A1,2026年6月第1号)',
|
'user.customer.hint.autoCustomerCode': '保存后系统自动生成(如 AF0A1,2026年6月第1号)',
|
||||||
'user.customer.message.loadFailed': '加载失败',
|
'user.customer.message.loadFailed': '加载失败',
|
||||||
'user.customer.message.createSuccess': '新增成功',
|
'user.customer.message.createSuccess': '新增成功',
|
||||||
@ -5283,6 +5293,9 @@ export default {
|
|||||||
'user.customer.message.saveFailed': '保存失败',
|
'user.customer.message.saveFailed': '保存失败',
|
||||||
'user.customer.message.resetPasswordSuccess': '重置密码成功',
|
'user.customer.message.resetPasswordSuccess': '重置密码成功',
|
||||||
'user.customer.message.resetPasswordFailed': '重置密码失败',
|
'user.customer.message.resetPasswordFailed': '重置密码失败',
|
||||||
|
'user.customer.message.adjustBalanceSuccess': '余额已调整并记入流水',
|
||||||
|
'user.customer.message.adjustBalanceFailed': '调整余额失败',
|
||||||
|
'user.customer.message.adjustBalanceIdMissing': '无法获取客户 ID',
|
||||||
'user.customer.pagination.total': '共 {count} 条记录',
|
'user.customer.pagination.total': '共 {count} 条记录',
|
||||||
'user.customer.pagination.prev': '上一页',
|
'user.customer.pagination.prev': '上一页',
|
||||||
'user.customer.pagination.next': '下一页',
|
'user.customer.pagination.next': '下一页',
|
||||||
|
|||||||
@ -77,6 +77,43 @@ export default function setupUserLoginInfoGuard(router: Router) {
|
|||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const rbacUserStore = useRbacUserStore();
|
const rbacUserStore = useRbacUserStore();
|
||||||
|
|
||||||
|
// 管理员「OMS登录」代登:须先于登录页 H5 分流,否则会丢掉 accessToken
|
||||||
|
const ssoToken =
|
||||||
|
typeof to.query.accessToken === 'string' ? to.query.accessToken : '';
|
||||||
|
if (to.query.sso === '1' && ssoToken) {
|
||||||
|
NProgress.done();
|
||||||
|
try {
|
||||||
|
const refreshToken =
|
||||||
|
typeof to.query.refreshToken === 'string'
|
||||||
|
? to.query.refreshToken
|
||||||
|
: undefined;
|
||||||
|
const ok = await rbacUserStore.loginBySsoResult({
|
||||||
|
accessToken: ssoToken,
|
||||||
|
refreshToken: refreshToken || null,
|
||||||
|
});
|
||||||
|
if (ok && rbacUserStore.userInfo) {
|
||||||
|
applyRbacUserToUserStore(rbacUserStore.userInfo);
|
||||||
|
if (rbacUserStore.token) {
|
||||||
|
setToken(rbacUserStore.token, true);
|
||||||
|
}
|
||||||
|
next({
|
||||||
|
path: getDefaultHomePathByType(OmsLoginType.Customer),
|
||||||
|
query: {},
|
||||||
|
replace: true,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('客户门户 SSO 登录失败', error);
|
||||||
|
}
|
||||||
|
next({
|
||||||
|
path: preferH5Portal() ? '/h5/login' : '/login',
|
||||||
|
query: {},
|
||||||
|
replace: true,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (isLoginRouteName(to.name as string)) {
|
if (isLoginRouteName(to.name as string)) {
|
||||||
NProgress.done();
|
NProgress.done();
|
||||||
hasEnsuredUser = false;
|
hasEnsuredUser = false;
|
||||||
@ -133,41 +170,6 @@ export default function setupUserLoginInfoGuard(router: Router) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ssoToken =
|
|
||||||
typeof to.query.accessToken === 'string' ? to.query.accessToken : '';
|
|
||||||
if (to.query.sso === '1' && ssoToken) {
|
|
||||||
try {
|
|
||||||
const refreshToken =
|
|
||||||
typeof to.query.refreshToken === 'string'
|
|
||||||
? to.query.refreshToken
|
|
||||||
: undefined;
|
|
||||||
const ok = await rbacUserStore.loginBySsoResult({
|
|
||||||
accessToken: ssoToken,
|
|
||||||
refreshToken: refreshToken || null,
|
|
||||||
});
|
|
||||||
if (ok && rbacUserStore.userInfo) {
|
|
||||||
applyRbacUserToUserStore(rbacUserStore.userInfo);
|
|
||||||
if (rbacUserStore.token) {
|
|
||||||
setToken(rbacUserStore.token, true);
|
|
||||||
}
|
|
||||||
next({
|
|
||||||
path: getDefaultHomePathByType(OmsLoginType.Customer),
|
|
||||||
query: {},
|
|
||||||
replace: true,
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('客户门户 SSO 登录失败', error);
|
|
||||||
}
|
|
||||||
next({
|
|
||||||
path: preferH5Portal() ? '/h5/login' : '/login',
|
|
||||||
query: {},
|
|
||||||
replace: true,
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 官网「去发货」:客户已登录进工作台;管理端账号展示客户登录页,避免误进后台
|
// 官网「去发货」:客户已登录进工作台;管理端账号展示客户登录页,避免误进后台
|
||||||
const fromOfficialSite = to.query.from === 'official-site';
|
const fromOfficialSite = to.query.from === 'official-site';
|
||||||
if (isLogin() && fromOfficialSite && to.name === 'login') {
|
if (isLogin() && fromOfficialSite && to.name === 'login') {
|
||||||
|
|||||||
@ -102,6 +102,10 @@ export const warehouseActionIcons = {
|
|||||||
enable: svg(
|
enable: svg(
|
||||||
'<circle cx="12" cy="12" r="9"/><path d="M20 6 9 17l-5-5"/>',
|
'<circle cx="12" cy="12" r="9"/><path d="M20 6 9 17l-5-5"/>',
|
||||||
),
|
),
|
||||||
|
/** 调整余额 */
|
||||||
|
adjustBalance: svg(
|
||||||
|
'<rect x="2" y="5" width="20" height="14" rx="2"/><path d="M2 10h20"/><path d="M12 13v4"/><path d="M10 15h4"/>',
|
||||||
|
),
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
export type WarehouseActionVariant = keyof typeof warehouseActionIcons
|
export type WarehouseActionVariant = keyof typeof warehouseActionIcons
|
||||||
|
|||||||
@ -20,6 +20,8 @@
|
|||||||
<a-option value="all">{{ t('user.accountFlow.search.bizTypeAll') }}</a-option>
|
<a-option value="all">{{ t('user.accountFlow.search.bizTypeAll') }}</a-option>
|
||||||
<a-option value="recharge">{{ t('user.accountFlow.bizType.recharge') }}</a-option>
|
<a-option value="recharge">{{ t('user.accountFlow.bizType.recharge') }}</a-option>
|
||||||
<a-option value="orderPay">{{ t('user.accountFlow.bizType.orderPay') }}</a-option>
|
<a-option value="orderPay">{{ t('user.accountFlow.bizType.orderPay') }}</a-option>
|
||||||
|
<a-option value="pickupPay">{{ t('user.accountFlow.bizType.pickupPay') }}</a-option>
|
||||||
|
<a-option value="manualAdjust">{{ t('user.accountFlow.bizType.manualAdjust') }}</a-option>
|
||||||
</a-select>
|
</a-select>
|
||||||
<a-input-number
|
<a-input-number
|
||||||
v-model="customerIdFilter"
|
v-model="customerIdFilter"
|
||||||
|
|||||||
@ -254,6 +254,7 @@
|
|||||||
v-model="formState.accountBalance"
|
v-model="formState.accountBalance"
|
||||||
:placeholder="t('user.customer.placeholder.amount')"
|
:placeholder="t('user.customer.placeholder.amount')"
|
||||||
:precision="2"
|
:precision="2"
|
||||||
|
:disabled="isEdit"
|
||||||
hide-button
|
hide-button
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
/>
|
/>
|
||||||
@ -423,6 +424,49 @@
|
|||||||
:customer-id="openapiCustomerId"
|
:customer-id="openapiCustomerId"
|
||||||
/>
|
/>
|
||||||
</a-modal>
|
</a-modal>
|
||||||
|
|
||||||
|
<a-modal
|
||||||
|
v-model:visible="adjustBalanceVisible"
|
||||||
|
:title="t('user.customer.actions.adjustBalance')"
|
||||||
|
:ok-loading="adjustBalanceLoading"
|
||||||
|
unmount-on-close
|
||||||
|
:on-before-ok="handleAdjustBalanceSubmit"
|
||||||
|
@cancel="adjustBalanceVisible = false"
|
||||||
|
>
|
||||||
|
<a-form :model="adjustBalanceForm" layout="vertical">
|
||||||
|
<a-form-item :label="t('user.customer.fields.customerCode')">
|
||||||
|
<a-input :model-value="adjustBalanceTarget?.customerCode || ''" disabled />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item :label="t('user.customer.fields.accountBalance')">
|
||||||
|
<a-input :model-value="adjustBalanceCurrentDisplay" disabled />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item
|
||||||
|
:label="t('user.customer.fields.adjustAmount')"
|
||||||
|
required
|
||||||
|
>
|
||||||
|
<a-input-number
|
||||||
|
v-model="adjustBalanceForm.amount"
|
||||||
|
:placeholder="t('user.customer.placeholder.adjustAmount')"
|
||||||
|
:precision="2"
|
||||||
|
hide-button
|
||||||
|
style="width: 100%"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item
|
||||||
|
:label="t('user.customer.fields.adjustRemark')"
|
||||||
|
required
|
||||||
|
>
|
||||||
|
<a-textarea
|
||||||
|
v-model="adjustBalanceForm.remark"
|
||||||
|
:placeholder="t('user.customer.placeholder.adjustRemark')"
|
||||||
|
:max-length="512"
|
||||||
|
show-word-limit
|
||||||
|
:auto-size="{ minRows: 3, maxRows: 6 }"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
<p class="adjust-balance-hint">{{ t('user.customer.tip.adjustBalance') }}</p>
|
||||||
|
</a-form>
|
||||||
|
</a-modal>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -903,6 +947,11 @@ function actionRenderer(_row: any, rowIndex: number): string {
|
|||||||
return wrapWarehouseActions(
|
return wrapWarehouseActions(
|
||||||
[
|
[
|
||||||
renderWarehouseActionBtn('edit', t('user.customer.actions.edit')),
|
renderWarehouseActionBtn('edit', t('user.customer.actions.edit')),
|
||||||
|
renderWarehouseActionBtn(
|
||||||
|
'adjustBalance',
|
||||||
|
t('user.customer.actions.adjustBalance'),
|
||||||
|
'adjustBalance',
|
||||||
|
),
|
||||||
...(isMain
|
...(isMain
|
||||||
? [renderWarehouseActionBtn('openapi', t('user.customer.actions.openapi'), 'auth')]
|
? [renderWarehouseActionBtn('openapi', t('user.customer.actions.openapi'), 'auth')]
|
||||||
: []),
|
: []),
|
||||||
@ -961,6 +1010,9 @@ function handleActionClick(row: any, rowIndex: number, action?: string) {
|
|||||||
case 'edit':
|
case 'edit':
|
||||||
handleEdit(record)
|
handleEdit(record)
|
||||||
break
|
break
|
||||||
|
case 'adjustBalance':
|
||||||
|
handleAdjustBalance(record)
|
||||||
|
break
|
||||||
case 'delete':
|
case 'delete':
|
||||||
handleDelete(resolveCustomerId(record))
|
handleDelete(resolveCustomerId(record))
|
||||||
break
|
break
|
||||||
@ -1149,6 +1201,59 @@ function handleResetPassword(record: CustomerRow) {
|
|||||||
resetPwdVisible.value = true
|
resetPwdVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const adjustBalanceVisible = ref(false)
|
||||||
|
const adjustBalanceLoading = ref(false)
|
||||||
|
const adjustBalanceTarget = ref<CustomerRow | null>(null)
|
||||||
|
const adjustBalanceForm = reactive({
|
||||||
|
amount: undefined as number | undefined,
|
||||||
|
remark: '',
|
||||||
|
})
|
||||||
|
|
||||||
|
const adjustBalanceCurrentDisplay = computed(() => {
|
||||||
|
const raw = adjustBalanceTarget.value?.accountBalance ?? adjustBalanceTarget.value?.balance
|
||||||
|
const n = Number(raw)
|
||||||
|
if (!Number.isFinite(n)) return '--'
|
||||||
|
return n.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
|
||||||
|
})
|
||||||
|
|
||||||
|
function handleAdjustBalance(record: CustomerRow) {
|
||||||
|
adjustBalanceTarget.value = record
|
||||||
|
adjustBalanceForm.amount = undefined
|
||||||
|
adjustBalanceForm.remark = ''
|
||||||
|
adjustBalanceVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleAdjustBalanceSubmit(): Promise<boolean> {
|
||||||
|
const customerId = resolveCustomerId(adjustBalanceTarget.value)
|
||||||
|
if (customerId == null) {
|
||||||
|
Message.warning(t('user.customer.message.adjustBalanceIdMissing'))
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
const amount = Number(adjustBalanceForm.amount)
|
||||||
|
if (!Number.isFinite(amount) || amount === 0) {
|
||||||
|
Message.warning(t('user.customer.rules.adjustAmountRequired'))
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
const remark = String(adjustBalanceForm.remark || '').trim()
|
||||||
|
if (remark.length < 2) {
|
||||||
|
Message.warning(t('user.customer.rules.adjustRemarkRequired'))
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
adjustBalanceLoading.value = true
|
||||||
|
try {
|
||||||
|
await CustomerService.adjustBalance(customerId, amount, remark)
|
||||||
|
Message.success(t('user.customer.message.adjustBalanceSuccess'))
|
||||||
|
adjustBalanceVisible.value = false
|
||||||
|
await loadList()
|
||||||
|
return true
|
||||||
|
} catch (e: any) {
|
||||||
|
Message.error(e?.message || t('user.customer.message.adjustBalanceFailed'))
|
||||||
|
return false
|
||||||
|
} finally {
|
||||||
|
adjustBalanceLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function handleResetPwdSubmit() {
|
async function handleResetPwdSubmit() {
|
||||||
const customerId = resolveCustomerId(resetPwdTarget.value)
|
const customerId = resolveCustomerId(resetPwdTarget.value)
|
||||||
if (customerId == null) {
|
if (customerId == null) {
|
||||||
@ -1342,6 +1447,13 @@ onMounted(() => {
|
|||||||
padding: 4px 0;
|
padding: 4px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.adjust-balance-hint {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.5;
|
||||||
|
color: var(--color-text-3);
|
||||||
|
}
|
||||||
|
|
||||||
.form-section-title {
|
.form-section-title {
|
||||||
margin: 0 0 12px;
|
margin: 0 0 12px;
|
||||||
padding: 0 0 8px;
|
padding: 0 0 8px;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user