Files
frontend/apps/web-antd/src/views/mall/promotion/coupon/data.ts
2025-06-19 14:26:13 +08:00

130 lines
2.7 KiB
TypeScript

import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils';
import { discountFormat } from './formatter';
/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'nickname',
label: '会员昵称',
component: 'Input',
componentProps: {
placeholder: '请输入会员昵称',
clearable: true,
},
},
{
fieldName: 'createTime',
label: '领取时间',
component: 'RangePicker',
componentProps: {
...getRangePickerDefaultProps(),
clearable: true,
},
},
];
}
/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions['columns'] {
return [
{
field: 'nickname',
title: '会员昵称',
minWidth: 100,
},
{
field: 'name',
title: '优惠券名称',
minWidth: 140,
},
{
field: 'productScope',
title: '类型',
minWidth: 110,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.PROMOTION_PRODUCT_SCOPE },
},
},
{
field: 'discountType',
title: '优惠',
minWidth: 110,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.PROMOTION_DISCOUNT_TYPE },
},
},
{
field: 'discountPrice',
title: '优惠力度',
minWidth: 110,
formatter: ({ row }) => {
return discountFormat(row);
},
},
{
field: 'takeType',
title: '领取方式',
minWidth: 110,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.PROMOTION_COUPON_TAKE_TYPE },
},
},
{
field: 'status',
title: '状态',
minWidth: 110,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.PROMOTION_COUPON_STATUS },
},
},
{
field: 'createTime',
title: '领取时间',
width: 180,
formatter: 'formatDateTime',
},
{
field: 'useTime',
title: '使用时间',
width: 180,
formatter: 'formatDateTime',
},
{
title: '操作',
width: 100,
fixed: 'right',
slots: { default: 'actions' },
},
];
}
/** 获取状态选项卡配置 */
export function getStatusTabs() {
const tabs = [
{
label: '全部',
value: 'all',
},
];
// 添加字典状态选项
const statusOptions = getDictOptions(DICT_TYPE.PROMOTION_COUPON_STATUS);
for (const option of statusOptions) {
tabs.push({
label: option.label,
value: String(option.value),
});
}
return tabs;
}