This commit is contained in:
@@ -95,22 +95,24 @@
|
||||
{{ formatMoney(scope.row.balance_after) }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="佣金类型" prop="commission_type" width="120">
|
||||
<ElTableColumn label="佣金来源" prop="commission_source" width="120">
|
||||
<template #default="scope">
|
||||
<ElTag
|
||||
:type="
|
||||
CommissionTypeMap[scope.row.commission_type as keyof typeof CommissionTypeMap]
|
||||
?.type || 'info'
|
||||
CommissionSourceMap[
|
||||
scope.row.commission_source as keyof typeof CommissionSourceMap
|
||||
]?.type || 'info'
|
||||
"
|
||||
>
|
||||
{{
|
||||
CommissionTypeMap[scope.row.commission_type as keyof typeof CommissionTypeMap]
|
||||
?.label || scope.row.commission_type
|
||||
CommissionSourceMap[
|
||||
scope.row.commission_source as keyof typeof CommissionSourceMap
|
||||
]?.label || scope.row.commission_source
|
||||
}}
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="状态" prop="status" width="100">
|
||||
<ElTableColumn label="状态" prop="status_name" width="100">
|
||||
<template #default="scope">
|
||||
<ElTag
|
||||
:type="
|
||||
@@ -119,13 +121,18 @@
|
||||
"
|
||||
>
|
||||
{{
|
||||
CommissionStatusMap[scope.row.status as keyof typeof CommissionStatusMap]
|
||||
?.label || scope.row.status
|
||||
scope.row.status_name || CommissionStatusMap[scope.row.status]?.label || '-'
|
||||
}}
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn label="订单号" prop="order_no" min-width="180" show-overflow-tooltip />
|
||||
<ElTableColumn
|
||||
label="卖家店铺"
|
||||
prop="seller_shop_name"
|
||||
min-width="150"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<ElTableColumn label="ICCID" prop="iccid" min-width="150" show-overflow-tooltip />
|
||||
<ElTableColumn
|
||||
label="设备号"
|
||||
@@ -369,7 +376,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { h, watch, onBeforeUnmount } from 'vue'
|
||||
import { h, watch, onBeforeUnmount, ref, reactive, onMounted, computed } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { CommissionService } from '@/api/modules'
|
||||
import { ElMessage, ElMessageBox, ElTag } from 'element-plus'
|
||||
@@ -389,7 +396,7 @@
|
||||
CommissionStatusMap,
|
||||
WithdrawalStatusMap,
|
||||
WithdrawalMethodMap,
|
||||
CommissionTypeMap
|
||||
CommissionSourceMap
|
||||
} from '@/config/constants/commission'
|
||||
|
||||
defineOptions({ name: 'AgentCommission' })
|
||||
@@ -605,13 +612,13 @@
|
||||
getTableData()
|
||||
})
|
||||
|
||||
// 获取代理商佣金汇总列表
|
||||
// 获取代理商资金汇总列表
|
||||
const getTableData = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const params = {
|
||||
page: pagination.page,
|
||||
pageSize: pagination.pageSize,
|
||||
page_size: pagination.pageSize,
|
||||
shop_name: searchForm.shop_name || undefined,
|
||||
shop_code: searchForm.shop_code || undefined
|
||||
}
|
||||
@@ -724,7 +731,7 @@
|
||||
try {
|
||||
const params = {
|
||||
page: commissionPagination.page,
|
||||
pageSize: commissionPagination.pageSize
|
||||
page_size: commissionPagination.pageSize
|
||||
}
|
||||
const res = await CommissionService.getShopCommissionRecords(
|
||||
currentShop.value.shop_id,
|
||||
@@ -761,7 +768,7 @@
|
||||
try {
|
||||
const params = {
|
||||
page: withdrawalPagination.page,
|
||||
pageSize: withdrawalPagination.pageSize
|
||||
page_size: withdrawalPagination.pageSize
|
||||
}
|
||||
const res = await CommissionService.getShopWithdrawalRequests(
|
||||
currentShop.value.shop_id,
|
||||
@@ -798,7 +805,7 @@
|
||||
try {
|
||||
const params = {
|
||||
page: mainWalletPagination.page,
|
||||
pageSize: mainWalletPagination.pageSize
|
||||
page_size: mainWalletPagination.pageSize
|
||||
}
|
||||
const res = await CommissionService.getMainWalletTransactions(
|
||||
currentShop.value.shop_id,
|
||||
@@ -199,22 +199,15 @@
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import type {
|
||||
MyCommissionSummary,
|
||||
MyCommissionRecordItem,
|
||||
ShopCommissionRecordItem,
|
||||
WithdrawalRequestItem,
|
||||
CommissionRecordQueryParams,
|
||||
WithdrawalRequestQueryParams,
|
||||
SubmitWithdrawalParams,
|
||||
CommissionType,
|
||||
CommissionStatus,
|
||||
WithdrawalStatus
|
||||
} from '@/types/api/commission'
|
||||
import { WithdrawalMethod } from '@/types/api/commission'
|
||||
import {
|
||||
CommissionStatusMap,
|
||||
CommissionTypeMap,
|
||||
WithdrawalStatusMap,
|
||||
WithdrawalMethodMap
|
||||
} from '@/config/constants/commission'
|
||||
import { WithdrawalStatusMap, WithdrawalMethodMap } from '@/config/constants/commission'
|
||||
import type { SearchFormItem } from '@/types'
|
||||
import { useCheckedColumns } from '@/composables/useCheckedColumns'
|
||||
import { useAuth } from '@/composables/useAuth'
|
||||
@@ -227,7 +220,7 @@
|
||||
const userStore = useUserStore()
|
||||
|
||||
// 获取当前用户的 shop_id
|
||||
const currentShopId = computed(() => userStore.userInfo?.shop_id)
|
||||
const currentShopId = computed(() => userStore.info?.shop_id)
|
||||
|
||||
// 如果没有 shop_id,显示提示
|
||||
const hasShopId = computed(() => !!currentShopId.value)
|
||||
@@ -237,6 +230,7 @@
|
||||
|
||||
// 佣金概览
|
||||
const summary = ref<MyCommissionSummary>({
|
||||
main_balance: 0,
|
||||
total_commission: 0,
|
||||
available_commission: 0,
|
||||
frozen_commission: 0,
|
||||
@@ -251,10 +245,13 @@
|
||||
|
||||
// 搜索表单初始值
|
||||
const initialCommissionSearchState = {
|
||||
commission_type: undefined as CommissionType | undefined,
|
||||
status: undefined as CommissionStatus | undefined,
|
||||
commission_source: undefined as string | undefined,
|
||||
status: undefined as number | undefined,
|
||||
start_time: '',
|
||||
end_time: ''
|
||||
end_time: '',
|
||||
iccid: '',
|
||||
virtual_no: '',
|
||||
order_no: ''
|
||||
}
|
||||
|
||||
// 搜索表单
|
||||
@@ -263,16 +260,16 @@
|
||||
// 搜索表单配置
|
||||
const commissionSearchItems = computed<SearchFormItem[]>(() => [
|
||||
{
|
||||
label: '佣金类型',
|
||||
prop: 'commission_type',
|
||||
label: '佣金来源',
|
||||
prop: 'commission_source',
|
||||
type: 'select',
|
||||
options: [
|
||||
{ label: '一次性佣金', value: 'one_time' },
|
||||
{ label: '长期佣金', value: 'long_term' }
|
||||
{ label: '成本差价', value: 'cost_diff' },
|
||||
{ label: '一次性佣金', value: 'one_time' }
|
||||
],
|
||||
config: {
|
||||
clearable: true,
|
||||
placeholder: '请选择佣金类型'
|
||||
placeholder: '请选择佣金来源'
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -290,6 +287,33 @@
|
||||
placeholder: '请选择状态'
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'ICCID',
|
||||
prop: 'iccid',
|
||||
type: 'input',
|
||||
config: {
|
||||
clearable: true,
|
||||
placeholder: '请输入ICCID'
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '虚拟号',
|
||||
prop: 'virtual_no',
|
||||
type: 'input',
|
||||
config: {
|
||||
clearable: true,
|
||||
placeholder: '请输入虚拟号'
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '订单号',
|
||||
prop: 'order_no',
|
||||
type: 'input',
|
||||
config: {
|
||||
clearable: true,
|
||||
placeholder: '请输入订单号'
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '时间范围',
|
||||
prop: 'dateRange',
|
||||
@@ -322,64 +346,95 @@
|
||||
|
||||
// 列配置
|
||||
const commissionColumnOptions = [
|
||||
{ label: 'ID', prop: 'id' },
|
||||
{ label: '佣金金额', prop: 'amount' },
|
||||
{ label: '佣金类型', prop: 'commission_type' },
|
||||
{ label: '状态', prop: 'status' },
|
||||
{ label: '订单ID', prop: 'order_id' },
|
||||
{ label: '佣金来源', prop: 'commission_source' },
|
||||
{ label: '状态', prop: 'status_name' },
|
||||
{ label: 'ICCID', prop: 'iccid' },
|
||||
{ label: '虚拟号', prop: 'virtual_no' },
|
||||
{ label: '订单号', prop: 'order_no' },
|
||||
{ label: '卖家店铺', prop: 'seller_shop_name' },
|
||||
{ label: '入账后余额', prop: 'balance_after' },
|
||||
{ label: '创建时间', prop: 'created_at' }
|
||||
]
|
||||
|
||||
const commissionList = ref<MyCommissionRecordItem[]>([])
|
||||
const commissionList = ref<ShopCommissionRecordItem[]>([])
|
||||
|
||||
// 佣金来源映射
|
||||
const CommissionSourceMap = {
|
||||
cost_diff: { label: '成本差价', type: 'primary' as const },
|
||||
one_time: { label: '一次性佣金', type: 'success' as const }
|
||||
}
|
||||
|
||||
// 状态映射
|
||||
const CommissionRecordStatusMap = {
|
||||
1: { label: '已冻结', type: 'info' as const },
|
||||
2: { label: '解冻中', type: 'warning' as const },
|
||||
3: { label: '已发放', type: 'success' as const },
|
||||
4: { label: '已失效', type: 'danger' as const }
|
||||
}
|
||||
|
||||
// 动态列配置
|
||||
const { columnChecks: commissionColumnChecks, columns: commissionColumns } = useCheckedColumns(
|
||||
() => [
|
||||
{
|
||||
prop: 'id',
|
||||
label: 'ID',
|
||||
width: 80
|
||||
},
|
||||
{
|
||||
prop: 'amount',
|
||||
label: '佣金金额',
|
||||
width: 140,
|
||||
formatter: (row: MyCommissionRecordItem) => formatMoney(row.amount)
|
||||
width: 120,
|
||||
formatter: (row: ShopCommissionRecordItem) => formatMoney(row.amount)
|
||||
},
|
||||
{
|
||||
prop: 'commission_type',
|
||||
label: '佣金类型',
|
||||
prop: 'commission_source',
|
||||
label: '佣金来源',
|
||||
width: 120,
|
||||
formatter: (row: MyCommissionRecordItem) => {
|
||||
const config = CommissionTypeMap[row.commission_type as keyof typeof CommissionTypeMap]
|
||||
formatter: (row: ShopCommissionRecordItem) => {
|
||||
const config =
|
||||
CommissionSourceMap[row.commission_source as keyof typeof CommissionSourceMap]
|
||||
if (!config) return String(row.commission_source ?? '-')
|
||||
return h(ElTag, { type: config.type }, () => config.label)
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'status',
|
||||
prop: 'status_name',
|
||||
label: '状态',
|
||||
width: 100,
|
||||
formatter: (row: MyCommissionRecordItem) => {
|
||||
const config = CommissionStatusMap[row.status as keyof typeof CommissionStatusMap]
|
||||
return h(ElTag, { type: config.type }, () => config.label)
|
||||
formatter: (row: ShopCommissionRecordItem) => {
|
||||
return String(row.status_name ?? '-')
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'order_id',
|
||||
label: '订单ID',
|
||||
width: 100,
|
||||
formatter: (row: MyCommissionRecordItem) => row.order_id || '-'
|
||||
prop: 'iccid',
|
||||
label: 'ICCID',
|
||||
formatter: (row: ShopCommissionRecordItem) => row.iccid || '-'
|
||||
},
|
||||
{
|
||||
prop: 'shop_id',
|
||||
label: '店铺ID',
|
||||
width: 100
|
||||
prop: 'virtual_no',
|
||||
label: '虚拟号',
|
||||
width: 130,
|
||||
formatter: (row: ShopCommissionRecordItem) => row.virtual_no || '-'
|
||||
},
|
||||
{
|
||||
prop: 'order_no',
|
||||
label: '订单号',
|
||||
width: 160,
|
||||
formatter: (row: ShopCommissionRecordItem) => row.order_no || '-'
|
||||
},
|
||||
{
|
||||
prop: 'seller_shop_name',
|
||||
label: '卖家店铺',
|
||||
width: 150,
|
||||
formatter: (row: ShopCommissionRecordItem) => row.seller_shop_name || '-'
|
||||
},
|
||||
{
|
||||
prop: 'balance_after',
|
||||
label: '入账后余额',
|
||||
width: 120,
|
||||
formatter: (row: ShopCommissionRecordItem) => formatMoney(row.balance_after)
|
||||
},
|
||||
{
|
||||
prop: 'created_at',
|
||||
label: '创建时间',
|
||||
width: 180,
|
||||
formatter: (row: MyCommissionRecordItem) => formatDateTime(row.created_at)
|
||||
formatter: (row: ShopCommissionRecordItem) => formatDateTime(row.created_at)
|
||||
}
|
||||
]
|
||||
)
|
||||
@@ -393,14 +448,17 @@
|
||||
|
||||
commissionLoading.value = true
|
||||
try {
|
||||
const params = {
|
||||
pageSize: commissionPagination.pageSize,
|
||||
current: commissionPagination.page,
|
||||
commission_type: commissionSearchForm.commission_type,
|
||||
const params: CommissionRecordQueryParams = {
|
||||
page_size: commissionPagination.pageSize,
|
||||
page: commissionPagination.page,
|
||||
commission_source: commissionSearchForm.commission_source,
|
||||
status: commissionSearchForm.status,
|
||||
start_time: commissionSearchForm.start_time || undefined,
|
||||
end_time: commissionSearchForm.end_time || undefined
|
||||
} as CommissionRecordQueryParams
|
||||
end_time: commissionSearchForm.end_time || undefined,
|
||||
iccid: commissionSearchForm.iccid || undefined,
|
||||
virtual_no: commissionSearchForm.virtual_no || undefined,
|
||||
order_no: commissionSearchForm.order_no || undefined
|
||||
}
|
||||
const res = await CommissionService.getShopCommissionRecords(currentShopId.value, params)
|
||||
if (res.code === 0) {
|
||||
commissionList.value = res.data.items || []
|
||||
@@ -512,8 +570,10 @@
|
||||
{ label: '手续费', prop: 'fee' },
|
||||
{ label: '实际到账', prop: 'actual_amount' },
|
||||
{ label: '提现方式', prop: 'withdrawal_method' },
|
||||
{ label: '状态', prop: 'status' },
|
||||
{ label: '申请时间', prop: 'created_at' }
|
||||
{ label: '状态', prop: 'status_name' },
|
||||
{ label: '拒绝原因', prop: 'reject_reason' },
|
||||
{ label: '申请时间', prop: 'created_at' },
|
||||
{ label: '到账时间', prop: 'paid_at' }
|
||||
]
|
||||
|
||||
const withdrawalList = ref<WithdrawalRequestItem[]>([])
|
||||
@@ -560,19 +620,33 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'status',
|
||||
prop: 'status_name',
|
||||
label: '状态',
|
||||
width: 100,
|
||||
formatter: (row: WithdrawalRequestItem) => {
|
||||
const config = WithdrawalStatusMap[row.status as keyof typeof WithdrawalStatusMap]
|
||||
return h(ElTag, { type: config.type }, () => config.label)
|
||||
const tagType = config?.type || 'info'
|
||||
const label = row.status_name || config?.label || String(row.status)
|
||||
return h(ElTag, { type: tagType }, () => label)
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'reject_reason',
|
||||
label: '拒绝原因',
|
||||
minWidth: 120,
|
||||
formatter: (row: WithdrawalRequestItem) => row.reject_reason || '-'
|
||||
},
|
||||
{
|
||||
prop: 'created_at',
|
||||
label: '申请时间',
|
||||
width: 180,
|
||||
formatter: (row: WithdrawalRequestItem) => formatDateTime(row.created_at)
|
||||
},
|
||||
{
|
||||
prop: 'paid_at',
|
||||
label: '到账时间',
|
||||
width: 180,
|
||||
formatter: (row: WithdrawalRequestItem) => (row.paid_at ? formatDateTime(row.paid_at) : '-')
|
||||
}
|
||||
]
|
||||
)
|
||||
@@ -586,13 +660,13 @@
|
||||
|
||||
withdrawalLoading.value = true
|
||||
try {
|
||||
const params = {
|
||||
pageSize: withdrawalPagination.pageSize,
|
||||
current: withdrawalPagination.page,
|
||||
const params: WithdrawalRequestQueryParams = {
|
||||
page_size: withdrawalPagination.pageSize,
|
||||
page: withdrawalPagination.page,
|
||||
status: withdrawalSearchForm.status,
|
||||
start_time: withdrawalSearchForm.start_time || undefined,
|
||||
end_time: withdrawalSearchForm.end_time || undefined
|
||||
} as WithdrawalRequestQueryParams
|
||||
}
|
||||
const res = await CommissionService.getShopWithdrawalRequests(currentShopId.value, params)
|
||||
if (res.code === 0) {
|
||||
withdrawalList.value = res.data.items || []
|
||||
@@ -655,7 +729,7 @@
|
||||
amount: [
|
||||
{ required: true, message: '请输入提现金额', trigger: 'blur' },
|
||||
{
|
||||
validator: (rule, value, callback) => {
|
||||
validator: (_rule, value, callback) => {
|
||||
if (value < 100) {
|
||||
callback(new Error('提现金额不能小于100分(1元)'))
|
||||
} else if (value > summary.value.available_commission) {
|
||||
@@ -678,7 +752,7 @@
|
||||
],
|
||||
bank_name: [
|
||||
{
|
||||
validator: (rule, value, callback) => {
|
||||
validator: (_rule, value, callback) => {
|
||||
if (withdrawalForm.withdrawal_method === WithdrawalMethod.BANK && !value) {
|
||||
callback(new Error('请选择银行名称'))
|
||||
} else {
|
||||
@@ -740,9 +814,9 @@
|
||||
withdrawalDialogVisible.value = false
|
||||
|
||||
// 刷新数据
|
||||
loadSummary()
|
||||
await loadSummary()
|
||||
if (activeTab.value === 'withdrawal') {
|
||||
getWithdrawalList()
|
||||
await getWithdrawalList()
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
@@ -765,13 +839,14 @@
|
||||
// 调用 fund-summary 接口,通过 shop_id 过滤获取自己的数据
|
||||
const res = await CommissionService.getShopFundSummary({
|
||||
page: 1,
|
||||
pageSize: 1
|
||||
page_size: 1
|
||||
})
|
||||
if (res.code === 0 && res.data.items && res.data.items.length > 0) {
|
||||
// 从结果中找到当前用户的店铺数据
|
||||
const myShopData = res.data.items.find(item => item.shop_id === currentShopId.value)
|
||||
const myShopData = res.data.items.find((item) => item.shop_id === currentShopId.value)
|
||||
if (myShopData) {
|
||||
summary.value = {
|
||||
main_balance: myShopData.main_balance || 0,
|
||||
total_commission: myShopData.total_commission,
|
||||
available_commission: myShopData.available_commission,
|
||||
frozen_commission: myShopData.frozen_commission,
|
||||
@@ -803,9 +878,3 @@
|
||||
getCommissionList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.my-commission-page {
|
||||
// 样式已移动到分析页的佣金概览组件
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -38,11 +38,7 @@
|
||||
</ArtTable>
|
||||
|
||||
<!-- 拒绝提现对话框 -->
|
||||
<ElDialog
|
||||
v-model="rejectDialogVisible"
|
||||
title="拒绝提现申请"
|
||||
width="500px"
|
||||
>
|
||||
<ElDialog v-model="rejectDialogVisible" title="拒绝提现申请" width="500px">
|
||||
<ElForm ref="rejectFormRef" :model="rejectForm" :rules="rejectRules" label-width="100px">
|
||||
<ElFormItem label="拒绝原因" prop="reject_reason">
|
||||
<ElInput
|
||||
@@ -199,12 +195,8 @@
|
||||
const rejectFormRef = ref<FormInstance>()
|
||||
|
||||
const rejectRules = reactive<FormRules>({
|
||||
reject_reason: [
|
||||
{ required: true, message: '请输入拒绝原因', trigger: 'blur' }
|
||||
],
|
||||
remark: [
|
||||
{ required: true, message: '请输入备注', trigger: 'blur' }
|
||||
]
|
||||
reject_reason: [{ required: true, message: '请输入拒绝原因', trigger: 'blur' }],
|
||||
remark: [{ required: true, message: '请输入备注', trigger: 'blur' }]
|
||||
})
|
||||
|
||||
const rejectForm = reactive({
|
||||
@@ -318,7 +310,7 @@
|
||||
try {
|
||||
const params = {
|
||||
page: pagination.page,
|
||||
pageSize: pagination.pageSize,
|
||||
page_size: pagination.pageSize,
|
||||
withdrawal_no: searchForm.withdrawal_no || undefined,
|
||||
shop_name: searchForm.shop_name || undefined,
|
||||
status: searchForm.status,
|
||||
|
||||
@@ -1,257 +0,0 @@
|
||||
<template>
|
||||
<ArtTableFullScreen>
|
||||
<div class="withdrawal-settings-page" id="table-full-screen">
|
||||
<!-- 配置列表 -->
|
||||
<ElCard shadow="never" class="art-table-card">
|
||||
<!-- 表格头部 -->
|
||||
<ArtTableHeader
|
||||
:columnList="columnOptions"
|
||||
v-model:columns="columnChecks"
|
||||
@refresh="handleRefresh"
|
||||
>
|
||||
<template #left>
|
||||
<ElButton type="primary" @click="showDialog" v-permission="'withdrawal_settings:add'"
|
||||
>新增配置</ElButton
|
||||
>
|
||||
</template>
|
||||
</ArtTableHeader>
|
||||
|
||||
<!-- 表格 -->
|
||||
<ArtTable
|
||||
ref="tableRef"
|
||||
row-key="id"
|
||||
:loading="loading"
|
||||
:data="settingsList"
|
||||
:marginTop="10"
|
||||
>
|
||||
<template #default>
|
||||
<ElTableColumn v-for="col in columns" :key="col.prop || col.type" v-bind="col" />
|
||||
</template>
|
||||
</ArtTable>
|
||||
</ElCard>
|
||||
|
||||
<!-- 新增配置对话框 -->
|
||||
<ElDialog v-model="dialogVisible" title="新增提现配置" width="500px">
|
||||
<ElForm ref="formRef" :model="form" :rules="rules" label-width="110px">
|
||||
<ElFormItem label="最低提现金额" prop="min_withdrawal_amount">
|
||||
<ElInputNumber
|
||||
v-model="form.min_withdrawal_amount"
|
||||
:min="1"
|
||||
:precision="2"
|
||||
:step="10"
|
||||
style="width: 100%"
|
||||
/>
|
||||
<div class="form-tip">单位:元</div>
|
||||
</ElFormItem>
|
||||
|
||||
<ElFormItem label="手续费率" prop="fee_rate">
|
||||
<ElInputNumber
|
||||
v-model="form.fee_rate"
|
||||
:min="0"
|
||||
:max="100"
|
||||
:precision="2"
|
||||
:step="0.1"
|
||||
style="width: 100%"
|
||||
/>
|
||||
<div class="form-tip">单位:%(百分比)</div>
|
||||
</ElFormItem>
|
||||
|
||||
<ElFormItem label="每日提现次数" prop="daily_withdrawal_limit">
|
||||
<ElInputNumber
|
||||
v-model="form.daily_withdrawal_limit"
|
||||
:min="1"
|
||||
:max="100"
|
||||
:step="1"
|
||||
style="width: 100%"
|
||||
/>
|
||||
<div class="form-tip">单位:次</div>
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<ElButton @click="dialogVisible = false">取消</ElButton>
|
||||
<ElButton type="primary" @click="handleSubmit(formRef)" :loading="submitLoading">
|
||||
提交
|
||||
</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</div>
|
||||
</ArtTableFullScreen>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { h } from 'vue'
|
||||
import { CommissionService } from '@/api/modules'
|
||||
import { ElMessage, ElTag } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import type { WithdrawalSettingItem } from '@/types/api/commission'
|
||||
import { useCheckedColumns } from '@/composables/useCheckedColumns'
|
||||
import { useAuth } from '@/composables/useAuth'
|
||||
import { formatDateTime, formatMoney, formatFeeRate } from '@/utils/business/format'
|
||||
|
||||
defineOptions({ name: 'CommissionWithdrawalSettings' })
|
||||
|
||||
const { hasAuth } = useAuth()
|
||||
|
||||
const dialogVisible = ref(false)
|
||||
const loading = ref(false)
|
||||
const submitLoading = ref(false)
|
||||
const tableRef = ref()
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
// 配置列表
|
||||
const settingsList = ref<WithdrawalSettingItem[]>([])
|
||||
|
||||
// 表单数据(使用元和百分比)
|
||||
const form = reactive({
|
||||
min_withdrawal_amount: 100,
|
||||
fee_rate: 0.2,
|
||||
daily_withdrawal_limit: 3
|
||||
})
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive<FormRules>({
|
||||
min_withdrawal_amount: [
|
||||
{ required: true, message: '请输入最低提现金额', trigger: 'blur' },
|
||||
{ type: 'number', min: 1, message: '最低提现金额必须大于0', trigger: 'blur' }
|
||||
],
|
||||
fee_rate: [
|
||||
{ required: true, message: '请输入手续费率', trigger: 'blur' },
|
||||
{ type: 'number', min: 0, max: 100, message: '手续费率必须在0-100之间', trigger: 'blur' }
|
||||
],
|
||||
daily_withdrawal_limit: [
|
||||
{ required: true, message: '请输入每日提现次数', trigger: 'blur' },
|
||||
{ type: 'number', min: 1, message: '每日提现次数必须大于0', trigger: 'blur' }
|
||||
]
|
||||
})
|
||||
|
||||
// 列配置
|
||||
const columnOptions = [
|
||||
{ label: '最低提现金额', prop: 'min_withdrawal_amount' },
|
||||
{ label: '手续费率', prop: 'fee_rate' },
|
||||
{ label: '每日提现次数', prop: 'daily_withdrawal_limit' },
|
||||
{ label: '到账天数', prop: 'arrival_days' },
|
||||
{ label: '是否生效', prop: 'is_active' },
|
||||
{ label: '创建人', prop: 'creator_name' },
|
||||
{ label: '创建时间', prop: 'created_at' }
|
||||
]
|
||||
|
||||
// 动态列配置
|
||||
const { columnChecks, columns } = useCheckedColumns(() => [
|
||||
{
|
||||
prop: 'min_withdrawal_amount',
|
||||
label: '最低提现金额',
|
||||
formatter: (row: WithdrawalSettingItem) => formatMoney(row.min_withdrawal_amount)
|
||||
},
|
||||
{
|
||||
prop: 'fee_rate',
|
||||
label: '手续费率',
|
||||
formatter: (row: WithdrawalSettingItem) => formatFeeRate(row.fee_rate)
|
||||
},
|
||||
{
|
||||
prop: 'daily_withdrawal_limit',
|
||||
label: '每日提现次数',
|
||||
formatter: (row: WithdrawalSettingItem) => `${row.daily_withdrawal_limit} 次`
|
||||
},
|
||||
{
|
||||
prop: 'arrival_days',
|
||||
label: '到账天数',
|
||||
formatter: (row: WithdrawalSettingItem) => {
|
||||
return row.arrival_days === 0 ? '实时到账' : `${row.arrival_days} 天`
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'is_active',
|
||||
label: '是否生效',
|
||||
formatter: (row: WithdrawalSettingItem) => {
|
||||
return h(ElTag, { type: row.is_active ? 'success' : 'info' }, () =>
|
||||
row.is_active ? '生效中' : '已失效'
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'creator_name',
|
||||
label: '创建人',
|
||||
formatter: (row: WithdrawalSettingItem) => row.creator_name || '-'
|
||||
},
|
||||
{
|
||||
prop: 'created_at',
|
||||
label: '创建时间',
|
||||
formatter: (row: WithdrawalSettingItem) => formatDateTime(row.created_at)
|
||||
}
|
||||
])
|
||||
|
||||
onMounted(() => {
|
||||
loadSettingsList()
|
||||
})
|
||||
|
||||
// 加载配置列表
|
||||
const loadSettingsList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await CommissionService.getWithdrawalSettings()
|
||||
if (res.code === 0) {
|
||||
settingsList.value = res.data.items || []
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取配置列表失败:', error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 刷新数据
|
||||
const handleRefresh = () => {
|
||||
loadSettingsList()
|
||||
}
|
||||
|
||||
// 显示新增对话框
|
||||
const showDialog = () => {
|
||||
dialogVisible.value = true
|
||||
// 重置表单
|
||||
form.min_withdrawal_amount = 100
|
||||
form.fee_rate = 0.2
|
||||
form.daily_withdrawal_limit = 3
|
||||
formRef.value?.clearValidate()
|
||||
}
|
||||
|
||||
// 提交表单
|
||||
const handleSubmit = async (formEl: FormInstance | undefined) => {
|
||||
if (!formEl) return
|
||||
|
||||
await formEl.validate(async (valid) => {
|
||||
if (valid) {
|
||||
submitLoading.value = true
|
||||
try {
|
||||
// 转换单位:元 -> 分,百分比 -> 基点
|
||||
const params = {
|
||||
min_withdrawal_amount: Math.round(form.min_withdrawal_amount * 100), // 元转分
|
||||
fee_rate: Math.round(form.fee_rate * 100), // 百分比转基点
|
||||
daily_withdrawal_limit: form.daily_withdrawal_limit
|
||||
}
|
||||
|
||||
await CommissionService.createWithdrawalSetting(params)
|
||||
ElMessage.success('新增配置成功')
|
||||
dialogVisible.value = false
|
||||
formEl.resetFields()
|
||||
loadSettingsList()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
submitLoading.value = false
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.withdrawal-settings-page {
|
||||
.form-tip {
|
||||
margin-top: 4px;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user