176 lines
4.1 KiB
TypeScript
176 lines
4.1 KiB
TypeScript
// 表单字段类型枚举
|
||
export enum FieldType {
|
||
TEXT = 'text',
|
||
TEXTAREA = 'textarea',
|
||
SELECT = 'select',
|
||
DATE = 'date',
|
||
TIME = 'time',
|
||
NUMBER = 'number',
|
||
SWITCH = 'switch',
|
||
RADIO = 'radio',
|
||
CHECKBOX = 'checkbox',
|
||
LOCATION = 'location',
|
||
UPLOADIMAGE = 'uploadimage',
|
||
TIMEINTERVAL = 'timeinterval',
|
||
NUMBERINTERVAL = 'numberinterval',
|
||
RANGE = 'range',
|
||
TEXTAREATAG = 'textareaTag',
|
||
ACTIVITYINFO = 'activityInfo',
|
||
WECHATCONTACT = 'wechatContact'
|
||
}
|
||
|
||
// 表单字段配置接口
|
||
export interface FormFieldConfig {
|
||
prop: string
|
||
label: string
|
||
type: FieldType
|
||
placeholder?: string
|
||
required?: boolean
|
||
defaultValue?: any
|
||
options?: Array<{ label: string; value: any }>
|
||
rules?: Array<{
|
||
required?: boolean
|
||
min?: number
|
||
max?: number
|
||
pattern?: RegExp
|
||
message: string
|
||
}>
|
||
props?: Record<string, any>
|
||
description?: string
|
||
children?: FormFieldConfig[]
|
||
iconType?: string
|
||
}
|
||
|
||
// 发布球局表单配置
|
||
export const publishBallFormSchema: FormFieldConfig[] = [
|
||
{
|
||
prop: 'image_list',
|
||
label: '活动封页',
|
||
type: FieldType.UPLOADIMAGE,
|
||
placeholder: '请选择活动类型',
|
||
required: true,
|
||
props: {
|
||
maxCount: 9
|
||
}
|
||
},
|
||
{
|
||
prop: 'title',
|
||
label: '',
|
||
type: FieldType.TEXT,
|
||
placeholder: '好的标题更吸引人哦',
|
||
required: true,
|
||
props: {
|
||
maxLength: 20
|
||
}
|
||
},
|
||
{
|
||
prop: 'timeRange',
|
||
label: '',
|
||
type: FieldType.TIMEINTERVAL,
|
||
placeholder: '请选择活动日期',
|
||
required: true
|
||
},
|
||
{
|
||
prop: 'activityInfo',
|
||
label: '活动信息',
|
||
type: FieldType.ACTIVITYINFO,
|
||
placeholder: '请选择活动时间',
|
||
required: true,
|
||
children: [
|
||
{
|
||
prop: 'price',
|
||
label: '费用',
|
||
iconType: 'ICON_COST',
|
||
type: FieldType.NUMBER,
|
||
placeholder: '请输入活动费用(元)',
|
||
defaultValue: 0,
|
||
rules: [
|
||
{ min: 0, message: '费用不能为负数' },
|
||
{ max: 1000, message: '费用不能超过1000元' }
|
||
],
|
||
},
|
||
{
|
||
prop: 'location_name',
|
||
label: '地点',
|
||
iconType: 'ICON_LOCATION',
|
||
type: FieldType.LOCATION,
|
||
placeholder: '请选择活动地点',
|
||
required: true,
|
||
},
|
||
{
|
||
prop: 'play_type',
|
||
label: '玩法',
|
||
iconType: 'ICON_GAMEPLAY',
|
||
type: FieldType.SELECT,
|
||
placeholder: '请选择玩法',
|
||
required: true,
|
||
options: [
|
||
{ label: '不限', value: '不限' },
|
||
{ label: '单打', value: '单打' },
|
||
{ label: '双打', value: '双打' },
|
||
{ label: '拉球', value: '拉球' }
|
||
],
|
||
}
|
||
]
|
||
},
|
||
{
|
||
prop: 'players',
|
||
label: '人数要求',
|
||
type: FieldType.NUMBERINTERVAL,
|
||
placeholder: '请输入最少参与人数',
|
||
defaultValue: 1,
|
||
props: {
|
||
showSummary: true,
|
||
summary: '最少1人,最多4人',
|
||
}
|
||
},
|
||
|
||
{
|
||
prop: 'skill_level',
|
||
label: 'NTRP 水平要求',
|
||
type: FieldType.RANGE,
|
||
placeholder: '请选择开始时间',
|
||
required: true,
|
||
props: {
|
||
showTitle: false,
|
||
showSummary: true,
|
||
className: 'ntrp-range',
|
||
step: 0.5,
|
||
min: 1.0,
|
||
max: 5.0,
|
||
}
|
||
},
|
||
{
|
||
prop: 'descriptionInfo',
|
||
label: '补充要求(选填)',
|
||
type: FieldType.TEXTAREATAG,
|
||
placeholder: '补充性别偏好、特殊要求和注意事项等信息',
|
||
required: true,
|
||
options:[
|
||
{ label: '仅限男生', value: '仅限男生' },
|
||
{ label: '仅限女生', value: '仅限女生' },
|
||
{ label: '性别不限', value: '性别不限' }
|
||
]
|
||
},
|
||
{
|
||
prop: 'is_substitute_supported',
|
||
label: '',
|
||
type: FieldType.CHECKBOX,
|
||
placeholder: '开启自动候补逻辑',
|
||
required: true,
|
||
props:{
|
||
subTitle: '开启自动候补逻辑',
|
||
showToast: true,
|
||
description: '开启后,当活动人数不足时,系统会自动将活动状态改为“候补”,并通知用户。',
|
||
}
|
||
},
|
||
{
|
||
prop: 'is_wechat_contact',
|
||
label: '',
|
||
type: FieldType.WECHATCONTACT,
|
||
required: true,
|
||
props:{
|
||
subTitle: '允许球友微信联系我',
|
||
}
|
||
}
|
||
]
|