feat: 后台支持咨询跟进状态管理
This commit is contained in:
1 parent
d981f63f65
commit
754da72245
2 files changed
+86
No files matched your search
@@ -9,6 +9,7 @@ import {
|
|||||||
Table,
|
Table,
|
||||||
Tag,
|
Tag,
|
||||||
message,
|
message,
|
||||||
|
Input,
|
||||||
} from "antd";
|
} from "antd";
|
||||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
import type { AdminBooking, InquirySubmission } from "@personal-brand/api-client";
|
import type { AdminBooking, InquirySubmission } from "@personal-brand/api-client";
|
||||||
@@ -23,6 +24,22 @@ const labels: Record<string, string> = {
|
|||||||
completed: "已完成",
|
completed: "已完成",
|
||||||
cancelled: "已取消",
|
cancelled: "已取消",
|
||||||
};
|
};
|
||||||
|
const inquiryStatuses = [
|
||||||
|
"new",
|
||||||
|
"reviewing",
|
||||||
|
"replied",
|
||||||
|
"qualified",
|
||||||
|
"converted",
|
||||||
|
"closed",
|
||||||
|
] as const;
|
||||||
|
const inquiryLabels: Record<string, string> = {
|
||||||
|
new: "新提交",
|
||||||
|
reviewing: "评估中",
|
||||||
|
replied: "已回复",
|
||||||
|
qualified: "已确认需求",
|
||||||
|
converted: "已转化",
|
||||||
|
closed: "已关闭",
|
||||||
|
};
|
||||||
|
|
||||||
export function InquiriesPage() {
|
export function InquiriesPage() {
|
||||||
const client = createApiClient();
|
const client = createApiClient();
|
||||||
@@ -54,6 +71,25 @@ export function InquiriesPage() {
|
|||||||
queryKey: ["admin-inquiry-submissions"],
|
queryKey: ["admin-inquiry-submissions"],
|
||||||
queryFn: () => client.listAdminInquirySubmissions(),
|
queryFn: () => client.listAdminInquirySubmissions(),
|
||||||
});
|
});
|
||||||
|
const updateSubmission = useMutation({
|
||||||
|
mutationFn: ({
|
||||||
|
id,
|
||||||
|
status,
|
||||||
|
adminNote,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
status: InquirySubmission["status"];
|
||||||
|
adminNote?: string;
|
||||||
|
}) =>
|
||||||
|
client.updateAdminInquirySubmission(id, {
|
||||||
|
status,
|
||||||
|
...(adminNote === undefined ? {} : { adminNote }),
|
||||||
|
}),
|
||||||
|
onSuccess: () => {
|
||||||
|
message.success("咨询跟进已更新");
|
||||||
|
void queryClient.invalidateQueries({ queryKey: ["admin-inquiry-submissions"] });
|
||||||
|
},
|
||||||
|
});
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
title="咨询记录"
|
title="咨询记录"
|
||||||
@@ -164,6 +200,16 @@ export function InquiriesPage() {
|
|||||||
dataSource={submissions.data ?? []}
|
dataSource={submissions.data ?? []}
|
||||||
columns={[
|
columns={[
|
||||||
{ title: "表单", dataIndex: ["inquiryForm", "name"] },
|
{ title: "表单", dataIndex: ["inquiryForm", "name"] },
|
||||||
|
{
|
||||||
|
title: "来源业务",
|
||||||
|
dataIndex: ["offering", "name"],
|
||||||
|
render: (value) => value || "品牌咨询",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "状态",
|
||||||
|
dataIndex: "status",
|
||||||
|
render: (value) => <Tag>{inquiryLabels[value] ?? value}</Tag>,
|
||||||
|
},
|
||||||
{ title: "版本", dataIndex: "formVersion", render: (value) => `v${value}` },
|
{ title: "版本", dataIndex: "formVersion", render: (value) => `v${value}` },
|
||||||
{
|
{
|
||||||
title: "提交时间",
|
title: "提交时间",
|
||||||
@@ -175,6 +221,34 @@ export function InquiriesPage() {
|
|||||||
dataIndex: "values",
|
dataIndex: "values",
|
||||||
render: (value: Record<string, unknown>) => JSON.stringify(value),
|
render: (value: Record<string, unknown>) => JSON.stringify(value),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: "跟进",
|
||||||
|
render: (_: unknown, item: InquirySubmission) => (
|
||||||
|
<Space>
|
||||||
|
<Select
|
||||||
|
size="small"
|
||||||
|
value={item.status}
|
||||||
|
options={inquiryStatuses.map((value) => ({
|
||||||
|
value,
|
||||||
|
label: inquiryLabels[value],
|
||||||
|
}))}
|
||||||
|
onChange={(value) => updateSubmission.mutate({ id: item.id, status: value })}
|
||||||
|
/>
|
||||||
|
<Input
|
||||||
|
size="small"
|
||||||
|
placeholder="备注"
|
||||||
|
defaultValue={item.adminNote ?? ""}
|
||||||
|
onPressEnter={(event) =>
|
||||||
|
updateSubmission.mutate({
|
||||||
|
id: item.id,
|
||||||
|
status: item.status,
|
||||||
|
adminNote: event.currentTarget.value,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</Space>
|
||||||
|
),
|
||||||
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
@@ -185,7 +185,10 @@ export interface InquirySubmission {
|
|||||||
values: Record<string, unknown>;
|
values: Record<string, unknown>;
|
||||||
activeFields: Record<string, boolean>;
|
activeFields: Record<string, boolean>;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
|
status: "new" | "reviewing" | "replied" | "qualified" | "converted" | "closed";
|
||||||
|
adminNote?: string | null;
|
||||||
inquiryForm?: { name: string };
|
inquiryForm?: { name: string };
|
||||||
|
offering?: { id: string; name: string } | null;
|
||||||
}
|
}
|
||||||
export interface PublicWorkspace {
|
export interface PublicWorkspace {
|
||||||
contractVersion: string;
|
contractVersion: string;
|
||||||
@@ -403,6 +406,15 @@ export class ApiClient {
|
|||||||
listAdminInquirySubmissions(): Promise<InquirySubmission[]> {
|
listAdminInquirySubmissions(): Promise<InquirySubmission[]> {
|
||||||
return this.request("/admin/workspace/submissions");
|
return this.request("/admin/workspace/submissions");
|
||||||
}
|
}
|
||||||
|
updateAdminInquirySubmission(
|
||||||
|
id: string,
|
||||||
|
body: { status: InquirySubmission["status"]; adminNote?: string },
|
||||||
|
): Promise<InquirySubmission> {
|
||||||
|
return this.request(`/admin/workspace/submissions/${encodeURIComponent(id)}`, {
|
||||||
|
method: "PATCH",
|
||||||
|
body,
|
||||||
|
});
|
||||||
|
}
|
||||||
createAdminInquiryForm(body: {
|
createAdminInquiryForm(body: {
|
||||||
name: string;
|
name: string;
|
||||||
offeringId?: string;
|
offeringId?: string;
|
||||||
|
|||||||
Reference in new issue
Block a user