新增跟進提醒相關API接口及聊天窗口功能:在API中添加跟進提醒列表、添加和處理功能,並在聊天窗口中整合好友ID以支持提醒功能,提升用戶互動體驗。

This commit is contained in:
超级老白兔
2025-09-26 16:31:32 +08:00
parent 7699397bda
commit 5ea49ef6f1
3 changed files with 154 additions and 50 deletions

View File

@@ -321,3 +321,34 @@ export const forwardMessage = (
export const recallMessage = (messageId: string): Promise<void> => {
return request2(`/v1/messages/${messageId}/recall`, {}, "PUT");
};
// ============== 跟进提醒相关接口 ==============
// 跟进提醒列表
export const getFollowUpList = (params: {
isProcess?: string;
isRemind?: string;
keyword?: string;
level?: string;
limit?: string;
page?: string;
friendId?: string;
}) => {
return request("/v1/kefu/followUp/list", params, "GET");
};
// 跟进提醒添加
export const addFollowUp = (params: {
description?: string;
friendId: string;
reminderTime?: string;
title?: string;
type?: string; // 0其他 1电话回访 2发送消息 3安排会议 4发送邮件
}) => {
return request("/v1/kefu/followUp/add", params, "POST");
};
// 跟进提醒处理
export const processFollowUp = (params: { ids?: string }) => {
return request("/v1/kefu/followUp/process", params, "GET");
};

View File

@@ -1,4 +1,4 @@
import React, { useState } from "react";
import React, { useState, useEffect, useCallback } from "react";
import {
Modal,
Form,
@@ -10,6 +10,7 @@ import {
Tag,
Space,
Typography,
message,
} from "antd";
import {
PlusOutlined,
@@ -17,93 +18,153 @@ import {
PhoneOutlined,
MessageOutlined,
} from "@ant-design/icons";
import {
getFollowUpList,
addFollowUp,
processFollowUp,
} from "@/pages/pc/ckbox/weChat/api";
import styles from "./index.module.scss";
const { Option } = Select;
const { TextArea } = Input;
const { Text } = Typography;
// 类型映射
const typeMap: { [key: string]: string } = {
"1": "电话",
"2": "消息",
"3": "会议",
"4": "邮件",
"0": "其他",
};
interface FollowupReminder {
id: string;
type: "电话" | "消息";
type: "电话" | "消息" | "其他" | "会议" | "邮件";
status: "待处理" | "已完成" | "已取消";
content: string;
scheduledTime: string;
recipient: string;
title?: string;
description?: string;
friendId?: string;
}
interface FollowupReminderModalProps {
visible: boolean;
onClose: () => void;
recipientName?: string;
friendId?: string;
}
const FollowupReminderModal: React.FC<FollowupReminderModalProps> = ({
visible,
onClose,
recipientName = "客户",
friendId,
}) => {
const [form] = Form.useForm();
const [reminders, setReminders] = useState<FollowupReminder[]>([
{
id: "1",
type: "电话",
status: "待处理",
content: "周三14点回访",
scheduledTime: "2024/3/6 14:00:00",
recipient: "李先生",
},
{
id: "2",
type: "消息",
status: "待处理",
content: "发送产品演示视频",
scheduledTime: "2024/3/7 09:00:00",
recipient: "张总",
},
{
id: "3",
type: "消息",
status: "待处理",
content: "发送产品演示视频",
scheduledTime: "2024/3/7 09:00:00",
recipient: "张总",
},
{
id: "4",
type: "消息",
status: "待处理",
content: "发送产品演示视频",
scheduledTime: "2024/3/7 09:00:00",
recipient: "张总",
},
]);
const [reminders, setReminders] = useState<FollowupReminder[]>([]);
const [loading, setLoading] = useState(false);
const [addLoading, setAddLoading] = useState(false);
// 跟进方式选项
const followupMethods = [
{ value: "电话回访", label: "电话回访" },
{ value: "微信消息", label: "微信消息" },
{ value: "邮件", label: "邮件" },
{ value: "短信", label: "短信" },
{ value: "1", label: "电话回访" },
{ value: "2", label: "发送消息" },
{ value: "3", label: "安排会议" },
{ value: "4", label: "发送邮件" },
{ value: "0", label: "其他" },
];
// 加载跟进提醒列表
const loadFollowUpList = useCallback(async () => {
if (!friendId) return;
setLoading(true);
try {
const response = await getFollowUpList({
friendId,
limit: "50",
page: "1",
});
if (response && response.list) {
const formattedReminders = response.list.map((item: any) => ({
id: item.id?.toString() || "",
type: typeMap[item.type] || "其他",
status: item.isProcess === 1 ? "已完成" : "待处理",
content: item.description || item.title || "",
scheduledTime: item.reminderTime || "",
recipient: recipientName,
title: item.title,
description: item.description,
friendId: item.friendId,
}));
setReminders(formattedReminders);
}
} catch (error) {
console.error("加载跟进提醒列表失败:", error);
message.error("加载跟进提醒列表失败");
} finally {
setLoading(false);
}
}, [friendId, recipientName]);
// 当模态框打开时加载数据
useEffect(() => {
if (visible && friendId) {
loadFollowUpList();
}
}, [visible, friendId, loadFollowUpList]);
// 处理添加提醒
const handleAddReminder = async () => {
if (!friendId) {
message.error("缺少好友ID无法添加提醒");
return;
}
setAddLoading(true);
try {
const values = await form.validateFields();
const newReminder: FollowupReminder = {
id: Date.now().toString(),
type: values.method === "电话回访" ? "电话" : "消息",
status: "待处理",
content: values.content,
scheduledTime: values.dateTime.format("YYYY/M/D HH:mm:ss"),
recipient: recipientName,
const params = {
friendId,
type: values.method,
title: values.content,
description: values.content,
reminderTime: values.dateTime.format("YYYY-MM-DD HH:mm:ss"),
};
setReminders([...reminders, newReminder]);
form.resetFields();
const response = await addFollowUp(params);
if (response) {
message.success("添加跟进提醒成功");
form.resetFields();
// 重新加载列表
loadFollowUpList();
}
} catch (error) {
console.error("表单验证失败:", error);
console.error("添加跟进提醒失败:", error);
message.error("添加跟进提醒失败");
} finally {
setAddLoading(false);
}
};
// 处理跟进提醒
const handleProcessReminder = async (id: string) => {
try {
const response = await processFollowUp({ ids: id });
if (response) {
message.success("处理成功");
// 重新加载列表
loadFollowUpList();
}
} catch (error) {
console.error("处理跟进提醒失败:", error);
message.error("处理跟进提醒失败");
}
};
@@ -192,6 +253,7 @@ const FollowupReminderModal: React.FC<FollowupReminderModalProps> = ({
icon={<PlusOutlined />}
onClick={handleAddReminder}
className={styles.addButton}
loading={addLoading}
block
>
@@ -203,6 +265,7 @@ const FollowupReminderModal: React.FC<FollowupReminderModalProps> = ({
<div className={styles.remindersList}>
<List
dataSource={reminders}
loading={loading}
renderItem={reminder => (
<List.Item className={styles.reminderItem}>
<div className={styles.reminderContent}>
@@ -236,6 +299,15 @@ const FollowupReminderModal: React.FC<FollowupReminderModalProps> = ({
<Text className={styles.scheduledTime}>
{reminder.scheduledTime}
</Text>
{reminder.status === "待处理" && (
<Button
type="link"
size="small"
onClick={() => handleProcessReminder(reminder.id)}
>
</Button>
)}
</Space>
</div>
</div>

View File

@@ -161,6 +161,7 @@ const ChatWindow: React.FC<ChatWindowProps> = ({ contract }) => {
visible={followupModalVisible}
onClose={handleFollowupModalClose}
recipientName={contract.nickname || contract.name}
friendId={contract.id?.toString()}
/>
{/* 待办事项模态框 */}