|
|
|
import { useCallback, useEffect, useState } from 'react'
|
|
|
|
import { ReloadOutlined, ReadOutlined, CheckSquareOutlined, StarOutlined, RightOutlined, LeftOutlined, ExpandOutlined, AppstoreOutlined } from '@ant-design/icons'
|
|
|
|
import { Flex, Button, Tooltip, List, Form, Row, Col, Drawer, Dropdown, Input, Checkbox, DatePicker, Switch, Breadcrumb } from 'antd'
|
|
|
|
import dayjs from 'dayjs'
|
|
|
|
import { useEmailList } from '@/hooks/useEmail';
|
|
|
|
import { isEmpty } from '@/utils/commons';
|
|
|
|
import { MailboxDirIcon } from './MailboxDirIcon'
|
|
|
|
|
|
|
|
const { RangePicker } = DatePicker
|
|
|
|
const MailBox = ({ mailboxDir, onMailItemClick, ...props}) => {
|
|
|
|
const DATE_RANGE_PRESETS = [
|
|
|
|
{
|
|
|
|
label: '本周',
|
|
|
|
value: [dayjs().startOf('w'), dayjs().endOf('w')],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '上周',
|
|
|
|
value: [dayjs().startOf('w').subtract(7, 'days'), dayjs().endOf('w').subtract(7, 'days')],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '本月',
|
|
|
|
value: [dayjs().startOf('M'), dayjs().endOf('M')],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '上月',
|
|
|
|
value: [dayjs().subtract(1, 'M').startOf('M'), dayjs().subtract(1, 'M').endOf('M')],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '前三月',
|
|
|
|
value: [dayjs().subtract(2, 'M').startOf('M'), dayjs().endOf('M')],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: '本年',
|
|
|
|
value: [dayjs().startOf('y'), dayjs().endOf('y')],
|
|
|
|
},
|
|
|
|
]
|
|
|
|
const [form] = Form.useForm()
|
|
|
|
|
|
|
|
const { mailList, isLoading, error } = useEmailList(mailboxDir);
|
|
|
|
const pagedList = mailList.length === 0 ? [] : mailList.slice(0, 50)
|
|
|
|
|
|
|
|
console.info('props.breadcrumb: ', props.breadcrumb)
|
|
|
|
console.info('props.mailboxDir: ', mailboxDir)
|
|
|
|
|
|
|
|
const mailItemRender = (item) => {
|
|
|
|
const isOrderNode = mailboxDir.COLI_SN > 0
|
|
|
|
const orderNumber = (isEmpty(item.MAI_COLI_ID) || isOrderNode) ? '' : (item.MAI_COLI_ID + ' - ')
|
|
|
|
const countryName = isEmpty(item.CountryCN) ? '' : ('[' + (item.CountryCN === null ? 'USA' : item.CountryCN) + '] ')
|
|
|
|
const mailStateClass = item.MOI_ReadState === 0 ? 'font-bold' : ''
|
|
|
|
return (
|
|
|
|
<li className='flex border border-solid border-t-0 border-x-0 border-gray-200 hover:bg-neutral-50 p-2' onClick={() => {
|
|
|
|
console.info('item: ', item)
|
|
|
|
onMailItemClick(item.MAI_SN)
|
|
|
|
}}>
|
|
|
|
<div className=''>
|
|
|
|
<Checkbox></Checkbox>
|
|
|
|
</div>
|
|
|
|
<div className='flex-1 pl-2'>
|
|
|
|
<Flex gap='small' vertical={true} justify='space-between' className='cursor-pointer'>
|
|
|
|
<div>{orderNumber}<span className={mailStateClass}>{item.MAI_Subject}</span></div>
|
|
|
|
<span className='text-neutral-500 text-wrap break-words break-all '>{countryName + item.SenderReceiver + ' ' + item.SRDate}</span>
|
|
|
|
</Flex>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<div className='bg-white h-auto px-1 flex gap-1 items-center'>
|
|
|
|
<Dropdown.Button
|
|
|
|
className='w-auto'
|
|
|
|
placement='bottom'
|
|
|
|
arrow
|
|
|
|
type={'primary'}
|
|
|
|
menu={{
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
key: '1',
|
|
|
|
label: '一催模板一,询问客人是否收到报价信',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: '2',
|
|
|
|
label: '一催模板二,询问客人是否修改行程',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'divider',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: '3',
|
|
|
|
label: '二催模板一,询问客人对行程的看法',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: '4',
|
|
|
|
label: '二催模板二,表达服务的意识',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'divider',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: '5',
|
|
|
|
label: '三催模板三,强调价格有效期',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
onClick: (item) => {
|
|
|
|
console.info('menu', item)
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
onClick={() => {
|
|
|
|
console.info('新邮件')
|
|
|
|
}}>
|
|
|
|
新邮件
|
|
|
|
</Dropdown.Button>
|
|
|
|
<Flex wrap gap='middle' justify={'center'} className='min-w-40'>
|
|
|
|
<Tooltip title='全选'>
|
|
|
|
<Checkbox></Checkbox>
|
|
|
|
</Tooltip>
|
|
|
|
<Tooltip title='标记已读'>
|
|
|
|
<Button shape='circle' type='text' size='small' icon={<ReadOutlined />} />
|
|
|
|
</Tooltip>
|
|
|
|
<Tooltip title='已处理'>
|
|
|
|
<Button shape='circle' type='text' size='small' icon={<CheckSquareOutlined />} />
|
|
|
|
</Tooltip>
|
|
|
|
<Tooltip title='刷新'>
|
|
|
|
<Button shape='circle' type='text' size='small' icon={<ReloadOutlined />} />
|
|
|
|
</Tooltip>
|
|
|
|
</Flex>
|
|
|
|
<Input.Search
|
|
|
|
className=''
|
|
|
|
allowClear
|
|
|
|
onChange={(e) => {}}
|
|
|
|
onPressEnter={(e) => {
|
|
|
|
return false
|
|
|
|
}}
|
|
|
|
placeholder={`邮件主题`}
|
|
|
|
/>
|
|
|
|
<Tooltip title='高级搜索'>
|
|
|
|
<Switch checkedChildren={<ExpandOutlined />}
|
|
|
|
unCheckedChildren={<ExpandOutlined />} defaultChecked={false} />
|
|
|
|
</Tooltip>
|
|
|
|
</div>
|
|
|
|
<div className='bg-white h-auto p-1 flex gap-1 items-center hidden'>
|
|
|
|
<Form
|
|
|
|
form={form}
|
|
|
|
initialValues={{}}
|
|
|
|
// onFinish={handleSubmit}
|
|
|
|
>
|
|
|
|
<Row justify='start' gutter={16}>
|
|
|
|
<Col span={8}>
|
|
|
|
<Form.Item label='订单号' name='orderNumber'>
|
|
|
|
<Input placeholder='订单号' allowClear />
|
|
|
|
</Form.Item>
|
|
|
|
</Col>
|
|
|
|
<Col span={10}>
|
|
|
|
<Form.Item label='日期' name='confirmDateRange'>
|
|
|
|
<RangePicker allowClear={true} inputReadOnly={true} presets={DATE_RANGE_PRESETS} />
|
|
|
|
</Form.Item>
|
|
|
|
</Col>
|
|
|
|
<Col span={1} offset={1}>
|
|
|
|
<Button type='primary' htmlType='submit'>
|
|
|
|
搜索
|
|
|
|
</Button>
|
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
</Form>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className='bg-white overflow-y-auto' style={{ height: 'calc(100vh - 198px)' }}>
|
|
|
|
<List loading={isLoading}
|
|
|
|
header={
|
|
|
|
<Flex align='center' justify="space-between">
|
|
|
|
<Breadcrumb
|
|
|
|
items={
|
|
|
|
props.breadcrumb.map(bc => {
|
|
|
|
return {
|
|
|
|
title: (
|
|
|
|
<>
|
|
|
|
<MailboxDirIcon type={bc?.iconIndex} />
|
|
|
|
<span>{bc.title}</span>
|
|
|
|
</>
|
|
|
|
),
|
|
|
|
}
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
<Flex align="center" justify="space-between">
|
|
|
|
<span>1-50 of {mailList.length}</span>
|
|
|
|
<Button icon={<LeftOutlined />} type="text" iconPosition={'end'}></Button>
|
|
|
|
<Button icon={<RightOutlined />} type="text" iconPosition={'end'}></Button>
|
|
|
|
</Flex>
|
|
|
|
|
|
|
|
</Flex>
|
|
|
|
}
|
|
|
|
itemLayout='vertical'
|
|
|
|
pagination={false}
|
|
|
|
dataSource={pagedList}
|
|
|
|
renderItem={mailItemRender}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default MailBox
|