diff --git a/Cunkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageEnter/components/toContract/index.tsx b/Cunkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageEnter/components/toContract/index.tsx index 96e95ceb..8fd4c404 100644 --- a/Cunkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageEnter/components/toContract/index.tsx +++ b/Cunkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageEnter/components/toContract/index.tsx @@ -7,6 +7,8 @@ import { WechatFriendRebackAllot, } from "@/pages/pc/ckbox/weChat/api"; import { useCurrentContact } from "@/store/module/weChat/weChat"; +import { deleteChatSession } from "@/store/module/ckchat/ckchat"; +import { contractService, weChatGroupService } from "@/utils/db"; const { TextArea } = Input; const { Option } = Select; @@ -85,6 +87,18 @@ const ToContract: React.FC = ({ } message.success("转接成功"); + try { + // 删除聊天会话 + deleteChatSession(currentContact.id.toString()); + // 删除本地数据库记录 + if ("chatroomId" in currentContact) { + await weChatGroupService.delete(currentContact.id); + } else { + await contractService.delete(currentContact.id.toString()); + } + } catch (deleteError) { + console.error("删除本地数据失败:", deleteError); + } closeModal(); } catch (error) { console.error("转接失败:", error); @@ -113,6 +127,18 @@ const ToContract: React.FC = ({ } message.success("转回成功"); + try { + // 删除聊天会话 + deleteChatSession(currentContact.id.toString()); + // 删除本地数据库记录 + if ("chatroomId" in currentContact) { + await weChatGroupService.delete(currentContact.id); + } else { + await contractService.delete(currentContact.id); + } + } catch (deleteError) { + console.error("删除本地数据失败:", deleteError); + } closeModal(); } catch (error) { console.error("转回失败:", error); diff --git a/Cunkebao/src/pages/pc/ckbox/weChat/components/SidebarMenu/MessageList/index.tsx b/Cunkebao/src/pages/pc/ckbox/weChat/components/SidebarMenu/MessageList/index.tsx index f954caaa..820571cc 100644 --- a/Cunkebao/src/pages/pc/ckbox/weChat/components/SidebarMenu/MessageList/index.tsx +++ b/Cunkebao/src/pages/pc/ckbox/weChat/components/SidebarMenu/MessageList/index.tsx @@ -19,17 +19,29 @@ const MessageList: React.FC = () => { const [chatSessions, setChatSessions] = useState< (ContractData | weChatGroup)[] >([]); - + const searchKeyword = useCkChatStore(state => state.searchKeyword); useEffect(() => { - if (kfSelected == 0) { - setChatSessions(getChatSessions); - } else { - const newChatSessions = getChatSessions.filter( - v => v.wechatAccountId === kfSelected && kfSelected != 0, + let filteredSessions = getChatSessions; + + // 根据客服筛选 + if (kfSelected !== 0) { + filteredSessions = filteredSessions.filter( + v => v.wechatAccountId === kfSelected, ); - setChatSessions(newChatSessions); } - }, [getChatSessions, kfSelected]); + + // 根据搜索关键词进行模糊匹配 + if (searchKeyword.trim()) { + const keyword = searchKeyword.toLowerCase(); + filteredSessions = filteredSessions.filter(v => { + const nickname = (v.nickname || "").toLowerCase(); + const conRemark = (v.conRemark || "").toLowerCase(); + return nickname.includes(keyword) || conRemark.includes(keyword); + }); + } + + setChatSessions(filteredSessions); + }, [getChatSessions, kfSelected, searchKeyword]); return (