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