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

This commit is contained in:
YunaiV
2025-10-05 22:06:58 +08:00
parent 25e434276a
commit b587032597
4 changed files with 100 additions and 91 deletions

View File

@@ -6,31 +6,41 @@ export namespace PayTransferApi {
/** 转账单信息 */ /** 转账单信息 */
export interface Transfer { export interface Transfer {
id: number; id: number;
no: string;
appId: number; appId: number;
appName: string;
channelId: number; channelId: number;
channelCode: string; channelCode: string;
merchantTransferId: string; merchantTransferId: string;
type: number; channelTransferNo: string;
price: number; price: number;
subject: string; subject: string;
userName: string; userName: string;
alipayLogonId: string; userAccount: string;
openid: string; userIp: string;
status: number; status: number;
successTime: Date;
createTime: Date; createTime: Date;
updateTime: Date;
notifyUrl: string;
channelNotifyData: string;
} }
/** 转账单分页请求 */ /** 转账单分页请求 */
export interface TransferPageReq extends PageParam { export interface TransferPageReq extends PageParam {
no?: string;
appId?: number; appId?: number;
channelId?: number; channelId?: number;
channelCode?: string; channelCode?: string;
merchantTransferId?: string; merchantTransferId?: string;
channelTransferNo?: string;
type?: number; type?: number;
price?: number; price?: number;
subject?: string; subject?: string;
userName?: string; userName?: string;
userAccount?: string;
status?: number; status?: number;
successTime?: Date[];
createTime?: Date[]; createTime?: Date[];
} }
} }

View File

