diff --git a/src/components/admin/FormSchemaVisualEditor.vue b/src/components/admin/FormSchemaVisualEditor.vue index b47470c..bcd84d6 100644 --- a/src/components/admin/FormSchemaVisualEditor.vue +++ b/src/components/admin/FormSchemaVisualEditor.vue @@ -118,6 +118,13 @@ function applyOptionsText(element: FormSchemaEditorItem, raw: string) { placeholder="如 project_name" /> + +
标题补充
+ +
占位提示
diff --git a/src/utils/defaultSignupFormSchema.ts b/src/utils/defaultSignupFormSchema.ts index e4740c6..94ac771 100644 --- a/src/utils/defaultSignupFormSchema.ts +++ b/src/utils/defaultSignupFormSchema.ts @@ -6,6 +6,8 @@ export interface SignupFormSchemaField { key: string type: string label: string + /** 标题后、`*`(若有)后面的补充文案(与管理端「标题补充」一致,JSON:`title_supplement`) */ + title_supplement?: string required: boolean placeholder?: string help?: string @@ -156,6 +158,9 @@ export function normalizeSignupSchema(raw: unknown): SignupFormSchemaField[] { const helpRaw = o.help const help = helpRaw != null && String(helpRaw).trim() !== '' ? String(helpRaw).trim() : undefined + const tsRaw = o.title_supplement + const title_supplement = + tsRaw != null && String(tsRaw).trim() !== '' ? String(tsRaw).trim() : undefined let required_when: { field: string; values: string[] } | undefined const rw = o.required_when if (rw != null && typeof rw === 'object' && !Array.isArray(rw)) { @@ -188,7 +193,7 @@ export function normalizeSignupSchema(raw: unknown): SignupFormSchemaField[] { } } } - out.push({ key, type, label, required, placeholder, help, options, required_when }) + out.push({ key, type, label, title_supplement, required, placeholder, help, options, required_when }) } return out.length ? out : DEFAULT_SIGNUP_FORM_SCHEMA.map((f) => ({ ...f })) } diff --git a/src/utils/formSchemaEditor.ts b/src/utils/formSchemaEditor.ts index ea164e8..c433b17 100644 --- a/src/utils/formSchemaEditor.ts +++ b/src/utils/formSchemaEditor.ts @@ -9,6 +9,8 @@ export interface FormSchemaEditorItem { type: string label: string required: boolean + /** 选手端展示在标题后;必填时落在 * 之后(入库 title_supplement) */ + titleSupplement?: string placeholder?: string help?: string /** select 等:{ label, value } */ @@ -56,6 +58,7 @@ export function createEmptySchemaItem( type, label: purpose === 'review' ? `评分维度 ${index + 1}` : `字段 ${index + 1}`, required: purpose !== 'review', + titleSupplement: '', placeholder: '', help: '', options: [], @@ -110,6 +113,7 @@ export function schemaJsonToEditorItems(json: unknown, purpose: FormSchemaPurpos type, label: String(o.label ?? `字段 ${index + 1}`), required: Boolean(o.required), + titleSupplement: o.title_supplement != null ? String(o.title_supplement) : '', placeholder: o.placeholder != null ? String(o.placeholder) : '', help: o.help != null ? String(o.help) : '', options: type === 'select' ? normalizeOptions(o.options) : [], @@ -131,6 +135,7 @@ export function editorItemsToSchemaJson(items: FormSchemaEditorItem[], purpose: } if (item.placeholder?.trim()) row.placeholder = item.placeholder.trim() if (item.help?.trim()) row.help = item.help.trim() + if (item.titleSupplement?.trim()) row.title_supplement = item.titleSupplement.trim() if (item.type === 'select' && item.options?.length) { row.options = item.options.filter((o) => o.value !== '' || o.label !== '') } diff --git a/src/views/ApplyFormView.vue b/src/views/ApplyFormView.vue index 160ac7c..a7e1975 100644 --- a/src/views/ApplyFormView.vue +++ b/src/views/ApplyFormView.vue @@ -68,6 +68,11 @@ function participantFieldHelp(help?: string): string { return t } +/** 管理端「标题补充」:展示在标题后,必填时位于 * 之后 */ +function participantFieldTitleSupplement(field: SignupFormSchemaField): string { + return String(field.title_supplement ?? '').trim() +} + function apiBase() { return getApiBase() } @@ -1091,9 +1096,15 @@ onMounted(() => { >