This commit is contained in:
@@ -121,15 +121,16 @@
|
||||
<ElFormItem label="提现金额" prop="amount">
|
||||
<ElInputNumber
|
||||
v-model="withdrawalForm.amount"
|
||||
:min="100"
|
||||
:max="summary.available_commission"
|
||||
:precision="0"
|
||||
:step="100"
|
||||
:min="withdrawalAmountMin"
|
||||
:max="withdrawalAmountMax"
|
||||
:precision="2"
|
||||
:step="1"
|
||||
:disabled="isWithdrawalAmountDisabled"
|
||||
style="width: 100%"
|
||||
placeholder="请输入提现金额(分)"
|
||||
placeholder="请输入提现金额(元)"
|
||||
/>
|
||||
<div style="margin-top: 4px; font-size: 12px; color: var(--el-text-color-secondary)">
|
||||
金额单位为分,如1元=100分
|
||||
金额单位为元
|
||||
</div>
|
||||
</ElFormItem>
|
||||
<ElFormItem label="提现方式" prop="withdrawal_method">
|
||||
@@ -183,7 +184,12 @@
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<ElButton @click="withdrawalDialogVisible = false">取消</ElButton>
|
||||
<ElButton type="primary" @click="handleSubmitWithdrawal" :loading="submitLoading">
|
||||
<ElButton
|
||||
type="primary"
|
||||
@click="handleSubmitWithdrawal"
|
||||
:loading="submitLoading"
|
||||
:disabled="isWithdrawalAmountDisabled"
|
||||
>
|
||||
提交
|
||||
</ElButton>
|
||||
</div>
|
||||
@@ -211,7 +217,7 @@
|
||||
import type { SearchFormItem } from '@/types'
|
||||
import { useCheckedColumns } from '@/composables/useCheckedColumns'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { formatDateTime, formatMoney } from '@/utils/business/format'
|
||||
import { formatDateTime, formatMoney, yuanToFen } from '@/utils/business/format'
|
||||
|
||||
defineOptions({ name: 'MyCommission' })
|
||||
|
||||
@@ -700,10 +706,25 @@
|
||||
const withdrawalDialogVisible = ref(false)
|
||||
const submitLoading = ref(false)
|
||||
const withdrawalFormRef = ref<FormInstance>()
|
||||
const minimumWithdrawalFen = 100
|
||||
const availableCommissionYuan = computed(() =>
|
||||
Number((summary.value.available_commission / 100).toFixed(2))
|
||||
)
|
||||
const isWithdrawalAmountDisabled = computed(
|
||||
() => summary.value.available_commission < minimumWithdrawalFen
|
||||
)
|
||||
const withdrawalAmountMin = computed(() => (isWithdrawalAmountDisabled.value ? 0 : 1))
|
||||
const withdrawalAmountMax = computed(() =>
|
||||
Math.max(withdrawalAmountMin.value, availableCommissionYuan.value)
|
||||
)
|
||||
|
||||
type WithdrawalForm = Omit<SubmitWithdrawalParams, 'amount'> & {
|
||||
amount: number | undefined
|
||||
}
|
||||
|
||||
// 提现表单
|
||||
const withdrawalForm = reactive<SubmitWithdrawalParams>({
|
||||
amount: 0,
|
||||
const withdrawalForm = reactive<WithdrawalForm>({
|
||||
amount: undefined,
|
||||
withdrawal_method: WithdrawalMethod.ALIPAY,
|
||||
account_name: '',
|
||||
account_number: '',
|
||||
@@ -717,9 +738,15 @@
|
||||
{ required: true, message: '请输入提现金额', trigger: 'blur' },
|
||||
{
|
||||
validator: (_rule, value, callback) => {
|
||||
if (value < 100) {
|
||||
callback(new Error('提现金额不能小于100分(1元)'))
|
||||
} else if (value > summary.value.available_commission) {
|
||||
const amountFen = yuanToFen(value)
|
||||
|
||||
if (isWithdrawalAmountDisabled.value) {
|
||||
callback(new Error('当前无可提现金额'))
|
||||
} else if (amountFen === undefined) {
|
||||
callback(new Error('请输入提现金额'))
|
||||
} else if (amountFen < minimumWithdrawalFen) {
|
||||
callback(new Error('提现金额不能小于1元'))
|
||||
} else if (amountFen > summary.value.available_commission) {
|
||||
callback(new Error('提现金额不能大于可提现佣金'))
|
||||
} else {
|
||||
callback()
|
||||
@@ -759,7 +786,7 @@
|
||||
// 关闭对话框
|
||||
const handleDialogClose = () => {
|
||||
withdrawalFormRef.value?.resetFields()
|
||||
withdrawalForm.amount = 0
|
||||
withdrawalForm.amount = undefined
|
||||
withdrawalForm.withdrawal_method = WithdrawalMethod.ALIPAY
|
||||
withdrawalForm.account_name = ''
|
||||
withdrawalForm.account_number = ''
|
||||
@@ -774,13 +801,23 @@
|
||||
ElMessage.warning('未找到店铺信息')
|
||||
return
|
||||
}
|
||||
if (isWithdrawalAmountDisabled.value) {
|
||||
ElMessage.warning('当前无可提现金额')
|
||||
return
|
||||
}
|
||||
|
||||
await withdrawalFormRef.value.validate(async (valid) => {
|
||||
if (valid) {
|
||||
submitLoading.value = true
|
||||
try {
|
||||
const amount = yuanToFen(withdrawalForm.amount)
|
||||
if (amount === undefined) {
|
||||
ElMessage.warning('请输入提现金额')
|
||||
return
|
||||
}
|
||||
|
||||
const params: SubmitWithdrawalParams = {
|
||||
amount: withdrawalForm.amount,
|
||||
amount,
|
||||
withdrawal_method: withdrawalForm.withdrawal_method,
|
||||
account_name: withdrawalForm.account_name,
|
||||
account_number: withdrawalForm.account_number,
|
||||
|
||||
Reference in New Issue
Block a user