feat:【antd】【ele】【pay 支付】pay/wallet/balance 迁移 ele 版本

This commit is contained in:
YunaiV
2025-10-06 13:36:03 +08:00
parent 385b5eaaec
commit b2de0e2a29
9 changed files with 130 additions and 156 deletions

View File

@@ -22,7 +22,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '应用编号', label: '应用编号',
component: 'Input', component: 'Input',
componentProps: { componentProps: {
allowClear: true, clearable: true,
placeholder: '请输入应用编号', placeholder: '请输入应用编号',
}, },
}, },
@@ -31,7 +31,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '支付渠道', label: '支付渠道',
component: 'Select', component: 'Select',
componentProps: { componentProps: {
allowClear: true, clearable: true,
placeholder: '请选择支付渠道', placeholder: '请选择支付渠道',
options: getDictOptions(DICT_TYPE.PAY_CHANNEL_CODE, 'string'), options: getDictOptions(DICT_TYPE.PAY_CHANNEL_CODE, 'string'),
}, },
@@ -41,7 +41,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '商户单号', label: '商户单号',
component: 'Input', component: 'Input',
componentProps: { componentProps: {
allowClear: true, clearable: true,
placeholder: '请输入商户单号', placeholder: '请输入商户单号',
}, },
}, },
@@ -50,7 +50,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '支付单号', label: '支付单号',
component: 'Input', component: 'Input',
componentProps: { componentProps: {
allowClear: true, clearable: true,
placeholder: '请输入支付单号', placeholder: '请输入支付单号',
}, },
}, },
@@ -59,7 +59,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '渠道单号', label: '渠道单号',
component: 'Input', component: 'Input',
componentProps: { componentProps: {
allowClear: true, clearable: true,
placeholder: '请输入渠道单号', placeholder: '请输入渠道单号',
}, },
}, },
@@ -68,7 +68,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '支付状态', label: '支付状态',
component: 'Select', component: 'Select',
componentProps: { componentProps: {
allowClear: true, clearable: true,
placeholder: '请选择支付状态', placeholder: '请选择支付状态',
options: getDictOptions(DICT_TYPE.PAY_ORDER_STATUS, 'number'), options: getDictOptions(DICT_TYPE.PAY_ORDER_STATUS, 'number'),
}, },
@@ -79,7 +79,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
component: 'RangePicker', component: 'RangePicker',
componentProps: { componentProps: {
...getRangePickerDefaultProps(), ...getRangePickerDefaultProps(),
allowClear: true, clearable: true,
}, },
}, },
]; ];

View File

@@ -22,7 +22,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '应用编号', label: '应用编号',
component: 'Input', component: 'Input',
componentProps: { componentProps: {
allowClear: true, clearable: true,
placeholder: '请输入应用编号', placeholder: '请输入应用编号',
}, },
}, },
@@ -41,7 +41,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '商户单号', label: '商户单号',
component: 'Input', component: 'Input',
componentProps: { componentProps: {
allowClear: true, clearable: true,
placeholder: '请输入商户单号', placeholder: '请输入商户单号',
}, },
}, },
@@ -50,7 +50,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '退款单号', label: '退款单号',
component: 'Input', component: 'Input',
componentProps: { componentProps: {
allowClear: true, clearable: true,
placeholder: '请输入退款单号', placeholder: '请输入退款单号',
}, },
}, },
@@ -59,7 +59,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '渠道单号', label: '渠道单号',
component: 'Input', component: 'Input',
componentProps: { componentProps: {
allowClear: true, clearable: true,
placeholder: '请输入渠道单号', placeholder: '请输入渠道单号',
}, },
}, },
@@ -68,7 +68,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '渠道退款单号', label: '渠道退款单号',
component: 'Input', component: 'Input',
componentProps: { componentProps: {
allowClear: true, clearable: true,
placeholder: '请输入渠道退款单号', placeholder: '请输入渠道退款单号',
}, },
}, },
@@ -77,7 +77,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '退款状态', label: '退款状态',
component: 'Select', component: 'Select',
componentProps: { componentProps: {
allowClear: true, clearable: true,
placeholder: '请选择退款状态', placeholder: '请选择退款状态',
options: getDictOptions(DICT_TYPE.PAY_REFUND_STATUS, 'number'), options: getDictOptions(DICT_TYPE.PAY_REFUND_STATUS, 'number'),
}, },
@@ -88,7 +88,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
component: 'RangePicker', component: 'RangePicker',
componentProps: { componentProps: {
...getRangePickerDefaultProps(), ...getRangePickerDefaultProps(),
allowClear: true, clearable: true,
}, },
}, },
]; ];

