feat: 业务视图切换联动字段分组
This commit is contained in:
1 parent
46b1690f6c
commit
bfbcee45bb
2 files changed
+87
-50
No files matched your search
@@ -28,11 +28,22 @@
|
||||
|
||||
.service-offering-editor__form {
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: 72vh;
|
||||
overflow-y: auto;
|
||||
padding-right: 4px;
|
||||
}
|
||||
|
||||
.service-offering-editor__form-scroll {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.service-offering-editor__preview .ant-alert {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
@media (max-width: 860px) {
|
||||
.service-offering-editor {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
Alert,
|
||||
Button,
|
||||
Form,
|
||||
Input,
|
||||
@@ -20,6 +21,7 @@ import type {
|
||||
TemplateAdminSection,
|
||||
} from "@personal-brand/api-client";
|
||||
import { useMemo, useState } from "react";
|
||||
import { useEffect, useRef } from "react";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
|
||||
import { ImageUrlField } from "../../components/ImageUrlField.js";
|
||||
@@ -43,6 +45,9 @@ export function ServicesPage() {
|
||||
const [offeringOpen, setOfferingOpen] = useState(false);
|
||||
const [editingOffering, setEditingOffering] = useState<Offering | null>(null);
|
||||
const [previewPage, setPreviewPage] = useState<"offerings" | "detail">("detail");
|
||||
const listFieldsRef = useRef<HTMLDivElement | null>(null);
|
||||
const detailFieldsRef = useRef<HTMLDivElement | null>(null);
|
||||
const formScrollRef = useRef<HTMLDivElement | null>(null);
|
||||
const offerings = useQuery({
|
||||
queryKey: ["admin-offerings"],
|
||||
queryFn: () => client.listAdminOfferings(),
|
||||
@@ -129,6 +134,14 @@ export function ServicesPage() {
|
||||
),
|
||||
[templateFields, listFields, detailFields],
|
||||
);
|
||||
useEffect(() => {
|
||||
const target = previewPage === "offerings" ? listFieldsRef.current : detailFieldsRef.current;
|
||||
if (!target || !formScrollRef.current) return;
|
||||
formScrollRef.current.scrollTo({
|
||||
top: target.offsetTop - formScrollRef.current.offsetTop - 12,
|
||||
behavior: "smooth",
|
||||
});
|
||||
}, [previewPage, editingOffering?.id]);
|
||||
const previewWorkspaceDraft = useMemo<RuntimeWorkspace | undefined>(() => {
|
||||
if (!previewWorkspace.data || !editingOffering) return undefined;
|
||||
const values = offeringForm.getFieldsValue(true) as Record<string, unknown>;
|
||||
@@ -386,6 +399,16 @@ export function ServicesPage() {
|
||||
]}
|
||||
onChange={(value) => setPreviewPage(value as "offerings" | "detail")}
|
||||
/>
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
message={previewPage === "offerings" ? "正在核对列表展示" : "正在核对详情展示"}
|
||||
description={
|
||||
previewPage === "offerings"
|
||||
? "右侧「列表展示」字段修改后,会实时反映在当前卡片。"
|
||||
: "右侧「详情展示」字段修改后,会实时反映在当前详情内容。"
|
||||
}
|
||||
/>
|
||||
<ComponentTemplatePreview
|
||||
workspace={previewWorkspaceDraft}
|
||||
page={previewPage}
|
||||
@@ -407,60 +430,63 @@ export function ServicesPage() {
|
||||
layout="vertical"
|
||||
onFinish={(values) => saveOffering.mutate(values as Record<string, unknown>)}
|
||||
>
|
||||
<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="名称" rules={[{ required: true }]}>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item name="summary" label="一句话说明">
|
||||
<Input />
|
||||
</Form.Item>
|
||||
{!hasTemplateDetailCopy ? (
|
||||
<Form.Item name="description" label="详细介绍">
|
||||
<Input.TextArea rows={5} />
|
||||
<div ref={formScrollRef} className="service-offering-editor__form-scroll">
|
||||
<Typography.Title level={5}>基础信息</Typography.Title>
|
||||
<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}
|
||||
<Form.Item name="priceText" label="价格展示">
|
||||
<Input placeholder="例如:按现场评估报价 / ¥ 2,800 起" />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="coverUrl"
|
||||
label="封面图片地址"
|
||||
help="填写图片地址;图片上传能力将在后续媒体管理中提供。"
|
||||
>
|
||||
<ImageUrlField placeholder="粘贴服务或产品封面图片地址" />
|
||||
</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>
|
||||
<Form.Item name="name" label="名称" rules={[{ required: true }]}>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
<Form.Item name="summary" label="一句话说明">
|
||||
<Input />
|
||||
</Form.Item>
|
||||
{!hasTemplateDetailCopy ? (
|
||||
<Form.Item name="description" label="详细介绍">
|
||||
<Input.TextArea rows={5} />
|
||||
</Form.Item>
|
||||
) : null}
|
||||
<Form.Item name="priceText" label="价格展示">
|
||||
<Input placeholder="例如:按现场评估报价 / ¥ 2,800 起" />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="coverUrl"
|
||||
label="封面图片地址"
|
||||
help="填写图片地址;图片上传能力将在后续媒体管理中提供。"
|
||||
>
|
||||
<ImageUrlField placeholder="粘贴服务或产品封面图片地址" />
|
||||
</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>
|
||||
</div>
|
||||
{templateFields.length ? (
|
||||
<>
|
||||
<Typography.Paragraph type="secondary">
|
||||
以下模板字段与左侧预览及小程序页面编辑的是同一份业务数据。
|
||||
</Typography.Paragraph>
|
||||
{listFields.length ? (
|
||||
<>
|
||||
<div ref={listFieldsRef}>
|
||||
<Typography.Title level={5}>列表展示</Typography.Title>
|
||||
<RecordContentFields
|
||||
section={{
|
||||
@@ -468,10 +494,10 @@ export function ServicesPage() {
|
||||
fields: listFields,
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
</div>
|
||||
) : null}
|
||||
{detailFields.length ? (
|
||||
<>
|
||||
<div ref={detailFieldsRef}>
|
||||
<Typography.Title level={5}>详情展示</Typography.Title>
|
||||
<RecordContentFields
|
||||
section={{
|
||||
@@ -479,7 +505,7 @@ export function ServicesPage() {
|
||||
fields: detailFields,
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
</div>
|
||||
) : null}
|
||||
{otherFields.length ? (
|
||||
<>
|
||||
|
||||
Reference in new issue
Block a user