167 lines
3.7 KiB
TypeScript
167 lines
3.7 KiB
TypeScript
import type { VbenFormSchema } from '#/adapter/form';
|
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
|
|
|
import { DICT_TYPE, getDictOptions } from '#/utils';
|
|
|
|
/** 表单配置 */
|
|
export function useFormSchema(): VbenFormSchema[] {
|
|
return [
|
|
{
|
|
fieldName: 'id',
|
|
component: 'Input',
|
|
dependencies: {
|
|
triggerFields: [''],
|
|
show: () => false,
|
|
},
|
|
},
|
|
{
|
|
fieldName: 'name',
|
|
label: '活动名称',
|
|
component: 'Input',
|
|
componentProps: {
|
|
placeholder: '请输入活动名称',
|
|
},
|
|
rules: 'required',
|
|
},
|
|
{
|
|
fieldName: 'startTime',
|
|
label: '开始时间',
|
|
component: 'DatePicker',
|
|
componentProps: {
|
|
placeholder: '请选择开始时间',
|
|
showTime: true,
|
|
valueFormat: 'x',
|
|
format: 'YYYY-MM-DD HH:mm:ss',
|
|
},
|
|
rules: 'required',
|
|
},
|
|
{
|
|
fieldName: 'endTime',
|
|
label: '结束时间',
|
|
component: 'DatePicker',
|
|
componentProps: {
|
|
placeholder: '请选择结束时间',
|
|
showTime: true,
|
|
valueFormat: 'x',
|
|
format: 'YYYY-MM-DD HH:mm:ss',
|
|
},
|
|
rules: 'required',
|
|
},
|
|
{
|
|
fieldName: 'conditionType',
|
|
label: '条件类型',
|
|
component: 'RadioGroup',
|
|
componentProps: {
|
|
options: getDictOptions(DICT_TYPE.PROMOTION_CONDITION_TYPE, 'number'),
|
|
},
|
|
rules: 'required',
|
|
},
|
|
{
|
|
fieldName: 'productScope',
|
|
label: '商品范围',
|
|
component: 'RadioGroup',
|
|
componentProps: {
|
|
options: getDictOptions(DICT_TYPE.PROMOTION_PRODUCT_SCOPE, 'number'),
|
|
},
|
|
rules: 'required',
|
|
},
|
|
{
|
|
fieldName: 'remark',
|
|
label: '备注',
|
|
component: 'Textarea',
|
|
componentProps: {
|
|
placeholder: '请输入备注',
|
|
rows: 4,
|
|
},
|
|
},
|
|
];
|
|
}
|
|
|
|
/** 列表的搜索表单 */
|
|
export function useGridFormSchema(): VbenFormSchema[] {
|
|
return [
|
|
{
|
|
fieldName: 'name',
|
|
label: '活动名称',
|
|
component: 'Input',
|
|
componentProps: {
|
|
placeholder: '请输入活动名称',
|
|
clearable: true,
|
|
},
|
|
},
|
|
{
|
|
fieldName: 'status',
|
|
label: '活动状态',
|
|
component: 'Select',
|
|
componentProps: {
|
|
placeholder: '请选择活动状态',
|
|
clearable: true,
|
|
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
|
},
|
|
},
|
|
{
|
|
fieldName: 'createTime',
|
|
label: '活动时间',
|
|
component: 'RangePicker',
|
|
componentProps: {
|
|
placeholder: ['活动开始日期', '活动结束日期'],
|
|
clearable: true,
|
|
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
|
},
|
|
},
|
|
];
|
|
}
|
|
|
|
/** 列表的字段 */
|
|
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
|
return [
|
|
{
|
|
field: 'name',
|
|
title: '活动名称',
|
|
minWidth: 140,
|
|
},
|
|
{
|
|
field: 'productScope',
|
|
title: '活动范围',
|
|
minWidth: 100,
|
|
cellRender: {
|
|
name: 'CellDict',
|
|
props: { type: DICT_TYPE.PROMOTION_PRODUCT_SCOPE },
|
|
},
|
|
},
|
|
{
|
|
field: 'startTime',
|
|
title: '活动开始时间',
|
|
width: 180,
|
|
formatter: 'formatDateTime',
|
|
},
|
|
{
|
|
field: 'endTime',
|
|
title: '活动结束时间',
|
|
width: 180,
|
|
formatter: 'formatDateTime',
|
|
},
|
|
{
|
|
field: 'status',
|
|
title: '状态',
|
|
minWidth: 100,
|
|
cellRender: {
|
|
name: 'CellDict',
|
|
props: { type: DICT_TYPE.COMMON_STATUS },
|
|
},
|
|
},
|
|
{
|
|
field: 'createTime',
|
|
title: '创建时间',
|
|
width: 180,
|
|
formatter: 'formatDateTime',
|
|
},
|
|
{
|
|
title: '操作',
|
|
width: 180,
|
|
fixed: 'right',
|
|
slots: { default: 'actions' },
|
|
},
|
|
];
|
|
}
|