开发: 添加及修改路由
This commit is contained in:
@@ -106,7 +106,7 @@ export interface IChat {
|
||||
}
|
||||
export interface IChatItem {
|
||||
from?: IStaffsItem;
|
||||
to?: ICustFollow;
|
||||
to?: ICustFollow | IStaffsItem | IGroup;
|
||||
group?: any;
|
||||
chat?: IChat;
|
||||
}
|
||||
|
@@ -5,6 +5,8 @@
|
||||
* @returns
|
||||
*/
|
||||
|
||||
import React, { useEffect, useState } from 'react';
|
||||
|
||||
export const groupMembersCount = (data: any[], state: any) => {
|
||||
let count = 0;
|
||||
data.forEach((item) => {
|
||||
@@ -86,3 +88,35 @@ export const formatTags = (data: any) => {
|
||||
}
|
||||
return <></>;
|
||||
};
|
||||
|
||||
type IGroupIcon = {
|
||||
groupList: any[];
|
||||
};
|
||||
/**
|
||||
* todo 群头像拼接
|
||||
* @param props
|
||||
* @returns
|
||||
*/
|
||||
export const GroupIcon: React.FC<IGroupIcon> = (props) => {
|
||||
const [list, setList] = useState<any>([[], [], []]);
|
||||
|
||||
useEffect(() => {
|
||||
let temp: any = [[], [], []];
|
||||
const { groupList } = props;
|
||||
for (let index = 0; index < 9; index++) {
|
||||
const element = groupList[index];
|
||||
|
||||
if (index < 3) {
|
||||
temp[0].push(element);
|
||||
} else if (index < 6) {
|
||||
temp[1].push(element);
|
||||
} else {
|
||||
temp[2].push(element);
|
||||
}
|
||||
}
|
||||
console.log(temp);
|
||||
}, [props.groupList]);
|
||||
|
||||
// <div className={styles.avatar}>{item.name ? item.name[0] : '群'}</div>;
|
||||
return <div></div>;
|
||||
};
|
||||
|
@@ -12,11 +12,7 @@ import { ChatBar } from './components/ChatBar';
|
||||
import { ChatTime } from './components/ChatTime';
|
||||
import { Gender } from './components/Gender';
|
||||
import styles from './index.module.scss';
|
||||
interface ISearchWord {
|
||||
'0': string;
|
||||
'1': string;
|
||||
'2': string;
|
||||
}
|
||||
|
||||
const ChatLogs: React.FC = () => {
|
||||
const [param] = useState({
|
||||
curr_page: 1,
|
||||
@@ -80,7 +76,7 @@ const ChatLogs: React.FC = () => {
|
||||
'3': '离职继承完成',
|
||||
};
|
||||
|
||||
const [searchWord, setSearchWord] = useState<ISearchWord>({
|
||||
const [searchWord, setSearchWord] = useState<any>({
|
||||
'0': '',
|
||||
'1': '',
|
||||
'2': '',
|
||||
@@ -100,72 +96,6 @@ const ChatLogs: React.FC = () => {
|
||||
setFlolowsBox(false);
|
||||
}
|
||||
|
||||
// 监听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 });
|
||||
const myScript = document.createElement('script');
|
||||
myScript.src = '/public/scripts/amrnb.js';
|
||||
myScript.async = false;
|
||||
document.body.appendChild(myScript);
|
||||
|
||||
return () => {
|
||||
document.removeEventListener('click', show, false);
|
||||
observer.disconnect();
|
||||
document.body.removeChild(myScript);
|
||||
};
|
||||
}, []);
|
||||
|
||||
// 获取员工
|
||||
const getStaffsList = () => {
|
||||
post({ url: '/Staffs/Data' }).then((res) => {
|
||||
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);
|
||||
getCustFollowsList();
|
||||
getGroupList();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const page = (curr: number) => {
|
||||
param.curr_page = curr;
|
||||
param.msg_from = selectStaffRef.current?.user_id + '';
|
||||
if (tabKey == '0') {
|
||||
param.msg_to_list = selectInnerStaffRef.current?.user_id + '';
|
||||
} else if (tabKey == '1') {
|
||||
param.msg_to_list = selectCustFollowRef.current?.cust_id + '';
|
||||
} else {
|
||||
param.room_id = selectGroupRef.current?.group_id + '';
|
||||
}
|
||||
timeShowRef.current = false;
|
||||
getChatLogsList();
|
||||
};
|
||||
|
||||
const getChatLogsList = () => {
|
||||
chatLogLoadingRef.current = true;
|
||||
setChatLogLoading(true);
|
||||
@@ -216,6 +146,20 @@ const ChatLogs: React.FC = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const page = (curr: number) => {
|
||||
param.curr_page = curr;
|
||||
param.msg_from = selectStaffRef.current?.user_id + '';
|
||||
if (tabKey == '0') {
|
||||
param.msg_to_list = selectInnerStaffRef.current?.user_id + '';
|
||||
} else if (tabKey == '1') {
|
||||
param.msg_to_list = selectCustFollowRef.current?.cust_id + '';
|
||||
} else {
|
||||
param.room_id = selectGroupRef.current?.group_id + '';
|
||||
}
|
||||
timeShowRef.current = false;
|
||||
getChatLogsList();
|
||||
};
|
||||
|
||||
const getGroupList = () => {
|
||||
post({
|
||||
url: '/Groups/GroupsList',
|
||||
@@ -271,6 +215,58 @@ const ChatLogs: React.FC = () => {
|
||||
});
|
||||
};
|
||||
|
||||
// 获取员工
|
||||
const getStaffsList = () => {
|
||||
post({ url: '/Staffs/Data' }).then((res) => {
|
||||
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);
|
||||
getCustFollowsList();
|
||||
getGroupList();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 监听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 });
|
||||
const myScript = document.createElement('script');
|
||||
myScript.src = '/public/scripts/amrnb.js';
|
||||
myScript.async = false;
|
||||
document.body.appendChild(myScript);
|
||||
|
||||
return () => {
|
||||
document.removeEventListener('click', show, false);
|
||||
observer.disconnect();
|
||||
document.body.removeChild(myScript);
|
||||
};
|
||||
}, []);
|
||||
|
||||
// const { notification } = App.useApp();
|
||||
const tabContent = () => {
|
||||
if (tabKey == '0') {
|
||||
@@ -549,7 +545,7 @@ const ChatLogs: React.FC = () => {
|
||||
<div
|
||||
key={item.user_id}
|
||||
className={styles.chatB}
|
||||
onClick={(e) => {
|
||||
onClick={() => {
|
||||
setSelectCustFollow(undefined);
|
||||
selectCustFollowRef.current = undefined;
|
||||
setSelectInnerStaff(undefined);
|
||||
@@ -637,7 +633,7 @@ const ChatLogs: React.FC = () => {
|
||||
setSearchWord({ ...searchWord });
|
||||
}}
|
||||
allowClear
|
||||
></Input>
|
||||
/>
|
||||
</Form>
|
||||
<Tabs
|
||||
items={tabs}
|
||||
@@ -647,7 +643,7 @@ const ChatLogs: React.FC = () => {
|
||||
onChange={(val) => {
|
||||
setTabKey(val);
|
||||
}}
|
||||
></Tabs>
|
||||
/>
|
||||
<div className={styles.chatBBox}>{tabContent()}</div>
|
||||
</div>
|
||||
<div style={{ flex: 1 }}>
|
||||
@@ -688,9 +684,7 @@ const ChatLogs: React.FC = () => {
|
||||
footer={false}
|
||||
>
|
||||
{tabKeyRef.current == '0' ? (
|
||||
<DepartmentMembersDetail
|
||||
record={selectInnerStaff as IStaffsItem}
|
||||
></DepartmentMembersDetail>
|
||||
<DepartmentMembersDetail record={selectInnerStaff as IStaffsItem} />
|
||||
) : tabKeyRef.current == '1' ? (
|
||||
<div>
|
||||
<div
|
||||
@@ -707,7 +701,7 @@ const ChatLogs: React.FC = () => {
|
||||
<div style={{ display: 'flex', flexDirection: 'column' }}>
|
||||
<div style={{ fontSize: 16 }}>
|
||||
<span style={{ marginRight: 8 }}>{selectCustFollow?.name}</span>
|
||||
<Gender gender={selectCustFollow?.gender}></Gender>
|
||||
<Gender gender={selectCustFollow?.gender} />
|
||||
</div>
|
||||
<div style={{ color: '#666' }}>{selectCustFollow?.description}</div>
|
||||
</div>
|
||||
@@ -718,7 +712,8 @@ const ChatLogs: React.FC = () => {
|
||||
) : (
|
||||
<div>
|
||||
<div style={{ marginBottom: 8, textIndent: '2em' }}>
|
||||
群主:{groupMembersObjRef.current[selectGroupRef.current?.owner]?.name}
|
||||
群主:
|
||||
{groupMembersObjRef.current[selectGroupRef.current?.owner as string]?.name}
|
||||
</div>
|
||||
<div style={{ marginBottom: 8 }}>
|
||||
{adminList(selectGroupRef.current?.admin_list, groupMembersObjRef.current)}
|
||||
@@ -937,26 +932,26 @@ const ChatLogs: React.FC = () => {
|
||||
没有更多聊天记录了
|
||||
</div>
|
||||
) : null}
|
||||
{chatLogs.map((item, i) => {
|
||||
{chatLogs.map((item) => {
|
||||
if (item.curr_page) {
|
||||
return (
|
||||
<div
|
||||
key={item.curr_page}
|
||||
className={`curr_page${param.curr_page}`}
|
||||
style={{ height: 0 }}
|
||||
></div>
|
||||
/>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<div key={item.msg_id}>
|
||||
{/* {item.show_time ? <ChatTime msgtime={item.msg_time}></ChatTime> : null} */}
|
||||
<ChatTime msgtime={item.msg_time}></ChatTime>
|
||||
<ChatTime msgtime={item.msg_time} />
|
||||
{tabKey == '2' ? (
|
||||
<ChatBar
|
||||
from={selectStaff}
|
||||
to={groupMembersObjRef.current[item.msg_from]}
|
||||
chat={item}
|
||||
></ChatBar>
|
||||
/>
|
||||
) : (
|
||||
<ChatBar
|
||||
from={selectStaff}
|
||||
@@ -966,7 +961,7 @@ const ChatLogs: React.FC = () => {
|
||||
: selectCustFollowRef.current
|
||||
}
|
||||
chat={item}
|
||||
></ChatBar>
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
Reference in New Issue
Block a user