fix(admin,api): 上分超额提示而非静默截断,并返回中文业务错误
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -143,6 +143,20 @@ const transferAmountDisabled = computed(() => {
|
||||
return max === 0;
|
||||
});
|
||||
|
||||
/** 勿用 el-input-number :max,否则会静默截断到上限 */
|
||||
const transferAmountExceedsCap = computed(() => {
|
||||
const max = transferAmountRange.value.max;
|
||||
if (max === undefined) return false;
|
||||
return transferAmount.value > max;
|
||||
});
|
||||
|
||||
const transferAmountCapError = computed(() => {
|
||||
if (!transferAmountExceedsCap.value) return '';
|
||||
return transferType.value === 'deposit'
|
||||
? t('err.insufficient_credit')
|
||||
: t('transfer.context.withdraw_exceed');
|
||||
});
|
||||
|
||||
/* ─── Init ─── */
|
||||
onMounted(async () => {
|
||||
await loadProfile();
|
||||
@@ -818,17 +832,20 @@ function statusTagType(s: string) {
|
||||
<el-form-item :label="t('common.col_id')">
|
||||
<span>{{ transferTarget?.id }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('user.field.amount')">
|
||||
<el-form-item :label="t('user.field.amount')" :error="transferAmountCapError">
|
||||
<el-input-number
|
||||
v-model="transferAmount"
|
||||
:min="transferAmountRange.min" :max="transferAmountRange.max"
|
||||
:disabled="transferAmountDisabled" :step="10" :precision="2" style="width: 100%"
|
||||
:min="transferAmountRange.min"
|
||||
:disabled="transferAmountDisabled"
|
||||
:step="10"
|
||||
:precision="2"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="transferVisible = false">{{ t('common.cancel') }}</el-button>
|
||||
<el-button type="primary" :loading="transferLoading" :disabled="transferAmountDisabled" @click="submitTransfer">{{ t('common.confirm') }}</el-button>
|
||||
<el-button type="primary" :loading="transferLoading" :disabled="transferAmountDisabled || transferAmountExceedsCap" @click="submitTransfer">{{ t('common.confirm') }}</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user