feat: 收口多品牌与模板构建基础
This commit is contained in:
1 parent
0425a1c672
commit
77224ea51f
317 files changed
+11290
-1158
No files matched your search
@@ -4,6 +4,7 @@ import {
|
||||
Form,
|
||||
Input,
|
||||
Modal,
|
||||
Popconfirm,
|
||||
Select,
|
||||
Space,
|
||||
Table,
|
||||
@@ -16,6 +17,7 @@ import type { Offering } from "@personal-brand/api-client";
|
||||
import { useState } from "react";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
|
||||
import { ImageUrlField } from "../../components/ImageUrlField.js";
|
||||
import { MutationError, QueryState } from "../../components/QueryState.js";
|
||||
|
||||
export function ServicesPage() {
|
||||
@@ -56,16 +58,19 @@ export function ServicesPage() {
|
||||
const beginOffering = (item?: Offering) => {
|
||||
setEditingOffering(item ?? null);
|
||||
setOfferingOpen(true);
|
||||
const config = item?.config ?? {};
|
||||
offeringForm.setFieldsValue(
|
||||
item
|
||||
? {
|
||||
...item,
|
||||
sections: config.sections ?? [],
|
||||
media: config.media ?? [],
|
||||
cta: config.cta ?? {},
|
||||
kind: item.kind,
|
||||
name: item.name,
|
||||
summary: item.summary ?? "",
|
||||
description: item.description ?? "",
|
||||
priceText: item.priceText ?? "",
|
||||
coverUrl: item.coverUrl ?? "",
|
||||
sortOrder: item.sortOrder,
|
||||
isEnabled: item.isEnabled,
|
||||
}
|
||||
: { kind: "service", isEnabled: true, sortOrder: 0, sections: [], media: [], cta: {} },
|
||||
: { kind: "service", isEnabled: true, sortOrder: 0 },
|
||||
);
|
||||
};
|
||||
return (
|
||||
@@ -129,9 +134,17 @@ export function ServicesPage() {
|
||||
>
|
||||
{item.isEnabled ? "禁用" : "启用"}
|
||||
</Button>
|
||||
<Button danger size="small" onClick={() => deleteOffering.mutate(item.id)}>
|
||||
删除
|
||||
</Button>
|
||||
<Popconfirm
|
||||
title="确认删除这项业务提供项?"
|
||||
description="如果它已经关联咨询表单,系统会阻止删除。"
|
||||
onConfirm={() => deleteOffering.mutate(item.id)}
|
||||
okText="删除"
|
||||
cancelText="取消"
|
||||
>
|
||||
<Button danger size="small" loading={deleteOffering.isPending}>
|
||||
删除
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
@@ -180,85 +193,22 @@ export function ServicesPage() {
|
||||
<Input.TextArea rows={5} />
|
||||
</Form.Item>
|
||||
<Form.Item name="priceText" label="价格展示">
|
||||
<Input />
|
||||
<Input placeholder="例如:按现场评估报价 / ¥ 2,800 起" />
|
||||
</Form.Item>
|
||||
<Form.Item name="coverUrl" label="封面图片 URL">
|
||||
<Input />
|
||||
<Form.Item
|
||||
name="coverUrl"
|
||||
label="封面图片地址"
|
||||
help="填写图片地址;图片上传能力将在后续媒体管理中提供。"
|
||||
>
|
||||
<ImageUrlField placeholder="粘贴服务或产品封面图片地址" />
|
||||
</Form.Item>
|
||||
<Form.List name="sections">
|
||||
{(fields, { add, remove }) => (
|
||||
<>
|
||||
<Form.Item label="内容分区">
|
||||
<Button onClick={() => add({ type: "text" })}>新增分区</Button>
|
||||
</Form.Item>
|
||||
{fields.map(({ key, name, ...restField }) => (
|
||||
<Space key={key} align="start" style={{ display: "flex", marginBottom: 8 }}>
|
||||
<Form.Item {...restField} name={[name, "type"]}>
|
||||
<Select
|
||||
style={{ width: 120 }}
|
||||
options={[
|
||||
{ value: "text", label: "文本" },
|
||||
{ value: "image-list", label: "图片列表" },
|
||||
{ value: "timeline", label: "时间线" },
|
||||
{ value: "faq", label: "常见问题" },
|
||||
]}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item {...restField} name={[name, "title"]}>
|
||||
<Input placeholder="分区标题" />
|
||||
</Form.Item>
|
||||
<Form.Item {...restField} name={[name, "content"]}>
|
||||
<Input placeholder="分区内容" />
|
||||
</Form.Item>
|
||||
<Button danger onClick={() => remove(name)}>
|
||||
删除
|
||||
</Button>
|
||||
</Space>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
</Form.List>
|
||||
<Form.List name="media">
|
||||
{(fields, { add, remove }) => (
|
||||
<>
|
||||
<Form.Item label="媒体列表">
|
||||
<Button onClick={() => add({ type: "image" })}>新增媒体</Button>
|
||||
</Form.Item>
|
||||
{fields.map(({ key, name, ...restField }) => (
|
||||
<Space key={key} align="start" style={{ display: "flex", marginBottom: 8 }}>
|
||||
<Form.Item {...restField} name={[name, "url"]}>
|
||||
<Input placeholder="图片 URL" />
|
||||
</Form.Item>
|
||||
<Form.Item {...restField} name={[name, "alt"]}>
|
||||
<Input placeholder="替代文本" />
|
||||
</Form.Item>
|
||||
<Button danger onClick={() => remove(name)}>
|
||||
删除
|
||||
</Button>
|
||||
</Space>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
</Form.List>
|
||||
<Form.Item label="行动按钮">
|
||||
<Space>
|
||||
<Form.Item name={["cta", "type"]} noStyle>
|
||||
<Select
|
||||
style={{ width: 150 }}
|
||||
allowClear
|
||||
placeholder="按钮行为"
|
||||
options={[
|
||||
{ value: "inquiry", label: "提交咨询" },
|
||||
{ value: "booking", label: "预约服务" },
|
||||
{ value: "contact", label: "联系品牌" },
|
||||
{ value: "external-link", label: "外部链接" },
|
||||
]}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item name={["cta", "label"]} noStyle>
|
||||
<Input placeholder="按钮文案" />
|
||||
</Form.Item>
|
||||
</Space>
|
||||
<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
|
||||
|
||||
Reference in new issue
Block a user