Compare commits

...
Author SHA1 Message Date
que01 61f216ae0e Merge pull request 'fix: 业务提供项点选后仅显示当前区块字段' (#13) from fix/offering-editor-target-filter into main
CI / Browser smoke (push) Has been skipped
CI / Static checks (push) Successful in 1m0s
CI / API integration (push) Successful in 1m29s
CI / Production build (push) Failing after 14m10s
Merge pull request #13: fix: 业务提供项点选后仅显示当前区块字段
2026-10-24 02:45:42 +00:00
que01 96c3d3292d fix: 业务提供项点选后仅显示当前区块字段
CI / Browser smoke (pull_request) Successful in 51s
CI / Static checks (pull_request) Successful in 1m11s
CI / API integration (pull_request) Successful in 1m24s
CI / Production build (pull_request) Successful in 1m50s
2026-10-24 10:37:33 +08:00
que01 cbbf122280 Merge pull request #12: feat: 业务提供项编辑弹窗支持区块点选联动
CI / Browser smoke (push) Has been skipped
CI / Static checks (push) Successful in 55s
CI / API integration (push) Successful in 1m25s
CI / Production build (push) Successful in 1m55s
2026-10-24 02:07:28 +00:00
4 changed files with 94 additions and 10 deletions

No files matched your search

@@ -1,7 +1,7 @@
{ {
"schemaVersion": 1, "schemaVersion": 1,
"scope": "模板完成证据登记,保留命令、日志与产物哈希", "scope": "模板完成证据登记,保留命令、日志与产物哈希",
"generatedAt": "2026-10-24T02:02:12.474Z", "generatedAt": "2026-10-24T02:35:52.145Z",
"templates": { "templates": {
"acheng-campus-food": { "acheng-campus-food": {
"real-manifest-interaction": { "real-manifest-interaction": {
@@ -256,5 +256,5 @@
} }
} }
}, },
"sourceTreeHash": "9d33ce8dbbddd34b91f045f49dc2316e36738ffec1429a93733d45d1b7b2a356" "sourceTreeHash": "a5506179992f144e6b4afb0f0dfc295c5d722a5aadf7027fd785479a8276320f"
} }
@@ -13,6 +13,14 @@ import type { PreviewSelection, PreviewTarget } from "../brand/preview-selection
import type { FormInstance } from "antd"; import type { FormInstance } from "antd";
import "./ServicesPage.css"; import "./ServicesPage.css";
const OFFERING_BASE_FIELD_BINDINGS: Record<string, string> = {
name: "offering.name",
summary: "offering.summary",
description: "offering.description",
priceText: "offering.priceText",
coverUrl: "offering.coverUrl",
};
type OfferingEditorModalProps = { type OfferingEditorModalProps = {
open: boolean; open: boolean;
editingOffering: Offering | null; editingOffering: Offering | null;
@@ -66,6 +74,23 @@ export function OfferingEditorModal({
? { targetKey: previewSelectionTarget.key, recordId: editingOffering.id } ? { targetKey: previewSelectionTarget.key, recordId: editingOffering.id }
: { targetKey: previewSelectionTarget.key } : { targetKey: previewSelectionTarget.key }
: undefined; : undefined;
// 点选某个区块后,右侧只保留该区块真正会展示的字段;未点选时仍展示完整表单。
const visibleBaseFields = (() => {
if (!selectedTarget) return undefined;
if (selectedTarget.source !== "offering") return new Set<string>();
const bindings = new Set(activePreviewBindings);
return new Set(
Object.entries(OFFERING_BASE_FIELD_BINDINGS)
.filter(([, binding]) => bindings.has(binding))
.map(([name]) => name),
);
})();
const isBaseFieldVisible = (name: string) => !visibleBaseFields || visibleBaseFields.has(name);
const showDescriptionField = !hasTemplateDetailCopy && isBaseFieldVisible("description");
const hasVisibleBaseFields =
["kind", "name", "summary", "priceText", "coverUrl", "sortOrder", "isEnabled"].some((name) =>
isBaseFieldVisible(name),
) || showDescriptionField;
// 点选区块后,在右侧滚动到并高亮对应的输入项;品牌通用区块没有对应输入项时只保留提示。 // 点选区块后,在右侧滚动到并高亮对应的输入项;品牌通用区块没有对应输入项时只保留提示。
useEffect(() => { useEffect(() => {
@@ -106,9 +131,11 @@ export function OfferingEditorModal({
showIcon showIcon
title={previewPage === "offerings" ? "正在核对列表展示" : "正在核对详情展示"} title={previewPage === "offerings" ? "正在核对列表展示" : "正在核对详情展示"}
description={ description={
previewPage === "offerings" selectedTarget
? "右侧「列表展示」字段修改后,会实时反映在当前卡片。" ? `右侧只显示「${selectedTarget.label}」对应的字段,修改会实时反映在左侧预览;点击预览空白处或「查看全部字段」可恢复。`
: "右侧「详情展示」字段修改后,会实时反映在当前详情内容。" : previewPage === "offerings"
? "点击左侧区块后,右侧只显示该区块对应的字段;未点选时显示全部列表展示字段。"
: "点击左侧区块后,右侧只显示该区块对应的字段;未点选时显示全部详情展示字段。"
} }
/> />
<ComponentTemplatePreview <ComponentTemplatePreview
@@ -129,7 +156,25 @@ export function OfferingEditorModal({
onFinish={onFinish} onFinish={onFinish}
> >
<div ref={formScroll} className="service-offering-editor__form-scroll"> <div ref={formScroll} className="service-offering-editor__form-scroll">
<h4 className="admin-subhead">基础信息</h4> {selectedTarget ? (
<div className="service-offering-editor__selection">
<div>
<strong>正在编辑「{selectedTarget.label}」</strong>
<p className="admin-section-description">
只显示这个区块对应的字段,其他字段已临时隐藏。
</p>
</div>
<Button
size="small"
htmlType="button"
onClick={() => onPreviewTargetSelected(undefined)}
>
查看全部字段
</Button>
</div>
) : null}
{hasVisibleBaseFields ? <h4 className="admin-subhead">基础信息</h4> : null}
{isBaseFieldVisible("kind") ? (
<Form.Item name="kind" label="类型" rules={[{ required: true }]}> <Form.Item name="kind" label="类型" rules={[{ required: true }]}>
<Select <Select
options={[ options={[
@@ -140,6 +185,8 @@ export function OfferingEditorModal({
]} ]}
/> />
</Form.Item> </Form.Item>
) : null}
{isBaseFieldVisible("name") ? (
<Form.Item <Form.Item
name="name" name="name"
label="名称" label="名称"
@@ -148,6 +195,8 @@ export function OfferingEditorModal({
> >
<Input /> <Input />
</Form.Item> </Form.Item>
) : null}
{isBaseFieldVisible("summary") ? (
<Form.Item <Form.Item
name="summary" name="summary"
label="一句话说明" label="一句话说明"
@@ -155,7 +204,8 @@ export function OfferingEditorModal({
> >
<Input /> <Input />
</Form.Item> </Form.Item>
{!hasTemplateDetailCopy ? ( ) : null}
{showDescriptionField ? (
<Form.Item <Form.Item
name="description" name="description"
label="详细介绍" label="详细介绍"
@@ -164,6 +214,7 @@ export function OfferingEditorModal({
<Input.TextArea rows={5} /> <Input.TextArea rows={5} />
</Form.Item> </Form.Item>
) : null} ) : null}
{isBaseFieldVisible("priceText") ? (
<Form.Item <Form.Item
name="priceText" name="priceText"
label="价格展示" label="价格展示"
@@ -171,6 +222,8 @@ export function OfferingEditorModal({
> >
<Input placeholder="例如:按现场评估报价 / ¥ 2,800 起" /> <Input placeholder="例如:按现场评估报价 / ¥ 2,800 起" />
</Form.Item> </Form.Item>
) : null}
{isBaseFieldVisible("coverUrl") ? (
<Form.Item <Form.Item
name="coverUrl" name="coverUrl"
label="封面图片地址" label="封面图片地址"
@@ -179,6 +232,8 @@ export function OfferingEditorModal({
> >
<ImageUrlField placeholder="粘贴服务或产品封面图片地址" scope="offering" /> <ImageUrlField placeholder="粘贴服务或产品封面图片地址" scope="offering" />
</Form.Item> </Form.Item>
) : null}
{isBaseFieldVisible("sortOrder") ? (
<Form.Item <Form.Item
name="sortOrder" name="sortOrder"
label="展示顺序" label="展示顺序"
@@ -187,6 +242,8 @@ export function OfferingEditorModal({
> >
<Input type="number" min={0} max={9999} /> <Input type="number" min={0} max={9999} />
</Form.Item> </Form.Item>
) : null}
{isBaseFieldVisible("isEnabled") ? (
<Form.Item name="isEnabled" label="公开状态"> <Form.Item name="isEnabled" label="公开状态">
<Select <Select
options={[ options={[
@@ -195,6 +252,7 @@ export function OfferingEditorModal({
]} ]}
/> />
</Form.Item> </Form.Item>
) : null}
{selectedTarget && selectedTarget.source !== "offering" ? ( {selectedTarget && selectedTarget.source !== "offering" ? (
<Alert <Alert
type="warning" type="warning"
@@ -55,6 +55,22 @@
margin-top: 0; margin-top: 0;
} }
.service-offering-editor__selection {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 12px;
margin-bottom: 16px;
padding: 12px 14px;
border: 1px solid rgba(22, 119, 255, 0.28);
border-radius: 10px;
background-color: rgba(22, 119, 255, 0.06);
}
.service-offering-editor__selection p {
margin: 4px 0 0;
}
.service-offering-editor__form-scroll .ant-form-item { .service-offering-editor__form-scroll .ant-form-item {
margin-bottom: 20px; margin-bottom: 20px;
} }
+13 -3
View File
@@ -195,6 +195,9 @@ test("业务编辑弹窗预览列表与详情详情同一份内容", async ({ pa
"acheng-campus-food.detail.dishDetail", "acheng-campus-food.detail.dishDetail",
); );
await expect(page.getByText("餐品与服务详情对应字段", { exact: true })).toBeVisible(); await expect(page.getByText("餐品与服务详情对应字段", { exact: true })).toBeVisible();
await expect(page.getByText("正在编辑「餐品与服务详情」", { exact: true })).toBeVisible();
await expect(page.getByLabel("名称", { exact: true })).toHaveCount(0);
await expect(page.getByLabel("类型", { exact: true })).toHaveCount(0);
await expect( await expect(
editor.locator('[data-presentation-binding="offering.config.details.background"]'), editor.locator('[data-presentation-binding="offering.config.details.background"]'),
).toHaveClass(/is-preview-active/); ).toHaveClass(/is-preview-active/);
@@ -209,6 +212,9 @@ test("业务编辑弹窗预览列表与详情详情同一份内容", async ({ pa
await preview.locator(".offering-card .dish-name").click(); await preview.locator(".offering-card .dish-name").click();
await expect(page.getByText("业务卡片对应字段", { exact: true })).toBeVisible(); await expect(page.getByText("业务卡片对应字段", { exact: true })).toBeVisible();
await expect(page.getByText("正在编辑「业务卡片」", { exact: true })).toBeVisible();
await expect(page.getByLabel("类型", { exact: true })).toHaveCount(0);
await expect(page.getByLabel("展示顺序", { exact: true })).toHaveCount(0);
await expect(editor.locator('[data-presentation-binding="offering.name"]')).toHaveClass( await expect(editor.locator('[data-presentation-binding="offering.name"]')).toHaveClass(
/is-preview-active/, /is-preview-active/,
); );
@@ -219,10 +225,14 @@ test("业务编辑弹窗预览列表与详情详情同一份内容", async ({ pa
await preview.locator(".menu-head").click(); await preview.locator(".menu-head").click();
await expect(preview).toHaveAttribute("data-active-target", "acheng-campus-food.offerings.menu"); await expect(preview).toHaveAttribute("data-active-target", "acheng-campus-food.offerings.menu");
await expect(page.getByText("「菜单页说明」属于页面通用内容", { exact: true })).toBeVisible(); await expect(page.getByText("「菜单页说明」属于页面通用内容", { exact: true })).toBeVisible();
await expect(editor.locator('[data-presentation-binding="offering.name"]')).not.toHaveClass( await expect(editor.locator('[data-presentation-binding="offering.name"]')).toHaveCount(0);
/is-preview-active/,
);
await expect(editor.getByText("详情主图", { exact: true })).toHaveCount(0); await expect(editor.getByText("详情主图", { exact: true })).toHaveCount(0);
await expect(page.getByLabel("名称", { exact: true })).toHaveCount(0);
await expect(page.getByLabel("类型", { exact: true })).toHaveCount(0);
await page.getByRole("button", { name: "查看全部字段" }).click();
await expect(page.getByLabel("名称", { exact: true })).toBeVisible();
await expect(page.getByLabel("类型", { exact: true })).toBeVisible();
await preview.locator(".offering-card .dish-name").click(); await preview.locator(".offering-card .dish-name").click();
await expect(page.getByText("业务卡片对应字段", { exact: true })).toBeVisible(); await expect(page.getByText("业务卡片对应字段", { exact: true })).toBeVisible();