diff --git a/.codex-tasks/form-designer-epic/EPIC.md b/.codex-tasks/form-designer-epic/EPIC.md new file mode 100644 index 0000000..c65709d --- /dev/null +++ b/.codex-tasks/form-designer-epic/EPIC.md @@ -0,0 +1,13 @@ +# 表单设计器完善 + +## 目标 + +让个人品牌平台的后台可以完整配置跨行业咨询表单:表单用途、关联业务、字段类型、必填规则和选项都由配置驱动,小程序继续只消费 Runtime Workspace。 + +## 验收 + +- 可配置 `inquiry`、`quote-request` 等用途。 +- 可将表单关联到品牌或具体业务提供项。 +- `select` / `radio` 字段可配置选项并正确下发。 +- 编辑失败时保留表单输入,成功后刷新 Runtime。 +- API、Admin build、小程序 fixture 全部通过。 diff --git a/.codex-tasks/form-designer-epic/PROGRESS.md b/.codex-tasks/form-designer-epic/PROGRESS.md new file mode 100644 index 0000000..cd5097a --- /dev/null +++ b/.codex-tasks/form-designer-epic/PROGRESS.md @@ -0,0 +1,13 @@ +# 进度 + +- 任务:表单设计器完善 +- 形态:epic +- 进度:3/3 +- 当前:全部子任务完成 +- 真相文件:`SUBTASKS.csv` + +## 验证 + +- API integration tests:25 passed。 +- Admin production build:通过。 +- Miniapp fixture 和 visual fixture:通过。 diff --git a/.codex-tasks/form-designer-epic/SUBTASKS.csv b/.codex-tasks/form-designer-epic/SUBTASKS.csv new file mode 100644 index 0000000..c436d5a --- /dev/null +++ b/.codex-tasks/form-designer-epic/SUBTASKS.csv @@ -0,0 +1,4 @@ +id,title,task_type,depends_on,status,task_dir,acceptance_criteria,validation_command,notes +1,表单设计器配置项,single-full,,DONE,tasks/designer,后台可配置用途业务关联和字段选项,pnpm --filter @personal-brand/admin build,已完成 +2,Runtime 契约测试,single-full,1,DONE,tasks/designer,用途和选项正确进入公开工作空间,pnpm --filter @personal-brand/api test:integration,已完成 +3,跨模板回归,single-full,2,DONE,tasks/regression,小程序 fixture 和视觉 fixture 通过,pnpm --filter @personal-brand/miniapp test:fixture && pnpm --filter @personal-brand/miniapp test:visual-fixture,已完成 diff --git a/.codex-tasks/form-designer-epic/tasks/designer/PROGRESS.md b/.codex-tasks/form-designer-epic/tasks/designer/PROGRESS.md new file mode 100644 index 0000000..f382031 --- /dev/null +++ b/.codex-tasks/form-designer-epic/tasks/designer/PROGRESS.md @@ -0,0 +1,7 @@ +# 表单设计器配置项 + +状态:DONE + +- 支持需求咨询、获取报价、预约服务用途。 +- 支持品牌级或业务提供项级关联。 +- 支持 select / radio 字段选项 JSON 编辑。 diff --git a/.codex-tasks/form-designer-epic/tasks/regression/PROGRESS.md b/.codex-tasks/form-designer-epic/tasks/regression/PROGRESS.md new file mode 100644 index 0000000..8f67d9b --- /dev/null +++ b/.codex-tasks/form-designer-epic/tasks/regression/PROGRESS.md @@ -0,0 +1,7 @@ +# 跨模板回归 + +状态:DONE + +- API 集成测试:25 passed。 +- Miniapp fixture:通过。 +- Miniapp visual fixture:通过。 diff --git a/apps/admin/src/features/workspace/WorkspacePage.tsx b/apps/admin/src/features/workspace/WorkspacePage.tsx index e0e9df2..110256f 100644 --- a/apps/admin/src/features/workspace/WorkspacePage.tsx +++ b/apps/admin/src/features/workspace/WorkspacePage.tsx @@ -133,8 +133,14 @@ export function WorkspacePage() { }, }); const createForm = useMutation({ - mutationFn: (values: { name: string; fieldsSnapshot: unknown[] }) => - client.createAdminInquiryForm(values), + mutationFn: (values: { + name: string; + offeringId?: string; + purpose?: InquiryForm["purpose"]; + targetType?: InquiryForm["targetType"]; + submissionAction?: InquiryForm["submissionAction"]; + fieldsSnapshot: unknown[]; + }) => client.createAdminInquiryForm(values), onSuccess: () => { message.success("咨询表单已创建"); setFormOpen(false); @@ -478,7 +484,17 @@ export function WorkspacePage() { setEditingForm(item); inquiryForm.setFieldsValue({ name: item.name, - fieldsSnapshot: item.fieldsSnapshot, + purpose: item.purpose, + offeringId: item.offeringId ?? undefined, + fieldsSnapshot: item.fieldsSnapshot.map((field) => { + const value = field as Record; + return { + ...value, + ...(Array.isArray(value.options) + ? { optionsText: JSON.stringify(value.options) } + : {}), + }; + }), }); setFormOpen(true); }} @@ -659,7 +675,25 @@ export function WorkspacePage() { (() => { const body = { name: typeof values.name === "string" ? values.name : "", - fieldsSnapshot: Array.isArray(values.fieldsSnapshot) ? values.fieldsSnapshot : [], + offeringId: typeof values.offeringId === "string" ? values.offeringId : undefined, + purpose: values.purpose as InquiryForm["purpose"], + targetType: values.offeringId ? "offering" : "brand", + submissionAction: + values.purpose === "quote-request" ? "create-quote" : "create-inquiry", + fieldsSnapshot: (Array.isArray(values.fieldsSnapshot) + ? values.fieldsSnapshot + : [] + ).map((field) => { + const item = field as Record; + if (typeof item.optionsText !== "string") return item; + try { + const options = JSON.parse(item.optionsText); + const { optionsText: _optionsText, ...rest } = item; + return { ...rest, options }; + } catch { + return item; + } + }), }; if (editingForm) updateForm.mutate({ id: editingForm.id, body }); else createForm.mutate(body); @@ -669,6 +703,29 @@ export function WorkspacePage() { + + + ({ + value: item.id, + label: item.name, + }))} + /> + + {(fields, { add, remove }) => ( <> @@ -699,6 +756,17 @@ export function WorkspacePage() { ].map((value) => ({ value, label: value }))} /> + + {({ getFieldValue }) => + ["select", "radio"].includes( + getFieldValue(["fieldsSnapshot", name, "type"]), + ) ? ( + + + + ) : null + } +