View File

@@ -22,7 +22,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '转账单号', label: '转账单号',
component: 'Input', component: 'Input',
componentProps: { componentProps: {
allowClear: true, clearable: true,
placeholder: '请输入转账单号', placeholder: '请输入转账单号',
}, },
}, },
@@ -32,7 +32,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
component: 'Select', component: 'Select',
componentProps: { componentProps: {
options: getDictOptions(DICT_TYPE.PAY_CHANNEL_CODE), options: getDictOptions(DICT_TYPE.PAY_CHANNEL_CODE),
allowClear: true, clearable: true,
placeholder: '请选择支付渠道', placeholder: '请选择支付渠道',
}, },
}, },
@@ -41,7 +41,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '商户单号', label: '商户单号',
component: 'Input', component: 'Input',
componentProps: { componentProps: {
allowClear: true, clearable: true,
placeholder: '请输入商户单号', placeholder: '请输入商户单号',
}, },
}, },
@@ -51,7 +51,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
component: 'Select', component: 'Select',
componentProps: { componentProps: {
options: getDictOptions(DICT_TYPE.PAY_TRANSFER_TYPE), options: getDictOptions(DICT_TYPE.PAY_TRANSFER_TYPE),
allowClear: true, clearable: true,
placeholder: '请选择类型', placeholder: '请选择类型',
}, },
}, },
@@ -61,7 +61,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
component: 'Select', component: 'Select',
componentProps: { componentProps: {
options: getDictOptions(DICT_TYPE.PAY_TRANSFER_STATUS), options: getDictOptions(DICT_TYPE.PAY_TRANSFER_STATUS),
allowClear: true, clearable: true,
placeholder: '请选择转账状态', placeholder: '请选择转账状态',
}, },
}, },
@@ -70,7 +70,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '收款人姓名', label: '收款人姓名',
component: 'Input', component: 'Input',
componentProps: { componentProps: {
allowClear: true, clearable: true,
placeholder: '请输入收款人姓名', placeholder: '请输入收款人姓名',
}, },
}, },
@@ -79,7 +79,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '收款人账号', label: '收款人账号',
component: 'Input', component: 'Input',
componentProps: { componentProps: {
allowClear: true, clearable: true,
placeholder: '请输入收款人账号', placeholder: '请输入收款人账号',
}, },
}, },
@@ -88,7 +88,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '渠道单号', label: '渠道单号',
component: 'Input', component: 'Input',
componentProps: { componentProps: {
allowClear: true, clearable: true,
placeholder: '请输入渠道单号', placeholder: '请输入渠道单号',
}, },
}, },
@@ -98,7 +98,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
component: 'RangePicker', component: 'RangePicker',
componentProps: { componentProps: {
...getRangePickerDefaultProps(), ...getRangePickerDefaultProps(),
allowClear: true, clearable: true,
}, },
}, },
]; ];

View File

