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,
|
||||
Tag,
|
||||
message,
|
||||
Input,
|
||||
} from "antd";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import type { AdminBooking, InquirySubmission } from "@personal-brand/api-client";
|
||||
@@ -23,6 +24,22 @@ const labels: Record<string, string> = {
|
||||
completed: "已完成",
|
||||
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() {
|
||||
const client = createApiClient();
|
||||
@@ -54,6 +71,25 @@ export function InquiriesPage() {
|
||||
queryKey: ["admin-inquiry-submissions"],
|
||||
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 (
|
||||
<Card
|
||||
title="咨询记录"
|
||||
@@ -164,6 +200,16 @@ export function InquiriesPage() {
|
||||
dataSource={submissions.data ?? []}
|
||||
columns={[
|
||||
{ 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: "提交时间",
|
||||
@@ -175,6 +221,34 @@ export function InquiriesPage() {
|
||||
dataIndex: "values",
|
||||
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>
|
||||
|
||||
Reference in new issue
Block a user