|
|
|
@ -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)' }}>
|
|
|
|
|