fix:【antd】【ele】【pay 支付】pay/refund 迁移 ele 版本

This commit is contained in:
YunaiV
2025-10-05 21:48:00 +08:00
parent cb04558426
commit 25e434276a
6 changed files with 149 additions and 124 deletions

View File

@@ -206,16 +206,20 @@ export function useDetailSchema(): DescriptionItemSchema[] {
field: 'payPrice', field: 'payPrice',
label: '支付金额', label: '支付金额',
content: (data: PayRefundApi.Refund) => content: (data: PayRefundApi.Refund) =>
h(Tag, { color: 'success' }, () => h(
`${erpPriceInputFormatter(data?.payPrice || 0)}` Tag,
{ color: 'success' },
() => `${erpPriceInputFormatter(data?.payPrice || 0)}`,
), ),
}, },
{ {
field: 'refundPrice', field: 'refundPrice',
label: '退款金额', label: '退款金额',
content: (data: PayRefundApi.Refund) => content: (data: PayRefundApi.Refund) =>
h(Tag, { color: 'danger' }, () => h(
`${erpPriceInputFormatter(data?.refundPrice || 0)}` Tag,
{ color: 'danger' },
() => `${erpPriceInputFormatter(data?.refundPrice || 0)}`,
), ),
}, },
{ {

View File

@@ -41,6 +41,7 @@ const [Modal, modalApi] = useVbenModal({
}, },
}); });
</script> </script>
<template> <template>
<Modal <Modal
title="退款详情" title="退款详情"

View File

