f
This commit is contained in:
@@ -1,29 +1,51 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { AgentApi } from '#/api/agent';
|
||||
|
||||
import { getOrderProcessStatusName } from '#/utils/agent';
|
||||
export type AgentOrderRow = AgentApi.AgentOrderListItem;
|
||||
|
||||
export function useOrderColumns(): VxeTableGridOptions['columns'] {
|
||||
export function useOrderColumns(
|
||||
onAgentCodeClick?: (row: AgentOrderRow) => void,
|
||||
onOrderNoClick?: (row: AgentOrderRow) => void,
|
||||
onOperationClick?: (e: { code: string; row: AgentOrderRow }) => void,
|
||||
): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'id',
|
||||
title: 'ID',
|
||||
width: 80,
|
||||
field: 'agent_code',
|
||||
title: '推广代理编号',
|
||||
width: 130,
|
||||
cellRender: onAgentCodeClick
|
||||
? {
|
||||
name: 'CellLink',
|
||||
props: { onClick: onAgentCodeClick },
|
||||
}
|
||||
: undefined,
|
||||
},
|
||||
{
|
||||
field: 'agent_id',
|
||||
title: '代理ID',
|
||||
width: 100,
|
||||
field: 'order_no',
|
||||
title: '商户订单号',
|
||||
minWidth: 180,
|
||||
cellRender: onOrderNoClick
|
||||
? {
|
||||
name: 'CellLink',
|
||||
props: { onClick: onOrderNoClick },
|
||||
}
|
||||
: undefined,
|
||||
},
|
||||
{
|
||||
field: 'order_id',
|
||||
title: '订单ID',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'product_id',
|
||||
title: '产品ID',
|
||||
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',
|
||||
@@ -35,35 +57,35 @@ export function useOrderColumns(): VxeTableGridOptions['columns'] {
|
||||
title: '订单金额',
|
||||
width: 120,
|
||||
formatter: ({ cellValue }: { cellValue: number }) =>
|
||||
`¥${cellValue.toFixed(2)}`,
|
||||
`¥${Number(cellValue).toFixed(2)}`,
|
||||
},
|
||||
{
|
||||
field: 'set_price',
|
||||
title: '设定价格',
|
||||
width: 120,
|
||||
formatter: ({ cellValue }: { cellValue: number }) =>
|
||||
`¥${cellValue.toFixed(2)}`,
|
||||
`¥${Number(cellValue).toFixed(2)}`,
|
||||
},
|
||||
{
|
||||
field: 'actual_base_price',
|
||||
title: '实际底价',
|
||||
width: 120,
|
||||
formatter: ({ cellValue }: { cellValue: number }) =>
|
||||
`¥${cellValue.toFixed(2)}`,
|
||||
`¥${Number(cellValue).toFixed(2)}`,
|
||||
},
|
||||
{
|
||||
field: 'price_cost',
|
||||
title: '提价成本',
|
||||
width: 120,
|
||||
formatter: ({ cellValue }: { cellValue: number }) =>
|
||||
`¥${cellValue.toFixed(2)}`,
|
||||
`¥${Number(cellValue).toFixed(2)}`,
|
||||
},
|
||||
{
|
||||
field: 'agent_profit',
|
||||
title: '代理收益',
|
||||
width: 120,
|
||||
formatter: ({ cellValue }: { cellValue: number }) =>
|
||||
`¥${cellValue.toFixed(2)}`,
|
||||
`¥${Number(cellValue).toFixed(2)}`,
|
||||
},
|
||||
{
|
||||
field: 'process_status',
|
||||
@@ -84,20 +106,54 @@ export function useOrderColumns(): VxeTableGridOptions['columns'] {
|
||||
width: 160,
|
||||
sortable: true,
|
||||
},
|
||||
] as const;
|
||||
...(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: 'InputNumber',
|
||||
fieldName: 'agent_id',
|
||||
label: '代理ID',
|
||||
component: 'Input',
|
||||
fieldName: 'agent_code',
|
||||
label: '推广代理编号',
|
||||
componentProps: {
|
||||
placeholder: '请输入推广代理编号',
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'InputNumber',
|
||||
fieldName: 'order_id',
|
||||
label: '订单ID',
|
||||
component: 'Input',
|
||||
fieldName: 'order_no',
|
||||
label: '商户订单号',
|
||||
componentProps: {
|
||||
placeholder: '请输入商户订单号',
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'Select',
|
||||
@@ -112,6 +168,20 @@ export function useOrderFormSchema(): VbenFormSchema[] {
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
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' },
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user