From 5ea49ef6f1649b5a842670feb50dc56318e2a9f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B6=85=E7=BA=A7=E8=80=81=E7=99=BD=E5=85=94?= Date: Fri, 26 Sep 2025 16:31:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=B7=9F=E9=80=B2=E6=8F=90?= =?UTF-8?q?=E9=86=92=E7=9B=B8=E9=97=9CAPI=E6=8E=A5=E5=8F=A3=E5=8F=8A?= =?UTF-8?q?=E8=81=8A=E5=A4=A9=E7=AA=97=E5=8F=A3=E5=8A=9F=E8=83=BD=EF=BC=9A?= =?UTF-8?q?=E5=9C=A8API=E4=B8=AD=E6=B7=BB=E5=8A=A0=E8=B7=9F=E9=80=B2?= =?UTF-8?q?=E6=8F=90=E9=86=92=E5=88=97=E8=A1=A8=E3=80=81=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=92=8C=E8=99=95=E7=90=86=E5=8A=9F=E8=83=BD=EF=BC=8C=E4=B8=A6?= =?UTF-8?q?=E5=9C=A8=E8=81=8A=E5=A4=A9=E7=AA=97=E5=8F=A3=E4=B8=AD=E6=95=B4?= =?UTF-8?q?=E5=90=88=E5=A5=BD=E5=8F=8BID=E4=BB=A5=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=8F=90=E9=86=92=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=8F=90=E5=8D=87?= =?UTF-8?q?=E7=94=A8=E6=88=B6=E4=BA=92=E5=8B=95=E9=AB=94=E9=A9=97=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Touchkebao/src/pages/pc/ckbox/weChat/api.ts | 31 ++++ .../FollowupReminderModal/index.tsx | 172 +++++++++++++----- .../weChat/components/ChatWindow/index.tsx | 1 + 3 files changed, 154 insertions(+), 50 deletions(-) diff --git a/Touchkebao/src/pages/pc/ckbox/weChat/api.ts b/Touchkebao/src/pages/pc/ckbox/weChat/api.ts index 4bdac18d..dbfa0cc2 100644 --- a/Touchkebao/src/pages/pc/ckbox/weChat/api.ts +++ b/Touchkebao/src/pages/pc/ckbox/weChat/api.ts @@ -321,3 +321,34 @@ export const forwardMessage = ( export const recallMessage = (messageId: string): Promise => { 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"); +}; diff --git a/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/FollowupReminderModal/index.tsx b/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/FollowupReminderModal/index.tsx index b13a2ab1..17d58d94 100644 --- a/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/FollowupReminderModal/index.tsx +++ b/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/FollowupReminderModal/index.tsx @@ -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 = ({ visible, onClose, recipientName = "客户", + friendId, }) => { const [form] = Form.useForm(); - const [reminders, setReminders] = useState([ - { - 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([]); + 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 = ({ icon={} onClick={handleAddReminder} className={styles.addButton} + loading={addLoading} block > 添加提醒 @@ -203,6 +265,7 @@ const FollowupReminderModal: React.FC = ({
(
@@ -236,6 +299,15 @@ const FollowupReminderModal: React.FC = ({ {reminder.scheduledTime} + {reminder.status === "待处理" && ( + + )}
diff --git a/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/index.tsx b/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/index.tsx index 8cecaf05..9e5dc383 100644 --- a/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/index.tsx +++ b/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/index.tsx @@ -161,6 +161,7 @@ const ChatWindow: React.FC = ({ contract }) => { visible={followupModalVisible} onClose={handleFollowupModalClose} recipientName={contract.nickname || contract.name} + friendId={contract.id?.toString()} /> {/* 待办事项模态框 */}