@@ -14,9 +14,12 @@ export namespace PayRefundApi {
tradeNo: string; tradeNo: string;
merchantOrderId: string; merchantOrderId: string;
merchantRefundNo: string; merchantRefundNo: string;
merchantRefundId: string;
notifyUrl: string; notifyUrl: string;
notifyStatus: number; notifyStatus: number;
status: number; status: number;
payPrice: number;
refundPrice: number;
type: number; type: number;
payAmount: number; payAmount: number;
refundAmount: number; refundAmount: number;

View File

@@ -1,18 +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 { PayRefundApi } from '#/api/pay/refund';
import type { DescriptionItemSchema } from '#/components/description'; import type { DescriptionItemSchema } from '#/components/description';
import { h } from 'vue'; import { h } from 'vue';
import { fenToYuan, formatDateTime } from '@vben/utils'; import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { erpPriceInputFormatter, formatDateTime } from '@vben/utils';
import { ElTag } from 'element-plus'; import { ElTag } from 'element-plus';
import { getAppList } from '#/api/pay/app';
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';
/** 列表的搜索表单 */ /** 列表的搜索表单 */
@@ -21,17 +20,10 @@ export function useGridFormSchema(): VbenFormSchema[] {
{ {
fieldName: 'appId', fieldName: 'appId',
label: '应用编号', label: '应用编号',
component: 'ApiSelect', component: 'Input',
componentProps: { componentProps: {
api: async () => { allowClear: true,
const data = await getAppList(); placeholder: '请输入应用编号',
return data.map((item) => ({
label: item.name,
value: item.id,
}));
},
autoSelect: 'first',
placeholder: '请选择数据源',
}, },
}, },
{ {
@@ -40,35 +32,53 @@ export function useGridFormSchema(): VbenFormSchema[] {
component: 'Select', component: 'Select',
componentProps: { componentProps: {
clearable: true, clearable: true,
placeholder: '请选择退款渠道',
options: getDictOptions(DICT_TYPE.PAY_CHANNEL_CODE, 'string'), options: getDictOptions(DICT_TYPE.PAY_CHANNEL_CODE, 'string'),
}, },
}, },
{ {
fieldName: 'merchantOrderId', fieldName: 'merchantOrderId',
label: '商户支付单号', label: '商户单号',
component: 'Input', component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入商户单号',
},
}, },
{ {
fieldName: 'merchantRefundId', fieldName: 'merchantRefundId',
label: '商户退款单号', label: '退款单号',
component: 'Input', component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入退款单号',
},
}, },
{ {
fieldName: 'channelOrderNo', fieldName: 'channelOrderNo',
label: '渠道支付单号', label: '渠道单号',
component: 'Input', component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入渠道单号',
},
}, },
{ {
fieldName: 'channelRefundNo', fieldName: 'channelRefundNo',
label: '渠道退款单号', label: '渠道退款单号',
component: 'Input', component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入渠道退款单号',
},
}, },
{ {
fieldName: 'status', fieldName: 'status',
label: '退款状态', label: '退款状态',
component: 'Select', component: 'Select',
componentProps: { componentProps: {
clearable: true, allowClear: true,
placeholder: '请选择退款状态',
options: getDictOptions(DICT_TYPE.PAY_REFUND_STATUS, 'number'), options: getDictOptions(DICT_TYPE.PAY_REFUND_STATUS, 'number'),
}, },
}, },
@@ -78,7 +88,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
component: 'RangePicker', component: 'RangePicker',
componentProps: { componentProps: {
...getRangePickerDefaultProps(), ...getRangePickerDefaultProps(),
clearable: true, allowClear: true,
}, },
}, },
]; ];
@@ -90,81 +100,99 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'id', field: 'id',
title: '编号', title: '编号',
}, minWidth: 100,
{
field: 'merchantRefundId',
title: '退款订单号',
},
{
field: 'channelRefundNo',
title: '渠道退款单号',
}, },
{ {
field: 'payPrice', field: 'payPrice',
title: '支付金额', title: '支付金额',
formatter: 'formatFenToYuanAmount', minWidth: 120,
formatter: 'formatAmount2',
}, },
{ {
field: 'refundPrice', field: 'refundPrice',
title: '退款金额', title: '退款金额',
formatter: 'formatFenToYuanAmount', minWidth: 120,
formatter: 'formatAmount2',
},
{
field: 'merchantRefundId',
title: '退款单号',
minWidth: 240,
slots: {
default: 'no',
},
}, },
{ {
field: 'status', field: 'status',
title: '退款状态', title: '退款状态',
minWidth: 120,
cellRender: { cellRender: {
name: 'CellDict', name: 'CellDict',
props: { type: DICT_TYPE.PAY_REFUND_STATUS }, props: { type: DICT_TYPE.PAY_REFUND_STATUS },
}, },
}, },
{ {
field: 'createTime', field: 'channelCode',
title: '创建时间', title: '退款渠道',
minWidth: 120,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.PAY_CHANNEL_CODE },
},
},
{
field: 'successTime',
title: '退款时间',
minWidth: 180,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
{
field: 'createTime',
title: '创建时间',
minWidth: 180,
formatter: 'formatDateTime',
},
{
field: 'reason',
title: '退款原因',
minWidth: 200,
},
{ {
title: '操作', title: '操作',
width: 100, width: 80,
fixed: 'right', fixed: 'right',
slots: { default: 'actions' }, slots: { default: 'actions' },
}, },
]; ];
} }
/** 详情的字段 */ /** 详情的字段 */
export function useBaseDetailSchema(): DescriptionItemSchema[] { export function useDetailSchema(): DescriptionItemSchema[] {
return [ return [
// 基本信息部分
{ {
field: 'merchantRefundId', field: 'merchantRefundId',
label: '商户退款单号', label: '商户退款单号',
content: (data) => content: (data: PayRefundApi.Refund) =>
h(ElTag, {}, () => { h(ElTag, {}, () => data?.merchantRefundId || '-'),
return data?.merchantRefundId || '-';
}),
}, },
{ {
field: 'channelRefundNo', field: 'channelRefundNo',
label: '渠道退款单号', label: '渠道退款单号',
content: (data) => content: (data: PayRefundApi.Refund) =>
h(ElTag, {}, () => { h(ElTag, { type: 'success' }, () => data?.channelRefundNo || '-'),
return data?.channelRefundNo || '-';
}),
}, },
{ {
field: 'merchantOrderId', field: 'merchantOrderId',
label: '商户支付单号', label: '商户支付单号',
content: (data) => content: (data: PayRefundApi.Refund) =>
h(ElTag, {}, () => { h(ElTag, {}, () => data?.merchantOrderId || '-'),
return data?.merchantOrderId || '-';
}),
}, },
{ {
field: 'channelOrderNo', field: 'channelOrderNo',
label: '渠道支付单号', label: '渠道支付单号',
content: (data) => content: (data: PayRefundApi.Refund) =>
h(ElTag, {}, () => { h(ElTag, { type: 'success' }, () => data?.channelOrderNo || '-'),
return data?.channelOrderNo || '-';
}),
}, },
{ {
field: 'appId', field: 'appId',
@@ -177,23 +205,27 @@ export function useBaseDetailSchema(): DescriptionItemSchema[] {
{ {
field: 'payPrice', field: 'payPrice',
label: '支付金额', label: '支付金额',
content: (data) => content: (data: PayRefundApi.Refund) =>
h(ElTag, { color: 'success' }, () => { h(
return fenToYuan(data.payPrice || 0); ElTag,
}), { type: 'success' },
() => `${erpPriceInputFormatter(data?.payPrice || 0)}`,
),
}, },
{ {
field: 'refundPrice', field: 'refundPrice',
label: '退款金额', label: '退款金额',
content: (data) => content: (data: PayRefundApi.Refund) =>
h(ElTag, { color: 'red' }, () => { h(
return fenToYuan(data.refundPrice || 0); ElTag,
}), { type: 'danger' },
() => `${erpPriceInputFormatter(data?.refundPrice || 0)}`,
),
}, },
{ {
field: 'status', field: 'status',
label: '退款状态', label: '退款状态',
content: (data) => content: (data: any) =>
h(DictTag, { h(DictTag, {
type: DICT_TYPE.PAY_REFUND_STATUS, type: DICT_TYPE.PAY_REFUND_STATUS,
value: data?.status, value: data?.status,
@@ -202,28 +234,26 @@ export function useBaseDetailSchema(): DescriptionItemSchema[] {
{ {
field: 'successTime', field: 'successTime',
label: '退款时间', label: '退款时间',
content: (data) => formatDateTime(data.successTime) as string, content: (data: PayRefundApi.Refund) =>
formatDateTime(data?.successTime) as string,
}, },
{ {
field: 'createTime', field: 'createTime',
label: '创建时间', label: '创建时间',
content: (data) => formatDateTime(data.createTime) as string, content: (data: PayRefundApi.Refund) =>
formatDateTime(data?.createTime) as string,
}, },
{ {
field: 'updateTime', field: 'updateTime',
label: '更新时间', label: '更新时间',
content: (data) => formatDateTime(data.updateTime) as string, content: (data: PayRefundApi.Refund) =>
formatDateTime(data?.updateTime) as string,
}, },
]; // 渠道信息部分
}
/** 详情页的字段 */
export function useChannelDetailSchema(): DescriptionItemSchema[] {
return [
{ {
field: 'channelCode', field: 'channelCode',
label: '退款渠道', label: '退款渠道',
content: (data) => content: (data: PayRefundApi.Refund) =>
h(DictTag, { h(DictTag, {
type: DICT_TYPE.PAY_CHANNEL_CODE, type: DICT_TYPE.PAY_CHANNEL_CODE,
value: data?.channelCode, value: data?.channelCode,
@@ -241,6 +271,7 @@ export function useChannelDetailSchema(): DescriptionItemSchema[] {
field: 'notifyUrl', field: 'notifyUrl',
label: '通知 URL', label: '通知 URL',
}, },
// 错误信息部分
{ {
field: 'channelErrorCode', field: 'channelErrorCode',
label: '渠道错误码', label: '渠道错误码',

View File

@@ -1,35 +1,31 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { PayRefundApi } from '#/api/pay/refund';
import { DocAlert, Page, useVbenModal } from '@vben/common-ui'; import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
import { downloadFileFromBlobPart } from '@vben/utils';
import { ElTag } from 'element-plus';
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import * as RefundApi from '#/api/pay/refund'; import { getRefundPage } from '#/api/pay/refund';
import { $t } from '#/locales'; import { $t } from '#/locales';
import { useGridColumns, useGridFormSchema } from './data'; import { useGridColumns, useGridFormSchema } from './data';
import Detail from './modules/detail.vue'; import Detail from './modules/detail.vue';
const [RefundDetailModal, refundDetailModalApi] = useVbenModal({ const [DetailModal, detailModalApi] = useVbenModal({
connectedComponent: Detail, connectedComponent: Detail,
destroyOnClose: true, destroyOnClose: true,
}); });
/** 刷新表格 */ /** 刷新表格 */
function onRefresh() { function handleRefresh() {
gridApi.query(); gridApi.query();
} }
/** 导出表格 */
async function handleExport() {
const data = await RefundApi.exportRefund(await gridApi.formApi.getValues());
downloadFileFromBlobPart({ fileName: '支付退款.xls', source: data });
}
/** 查看详情 */ /** 查看详情 */
function handleDetail(row: any) { function handleDetail(row: PayRefundApi.Refund) {
refundDetailModalApi.setData(row).open(); detailModalApi.setData(row).open();
} }
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({
@@ -37,13 +33,16 @@ 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,
proxyConfig: { proxyConfig: {
ajax: { ajax: {
query: async ({ page }, formValues) => { query: async ({ page }, formValues) => {
return await RefundApi.getRefundPage({ return await getRefundPage({
pageNo: page.currentPage, pageNo: page.currentPage,
pageSize: page.pageSize, pageSize: page.pageSize,
...formValues, ...formValues,
@@ -53,12 +52,13 @@ const [Grid, gridApi] = useVbenVxeGrid({
}, },
rowConfig: { rowConfig: {
keyField: 'id', keyField: 'id',
isHover: true,
}, },
toolbarConfig: { toolbarConfig: {
refresh: true, refresh: true,
search: true, search: true,
}, },
} as VxeTableGridOptions<any>, } as VxeTableGridOptions<PayRefundApi.Refund>,
}); });
</script> </script>
<template> <template>
@@ -69,21 +69,8 @@ const [Grid, gridApi] = useVbenVxeGrid({
url="https://doc.iocoder.cn/pay/refund-demo/" url="https://doc.iocoder.cn/pay/refund-demo/"
/> />
</template> </template>
<RefundDetailModal @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:refund:query'],
onClick: handleExport,
},
]"
/>
</template>
<template #actions="{ row }"> <template #actions="{ row }">
<TableAction <TableAction
:actions="[ :actions="[
@@ -98,6 +85,21 @@ const [Grid, gridApi] = useVbenVxeGrid({
]" ]"
/> />
</template> </template>
<template #no="{ row }">
<div class="flex flex-col gap-1 text-left">
<p class="text-sm">
<ElTag size="small" type="primary"> 商户</ElTag> {{ row.merchantOrderId }}
</p>
<p class="text-sm" v-if="row.merchantRefundId">
<ElTag size="small" type="warning">退款</ElTag>
{{ row.merchantRefundId }}
</p>
<p class="text-sm" v-if="row.channelRefundNo">
<ElTag size="small" type="success">渠道</ElTag>
{{ row.channelRefundNo }}
</p>
</div>
</template>
</Grid> </Grid>
</Page> </Page>
</template> </template>

View File

@@ -5,37 +5,23 @@ import { ref } from 'vue';
import { useVbenModal } from '@vben/common-ui'; import { useVbenModal } from '@vben/common-ui';
import { ElDivider } from 'element-plus';
import { getRefund } from '#/api/pay/refund'; import { getRefund } from '#/api/pay/refund';
import { useDescription } from '#/components/description'; import { useDescription } from '#/components/description';
import { useBaseDetailSchema, useChannelDetailSchema } from '../data'; import { useDetailSchema } from '../data';
const formData = ref<PayRefundApi.Refund>(); const formData = ref<PayRefundApi.Refund>();
const [BaseDescription] = useDescription({ const [Descriptions] = useDescription({
componentProps: { componentProps: {
border: false, border: true,
column: 2, column: 2,
direction: 'horizontal', direction: 'horizontal',
labelWidth: 140,
title: '', title: '',
labelWidth: 200,
extra: '', extra: '',
}, },
schema: useBaseDetailSchema(), schema: useDetailSchema(),
});
const [ChannelDescription] = useDescription({
componentProps: {
border: false,
column: 2,
direction: 'horizontal',
title: '',
labelWidth: 200,
extra: '',
},
schema: useChannelDetailSchema(),
}); });
const [Modal, modalApi] = useVbenModal({ const [Modal, modalApi] = useVbenModal({
@@ -66,8 +52,6 @@ const [Modal, modalApi] = useVbenModal({
:show-cancel-button="false" :show-cancel-button="false"
:show-confirm-button="false" :show-confirm-button="false"
> >
<BaseDescription :data="formData" /> <Descriptions :data="formData" />
<ElDivider />
<ChannelDescription :data="formData" />
</Modal> </Modal>
</template> </template>