feat: 邮箱文件夹接口; 邮件列表接口

dev/ckeditor
Lei OT 4 months ago
parent 9100e4b19d
commit 9d31e69db9

File diff suppressed because one or more lines are too long

@ -25,6 +25,7 @@ export const HT3 = process.env.NODE_ENV === 'production' ? 'https://p9axztuwd7x
export const DATE_FORMAT = 'YYYY-MM-DD';
export const DATETIME_FORMAT = 'YYYY-MM-DD HH:mm:ss';
export const DATEEND_FORMAT = 'YYYY-MM-DD 23:59';
export const ERROR_IMG = 'https://hiana-crm.oss-accelerate.aliyuncs.com/WAMedia/afe412d4-3acf-4e79-a623-048aeb4d696a.png';
export const OSS_URL_CN = 'https://haina-sale-system.oss-cn-shenzhen.aliyuncs.com/WAMedia/';

@ -620,7 +620,7 @@ function createTreeNode(key, name, parent = null, _raw={}) {
* Builds a tree structure from a flat list of nodes.
* @returns {Array<object>} An array of root tree nodes.
*/
export const buildTree = (list, keyMap={}) => {
export const buildTree = (list, keyMap={ rootKeys: [], ignoreKeys: [] }) => {
if (!list || list.length === 0) {
return []
}
@ -635,12 +635,19 @@ export const buildTree = (list, keyMap={}) => {
list.forEach((item) => {
const node = nodeMap.get(item[keyMap.key])
if (item[keyMap.parent] === keyMap.rootKey || item[keyMap.parent] === 0 || item[keyMap.parent] === 1 || item[keyMap.parent] === null || item[keyMap.parent] === undefined) {
if (keyMap.rootKeys.includes(item[keyMap.parent]) || item[keyMap.parent] === null || item[keyMap.parent] === undefined) {
// This is a root node
treeRoots.push(node)
} else {
const parentNode = nodeMap.get(item[keyMap.parent])
if (parentNode) {
if (keyMap.ignoreKeys.includes(item[keyMap.parent])) {
const grandParentNode = nodeMap.get(parentNode.parent);
node.parent = parentNode.parent;
grandParentNode.children.push(node)
} else if (keyMap.ignoreKeys.includes(item[keyMap.key])) {
//
}
else if (parentNode) {
parentNode.children.push(node)
} else {
console.warn(`Parent with key '${item[keyMap.parent]}' not found for node '${item[keyMap.key]}'. This node will be treated as a root.`)

@ -113,7 +113,15 @@ function Follow() {
const [activeEmailId, setActiveEmailId] = useState(0)
const [activeAccount, setActiveAccount] = useState(accountDEI[0].value)
const [mailboxDir, setMailboxDir] = useState([])
const [deiStickyTree, setDeiStickyTree] = useState({})
const [stickyTree, setStickyTree] = useState([])
const [mergedTree, setMergedTree] = useState([]);
const [expandTree, setExpandTree] = useState([])
const [mailList, setMailList] = useState([]);
const DirTypeIcon = ({ type }) => {
const Icon = EmailDirTypeIcons[type || '0']?.component || EmailDirTypeIcons['0'].component
const className = EmailDirTypeIcons[type || '0']?.className || EmailDirTypeIcons['0'].className
@ -122,28 +130,27 @@ function Follow() {
const getOPIEmailDir = async (opi_sn = 0) => {
console.log('🌐requesting opi dir', opi_sn)
const x = await getEmailDirAction(opi_sn)
const x = await getEmailDirAction({opi_sn})
const mailboxSort = x //.sort(sortBy('MDR_Order'));
const dirs = mailboxSort.map((ele) => {
return { ...ele, icon: ele.ImageIndex !== void 0 ? <DirTypeIcon type={ele.ImageIndex} /> : false }
})
let tree = buildTree(dirs, { key: 'VKey', parent: 'VParent', name: 'VName', rootKey: 1 })
let tree = buildTree(dirs, { key: 'VKey', parent: 'VParent', name: 'VName', rootKeys: [1], ignoreKeys: [-227001, -227002] })
tree = tree.filter((ele) => ele.key !== 1)
// console.log(tree)
// console.log('tree', tree)
setMailboxDir(tree)
const level1 = tree.filter((ele) => !isEmpty(ele.children)).map((ele) => ele.key)
setExpandTree((pre) => [...pre, ...level1])
setMergedTree([...stickyTree, ...tree]);
// const level1 = []; // tree.filter((ele) => !isEmpty(ele.children)).map((ele) => ele.key)
// setExpandTree((pre) => [...pre, ...level1])
}
const getMailList = async ({ query, order }) => {
const opi_sn = accountListDEIMapped[activeAccount].OPI_SN
const opi_sn = accountListDEIMapped[activeAccount].OPI_SN || 404
const x = await queryEmailListAction({ opi_sn, query, order })
const _x = x.map(ele => ({...ele, key: ele.MAI_SN, title: ele.MAI_Subject, description: ele.SenderReceiver, mailDate: ele.SRDate, orderNo: ele.MAI_COLI_ID, country: ele.CountryCN}));
setMailList(_x);
}
const [deiStickyTree, setDeiStickyTree] = useState({})
const [stickyTree, setStickyTree] = useState([])
const [expandTree, setExpandTree] = useState([])
const [activeAccount, setActiveAccount] = useState()
const handleSwitchAccount = (value) => {
setActiveAccount(value)
setStickyTree(deiStickyTree[value] || [])
@ -153,25 +160,26 @@ function Follow() {
}
const handleTreeSelectGetMails = (selectedKeys, { node }) => {
// console.info('selectedKeys: ', selectedKeys, node)
console.info('selectedTreeKeys: ', selectedKeys, node)
if (node?.COLI_SN || node?._raw?.COLI_SN) {
// ;
// get order mails
// console.log('get order mails', { order: { coli_sn: node?.COLI_SN || node?._raw?.COLI_SN, order_source_type: node?._raw?.OrderSourceType || 227001, vkey: node.key } })
getMailList({ order: { coli_sn: node?.COLI_SN || node?._raw?.COLI_SN, order_source_type: node?._raw?.OrderSourceType || 227001, vkey: node.key } })
const coli_sn = node?.COLI_SN || node?._raw?.COLI_SN;
getMailList({ order: { coli_sn: coli_sn, order_source_type: node?._raw?.OrderSourceType || 227001, vkey: coli_sn, vparent: node?.parent || -1, mai_senddate1: node?._raw?.ApplyDate || '' } })
} else if ([-227001, -227002].includes(node.key) || [-227001, -227002].includes(node.parent) || node?.getMails === false) {
// nothing, expand only
console.log('nothing')
} else {
// get mail list
console.log('get mail list')
getMailList({ query: { vkey: selectedKeys[0] } })
getMailList({ query: { vkey: selectedKeys[0], vparent: node.parent } })
}
}
useEffect(() => {
fetchOrderList({ type: 'today' }, loginUser)
getOPIEmailDir()
getOPIEmailDir(accountList[0].OPI_SN)
return () => {}
}, [])
@ -192,19 +200,20 @@ function Follow() {
key: key + '-today',
getMails: false,
icon: <StarTwoTone />,
children: (sticky[0] || []).map((o) => ({ ...o, key: o.COLI_SN, title: `(${todoTypes[o.coli_ordertype] || o.COLI_State}) ${o.COLI_ID}` })),
children: (sticky[0] || []).map((o) => ({ key: `today-${o.COLI_SN}`, title: `(${todoTypes[o.coli_ordertype] || o.COLI_State}) ${o.COLI_ID}`, _raw: {...o, ApplyDate: '', OrderSourceType: 227001,parent: -1, }})),
},
{
title: '待办任务',
key: key + '-todo',
getMails: false,
icon: <CalendarTwoTone />,
children: (sticky[1] || []).map((o) => ({ ...o, key: o.COLI_SN, title: `(${todoTypes[o.coli_ordertype] || o.COLI_State}) ${o.COLI_ID}` })),
children: (sticky[1] || []).map((o) => ({ key: `todo-${o.COLI_SN}`, title: `(${todoTypes[o.coli_ordertype] || o.COLI_State}) ${o.COLI_ID}`, _raw: {...o, ApplyDate: '', OrderSourceType: 227001,parent: -1, } })),
},
]
// { key, title: deiName, children: sticky[0] };
return { ...acc, [key]: treeNode }
}, defaultStickyTree)
// console.log('tree 0', byState);
setDeiStickyTree(byState)
const first = accountDEI[0].value
setExpandTree([`${first}-today`, `${first}-todo`])
@ -224,13 +233,14 @@ function Follow() {
key='sticky-today'
blockNode
showIcon
showLine
showLine expandAction={'doubleClick'}
onSelect={handleTreeSelectGetMails}
onExpand={(expandedKeys) => setExpandTree(expandedKeys)}
expandedKeys={expandTree}
defaultExpandedKeys={expandTree}
defaultSelectedKeys={['today']}
treeData={[...(stickyTree || []), ...mailboxDir]}
// treeData={mergedTree}
titleRender={(node) => <Typography.Text ellipsis={{ tooltip: node.title }}>{node.title}</Typography.Text>}
/>
</div>
@ -239,7 +249,7 @@ function Follow() {
<Layout.Content style={{ maxHeight: 'calc(100vh - 166px)', height: 'calc(100vh - 166px)', minWidth: '360px' }}>
<Row>
<Col className='bg-white' span={14}>
<Mailbox />
<Mailbox dataSource={mailList} onMailClick={id => setActiveEmailId(id)} />
</Col>
<Col span={10} style={{ height: 'calc(100vh - 166px)' }}>

@ -88,11 +88,12 @@ const MailBox = (props) => {
<div className='bg-white overflow-y-auto' style={{ height: 'calc(100vh - 198px)' }}>
<List
// header={null}
header={<div>今日任务</div>}
header={<div>{props.title}</div>}
itemLayout='vertical'
size='large'
pagination={false}
dataSource={[
dataSource={props.dataSource}
dataSource1={[...props.dataSource,
{
key: Math.random().toString(36).substring(2, 9),
description: 'Fran Grundman <frangrundman@rogers.com>',
@ -208,8 +209,8 @@ const MailBox = (props) => {
extra={<Checkbox></Checkbox>}>
<List.Item.Meta
className='cursor-pointer'
onClick={() => console.info('item: ', item)}
title={<a href={item.href} onClick={() => console.info('')}></a>}
onClick={() => {console.info('item: ', item); props?.onMailClick(item.key)}}
title={<a href={item.href} onClick={() => {console.info(''); props?.onMailClick(item.key)}}>{item.title}</a>}
description={item.description + ' ' + item.mailDate}
/>
{item.content}LSS250501006, Thailand

Loading…
Cancel
Save