Files
scrm.antd/src/pages/ChatLogs/index.tsx

725 lines
24 KiB
TypeScript
Raw Normal View History

2023-04-11 15:29:40 +08:00
import { post } from '@/services/ajax';
import { DownOutlined, UpOutlined } from '@ant-design/icons';
2023-04-07 17:38:15 +08:00
import { PageContainer } from '@ant-design/pro-components';
2023-04-14 17:31:45 +08:00
import { Drawer, Form, Input, Tabs } from 'antd';
2023-04-11 15:29:40 +08:00
import Spin from 'antd/lib/spin';
import { stringify } from 'qs';
import React, { useEffect, useRef, useState } from 'react';
import { CustDetailContent } from '../CustomList/components/CustDetailContent';
2023-04-14 17:31:45 +08:00
import { DepartmentMembersDetail } from '../DepartmentsList/components/DepartmentMemberDetail';
2023-04-23 10:06:55 +08:00
import { GroupDetailContent } from '../GroupList/components/GroupDetailContent';
2023-04-13 17:36:49 +08:00
import { IChat, ICustFollow, IGroup, IGroupMembers, IStaffsItem } from './ChatLogsType';
2023-04-23 10:06:55 +08:00
import { getAdminList } from './ChatUtils';
2023-04-11 15:29:40 +08:00
import { ChatBar } from './components/ChatBar';
import { ChatTime } from './components/ChatTime';
2023-04-21 17:36:02 +08:00
import { GroupListWidget } from './GroupList';
2023-04-11 15:29:40 +08:00
import styles from './index.module.scss';
2023-04-17 17:47:31 +08:00
2023-04-07 17:38:15 +08:00
const ChatLogs: React.FC = () => {
2023-04-11 15:29:40 +08:00
const [param] = useState({
2023-04-07 17:38:15 +08:00
curr_page: 1,
page_count: 20,
2023-04-11 15:29:40 +08:00
msg_from: '',
msg_to_list: '',
2023-04-13 17:36:49 +08:00
room_id: '',
2023-04-07 17:38:15 +08:00
});
2023-04-13 17:36:49 +08:00
const [tabKey, setTabKey] = useState<string>('0');
2023-04-11 15:29:40 +08:00
const tabKeyRef = useRef('0');
2023-04-07 17:38:15 +08:00
2023-04-13 17:36:49 +08:00
const [open, setOpen] = useState(false);
// 员工
const [staffsList, setStaffsList] = useState<IStaffsItem[]>([]);
2023-04-11 15:29:40 +08:00
const [selectStaff, setSelectStaff] = useState<IStaffsItem>();
const selectStaffRef = useRef<IStaffsItem>();
2023-04-13 17:36:49 +08:00
// 内部联系人
const [innerStaffsList, setInnerStaffsList] = useState<IStaffsItem[]>([]);
const selectInnerStaffRef = useRef<IStaffsItem>();
const [selectInnerStaff, setSelectInnerStaff] = useState<IStaffsItem>();
2023-04-21 17:36:02 +08:00
const [loadingInner, setLoadingInner] = useState(false);
2023-04-13 17:36:49 +08:00
// 外部联系人
const [custFollowsList, setCustFollowsList] = useState<ICustFollow[]>([]);
const [selectCustFollow, setSelectCustFollow] = useState<ICustFollow>();
2023-04-11 15:29:40 +08:00
const selectCustFollowRef = useRef<ICustFollow>();
2023-04-21 17:36:02 +08:00
const [loadingOuter, setLoadingOuter] = useState(false);
2023-04-13 17:36:49 +08:00
// 群聊
const [groupList, setGroupList] = useState<IGroup[]>([]);
const selectGroupRef = useRef<IGroup>();
const [selectGroup, setSelectGroup] = useState<IGroup>();
2023-04-21 17:36:02 +08:00
const [loadingGroup, setLoadingGroup] = useState(false);
2023-04-13 17:36:49 +08:00
// 群成员
const [groupMembersList, setGroupMembersList] = useState<IGroupMembers[]>([]);
const groupMembersObjRef = useRef<any>({});
2023-04-11 15:29:40 +08:00
const [chatLogs, setChatLogs] = useState<IChat[]>([]);
const [tabs] = useState([
2023-04-07 17:38:15 +08:00
{
2023-04-11 15:29:40 +08:00
key: '0',
label: '内部联系人',
children: '',
2023-04-07 17:38:15 +08:00
},
{
2023-04-11 15:29:40 +08:00
key: '1',
label: '外部联系人',
children: '',
2023-04-07 17:38:15 +08:00
},
{
2023-04-11 15:29:40 +08:00
key: '2',
label: '客户群聊',
children: '',
2023-04-07 17:38:15 +08:00
},
2023-04-11 15:29:40 +08:00
]);
2023-04-17 17:47:31 +08:00
const [searchWord, setSearchWord] = useState<any>({
2023-04-13 17:36:49 +08:00
'0': '',
'1': '',
'2': '',
});
2023-04-23 10:06:55 +08:00
const [followBoxShow, setFlolowBoxShow] = useState(false);
2023-04-14 17:31:45 +08:00
const [delFollowListShow, setDelFollowListShow] = useState(false);
2023-04-13 17:36:49 +08:00
2023-04-11 15:29:40 +08:00
const timeShowRef = useRef(false);
const chatBoxRef = useRef<any>();
const isAllChatRef = useRef(false);
const chatLogLoadingRef = useRef(false);
const [chatLogLoading, setChatLogLoading] = useState(false);
2023-04-23 10:06:55 +08:00
const [staffSearchWord, setStaffSearchWord] = useState('');
2023-04-11 15:29:40 +08:00
function show() {
2023-04-23 10:06:55 +08:00
setFlolowBoxShow(false);
2023-04-11 15:29:40 +08:00
}
const getChatLogsList = () => {
chatLogLoadingRef.current = true;
setChatLogLoading(true);
post({
2023-04-23 10:06:55 +08:00
url: tabKeyRef.current == '2' ? '/ChatLogs/GroupList' : '/ChatLogs/List',
2023-04-11 15:29:40 +08:00
data: stringify(param),
}).then((res) => {
const count = res.count || 0;
chatLogLoadingRef.current = false;
2023-04-13 17:36:49 +08:00
2023-04-11 15:29:40 +08:00
setChatLogLoading(false);
isAllChatRef.current = count < param.page_count * param.curr_page;
if (res.err_code == 0) {
2023-04-18 17:28:06 +08:00
let arr: IChat[] = [];
2023-04-13 17:36:49 +08:00
if (Array.isArray(res.data) && res.data.length) {
const temp = res.data.reverse();
const mark = { curr_page: param.curr_page, msg_time: temp[temp.length - 1].msg_time };
2023-04-11 15:29:40 +08:00
if (param.curr_page == 1) {
2023-04-13 17:36:49 +08:00
arr = [...temp, mark];
2023-04-11 15:29:40 +08:00
} else {
2023-04-13 17:36:49 +08:00
arr = [...temp, mark, ...chatLogs];
2023-04-11 15:29:40 +08:00
}
2023-04-14 17:31:45 +08:00
// 5分钟外显示时间
// if (arr) {
// let show_time = '';
// arr.forEach((el, i) => {
// el.show_time = false;
// if (i == 0) {
// el.show_time = true;
// } else {
// if (show_time == '') {
// show_time = el.msg_time;
// } else {
// if (
// new Date(el.msg_time).getTime() - new Date(show_time).getTime() >
// 5 * 60 * 1000
// ) {
// el.show_time = true;
// show_time = el.msg_time;
// }
// }
// }
// });
// }
2023-04-13 17:36:49 +08:00
}
2023-04-18 17:28:06 +08:00
setChatLogs(arr);
2023-04-13 17:36:49 +08:00
}
});
};
2023-04-17 17:47:31 +08:00
const page = (curr: number) => {
param.curr_page = curr;
param.msg_from = selectStaffRef.current?.user_id + '';
2023-04-23 10:06:55 +08:00
if (tabKeyRef.current == '0') {
2023-04-17 17:47:31 +08:00
param.msg_to_list = selectInnerStaffRef.current?.user_id + '';
2023-04-23 10:06:55 +08:00
} else if (tabKeyRef.current == '1') {
2023-04-17 17:47:31 +08:00
param.msg_to_list = selectCustFollowRef.current?.cust_id + '';
} else {
param.room_id = selectGroupRef.current?.group_id + '';
}
timeShowRef.current = false;
getChatLogsList();
};
2023-04-13 17:36:49 +08:00
const getGroupList = () => {
2023-04-21 17:36:02 +08:00
setLoadingGroup(true);
2023-04-13 17:36:49 +08:00
post({
url: '/Groups/ChatGroups',
2023-04-13 17:36:49 +08:00
data: stringify({ user_id: selectStaffRef.current?.user_id }),
}).then((res) => {
2023-04-21 17:36:02 +08:00
setLoadingGroup(false);
2023-04-13 17:36:49 +08:00
if (res.err_code == 0) {
if (Array.isArray(res.data)) {
setGroupList(res.data);
// if (res.data.length) {
// setCustFollow(res.data[0]);
// selectCustFollowRef.current = res.data[0];
// page(1);
// }
}
}
});
};
// 群成员
const getGroupMembersList = () => {
post({
url: '/GroupMembers/GroupMembersList',
data: stringify({ group_id: selectGroupRef.current?.group_id }),
}).then((res) => {
if (res.err_code == 0) {
if (Array.isArray(res.data)) {
groupMembersObjRef.current = {};
let owner: IGroupMembers[] = [];
let admin_list: IGroupMembers[] = [];
let other: IGroupMembers[] = [];
2023-04-13 17:36:49 +08:00
res.data.forEach((item: IGroupMembers) => {
2023-04-18 09:57:53 +08:00
item.avatar = item.staff_avatar || item.avatar;
2023-04-13 17:36:49 +08:00
groupMembersObjRef.current[item.user_id] = item;
if (item.user_id == selectGroupRef.current?.owner) {
owner.push(item);
} else if (selectGroupRef.current?.adminUserIDs.includes(item.user_id)) {
admin_list.push(item);
} else {
other.push(item);
}
2023-04-13 17:36:49 +08:00
});
// 对群员 群主 > 管理员 > 普通成员 排序
setGroupMembersList([...owner, ...admin_list, ...other]);
2023-04-13 17:36:49 +08:00
page(1);
2023-04-11 15:29:40 +08:00
}
}
});
};
const getCustFollowsList = () => {
2023-04-21 17:36:02 +08:00
setLoadingOuter(true);
2023-04-11 15:29:40 +08:00
post({
url: '/CustFollows/List',
data: stringify({ user_id: selectStaffRef.current?.user_id }),
}).then((res) => {
2023-04-21 17:36:02 +08:00
setLoadingOuter(false);
2023-04-11 15:29:40 +08:00
if (res.err_code == 0) {
if (Array.isArray(res.data)) {
setCustFollowsList(res.data);
2023-04-13 17:36:49 +08:00
// if (res.data.length) {
// setCustFollow(res.data[0]);
// selectCustFollowRef.current = res.data[0];
// page(1);
// }
2023-04-11 15:29:40 +08:00
}
}
});
};
2023-04-07 17:38:15 +08:00
2023-04-17 17:47:31 +08:00
// 获取员工
const getStaffsList = () => {
2023-04-21 17:36:02 +08:00
setLoadingInner(true);
2023-04-17 17:47:31 +08:00
post({ url: '/Staffs/Data' }).then((res) => {
2023-04-21 17:36:02 +08:00
setLoadingInner(false);
2023-04-17 17:47:31 +08:00
if (res.err_code == 0) {
if (Array.isArray(res.data) && res.data.length) {
setSelectStaff(res.data[0]);
selectStaffRef.current = res.data[0];
// res.data.forEach((element: IStaffsItem) => {
// if (element.user_id == 'yangxb') {
// setSelectStaff(element);
// selectStaffRef.current = element;
// }
// });
setStaffsList(res.data);
setInnerStaffsList(res.data);
2023-04-21 14:59:48 +08:00
getCustFollowsList();
getGroupList();
2023-04-17 17:47:31 +08:00
}
}
});
};
// 监听DOM变动
const callback = function (mutationsList: any) {
// Use traditional 'for loops' for IE 11
for (let mutation of mutationsList) {
if (mutation.type === 'childList') {
document.querySelector('.curr_page' + param.curr_page)?.scrollIntoView(true);
} else if (mutation.type === 'attributes') {
console.log('The ' + mutation.attributeName + ' attribute was modified.');
}
}
};
const observer = new MutationObserver(callback);
useEffect(() => {
document.addEventListener('click', show, false);
getStaffsList();
observer.observe(chatBoxRef.current, { childList: true });
return () => {
document.removeEventListener('click', show, false);
observer.disconnect();
};
}, []);
// 外部联系人Item
2023-04-21 17:36:02 +08:00
const custFollowsListItem = (item: ICustFollow, i: number) => {
return (
<div
key={item.cust_id}
className={`${styles.chatB} ${item.state == 0 ? styles.state0 : ''} ${
selectCustFollow?.cust_id == item.cust_id ? styles.active : ''
}`}
onClick={() => {
tabKeyRef.current = tabKey;
setSelectInnerStaff(undefined);
selectInnerStaffRef.current = undefined;
setSelectGroup(undefined);
selectGroupRef.current = undefined;
setSelectCustFollow(item);
selectCustFollowRef.current = item;
page(1);
}}
2023-04-21 17:36:02 +08:00
style={{
display: item.name.includes(searchWord['1']) ? '' : 'none',
marginTop: i == 0 && item.state == 1 ? 1 : 0,
}}
>
<div className={styles.avatar} style={{ background: item?.avatar ? '#fff' : '' }}>
<img
src={item.avatar}
alt=""
style={{ maxWidth: '100%', maxHeight: '100%', objectFit: 'cover' }}
/>
</div>
<div className={styles.chatAMsg} style={{ flexDirection: 'column' }}>
<div className={styles.chatAName} title={item.name}>
{item.name}
</div>
<div>{item.remark}</div>
</div>
</div>
);
};
2023-04-21 17:36:02 +08:00
const checkCustFollowsIsEmpty = (state: number) => {
2023-04-23 09:14:09 +08:00
let count = 0;
2023-04-21 17:36:02 +08:00
for (const el of custFollowsList) {
if (el.name.includes(searchWord['1']) && el.state == state) {
2023-04-23 09:14:09 +08:00
count += 1;
2023-04-21 17:36:02 +08:00
}
}
2023-04-23 09:14:09 +08:00
return count;
2023-04-21 17:36:02 +08:00
};
2023-04-21 17:36:02 +08:00
const checkInnerIsEmpty = () => {
for (const el of innerStaffsList) {
if (el.name.includes(searchWord['0']) && selectInnerStaff?.user_id != el.user_id) {
return 1;
}
}
return 0;
};
2023-04-07 17:38:15 +08:00
// const { notification } = App.useApp();
2023-04-13 17:36:49 +08:00
const tabContent = () => {
if (tabKey == '0') {
// 内部联系人
return (
2023-04-21 17:36:02 +08:00
<Spin spinning={loadingInner}>
{innerStaffsList.length
? innerStaffsList.map((item) => {
if (item.user_id == selectStaff?.user_id) {
return null;
}
return (
<div
key={`${item.user_id}_${item.name}`}
className={`${styles.chatB} ${
selectInnerStaff?.user_id == item.user_id ? styles.active : ''
}`}
onClick={() => {
tabKeyRef.current = tabKey;
setSelectCustFollow(undefined);
selectCustFollowRef.current = undefined;
setSelectGroup(undefined);
selectGroupRef.current = undefined;
setSelectInnerStaff(item);
selectInnerStaffRef.current = item;
page(1);
}}
style={{ display: item.name.includes(searchWord['0']) ? '' : 'none' }}
>
<div className={styles.avatar}>
{item.avatar ? (
<img
src={item.avatar}
alt=""
style={{
width: '100%',
height: '100%',
objectFit: 'cover',
borderRadius: 4,
}}
/>
) : (
<>{item.name[0]}</>
)}
</div>
<div className={styles.chatAMsg}>
<div className={styles.chatAName} title={item.name}>
{item.name}
</div>
2023-04-13 17:36:49 +08:00
</div>
</div>
2023-04-21 17:36:02 +08:00
);
})
: null}
<div style={{ lineHeight: '34px', textAlign: 'center', color: '#999' }}>
{checkInnerIsEmpty() == 0 ? '暂无内部联系人' : ''}
</div>
</Spin>
2023-04-13 17:36:49 +08:00
);
} else if (tabKey == '1') {
return (
2023-04-21 17:36:02 +08:00
<Spin spinning={loadingOuter}>
{custFollowsList.length
? custFollowsList.map((item, i) => {
return item.state == 0 ? null : custFollowsListItem(item, i);
})
: null}
<div style={{ lineHeight: '34px', textAlign: 'center', color: '#999' }}>
{checkCustFollowsIsEmpty(1) == 0 ? '暂无外部联系人' : ''}
</div>
</Spin>
2023-04-13 17:36:49 +08:00
);
} else {
return (
2023-04-21 17:36:02 +08:00
<Spin spinning={loadingGroup}>
<GroupListWidget
groupList={groupList}
searchWord={searchWord['2']}
onClick={(item: IGroup) => {
tabKeyRef.current = tabKey;
setSelectCustFollow(undefined);
selectCustFollowRef.current = undefined;
setSelectInnerStaff(undefined);
selectInnerStaffRef.current = undefined;
setSelectGroup(item);
selectGroupRef.current = item;
selectGroupRef.current.adminUserIDs = getAdminList(item.admin_list);
getGroupMembersList();
}}
selectGroup={selectGroup}
/>
</Spin>
2023-04-14 17:31:45 +08:00
);
2023-04-13 17:36:49 +08:00
}
};
// 删除的联系人/群
const tabContentDel = () => {
if (tabKey == '0') {
return <></>;
} else if (tabKey == '1') {
return (
<div
className={`${styles.delFollowList} ${delFollowListShow ? styles.delFollowListShow : ''}`}
>
<div
className={styles.delFollowListBar}
onClick={() => {
setDelFollowListShow(!delFollowListShow);
}}
>
2023-04-23 09:14:09 +08:00
<span>{checkCustFollowsIsEmpty(0)}</span>
{delFollowListShow ? <UpOutlined /> : <DownOutlined />}
</div>
<div
className={`${styles.delFollowListBox} ${
delFollowListShow ? styles.delFollowListBoxShow : ''
}`}
>
2023-04-21 17:36:02 +08:00
{custFollowsList.map((item, i) => {
return item.state == 1 ? null : custFollowsListItem(item, i);
})}
2023-04-21 17:36:02 +08:00
<div style={{ lineHeight: '34px', color: '#999', textAlign: 'center' }}>
{checkCustFollowsIsEmpty(0) == 0 ? '暂无已删联系人' : ''}
</div>
</div>
</div>
);
} else {
2023-04-21 17:36:02 +08:00
return <></>;
}
};
2023-04-07 17:38:15 +08:00
return (
<PageContainer>
2023-04-11 15:29:40 +08:00
<div className={styles.box}>
<div className={styles.personnelBox}>
2023-04-23 10:06:55 +08:00
<div className={`${styles.flolowsBox} ${followBoxShow ? styles.show : ''}`}>
<Form
onClick={(e) => {
e.stopPropagation();
}}
style={{ padding: '12px 0', background: '#fff', position: 'sticky', top: 0 }}
>
<Input
placeholder="搜索"
style={{ margin: '0 12px', width: 'calc(100% - 24px)' }}
defaultValue={staffSearchWord}
onChange={(e) => {
setStaffSearchWord(e.target.value.trim());
}}
allowClear
/>
</Form>
2023-04-11 15:29:40 +08:00
{staffsList.map((item) => {
2023-04-23 10:06:55 +08:00
if (!item.name.includes(staffSearchWord)) return null;
2023-04-11 15:29:40 +08:00
return (
<div
key={item.user_id}
className={styles.chatB}
2023-04-17 17:47:31 +08:00
onClick={() => {
2023-04-13 17:36:49 +08:00
setSelectCustFollow(undefined);
selectCustFollowRef.current = undefined;
setSelectInnerStaff(undefined);
selectInnerStaffRef.current = undefined;
setSelectGroup(undefined);
selectGroupRef.current = undefined;
isAllChatRef.current = false;
setChatLogs([]);
2023-04-11 15:29:40 +08:00
setSelectStaff({ ...item });
selectStaffRef.current = { ...item };
2023-04-23 10:06:55 +08:00
setFlolowBoxShow(false);
2023-04-21 14:59:48 +08:00
// if (tabKey == '1') {
getCustFollowsList();
// } else if (tabKey == '2') {
getGroupList();
// }
2023-04-11 15:29:40 +08:00
}}
2023-04-14 17:31:45 +08:00
style={{ background: selectStaff?.user_id == item.user_id ? '#bae0ff' : '' }}
2023-04-11 15:29:40 +08:00
>
2023-04-14 17:31:45 +08:00
<div className={styles.avatar}>
{item.avatar ? (
<img
src={item.avatar}
alt=""
style={{
maxWidth: '100%',
maxHeight: '100%',
objectFit: 'cover',
borderRadius: 4,
}}
/>
) : (
<>{item.name[0]}</>
)}
</div>
2023-04-11 15:29:40 +08:00
<div className={styles.chatAMsg}>
<div className={styles.chatAName} title={item.name}>
{item.name}
</div>
</div>
</div>
);
})}
</div>
<div
className={`${styles.chatA}`}
onClick={(e) => {
e.stopPropagation();
2023-04-23 10:06:55 +08:00
setFlolowBoxShow(!followBoxShow);
2023-04-11 15:29:40 +08:00
}}
>
{selectStaff ? (
<>
2023-04-14 17:31:45 +08:00
<div className={styles.avatar}>
{selectStaff.avatar ? (
<img
src={selectStaff.avatar}
alt=""
style={{
maxWidth: '100%',
maxHeight: '100%',
objectFit: 'cover',
borderRadius: 4,
}}
/>
) : (
<>{selectStaff.name[0]}</>
)}
</div>
2023-04-11 15:29:40 +08:00
<div className={styles.chatAMsg}>
<div className={styles.chatAName} title={selectStaff.name}>
{selectStaff.name}
</div>
</div>
2023-04-23 10:06:55 +08:00
{followBoxShow ? <UpOutlined /> : <DownOutlined />}
2023-04-11 15:29:40 +08:00
</>
) : null}
</div>
<Form autoComplete="off">
<Input
2023-04-13 17:36:49 +08:00
placeholder="搜索"
2023-04-11 15:29:40 +08:00
style={{ margin: '0 12px', width: 'calc(100% - 24px)' }}
autoComplete="off"
2023-04-13 17:36:49 +08:00
defaultValue={searchWord[tabKey]}
key={tabKey}
onChange={(e) => {
searchWord[tabKey] = e.target.value.trim();
setSearchWord({ ...searchWord });
}}
allowClear
2023-04-17 17:47:31 +08:00
/>
2023-04-11 15:29:40 +08:00
</Form>
2023-04-13 17:36:49 +08:00
<Tabs
items={tabs}
size="small"
style={{ padding: '0 12px' }}
tabBarGutter={12}
onChange={(val) => {
setTabKey(val);
2023-04-21 14:59:48 +08:00
// if (val == '1') {
// getCustFollowsList();
// } else if (val == '2') {
// getGroupList();
// }
2023-04-13 17:36:49 +08:00
}}
2023-04-17 17:47:31 +08:00
/>
2023-04-13 17:36:49 +08:00
<div className={styles.chatBBox}>{tabContent()}</div>
{tabContentDel()}
2023-04-13 17:36:49 +08:00
</div>
<div style={{ flex: 1 }}>
<div className={styles.logTop}>
<div
2023-04-14 17:31:45 +08:00
style={{ cursor: 'pointer', fontSize: 18 }}
2023-04-13 17:36:49 +08:00
onClick={() => {
setOpen(true);
}}
>
{tabKeyRef.current == '0' ? (
<>{selectInnerStaffRef.current?.name}</>
) : tabKeyRef.current == '1' ? (
<>{selectCustFollowRef.current?.name}</>
) : (
2023-04-14 17:31:45 +08:00
<>
{selectGroupRef.current ? selectGroupRef.current?.name || '未知群名' : ''}
2023-04-14 17:31:45 +08:00
{selectGroupRef.current ? <>{groupMembersList.length}</> : null}
</>
2023-04-13 17:36:49 +08:00
)}
</div>
2023-04-14 17:31:45 +08:00
<Drawer
2023-04-13 17:36:49 +08:00
title={
tabKeyRef.current == '0' ? (
<>{selectInnerStaffRef.current?.name} </>
) : tabKeyRef.current == '1' ? (
<>{selectCustFollowRef.current?.name} </>
) : (
2023-04-14 17:31:45 +08:00
<>
{selectGroupRef.current?.name || '未知群名'} {groupMembersList.length}
2023-04-14 17:31:45 +08:00
</>
2023-04-13 17:36:49 +08:00
)
}
open={open}
2023-04-14 17:31:45 +08:00
width={600}
onClose={() => setOpen(false)}
2023-04-13 17:36:49 +08:00
footer={false}
2023-04-23 10:06:55 +08:00
destroyOnClose
2023-04-13 17:36:49 +08:00
>
{tabKeyRef.current == '0' ? (
2023-04-17 17:47:31 +08:00
<DepartmentMembersDetail record={selectInnerStaff as IStaffsItem} />
2023-04-13 17:36:49 +08:00
) : tabKeyRef.current == '1' ? (
<CustDetailContent record={selectCustFollow as ICustFollow} />
2023-04-13 17:36:49 +08:00
) : (
2023-04-23 10:06:55 +08:00
<GroupDetailContent record={selectGroup as IGroup} />
2023-04-13 17:36:49 +08:00
)}
2023-04-14 17:31:45 +08:00
</Drawer>
2023-04-11 15:29:40 +08:00
</div>
2023-04-14 17:31:45 +08:00
<Spin spinning={chatLogLoading} style={{ display: 'block' }} size="large">
2023-04-11 15:29:40 +08:00
<div
className={styles.chatLogBox}
ref={chatBoxRef}
2023-04-13 17:36:49 +08:00
onScroll={(e: any) => {
if (
e.target?.scrollTop == 0 &&
!isAllChatRef.current &&
!chatLogLoadingRef.current
) {
2023-04-11 15:29:40 +08:00
page(param.curr_page + 1);
}
}}
>
{isAllChatRef.current ? (
<div style={{ marginBottom: 12, textAlign: 'center', color: '#999' }}>
</div>
) : null}
2023-04-17 17:47:31 +08:00
{chatLogs.map((item) => {
2023-04-11 15:29:40 +08:00
if (item.curr_page) {
return (
<div
key={item.curr_page}
className={`curr_page${param.curr_page}`}
style={{ height: 0 }}
/>
);
2023-04-11 15:29:40 +08:00
} else {
return (
2023-04-23 10:06:55 +08:00
<div key={item.seq}>
2023-04-14 17:31:45 +08:00
{/* {item.show_time ? <ChatTime msgtime={item.msg_time}></ChatTime> : null} */}
2023-04-17 17:47:31 +08:00
<ChatTime msgtime={item.msg_time} />
2023-04-23 10:06:55 +08:00
{tabKeyRef.current == '2' ? (
<ChatBar
from={selectStaff}
to={groupMembersObjRef.current[item.msg_from]}
chat={item}
/>
2023-04-13 17:36:49 +08:00
) : (
2023-04-14 17:31:45 +08:00
<ChatBar
from={selectStaff}
to={
tabKeyRef.current == '0'
? selectInnerStaffRef.current
: selectCustFollowRef.current
}
2023-04-14 17:31:45 +08:00
chat={item}
2023-04-17 17:47:31 +08:00
/>
2023-04-13 17:36:49 +08:00
)}
2023-04-11 15:29:40 +08:00
</div>
);
}
})}
</div>
</Spin>
</div>
</div>
2023-04-07 17:38:15 +08:00
</PageContainer>
);
};
export default ChatLogs;