@@ -1,17 +1,17 @@
import type { VbenFormSchema } from '#/adapter/form'; import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { PayTransferApi } from '#/api/pay/transfer';
import type { DescriptionItemSchema } from '#/components/description'; import type { DescriptionItemSchema } from '#/components/description';
import { h } from 'vue'; import { h } from 'vue';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { erpPriceInputFormatter, formatDateTime } from '@vben/utils'; import { erpPriceInputFormatter, formatDateTime } from '@vben/utils';
import { Tag } from 'ant-design-vue'; import { Tag } from 'ant-design-vue';
import { DictTag } from '#/components/dict-tag'; import { DictTag } from '#/components/dict-tag';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { getRangePickerDefaultProps } from '#/utils'; import { getRangePickerDefaultProps } from '#/utils';
/** 列表的搜索表单 */ /** 列表的搜索表单 */
@@ -75,7 +75,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
}, },
}, },
{ {
fieldName: 'accountNo', fieldName: 'userAccount',
label: '收款人账号', label: '收款人账号',
component: 'Input', component: 'Input',
componentProps: { componentProps: {
@@ -110,96 +110,95 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'id', field: 'id',
title: '编号', title: '编号',
}, minWidth: 100,
{
field: 'createTime',
title: '创建时间',
formatter: 'formatDateTime',
},
{
field: 'appName',
title: '支付应用',
}, },
{ {
field: 'price', field: 'price',
title: '转账金额', title: '转账金额',
minWidth: 120,
formatter: 'formatAmount2', formatter: 'formatAmount2',
}, },
{
field: 'merchantTransferId',
title: '转账单号',
minWidth: 350,
slots: {
default: 'no',
},
},
{ {
field: 'status', field: 'status',
title: '转账状态', title: '转账状态',
minWidth: 120,
cellRender: { cellRender: {
name: 'CellDict', name: 'CellDict',
props: { type: DICT_TYPE.PAY_TRANSFER_STATUS }, props: { type: DICT_TYPE.PAY_TRANSFER_STATUS },
}, },
}, },
{
field: 'type',
title: '类型',
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.PAY_TRANSFER_TYPE },
},
},
{ {
field: 'channelCode', field: 'channelCode',
title: '支付渠道', title: '转账渠道',
minWidth: 140,
cellRender: { cellRender: {
name: 'CellDict', name: 'CellDict',
props: { type: DICT_TYPE.PAY_CHANNEL_CODE }, props: { type: DICT_TYPE.PAY_CHANNEL_CODE },
}, },
}, },
{ {
field: 'merchantTransferId', field: 'createTime',
title: '商户单号', title: '创建时间',
minWidth: 180,
formatter: 'formatDateTime',
}, },
{ {
field: 'channelTransferNo', field: 'successTime',
title: '渠道单号', title: '转账时间',
minWidth: 180,
formatter: 'formatDateTime',
},
{
field: 'subject',
title: '转账标题',
minWidth: 150,
},
{
field: 'appName',
title: '支付应用',
minWidth: 150,
}, },
{ {
field: 'userName', field: 'userName',
title: '收款人姓名', title: '收款人姓名',
minWidth: 150,
}, },
{ {
field: 'accountNo', field: 'userAccount',
title: '收款账号', title: '收款账号',
minWidth: 200,
}, },
{ {
title: '操作', title: '操作',
width: 120, width: 80,
fixed: 'right', fixed: 'right',
slots: { default: 'actions' }, slots: { default: 'actions' },
}, },
]; ];
} }
/** 详情的配置 */ /** 详情的字段 */
export function useDetailSchema(): DescriptionItemSchema[] { export function useDetailSchema(): DescriptionItemSchema[] {
return [ return [
{
field: 'id',
label: '编号',
},
{ {
field: 'merchantTransferId', field: 'merchantTransferId',
label: '商户单号', label: '商户单号',
content: (data) => { content: (data: PayTransferApi.Transfer) =>
return h(Tag, { h(Tag, {}, () => data?.merchantTransferId || '-'),
color: 'blue',
content: data?.merchantTransferId,
});
},
}, },
{ {
field: 'no', field: 'no',
label: '转账单号', label: '转账单号',
content: (data) => { content: (data: PayTransferApi.Transfer) =>
return h(Tag, { h(Tag, { color: 'orange' }, () => data?.no || '-'),
color: 'blue',
content: data?.no,
});
},
}, },
{ {
field: 'appId', field: 'appId',
@@ -208,7 +207,7 @@ export function useDetailSchema(): DescriptionItemSchema[] {
{ {
field: 'status', field: 'status',
label: '转账状态', label: '转账状态',
content: (data) => content: (data: any) =>
h(DictTag, { h(DictTag, {
type: DICT_TYPE.PAY_TRANSFER_STATUS, type: DICT_TYPE.PAY_TRANSFER_STATUS,
value: data?.status, value: data?.status,
@@ -217,22 +216,24 @@ export function useDetailSchema(): DescriptionItemSchema[] {
{ {
field: 'price', field: 'price',
label: '转账金额', label: '转账金额',
content: (data) => { content: (data: PayTransferApi.Transfer) =>
return h(Tag, { h(
color: 'blue', Tag,
content: `${erpPriceInputFormatter(data?.price)}`, { color: 'success' },
}); () => `${erpPriceInputFormatter(data?.price || 0)}`,
}, ),
}, },
{ {
field: 'successTime', field: 'successTime',
label: '转账时间', label: '转账时间',
content: (data) => formatDateTime(data?.successTime) as string, content: (data: PayTransferApi.Transfer) =>
formatDateTime(data?.successTime) as string,
}, },
{ {
field: 'createTime', field: 'createTime',
label: '创建时间', label: '创建时间',
content: (data) => formatDateTime(data?.createTime) as string, content: (data: PayTransferApi.Transfer) =>
formatDateTime(data?.createTime) as string,
}, },
{ {
field: 'userName', field: 'userName',
@@ -245,25 +246,23 @@ export function useDetailSchema(): DescriptionItemSchema[] {
{ {
field: 'channelCode', field: 'channelCode',
label: '支付渠道', label: '支付渠道',
content: (data) => content: (data: PayTransferApi.Transfer) =>
h(DictTag, { h(DictTag, {
type: DICT_TYPE.PAY_CHANNEL_CODE, type: DICT_TYPE.PAY_CHANNEL_CODE,
value: data?.channelCode, value: data?.channelCode,
}), }),
}, },
{ {
field: 'channelCode', field: 'userIp',
label: '支付 IP', label: '支付 IP',
}, },
{ {
field: 'channelTransferNo', field: 'channelTransferNo',
label: '渠道单号', label: '渠道单号',
content: (data) => { content: (data: PayTransferApi.Transfer) =>
return h(Tag, { data?.channelTransferNo
color: 'blue', ? h(Tag, { color: 'success' }, () => data.channelTransferNo)
content: data?.channelTransferNo, : '',
});
},
}, },
{ {
field: 'notifyUrl', field: 'notifyUrl',

View File

@@ -3,10 +3,11 @@ import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { PayTransferApi } from '#/api/pay/transfer'; import type { PayTransferApi } from '#/api/pay/transfer';
import { DocAlert, Page, useVbenModal } from '@vben/common-ui'; import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
import { downloadFileFromBlobPart } from '@vben/utils';
import { Tag } from 'ant-design-vue';
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { exportTransfer, getTransferPage } from '#/api/pay/transfer'; import { getTransferPage } from '#/api/pay/transfer';
import { $t } from '#/locales'; import { $t } from '#/locales';
import { useGridColumns, useGridFormSchema } from './data'; import { useGridColumns, useGridFormSchema } from './data';
@@ -18,16 +19,10 @@ const [DetailModal, detailModalApi] = useVbenModal({
}); });
/** 刷新表格 */ /** 刷新表格 */
function onRefresh() { function handleRefresh() {
gridApi.query(); gridApi.query();
} }
/** 导出表格 */
async function handleExport() {
const data = await exportTransfer(await gridApi.formApi.getValues());
downloadFileFromBlobPart({ fileName: '转账单.xls', source: data });
}
/** 查看转账详情 */ /** 查看转账详情 */
function handleDetail(row: PayTransferApi.Transfer) { function handleDetail(row: PayTransferApi.Transfer) {
detailModalApi.setData(row).open(); detailModalApi.setData(row).open();
@@ -38,6 +33,9 @@ const [Grid, gridApi] = useVbenVxeGrid({
schema: useGridFormSchema(), schema: useGridFormSchema(),
}, },
gridOptions: { gridOptions: {
cellConfig: {
height: 80,
},
columns: useGridColumns(), columns: useGridColumns(),
height: 'auto', height: 'auto',
keepSource: true, keepSource: true,
@@ -54,6 +52,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
}, },
rowConfig: { rowConfig: {
keyField: 'id', keyField: 'id',
isHover: true,
}, },
toolbarConfig: { toolbarConfig: {
refresh: true, refresh: true,
@@ -69,21 +68,8 @@ const [Grid, gridApi] = useVbenVxeGrid({
<DocAlert title="转账管理" url="https://doc.iocoder.cn/pay/transfer/" /> <DocAlert title="转账管理" url="https://doc.iocoder.cn/pay/transfer/" />
</template> </template>
<DetailModal @success="onRefresh" /> <DetailModal @success="handleRefresh" />
<Grid table-title="转账单列表"> <Grid table-title="转账单列表">
<template #toolbar-tools>
<TableAction
:actions="[
{
label: $t('ui.actionTitle.export'),
type: 'primary',
icon: ACTION_ICON.DOWNLOAD,
auth: ['pay:transfer:export'],
onClick: handleExport,
},
]"
/>
</template>
<template #actions="{ row }"> <template #actions="{ row }">
<TableAction <TableAction
:actions="[ :actions="[
@@ -97,6 +83,21 @@ const [Grid, gridApi] = useVbenVxeGrid({
]" ]"
/> />
</template> </template>
<template #no="{ row }">
<div class="flex flex-col gap-1 text-left">
<p class="text-sm">
<Tag size="small" color="blue"> 商户</Tag>
{{ row.merchantTransferId }}
</p>
<p class="text-sm" v-if="row.no">
<Tag size="small" color="orange">转账</Tag> {{ row.no }}
</p>
<p class="text-sm" v-if="row.channelTransferNo">
<Tag size="small" color="green">渠道</Tag>
{{ row.channelTransferNo }}
</p>
</div>
</template>
</Grid> </Grid>
</Page> </Page>
</template> </template>

View File

@@ -34,8 +34,7 @@ const [Modal, modalApi] = useVbenModal({
const [Descriptions] = useDescription({ const [Descriptions] = useDescription({
componentProps: { componentProps: {
title: '基本信息', bordered: true,
bordered: false,
column: 2, column: 2,
class: 'mx-4', class: 'mx-4',
}, },