From 89e365d89a418e070f681e62ea224f1658c79cd1 Mon Sep 17 00:00:00 2001 From: LiaoYijun Date: Wed, 11 Dec 2024 14:51:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E9=82=AE=E4=BB=B6=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/OrderStore.js | 21 ++++++ src/views/orders/Follow.jsx | 144 +++++++++++++++++------------------- 2 files changed, 87 insertions(+), 78 deletions(-) diff --git a/src/stores/OrderStore.js b/src/stores/OrderStore.js index 009752e..a9651fc 100644 --- a/src/stores/OrderStore.js +++ b/src/stores/OrderStore.js @@ -139,6 +139,27 @@ export const useOrderStore = create(devtools((set, get) => ({ }) }, + batchImportEmailMessage: () => { + const { orderList } = get() + + const orderPromiseList = orderList.map(order => { + return new Promise((resolve, reject) => { + fetchJSON(`${API_HOST}/generate_email_msg`, { coli_sn: order.COLI_SN, coli_id: order.COLI_ID }) + .then(json => { + if (json.errcode === 0) { + resolve(json) + } else { + reject(json?.errmsg + ': ' + json.errcode) + } + }) + }) + }) + + Promise.all(orderPromiseList).then((values) => { + console.log(values); + }) + }, + fetchOtherEmail: (coli_sn) => { return fetchJSON(`${EMAIL_HOST}/email_supplier`, { coli_sn }) .then(json => { diff --git a/src/views/orders/Follow.jsx b/src/views/orders/Follow.jsx index 8aae0c1..e09f4a8 100644 --- a/src/views/orders/Follow.jsx +++ b/src/views/orders/Follow.jsx @@ -5,23 +5,15 @@ import useFormStore from '@/stores/FormStore' import { useOrderStore } from '@/stores/OrderStore' import { copy, isNotEmpty, isEmpty } from '@/utils/commons' import { WhatsAppOutlined, ImportOutlined } from '@ant-design/icons' -import { - App, Badge, - Empty, - Flex,Button, - Radio, Space, Switch, Table, - Tabs, Divider, - Tag, Tooltip -} from 'antd' +import { App, Badge, Empty, Flex, Button, Radio, Space, Switch, Table, Tabs, Divider, Tag, Tooltip } from 'antd' import dayjs from 'dayjs' import { useCallback, useEffect, useState } from 'react' import { Link } from 'react-router-dom' import { useShallow } from 'zustand/react/shallow' -import { UNREAD_MARK } from '@/actions/ConversationActions'; -import AdvanceSearchForm from './AdvanceSearchForm'; +import { UNREAD_MARK } from '@/actions/ConversationActions' +import AdvanceSearchForm from './AdvanceSearchForm' function OrderGroupTable({ formValues }) { - const handleImportEmail = useCallback((order) => { importEmailMessage({ orderId: order.COLI_SN, orderNumber: order.COLI_ID }) .then((r) => { @@ -38,7 +30,8 @@ function OrderGroupTable({ formValues }) { description: ex.message, placement: 'top', duration: 4, - })) + }), + ) }, []) const orderColumns = [ @@ -57,7 +50,7 @@ function OrderGroupTable({ formValues }) { } size='small' onClick={() => handleImportEmail(record)} />} + whenTrue={