diff --git a/.codex-tasks/form-management-epic/EPIC.md b/.codex-tasks/form-management-epic/EPIC.md new file mode 100644 index 0000000..9e8b3e8 --- /dev/null +++ b/.codex-tasks/form-management-epic/EPIC.md @@ -0,0 +1,18 @@ +# 行业模板表单配置管理 + +## 目标 + +让不同品牌基于行业模板在后台配置、修改、启停咨询表单和字段;表单仍是品牌级 Runtime Workspace 配置,小程序只渲染,不出现行业分支。 + +## 交付边界 + +- 表单和字段必须按当前管理员品牌隔离。 +- 禁用表单不得出现在公开 Runtime,也不得接受新的客户提交。 +- 已有提交保留历史字段快照,不被表单修改破坏。 +- DTO 使用运行时校验,状态变更有自动化测试。 + +## 验收 + +- API 支持表单完整查询、编辑、启用 / 禁用和安全删除约束。 +- Admin 提供可用的表单配置 UI 和明确失败状态。 +- Runtime、小程序和历史提交回归通过。 diff --git a/.codex-tasks/form-management-epic/PROGRESS.md b/.codex-tasks/form-management-epic/PROGRESS.md new file mode 100644 index 0000000..2dfbfb7 --- /dev/null +++ b/.codex-tasks/form-management-epic/PROGRESS.md @@ -0,0 +1,11 @@ +# 进度 + +- 任务:行业模板表单配置管理 +- 形态:epic +- 进度:0/3 +- 当前:表单生命周期 API +- 真相文件:`SUBTASKS.csv` + +## 恢复说明 + +继续前读取 `EPIC.md`、`SUBTASKS.csv` 和本文件,从第一个非 `DONE` 子任务继续。 diff --git a/.codex-tasks/form-management-epic/SUBTASKS.csv b/.codex-tasks/form-management-epic/SUBTASKS.csv new file mode 100644 index 0000000..f897348 --- /dev/null +++ b/.codex-tasks/form-management-epic/SUBTASKS.csv @@ -0,0 +1,4 @@ +id,title,task_type,depends_on,status,task_dir,acceptance_criteria,validation_command,notes +1,表单生命周期 API, single-full,,IN_PROGRESS,tasks/form-api,更新启停和删除约束完成并有授权测试,pnpm --filter @personal-brand/api test:integration, +2,后台表单配置界面, single-full,1,TODO,tasks/form-ui,能编辑字段和切换启用状态且保留失败输入,pnpm --filter @personal-brand/admin build, +3,跨模板回归收口, single-full,2,TODO,tasks/regression,Runtime 和小程序 fixture 全部通过,pnpm --filter @personal-brand/miniapp test:fixture && pnpm --filter @personal-brand/miniapp test:visual-fixture, diff --git a/apps/admin/src/features/workspace/WorkspacePage.tsx b/apps/admin/src/features/workspace/WorkspacePage.tsx index 22a688f..e0e9df2 100644 --- a/apps/admin/src/features/workspace/WorkspacePage.tsx +++ b/apps/admin/src/features/workspace/WorkspacePage.tsx @@ -17,6 +17,7 @@ import { ApiClientError } from "@personal-brand/api-client"; import type { BrandFieldDefinition, BrandModule, + InquiryForm, PublicWorkspace, } from "@personal-brand/api-client"; import { useState } from "react"; @@ -28,6 +29,7 @@ export function WorkspacePage() { const queryClient = useQueryClient(); const [fieldOpen, setFieldOpen] = useState(false); const [formOpen, setFormOpen] = useState(false); + const [editingForm, setEditingForm] = useState(null); const [visualTarget, setVisualTarget] = useState(null); const [industryTarget, setIndustryTarget] = useState<{ key: "personal" | "food"; @@ -140,6 +142,18 @@ export function WorkspacePage() { void queryClient.invalidateQueries({ queryKey: ["admin-inquiry-forms"] }); }, }); + const updateForm = useMutation({ + mutationFn: ({ id, body }: { id: string; body: Partial }) => + client.updateAdminInquiryForm(id, body), + onSuccess: () => { + message.success("咨询表单已更新"); + setFormOpen(false); + setEditingForm(null); + inquiryForm.resetFields(); + void queryClient.invalidateQueries({ queryKey: ["admin-inquiry-forms"] }); + void queryClient.invalidateQueries({ queryKey: ["public-runtime-workspace"] }); + }, + }); if (query.isLoading) return ; if (query.isError || !query.data) { const errorStatus = @@ -429,7 +443,14 @@ export function WorkspacePage() { setFormOpen(true)}> + } @@ -447,9 +468,41 @@ export function WorkspacePage() { render: (value: unknown[]) => value?.length ?? 0, }, { title: "状态", dataIndex: "isEnabled", render: (value) => (value ? "启用" : "停用") }, + { + title: "操作", + render: (_: unknown, item: InquiryForm) => ( + + +