diff --git a/src/views/ChatUnassign.jsx b/src/views/ChatUnassign.jsx
new file mode 100644
index 0000000..4e83f2a
--- /dev/null
+++ b/src/views/ChatUnassign.jsx
@@ -0,0 +1,52 @@
+import { useCallback, useState, useEffect } from 'react';
+import { Divider, Layout, Flex, Image } from 'antd';
+import useFormStore from '@/stores/FormStore';
+import SearchForm from './Conversations/History/SearchForm';
+import ConversationsList from './Conversations/History/ConversationsList';
+import MessagesMatchList from './Conversations/History/MessagesMatchList';
+import MessagesList from './Conversations/History/MessagesList';
+import ImageAlbumPreview from './Conversations/History/ImageAlumPreview';
+import { flush, pick } from '@/utils/commons';
+import { fetchConversationsSearch, fetchConversationsUnassigned } from '@/actions/ConversationActions';
+
+const { Sider, Content } = Layout;
+const Unassign = (props) => {
+ const [selectedConversation, setSelectedConversation] = useFormStore((state) => [state.chatHistorySelectChat, state.setChatHistorySelectChat]);
+
+ const [conversationsListLoading, setConversationsListLoading] = useState(false);
+ const [conversationsList, setConversationsList] = useState([]);
+
+ useEffect(() => {
+ getConversationsList();
+ return () => {};
+ }, []);
+
+ const getConversationsList = async () => {
+ setConversationsListLoading(true);
+ const params = {};
+ const data = await fetchConversationsSearch(params);
+ setConversationsListLoading(false);
+ setConversationsList(data);
+ if (data.length === 1) {
+ setSelectedConversation(data[0]);
+ }
+ };
+ return (
+ <>
+
+
+ 未分配会话
+
+
+
+ {/*
+
+
+
+ */}
+
+
+ >
+ );
+};
+export default Unassign;
diff --git a/src/views/Conversations/ChatAssign.jsx b/src/views/Conversations/ChatAssign.jsx
new file mode 100644
index 0000000..6a54b16
--- /dev/null
+++ b/src/views/Conversations/ChatAssign.jsx
@@ -0,0 +1,55 @@
+import { useRef, useState, useEffect } from 'react';
+import { Layout, Button } from 'antd';
+import MessagesHeader from '@/views/Conversations/Online/MessagesHeader';
+import MessagesWrapper from '@/views/Conversations/Online/MessagesWrapper';
+import InputComposer from '@/views/Conversations/Online/InputComposer';
+import { UnorderedListOutlined, MenuUnfoldOutlined, MenuFoldOutlined } from '@ant-design/icons';
+import { useNavigate, useParams } from 'react-router-dom';
+import useConversationStore from '@/stores/ConversationStore';
+import useAuthStore from '@/stores/AuthStore';
+import { useShallow } from 'zustand/react/shallow';
+import InputAssign from './InputAssign';
+
+import { fetchConversationsList, fetchConversationsSearch } from '@/actions/ConversationActions';
+
+const { Content, Header, Footer } = Layout;
+
+function ChatAssign() {
+ const navigate = useNavigate();
+ const { whatsappid, conversationid } = useParams();
+
+ const [currentConversation, setCurrentConversation] = useConversationStore(useShallow((state) => [state.currentConversation, state.setCurrentConversation]));
+
+ async function refreshConversationList() {
+ const _list = await fetchConversationsSearch({ whatsapp_id: whatsappid });
+ if (_list.length > 0) {
+ setCurrentConversation(_list[0]);
+ }
+ }
+
+ useEffect(() => {
+ refreshConversationList();
+
+ return () => {};
+ }, [whatsappid]);
+
+
+ return (
+ <>
+
+
+
+
+
+ {/* */}
+
+ >
+ );
+}
+
+export default ChatAssign;
diff --git a/src/views/Conversations/History/ConversationsList.jsx b/src/views/Conversations/History/ConversationsList.jsx
index dc63c05..c012ac9 100644
--- a/src/views/Conversations/History/ConversationsList.jsx
+++ b/src/views/Conversations/History/ConversationsList.jsx
@@ -1,32 +1,8 @@
-import { useEffect, useState } from 'react';
import { Spin } from 'antd';
import { ChatItem } from 'react-chat-elements';
-import useFormStore from '@/stores/FormStore';
-import { flush, pick } from '@/utils/commons';
-import { fetchConversationsSearch } from '@/actions/ConversationActions';
-const ConversationsList = ({ ...props }) => {
- const [formValues,] = useFormStore(((state) => [state.chatHistoryForm,]));
- const [selectedConversation, setSelectedConversation] = useFormStore((state) => [state.chatHistorySelectChat, state.setChatHistorySelectChat]);
+const ConversationsList = ({ conversationsListLoading, handleChatItemClick, selectedConversation, conversationsList, ...props }) => {
- const [conversationsListLoading, setConversationsListLoading] = useState(false);
- const [conversationsList, setConversationsList] = useState([]);
-
- useEffect(() => {
- getConversationsList();
- return () => {};
- }, [formValues]);
-
- const getConversationsList = async () => {
- setConversationsListLoading(true);
- const params = flush(pick(formValues, ['opisn', 'whatsapp_id', 'search', 'from_date', 'end_date', 'coli_id']));
- const data = await fetchConversationsSearch(params);
- setConversationsListLoading(false);
- setConversationsList(data);
- if (data.length === 1) {
- setSelectedConversation(data[0]);
- }
- };
return (
<>
@@ -43,7 +19,7 @@ const ConversationsList = ({ ...props }) => {
// dateString={item.last_received_time}
dateString={item.dateText}
className={String(item.conversationid) === String(selectedConversation.conversationid) ? '__active text-primary bg-neutral-100' : ''}
- onClick={() => setSelectedConversation(item)}
+ onClick={() => handleChatItemClick(item)}
/>
))}
diff --git a/src/views/Conversations/InputAssign.jsx b/src/views/Conversations/InputAssign.jsx
new file mode 100644
index 0000000..a637deb
--- /dev/null
+++ b/src/views/Conversations/InputAssign.jsx
@@ -0,0 +1,43 @@
+import { useState } from 'react';
+import { App, Button, Form, Input } from 'antd';
+import SearchInput from '@/components/SearchInput';
+import { fetchSalesAgent } from '@/actions/CommonActions';
+import { postAssignConversation } from '@/actions/ConversationActions';
+
+const InputAssign = ({ initialValues, ...props }) => {
+ const { message } = App.useApp();
+ const [form] = Form.useForm();
+
+ const [subLoading, setSubLoading] = useState(false);
+ async function handleSubmit(values) {
+ const valuesSub = {
+ ...values,
+ opi_sn: values.opi_sn.value,
+ };
+ setSubLoading(true);
+ await postAssignConversation(valuesSub);
+ setSubLoading(false);
+ message.success('分配成功');
+ }
+ return (
+ <>
+
+
+
+
+
+
+
+ {/* */}
+
+
+
+ >
+ );
+};
+export default InputAssign;
diff --git a/src/views/Conversations/Online/MessagesWrapper.jsx b/src/views/Conversations/Online/MessagesWrapper.jsx
index e276141..6f10bb0 100644
--- a/src/views/Conversations/Online/MessagesWrapper.jsx
+++ b/src/views/Conversations/Online/MessagesWrapper.jsx
@@ -9,7 +9,7 @@ import { isEmpty } from '@/utils/commons';
import useAuthStore from '@/stores/AuthStore';
import { useVisibilityState } from '@/hooks/useVisibilityState';
-const MessagesWrapper = () => {
+const MessagesWrapper = ({ updateRead = true, forceGetMessages }) => {
const userId = useAuthStore((state) => state.loginUser.userId);
const [currentConversation, updateCurrentConversation, setCurrentConversation] = useConversationStore(useShallow((state) => [state.currentConversation, state.updateCurrentConversation, state.setCurrentConversation]));
@@ -27,7 +27,7 @@ const MessagesWrapper = () => {
const [longListLoading, setLongListLoading] = useState(false);
const [shouldScrollBottom, setShouldScrollBottom] = useState(true);
useEffect(() => {
- if (currentConversation.sn && activeMessages.length < 20) {
+ if (currentConversation.sn && (activeMessages.length < 20 || forceGetMessages !== undefined)) {
getFirstPageMessages(currentConversation);
}
setShouldScrollBottom(true);
@@ -43,7 +43,7 @@ const MessagesWrapper = () => {
}, [activeMessages]);
useEffect(() => {
- if (isVisible && currentConversation.opi_sn && currentConversation.whatsapp_phone_number && activeMessages.length > 0) {
+ if (updateRead === true && isVisible && currentConversation.opi_sn && currentConversation.whatsapp_phone_number && activeMessages.length > 0) {
fetchCleanUnreadMsgCount({ opisn: currentConversation.opi_sn, whatsappid: currentConversation.whatsapp_phone_number });
refreshTotalNotify();
}
@@ -53,7 +53,7 @@ const MessagesWrapper = () => {
const getFirstPageMessages = async (item) => {
setMsgLoading(true);
- const data = await fetchMessages({ opisn: userId, whatsappid: item.whatsapp_phone_number, lasttime: '' });
+ const data = await fetchMessages({ opisn: forceGetMessages ? '' : userId, whatsappid: item.whatsapp_phone_number, lasttime: '' });
setMsgLoading(false);
receivedMessageList(item.sn, data);
const thisLastTime = data.length > 0 ? data[0].orgmsgtime : '';