Files
tydata-admin/apps/web-antd/src/views/agent/agent-commission/data.ts

113 lines
2.7 KiB
TypeScript
Raw Normal View History

2025-06-08 20:16:51 +08:00
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
2025-12-31 12:40:55 +08:00
import type { AgentApi } from '#/api';
2025-06-08 20:16:51 +08:00
// 佣金记录列表列配置
2025-12-31 12:40:55 +08:00
export function useCommissionColumns(
onActionClick?: (params: { code: string; row: AgentApi.AgentCommissionListItem }) => void,
): VxeTableGridOptions['columns'] {
2025-06-08 20:16:51 +08:00
return [
{
field: 'agent_id',
title: '代理ID',
width: 100,
},
{
field: 'order_id',
title: '订单ID',
width: 100,
},
{
field: 'amount',
title: '佣金金额',
width: 120,
formatter: ({ cellValue }: { cellValue: number }) =>
`¥${cellValue.toFixed(2)}`,
},
{
field: 'product_name',
title: '产品名称',
width: 150,
},
{
field: 'status',
title: '状态',
width: 100,
formatter: ({ cellValue }: { cellValue: number }) => {
const statusMap: Record<number, string> = {
2025-12-30 18:01:01 +08:00
0: '已结算',
1: '冻结中',
2025-06-08 20:16:51 +08:00
2: '已取消',
};
return statusMap[cellValue] || '未知';
},
},
{
field: 'create_time',
title: '创建时间',
width: 160,
sortable: true,
sortType: 'string' as const,
},
2025-12-31 12:40:55 +08:00
{
align: 'center',
cellRender: {
name: 'CellOperation',
attrs: {
nameField: 'id',
nameTitle: '操作',
onClick: onActionClick,
},
options: [
{
code: 'unfreeze',
text: '解冻',
type: 'primary',
disabled: (row: AgentApi.AgentCommissionListItem) => row?.status !== 1,
},
{
code: 'cancel',
text: '取消',
type: 'default',
disabled: (row: AgentApi.AgentCommissionListItem) => row?.status !== 1,
},
{
code: 'settled',
text: '已结算',
type: 'success',
disabled: (row: AgentApi.AgentCommissionListItem) => row?.status !== 0,
},
],
},
field: 'operation',
fixed: 'right',
title: '操作',
width: 300,
},
2025-06-08 20:16:51 +08:00
];
}
// 佣金记录搜索表单配置
export function useCommissionFormSchema(): VbenFormSchema[] {
return [
{
component: 'Input',
fieldName: 'product_name',
label: '产品名称',
},
{
component: 'Select',
fieldName: 'status',
label: '状态',
componentProps: {
allowClear: true,
options: [
2025-12-30 18:01:01 +08:00
{ label: '已结算', value: 0 },
{ label: '冻结中', value: 1 },
2025-06-08 20:16:51 +08:00
{ label: '已取消', value: 2 },
],
},
},
];
}