You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.5 KiB
JavaScript
44 lines
1.5 KiB
JavaScript
import { useMemo } from 'react'
|
|
import { App, Dropdown } from 'antd'
|
|
import useConversationStore from '@/stores/ConversationStore'
|
|
import { emailTemplates, openPopup } from '@/hooks/useEmail'
|
|
import { isEmpty } from '@/utils/commons'
|
|
|
|
const NewEmailButton = ({ ...props }) => {
|
|
const { notification } = App.useApp()
|
|
const [mailboxActiveNode] = useConversationStore((state) => [state.mailboxActiveNode])
|
|
const [mailboxActiveCOLI] = useConversationStore((state) => [state.mailboxActiveCOLI])
|
|
|
|
const COLI_SN = useMemo(() => mailboxActiveCOLI || mailboxActiveNode?.COLI_SN || 0, [mailboxActiveNode.COLI_SN, mailboxActiveCOLI])
|
|
const handleTemplateDropdown = ({ key, domEvent }) => {
|
|
if (isEmpty(COLI_SN)) {
|
|
notification.warning({ message: '无法绑定订单', description: '请先选择到订单目录或订单邮件', placement: 'top' })
|
|
return false
|
|
}
|
|
openPopup(`/email/new/0/${COLI_SN}/${key}`, `new-0-${COLI_SN}-${key}`)
|
|
}
|
|
|
|
const handleNewEmail = () => {
|
|
openPopup(`/email/new/0/${COLI_SN}`, `new-0-${COLI_SN}`)
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<Dropdown.Button
|
|
size='small'
|
|
className={`w-auto ${props.className}`}
|
|
placement='bottom'
|
|
arrow
|
|
type={'primary'}
|
|
menu={{
|
|
items: emailTemplates,
|
|
onClick: handleTemplateDropdown,
|
|
}}
|
|
onClick={handleNewEmail}>
|
|
新邮件
|
|
</Dropdown.Button>
|
|
</>
|
|
)
|
|
}
|
|
export default NewEmailButton
|