diff --git a/src/stores/AuthStore.js b/src/stores/AuthStore.js index fce5851..24943ee 100644 --- a/src/stores/AuthStore.js +++ b/src/stores/AuthStore.js @@ -3,8 +3,10 @@ import { devtools } from 'zustand/middleware' import { fetchJSON } from '@/utils/request' import { isEmpty, isNotEmpty } from '@/utils/commons' import { API_HOST, BUILD_VERSION } from '@/config' + export const PERM_MERGE_CONVERSATION = 'merge-conversation' export const PERM_ASSIGN_NEW_CONVERSATION = 'assign-new-conversation' +export const PERM_USE_EMAL = 'use-email' const useAuthStore = create(devtools((set, get) => ({ loginUser: { @@ -24,6 +26,10 @@ const useAuthStore = create(devtools((set, get) => ({ isPermitted: (perm) => { const { loginUser } = get() + if (perm === PERM_USE_EMAL) { + return ['599', '495', '143', '370', '639', '513', '654', '404', '383', '227'].includes(loginUser.userId) + } + if (perm === PERM_MERGE_CONVERSATION) { return ['404', '383', '227'].includes(loginUser.userId) } @@ -74,7 +80,7 @@ const useAuthStore = create(devtools((set, get) => ({ backup: item.Isbakemail == 1, } }), - // whatsAppBusiness: json.result.opicode, + whatsAppBusiness: json.result.whatsappinfo.length > 0 ? json.result.whatsappinfo[0].whatsapp_waba : '', accountName: json.result.opicode, username: json.result.nick, avatarUrl: json.result.avatarUrl, diff --git a/src/stores/OrderStore.js b/src/stores/OrderStore.js index d3ba617..009752e 100644 --- a/src/stores/OrderStore.js +++ b/src/stores/OrderStore.js @@ -132,7 +132,7 @@ export const useOrderStore = create(devtools((set, get) => ({ return fetchJSON(`${API_HOST}/generate_email_msg`, { coli_sn: orderId, coli_id: orderNumber }) .then(json => { if (json.errcode === 0) { - console.info(json) + return json } else { throw new Error(json?.errmsg + ': ' + json.errcode) } diff --git a/src/views/AuthApp.jsx b/src/views/AuthApp.jsx index d1e6ed2..003c120 100644 --- a/src/views/AuthApp.jsx +++ b/src/views/AuthApp.jsx @@ -1,7 +1,9 @@ import ErrorBoundary from '@/components/ErrorBoundary' import useAuthStore from '@/stores/AuthStore' -import useConversationStore from '@/stores/ConversationStore' import { useThemeContext } from '@/stores/ThemeContext' +import { Conditional } from '@/components/Conditional' +import useConversationStore from '@/stores/ConversationStore' +import { PERM_USE_EMAL } from '@/stores/AuthStore' import { App as AntApp, ConfigProvider, @@ -31,7 +33,9 @@ function AuthApp() { const [messageApi, contextHolder] = message.useMessage() const { colorPrimary, borderRadius } = useThemeContext() - const [loginUser, sendNotify] = useAuthStore((state) => [state.loginUser, state.sendNotify]) + const [loginUser, sendNotify, isPermitted] = useAuthStore((state) => [ + state.loginUser, state.sendNotify, state.isPermitted + ]) const href = useHref() @@ -53,7 +57,8 @@ function AuthApp() { loadPageSpy(loginUser.username) connectWebsocket(loginUser.userId) fetchInitialData(loginUser) - startEmailInterval(loginUser.userId) + + if (isPermitted(PERM_USE_EMAL)) startEmailInterval(loginUser.userId) } return () => { disconnectWebsocket() @@ -63,7 +68,7 @@ function AuthApp() { const startEmailInterval = (userId) => { setInterval(() => { getEmailFetchAction({opi_sn: userId}) - }, 1000*60) + }, 1000*10) } const uploadLog = () => { @@ -109,7 +114,10 @@ function AuthApp() { insetInlineEnd: 94, }} > - + } + /> } tooltip={
上传日志给研发部
} onClick={() => uploadLog()} /> diff --git a/src/views/orders/Follow.jsx b/src/views/orders/Follow.jsx index 010d765..dade7fc 100644 --- a/src/views/orders/Follow.jsx +++ b/src/views/orders/Follow.jsx @@ -1,9 +1,10 @@ import { Conditional } from '@/components/Conditional' import useAuthStore from '@/stores/AuthStore' +import { PERM_MERGE_CONVERSATION } from '@/stores/AuthStore' import useFormStore from '@/stores/FormStore' import { useOrderStore } from '@/stores/OrderStore' import { copy, isNotEmpty, isEmpty } from '@/utils/commons' -import { WhatsAppOutlined } from '@ant-design/icons' +import { WhatsAppOutlined, ImportOutlined } from '@ant-design/icons' import { App, Badge, Empty, @@ -21,6 +22,25 @@ import AdvanceSearchForm from './AdvanceSearchForm'; function OrderGroupTable({ formValues }) { + const handleImportEmail = useCallback((order) => { + importEmailMessage({ orderId: order.COLI_SN, orderNumber: order.COLI_ID }) + .then((result) => { + console.info(result) + notification.info({ + message: 'Notification', + description: '订单邮件消息导入成功', + placement: 'top', + }) + }) + .catch((ex) => + notification.error({ + message: 'Notification', + description: ex.message, + placement: 'top', + duration: 4, + })) + }, []) + const orderColumns = [ { title: '订单号', @@ -35,11 +55,14 @@ function OrderGroupTable({ formValues }) { return ( + } size='small' onClick={() => handleImportEmail(record)} />} + /> {text} {tagIcon} - ) } @@ -53,7 +76,7 @@ function OrderGroupTable({ formValues }) { return ( } /> {text + regularText} @@ -130,7 +153,9 @@ function OrderGroupTable({ formValues }) { const orderList = useOrderStore((state) => state.orderList) const fetchOrderList = useOrderStore((state) => state.fetchOrderList) const importEmailMessage = useOrderStore((state) => state.importEmailMessage) - const loginUser = useAuthStore((state) => state.loginUser) + const [loginUser, isPermitted] = useAuthStore((state) => [ + state.loginUser, state.isPermitted + ]) useEffect(() => { let canSearch = true