fix: 业务提供项点选后仅显示当前区块字段
This commit is contained in:
1 parent
cbbf122280
commit
96c3d3292d
4 files changed
+150
-66
No files matched your search
@@ -13,6 +13,14 @@ import type { PreviewSelection, PreviewTarget } from "../brand/preview-selection
|
||||
import type { FormInstance } from "antd";
|
||||
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 = {
|
||||
open: boolean;
|
||||
editingOffering: Offering | null;
|
||||
@@ -66,6 +74,23 @@ export function OfferingEditorModal({
|
||||
? { targetKey: previewSelectionTarget.key, recordId: editingOffering.id }
|
||||
: { targetKey: previewSelectionTarget.key }
|
||||
: 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(() => {
|
||||
@@ -106,9 +131,11 @@ export function OfferingEditorModal({
|
||||
showIcon
|
||||
title={previewPage === "offerings" ? "正在核对列表展示" : "正在核对详情展示"}
|
||||
description={
|
||||
previewPage === "offerings"
|
||||
? "右侧「列表展示」字段修改后,会实时反映在当前卡片。"
|
||||
: "右侧「详情展示」字段修改后,会实时反映在当前详情内容。"
|
||||
selectedTarget
|
||||
? `右侧只显示「${selectedTarget.label}」对应的字段,修改会实时反映在左侧预览;点击预览空白处或「查看全部字段」可恢复。`
|
||||
: previewPage === "offerings"
|
||||
? "点击左侧区块后,右侧只显示该区块对应的字段;未点选时显示全部列表展示字段。"
|
||||
: "点击左侧区块后,右侧只显示该区块对应的字段;未点选时显示全部详情展示字段。"
|
||||
}
|
||||
/>
|
||||
<ComponentTemplatePreview
|
||||
@@ -129,33 +156,56 @@ export function OfferingEditorModal({
|
||||
onFinish={onFinish}
|
||||
>
|
||||
<div ref={formScroll} className="service-offering-editor__form-scroll">
|
||||
<h4 className="admin-subhead">基础信息</h4>
|
||||
<Form.Item name="kind" label="类型" rules={[{ required: true }]}>
|
||||
<Select
|
||||
options={[
|
||||
{ value: "service", label: "服务" },
|
||||
{ value: "product", label: "定制产品" },
|
||||
{ value: "package", label: "套餐" },
|
||||
{ value: "subscription", label: "订阅" },
|
||||
]}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="name"
|
||||
label="名称"
|
||||
data-presentation-binding="offering.name"
|
||||
rules={[{ required: true }]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="summary"
|
||||
label="一句话说明"
|
||||
data-presentation-binding="offering.summary"
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
{!hasTemplateDetailCopy ? (
|
||||
{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 }]}>
|
||||
<Select
|
||||
options={[
|
||||
{ value: "service", label: "服务" },
|
||||
{ value: "product", label: "定制产品" },
|
||||
{ value: "package", label: "套餐" },
|
||||
{ value: "subscription", label: "订阅" },
|
||||
]}
|
||||
/>
|
||||
</Form.Item>
|
||||
) : null}
|
||||
{isBaseFieldVisible("name") ? (
|
||||
<Form.Item
|
||||
name="name"
|
||||
label="名称"
|
||||
data-presentation-binding="offering.name"
|
||||
rules={[{ required: true }]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
) : null}
|
||||
{isBaseFieldVisible("summary") ? (
|
||||
<Form.Item
|
||||
name="summary"
|
||||
label="一句话说明"
|
||||
data-presentation-binding="offering.summary"
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
) : null}
|
||||
{showDescriptionField ? (
|
||||
<Form.Item
|
||||
name="description"
|
||||
label="详细介绍"
|
||||
@@ -164,37 +214,45 @@ export function OfferingEditorModal({
|
||||
<Input.TextArea rows={5} />
|
||||
</Form.Item>
|
||||
) : null}
|
||||
<Form.Item
|
||||
name="priceText"
|
||||
label="价格展示"
|
||||
data-presentation-binding="offering.priceText"
|
||||
>
|
||||
<Input placeholder="例如:按现场评估报价 / ¥ 2,800 起" />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="coverUrl"
|
||||
label="封面图片地址"
|
||||
help="点击上传,或粘贴服务/产品封面图片地址。"
|
||||
data-presentation-binding="offering.coverUrl"
|
||||
>
|
||||
<ImageUrlField placeholder="粘贴服务或产品封面图片地址" scope="offering" />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="sortOrder"
|
||||
label="展示顺序"
|
||||
help="数字越小越靠前,不确定时填写 0。"
|
||||
rules={[{ type: "number", min: 0, max: 9999 }]}
|
||||
>
|
||||
<Input type="number" min={0} max={9999} />
|
||||
</Form.Item>
|
||||
<Form.Item name="isEnabled" label="公开状态">
|
||||
<Select
|
||||
options={[
|
||||
{ value: true, label: "已启用" },
|
||||
{ value: false, label: "已停用" },
|
||||
]}
|
||||
/>
|
||||
</Form.Item>
|
||||
{isBaseFieldVisible("priceText") ? (
|
||||
<Form.Item
|
||||
name="priceText"
|
||||
label="价格展示"
|
||||
data-presentation-binding="offering.priceText"
|
||||
>
|
||||
<Input placeholder="例如:按现场评估报价 / ¥ 2,800 起" />
|
||||
</Form.Item>
|
||||
) : null}
|
||||
{isBaseFieldVisible("coverUrl") ? (
|
||||
<Form.Item
|
||||
name="coverUrl"
|
||||
label="封面图片地址"
|
||||
help="点击上传,或粘贴服务/产品封面图片地址。"
|
||||
data-presentation-binding="offering.coverUrl"
|
||||
>
|
||||
<ImageUrlField placeholder="粘贴服务或产品封面图片地址" scope="offering" />
|
||||
</Form.Item>
|
||||
) : null}
|
||||
{isBaseFieldVisible("sortOrder") ? (
|
||||
<Form.Item
|
||||
name="sortOrder"
|
||||
label="展示顺序"
|
||||
help="数字越小越靠前,不确定时填写 0。"
|
||||
rules={[{ type: "number", min: 0, max: 9999 }]}
|
||||
>
|
||||
<Input type="number" min={0} max={9999} />
|
||||
</Form.Item>
|
||||
) : null}
|
||||
{isBaseFieldVisible("isEnabled") ? (
|
||||
<Form.Item name="isEnabled" label="公开状态">
|
||||
<Select
|
||||
options={[
|
||||
{ value: true, label: "已启用" },
|
||||
{ value: false, label: "已停用" },
|
||||
]}
|
||||
/>
|
||||
</Form.Item>
|
||||
) : null}
|
||||
{selectedTarget && selectedTarget.source !== "offering" ? (
|
||||
<Alert
|
||||
type="warning"
|
||||
|
||||
@@ -55,6 +55,22 @@
|
||||
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 {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user