188 lines
4.8 KiB
TypeScript
188 lines
4.8 KiB
TypeScript
import type { VbenFormSchema } from '#/adapter/form';
|
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
|
import type { AgentApi } from '#/api/agent';
|
|
|
|
export type AgentOrderRow = AgentApi.AgentOrderListItem;
|
|
|
|
export function useOrderColumns(
|
|
onAgentCodeClick?: (row: AgentOrderRow) => void,
|
|
onOrderNoClick?: (row: AgentOrderRow) => void,
|
|
onOperationClick?: (e: { code: string; row: AgentOrderRow }) => void,
|
|
): VxeTableGridOptions['columns'] {
|
|
return [
|
|
{
|
|
field: 'agent_code',
|
|
title: '推广代理编号',
|
|
width: 130,
|
|
cellRender: onAgentCodeClick
|
|
? {
|
|
name: 'CellLink',
|
|
props: { onClick: onAgentCodeClick },
|
|
}
|
|
: undefined,
|
|
},
|
|
{
|
|
field: 'order_no',
|
|
title: '商户订单号',
|
|
minWidth: 180,
|
|
cellRender: onOrderNoClick
|
|
? {
|
|
name: 'CellLink',
|
|
props: { onClick: onOrderNoClick },
|
|
}
|
|
: undefined,
|
|
},
|
|
{
|
|
field: 'order_status',
|
|
title: '订单状态',
|
|
width: 100,
|
|
cellRender: {
|
|
name: 'CellTag',
|
|
options: [
|
|
{ value: 'pending', color: 'warning', label: '待支付' },
|
|
{ value: 'paid', color: 'success', label: '已支付' },
|
|
{ value: 'failed', color: 'error', label: '支付失败' },
|
|
{ value: 'refunded', color: 'default', label: '已退款' },
|
|
{ value: 'closed', color: 'default', label: '已关闭' },
|
|
],
|
|
},
|
|
},
|
|
{
|
|
field: 'product_name',
|
|
title: '产品名称',
|
|
width: 150,
|
|
},
|
|
{
|
|
field: 'order_amount',
|
|
title: '订单金额',
|
|
width: 120,
|
|
formatter: ({ cellValue }: { cellValue: number }) =>
|
|
`¥${Number(cellValue).toFixed(2)}`,
|
|
},
|
|
{
|
|
field: 'set_price',
|
|
title: '设定价格',
|
|
width: 120,
|
|
formatter: ({ cellValue }: { cellValue: number }) =>
|
|
`¥${Number(cellValue).toFixed(2)}`,
|
|
},
|
|
{
|
|
field: 'actual_base_price',
|
|
title: '实际底价',
|
|
width: 120,
|
|
formatter: ({ cellValue }: { cellValue: number }) =>
|
|
`¥${Number(cellValue).toFixed(2)}`,
|
|
},
|
|
{
|
|
field: 'price_cost',
|
|
title: '提价成本',
|
|
width: 120,
|
|
formatter: ({ cellValue }: { cellValue: number }) =>
|
|
`¥${Number(cellValue).toFixed(2)}`,
|
|
},
|
|
{
|
|
field: 'agent_profit',
|
|
title: '代理收益',
|
|
width: 120,
|
|
formatter: ({ cellValue }: { cellValue: number }) =>
|
|
`¥${Number(cellValue).toFixed(2)}`,
|
|
},
|
|
{
|
|
field: 'process_status',
|
|
title: '处理状态',
|
|
width: 100,
|
|
cellRender: {
|
|
name: 'CellTag',
|
|
options: [
|
|
{ value: 0, color: 'warning', label: '待处理' },
|
|
{ value: 1, color: 'success', label: '处理成功' },
|
|
{ value: 2, color: 'error', label: '处理失败' },
|
|
],
|
|
},
|
|
},
|
|
{
|
|
field: 'create_time',
|
|
title: '创建时间',
|
|
width: 160,
|
|
sortable: true,
|
|
},
|
|
...(onOperationClick
|
|
? [
|
|
{
|
|
align: 'center' as const,
|
|
cellRender: {
|
|
attrs: {
|
|
nameField: 'order_no',
|
|
nameTitle: '商户订单号',
|
|
onClick: onOperationClick,
|
|
},
|
|
name: 'CellOperation',
|
|
options: [
|
|
{
|
|
code: 'settlement',
|
|
text: '分账链路',
|
|
disabled: (row: AgentOrderRow) => !row.order_no,
|
|
},
|
|
],
|
|
},
|
|
field: 'operation',
|
|
fixed: 'right' as const,
|
|
title: '操作',
|
|
width: 110,
|
|
},
|
|
]
|
|
: []),
|
|
];
|
|
}
|
|
|
|
export function useOrderFormSchema(): VbenFormSchema[] {
|
|
return [
|
|
{
|
|
component: 'Input',
|
|
fieldName: 'agent_code',
|
|
label: '推广代理编号',
|
|
componentProps: {
|
|
placeholder: '请输入推广代理编号',
|
|
allowClear: true,
|
|
},
|
|
},
|
|
{
|
|
component: 'Input',
|
|
fieldName: 'order_no',
|
|
label: '商户订单号',
|
|
componentProps: {
|
|
placeholder: '请输入商户订单号',
|
|
allowClear: true,
|
|
},
|
|
},
|
|
{
|
|
component: 'Select',
|
|
fieldName: 'process_status',
|
|
label: '处理状态',
|
|
componentProps: {
|
|
allowClear: true,
|
|
options: [
|
|
{ label: '待处理', value: 0 },
|
|
{ label: '处理成功', value: 1 },
|
|
{ label: '处理失败', value: 2 },
|
|
],
|
|
},
|
|
},
|
|
{
|
|
component: 'Select',
|
|
fieldName: 'order_status',
|
|
label: '订单状态',
|
|
componentProps: {
|
|
allowClear: true,
|
|
options: [
|
|
{ label: '待支付', value: 'pending' },
|
|
{ label: '已支付', value: 'paid' },
|
|
{ label: '支付失败', value: 'failed' },
|
|
{ label: '已退款', value: 'refunded' },
|
|
{ label: '已关闭', value: 'closed' },
|
|
],
|
|
},
|
|
},
|
|
];
|
|
}
|