@@ -1,6 +1,7 @@
import type { VxeTableGridOptions } from '@vben/plugins/vxe-table'; import type { VxeTableGridOptions as VxeTableGridOptionsLegacy } from '@vben/plugins/vxe-table';
import type { VbenFormSchema } from '#/adapter/form'; import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { DICT_TYPE } from '@vben/constants'; import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks'; import { getDictOptions } from '@vben/hooks';
@@ -8,13 +9,16 @@ import { getDictOptions } from '@vben/hooks';
import { getRangePickerDefaultProps } from '#/utils'; import { getRangePickerDefaultProps } from '#/utils';
/** 列表的搜索表单 */ /** 列表的搜索表单 */
// TODO @霖:少了 placeholder
export function useGridFormSchema(): VbenFormSchema[] { export function useGridFormSchema(): VbenFormSchema[] {
return [ return [
{ {
fieldName: 'userId', fieldName: 'userId',
label: '用户编号', label: '用户编号',
component: 'Input', component: 'Input',
componentProps: {
placeholder: '请输入用户编号',
clearable: true,
},
}, },
{ {
fieldName: 'userType', fieldName: 'userType',
@@ -22,6 +26,8 @@ export function useGridFormSchema(): VbenFormSchema[] {
component: 'Select', component: 'Select',
componentProps: { componentProps: {
options: getDictOptions(DICT_TYPE.USER_TYPE, 'number'), options: getDictOptions(DICT_TYPE.USER_TYPE, 'number'),
placeholder: '请选择用户类型',
clearable: true,
}, },
}, },
{ {
@@ -29,27 +35,30 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '创建时间', label: '创建时间',
component: 'RangePicker', component: 'RangePicker',
componentProps: { componentProps: {
clearable: true,
...getRangePickerDefaultProps(), ...getRangePickerDefaultProps(),
clearable: true,
}, },
}, },
]; ];
} }
/** 列表的字段 */ /** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions['columns'] { export function useGridColumns(): VxeTableGridOptionsLegacy['columns'] {
return [ return [
{ {
title: '编号', title: '编号',
field: 'id', field: 'id',
minWidth: 100,
}, },
{ {
title: '用户编号', title: '用户编号',
field: 'userId', field: 'userId',
minWidth: 120,
}, },
{ {
title: '用户类型', title: '用户类型',
field: 'userType', field: 'userType',
minWidth: 120,
cellRender: { cellRender: {
name: 'CellDict', name: 'CellDict',
props: { type: DICT_TYPE.USER_TYPE }, props: { type: DICT_TYPE.USER_TYPE },
@@ -58,33 +67,73 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{ {
title: '余额', title: '余额',
field: 'balance', field: 'balance',
formatter: 'formatFenToYuanAmount', minWidth: 120,
formatter: 'formatAmount2',
}, },
{ {
title: '累计支出', title: '累计支出',
field: 'totalExpense', field: 'totalExpense',
formatter: 'formatFenToYuanAmount', minWidth: 120,
formatter: 'formatAmount2',
}, },
{ {
title: '累计充值', title: '累计充值',
field: 'totalRecharge', field: 'totalRecharge',
formatter: 'formatFenToYuanAmount', minWidth: 120,
formatter: 'formatAmount2',
}, },
{ {
title: '冻结金额', title: '冻结金额',
field: 'freezePrice', field: 'freezePrice',
formatter: 'formatFenToYuanAmount', minWidth: 120,
formatter: 'formatAmount2',
}, },
{ {
title: '创建时间', title: '创建时间',
field: 'createTime', field: 'createTime',
minWidth: 180,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{ {
title: '操作', title: '操作',
field: 'actions', field: 'actions',
width: 80,
fixed: 'right', fixed: 'right',
slots: { default: 'actions' }, slots: { default: 'actions' },
}, },
]; ];
} }
/** 钱包交易记录列表字段 */
export function useTransactionGridColumns(): VxeTableGridOptions['columns'] {
return [
{
field: 'id',
title: '编号',
minWidth: 100,
},
{
field: 'title',
title: '关联业务标题',
minWidth: 200,
},
{
field: 'price',
title: '交易金额',
minWidth: 120,
formatter: 'formatAmount2',
},
{
field: 'balance',
title: '钱包余额',
minWidth: 120,
formatter: 'formatAmount2',
},
{
field: 'createTime',
title: '交易时间',
minWidth: 180,
formatter: 'formatDateTime',
},
];
}

View File

@@ -9,20 +9,21 @@ import { getWalletPage } from '#/api/pay/wallet/balance';
import { $t } from '#/locales'; import { $t } from '#/locales';
import { useGridColumns, useGridFormSchema } from './data'; import { useGridColumns, useGridFormSchema } from './data';
import WalletDetail from './modules/detail.vue'; import Detail from './modules/detail.vue';
/** 刷新表格 */ const [DetailModal, detailModalApi] = useVbenModal({
function onRefresh() { connectedComponent: Detail,
gridApi.query();
}
const [WalletModal, walletModalApi] = useVbenModal({
connectedComponent: WalletDetail,
destroyOnClose: true, destroyOnClose: true,
}); });
/** 刷新表格 */
function handleRefresh() {
gridApi.query();
}
/** 查看钱包 */
function handleDetail(row: Required<PayWalletApi.Wallet>) { function handleDetail(row: Required<PayWalletApi.Wallet>) {
walletModalApi.setData(row).open(); detailModalApi.setData(row).open();
} }
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({
@@ -46,6 +47,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
}, },
rowConfig: { rowConfig: {
keyField: 'id', keyField: 'id',
isHover: true,
}, },
toolbarConfig: { toolbarConfig: {
refresh: true, refresh: true,
@@ -61,8 +63,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
<DocAlert title="钱包余额" url="https://doc.iocoder.cn/pay/build/" /> <DocAlert title="钱包余额" url="https://doc.iocoder.cn/pay/build/" />
</template> </template>
<WalletModal @reload="onRefresh" /> <DetailModal @reload="handleRefresh" />
<Grid> <Grid>
<template #actions="{ row }"> <template #actions="{ row }">
<TableAction <TableAction

View File

@@ -1,13 +1,40 @@
<script setup lang="ts"> <script setup lang="ts">
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { PayWalletApi } from '#/api/pay/wallet/balance'; import type { PayWalletApi } from '#/api/pay/wallet/balance';
import type { WalletTransactionApi } from '#/api/pay/wallet/transaction';
import { ref } from 'vue'; import { Page, useVbenModal } from '@vben/common-ui';
import { useVbenModal } from '@vben/common-ui'; import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { getTransactionPage } from '#/api/pay/wallet/transaction';
import WalletTransactionList from '../../transaction/index.vue'; import { useTransactionGridColumns } from '../data';
const walletId = ref(0); const [Grid, gridApi] = useVbenVxeGrid({
gridOptions: {
columns: useTransactionGridColumns(),
height: 'auto',
keepSource: true,
proxyConfig: {
ajax: {
query: async ({ page }) => {
return await getTransactionPage({
pageNo: page.currentPage,
pageSize: page.pageSize,
walletId: modalApi.getData<PayWalletApi.Wallet>().id,
});
},
},
},
rowConfig: {
keyField: 'id',
isHover: true,
},
toolbarConfig: {
enabled: false,
},
} as VxeTableGridOptions<WalletTransactionApi.Transaction>,
});
const [Modal, modalApi] = useVbenModal({ const [Modal, modalApi] = useVbenModal({
async onOpenChange(isOpen: boolean) { async onOpenChange(isOpen: boolean) {
@@ -15,13 +42,9 @@ const [Modal, modalApi] = useVbenModal({
return; return;
} }
// 加载数据 // 加载数据
const data = modalApi.getData<PayWalletApi.Wallet>();
if (!data || !data.id) {
return;
}
modalApi.lock(); modalApi.lock();
try { try {
walletId.value = data.id; await gridApi.query();
} finally { } finally {
modalApi.unlock(); modalApi.unlock();
} }
@@ -31,10 +54,12 @@ const [Modal, modalApi] = useVbenModal({
<template> <template>
<Modal <Modal
title="钱包交易记录" title="钱包交易记录"
class="w-2/5" class="w-1/2"
:show-cancel-button="false" :show-cancel-button="false"
:show-confirm-button="false" :show-confirm-button="false"
> >
<WalletTransactionList :wallet-id="walletId" /> <Page auto-content-height>
<Grid />
</Page>
</Modal> </Modal>
</template> </template>

View File

@@ -1,40 +0,0 @@
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions['columns'] {
return [
{
field: 'id',
title: '编号',
width: 80,
},
{
field: 'walletId',
title: '钱包编号',
width: 100,
},
{
field: 'title',
title: '关联业务标题',
width: 200,
},
{
field: 'price',
title: '交易金额',
width: 120,
formatter: ({ cellValue }) => `${cellValue / 100}`,
},
{
field: 'balance',
title: '钱包余额',
width: 120,
formatter: ({ cellValue }) => `${cellValue / 100}`,
},
{
field: 'createTime',
title: '交易时间',
width: 180,
formatter: 'formatDateTime',
},
];
}

View File

@@ -1,61 +0,0 @@
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { Page } from '@vben/common-ui';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { getWallet } from '#/api/pay/wallet/balance';
import { getTransactionPage } from '#/api/pay/wallet/transaction';
import { useGridColumns } from './data';
const props = defineProps({
walletId: {
type: Number,
required: false,
default: undefined,
},
userId: {
type: Number,
required: false,
default: undefined,
},
});
const [Grid] = useVbenVxeGrid({
gridOptions: {
columns: useGridColumns(),
height: 'auto',
keepSource: true,
proxyConfig: {
ajax: {
query: async ({ page }, formValues) => {
let walletId = props.walletId;
if (props.userId) {
const wallet = await getWallet({ userId: props.userId });
walletId = wallet.id;
}
return await getTransactionPage({
pageNo: page.currentPage,
pageSize: page.pageSize,
walletId,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
},
toolbarConfig: {
refresh: true,
},
} as VxeTableGridOptions<any>,
});
</script>
<template>
<Page auto-content-height>
<Grid />
</Page>
</template>