feat: 统一 Admin 后台设计语言
用中性灰底 + 单一强调色重做后台视觉,并集中到一套令牌: - 新增 apps/admin/src/lib/theme.ts,通过 ConfigProvider 注入主题令牌 - 新增 apps/admin/src/styles/admin.css 与 AdminSection、MetricCard、StatusTag 组件 - 侧栏改白底浅色并补图标,顶栏改 56px 白底,内容区最大宽 1200px - 全部页面接入状态标签,antd 原生彩色 Tag 与内联色值清零 - 登录与改密页、加载态骨架屏、错误提示条统一 - brand 页两个 Tab 统一为白卡片容器,消除双标题与宽度不一致 设计规范见 apps/admin/design.md。
This commit is contained in:
1 parent
bb94d80e13
commit
2f26828f09
34 files changed
+2159
-922
No files matched your search
@@ -1,20 +1,13 @@
|
||||
import {
|
||||
Badge,
|
||||
Button,
|
||||
Card,
|
||||
Descriptions,
|
||||
Drawer,
|
||||
Select,
|
||||
Space,
|
||||
Table,
|
||||
Tag,
|
||||
message,
|
||||
Input,
|
||||
} from "antd";
|
||||
import { Badge, Button, Descriptions, Drawer, Select, Space, Table, message, Input } from "antd";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import type { AdminBooking, InquirySubmission } from "@personal-brand/api-client";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
import { useState } from "react";
|
||||
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
|
||||
import { AdminSection } from "../../components/AdminSection.js";
|
||||
import { ErrorNote } from "../../components/QueryState.js";
|
||||
import { StatusTag } from "../../components/StatusTag.js";
|
||||
import type { StatusTone } from "../../components/StatusTag.js";
|
||||
|
||||
const statuses = ["received", "contacting", "confirmed", "completed", "cancelled"] as const;
|
||||
const labels: Record<string, string> = {
|
||||
@@ -41,6 +34,20 @@ const inquiryLabels: Record<string, string> = {
|
||||
closed: "已关闭",
|
||||
};
|
||||
|
||||
const statusTones: Record<string, StatusTone> = {
|
||||
received: "info",
|
||||
new: "info",
|
||||
contacting: "warning",
|
||||
reviewing: "warning",
|
||||
confirmed: "success",
|
||||
replied: "success",
|
||||
qualified: "success",
|
||||
converted: "success",
|
||||
completed: "success",
|
||||
cancelled: "error",
|
||||
closed: "neutral",
|
||||
};
|
||||
|
||||
export function InquiriesPage() {
|
||||
const client = createApiClient();
|
||||
const queryClient = useQueryClient();
|
||||
@@ -94,117 +101,119 @@ export function InquiriesPage() {
|
||||
onError: (error) => message.error(error instanceof Error ? error.message : "更新失败,请重试"),
|
||||
});
|
||||
return (
|
||||
<Card
|
||||
title="咨询记录"
|
||||
extra={
|
||||
<Space>
|
||||
<Select
|
||||
allowClear
|
||||
placeholder="全部状态"
|
||||
style={{ width: 130 }}
|
||||
value={status}
|
||||
onChange={setStatus}
|
||||
options={statuses.map((value) => ({ value, label: labels[value] }))}
|
||||
/>
|
||||
<Badge
|
||||
count={
|
||||
query.data?.filter((item) => !(item as AdminBooking & { isRead?: boolean }).isRead)
|
||||
.length ?? 0
|
||||
}
|
||||
showZero
|
||||
/>
|
||||
</Space>
|
||||
}
|
||||
>
|
||||
<Table
|
||||
rowKey="id"
|
||||
loading={query.isLoading}
|
||||
dataSource={query.data ?? []}
|
||||
columns={[
|
||||
{
|
||||
title: "编号",
|
||||
dataIndex: "bookingNo",
|
||||
render: (value: string, item: AdminBooking) => (
|
||||
<Button type="link" onClick={() => setSelectedId(item.id)}>
|
||||
{value}
|
||||
</Button>
|
||||
),
|
||||
},
|
||||
{ title: "联系人", dataIndex: "customerName" },
|
||||
{
|
||||
title: "提交时间",
|
||||
dataIndex: "createdAt",
|
||||
render: (value: string) => new Date(value).toLocaleString("zh-CN"),
|
||||
},
|
||||
{
|
||||
title: "状态",
|
||||
dataIndex: "status",
|
||||
render: (value: string) => <Tag>{labels[value] ?? value}</Tag>,
|
||||
},
|
||||
{
|
||||
title: "操作",
|
||||
render: (_: unknown, item: AdminBooking) => (
|
||||
<Space>
|
||||
<Select
|
||||
size="small"
|
||||
value={item.status}
|
||||
onChange={(value) => update.mutate({ id: item.id, value: value as never })}
|
||||
options={statuses.map((value) => ({ value, label: labels[value] }))}
|
||||
/>
|
||||
<Button size="small" onClick={() => read.mutate(item.id)}>
|
||||
标记已读
|
||||
</Button>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<Drawer
|
||||
title="咨询详情"
|
||||
open={Boolean(selectedId)}
|
||||
onClose={() => setSelectedId(undefined)}
|
||||
loading={detail.isLoading}
|
||||
width={520}
|
||||
<>
|
||||
<AdminPageHeader title="咨询记录" description="查看访客提交的咨询和预约,并跟进处理进度。" />
|
||||
<AdminSection
|
||||
title="预约咨询"
|
||||
extra={
|
||||
<Space>
|
||||
<Select
|
||||
allowClear
|
||||
placeholder="全部状态"
|
||||
className="admin-field-w-md"
|
||||
value={status}
|
||||
onChange={setStatus}
|
||||
options={statuses.map((value) => ({ value, label: labels[value] }))}
|
||||
/>
|
||||
<Badge
|
||||
count={
|
||||
query.data?.filter((item) => !(item as AdminBooking & { isRead?: boolean }).isRead)
|
||||
.length ?? 0
|
||||
}
|
||||
showZero
|
||||
/>
|
||||
</Space>
|
||||
}
|
||||
>
|
||||
{detail.data && (
|
||||
<Descriptions column={1} bordered size="small">
|
||||
<Descriptions.Item label="编号">{detail.data.bookingNo}</Descriptions.Item>
|
||||
<Descriptions.Item label="联系人">{detail.data.customerName}</Descriptions.Item>
|
||||
<Descriptions.Item label="状态">
|
||||
{labels[detail.data.status] ?? detail.data.status}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="提交时间">
|
||||
{new Date(detail.data.createdAt).toLocaleString("zh-CN")}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="管理员备注">
|
||||
{detail.data.adminNote || "暂无"}
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
)}
|
||||
</Drawer>
|
||||
<Card
|
||||
<Table
|
||||
rowKey="id"
|
||||
loading={query.isLoading}
|
||||
locale={{ emptyText: "还没有预约咨询。" }}
|
||||
dataSource={query.data ?? []}
|
||||
columns={[
|
||||
{
|
||||
title: "编号",
|
||||
dataIndex: "bookingNo",
|
||||
render: (value: string, item: AdminBooking) => (
|
||||
<Button type="link" onClick={() => setSelectedId(item.id)}>
|
||||
{value}
|
||||
</Button>
|
||||
),
|
||||
},
|
||||
{ title: "联系人", dataIndex: "customerName" },
|
||||
{
|
||||
title: "提交时间",
|
||||
dataIndex: "createdAt",
|
||||
render: (value: string) => new Date(value).toLocaleString("zh-CN"),
|
||||
},
|
||||
{
|
||||
title: "状态",
|
||||
dataIndex: "status",
|
||||
render: (value: string) => (
|
||||
<StatusTag tone={statusTones[value] ?? "neutral"} label={labels[value] ?? value} />
|
||||
),
|
||||
},
|
||||
{
|
||||
title: "操作",
|
||||
render: (_: unknown, item: AdminBooking) => (
|
||||
<Space>
|
||||
<Select
|
||||
size="small"
|
||||
value={item.status}
|
||||
onChange={(value) => update.mutate({ id: item.id, value: value as never })}
|
||||
options={statuses.map((value) => ({ value, label: labels[value] }))}
|
||||
/>
|
||||
<Button type="link" size="small" onClick={() => read.mutate(item.id)}>
|
||||
标记已读
|
||||
</Button>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<Drawer
|
||||
title="咨询详情"
|
||||
open={Boolean(selectedId)}
|
||||
onClose={() => setSelectedId(undefined)}
|
||||
loading={detail.isLoading}
|
||||
width={520}
|
||||
>
|
||||
{detail.data && (
|
||||
<Descriptions column={1} bordered size="small">
|
||||
<Descriptions.Item label="编号">{detail.data.bookingNo}</Descriptions.Item>
|
||||
<Descriptions.Item label="联系人">{detail.data.customerName}</Descriptions.Item>
|
||||
<Descriptions.Item label="状态">
|
||||
{labels[detail.data.status] ?? detail.data.status}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="提交时间">
|
||||
{new Date(detail.data.createdAt).toLocaleString("zh-CN")}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="管理员备注">
|
||||
{detail.data.adminNote || "暂无"}
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
)}
|
||||
</Drawer>
|
||||
</AdminSection>
|
||||
<AdminSection
|
||||
title={`动态咨询提交${submissions.data ? `(${submissions.data.length})` : ""}`}
|
||||
style={{ marginTop: 24 }}
|
||||
description="按模板表单提交的咨询记录,字段随表单配置变化。"
|
||||
extra={
|
||||
<Button onClick={() => void submissions.refetch()} loading={submissions.isFetching}>
|
||||
刷新提交记录
|
||||
</Button>
|
||||
}
|
||||
>
|
||||
{submissions.isError && (
|
||||
<Card type="inner" style={{ marginBottom: 16 }}>
|
||||
动态咨询提交加载失败:
|
||||
{submissions.error instanceof Error ? submissions.error.message : "未知错误"}
|
||||
<Button type="link" onClick={() => void submissions.refetch()}>
|
||||
重试
|
||||
</Button>
|
||||
</Card>
|
||||
)}
|
||||
<Space style={{ marginBottom: 12 }}>
|
||||
{submissions.isError ? (
|
||||
<ErrorNote error={submissions.error} onRetry={() => void submissions.refetch()} />
|
||||
) : null}
|
||||
<Space
|
||||
className={`admin-offset-bottom-sm ${submissions.isError ? "admin-offset-top" : ""}`}
|
||||
>
|
||||
<Select
|
||||
allowClear
|
||||
placeholder="动态咨询状态"
|
||||
style={{ width: 140 }}
|
||||
className="admin-field-w-md"
|
||||
value={submissionStatus}
|
||||
onChange={setSubmissionStatus}
|
||||
options={inquiryStatuses.map((value) => ({ value, label: inquiryLabels[value] }))}
|
||||
@@ -228,7 +237,10 @@ export function InquiriesPage() {
|
||||
title: "状态",
|
||||
dataIndex: "status",
|
||||
render: (value: InquirySubmission["status"]) => (
|
||||
<Tag>{inquiryLabels[value] ?? value}</Tag>
|
||||
<StatusTag
|
||||
tone={statusTones[value] ?? "neutral"}
|
||||
label={inquiryLabels[value] ?? value}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{ title: "版本", dataIndex: "formVersion", render: (value) => `v${value}` },
|
||||
@@ -251,7 +263,7 @@ export function InquiriesPage() {
|
||||
title: "跟进",
|
||||
render: (_: unknown, item: InquirySubmission) => (
|
||||
<Space>
|
||||
<Button size="small" onClick={() => setSelectedSubmission(item)}>
|
||||
<Button type="link" size="small" onClick={() => setSelectedSubmission(item)}>
|
||||
查看
|
||||
</Button>
|
||||
<Select
|
||||
@@ -314,7 +326,7 @@ export function InquiriesPage() {
|
||||
</Descriptions>
|
||||
)}
|
||||
</Drawer>
|
||||
</Card>
|
||||
</Card>
|
||||
</AdminSection>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user