From 71b4142dc8315370f62a4fcad52a483dd6a172e9 Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Fri, 1 Mar 2024 16:44:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=AE=A2=E5=8D=95=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E8=AE=BE=E7=BD=AE=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/OrderStore.js | 29 +++++++++++++------ .../Components/CustomerProfile.jsx | 2 -- src/views/OrderFollow.jsx | 4 +-- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/stores/OrderStore.js b/src/stores/OrderStore.js index 87fc156..855d318 100644 --- a/src/stores/OrderStore.js +++ b/src/stores/OrderStore.js @@ -4,7 +4,7 @@ import { API_HOST } from '@/config' const useOrderStore = create((set, get) => ({ - orderData: [], + orderList: [], orderDetail: {}, customerDetail: {}, lastQuotation: {}, @@ -51,21 +51,16 @@ const useOrderStore = create((set, get) => ({ .then(json => { if (json.errcode === 0) { set(() => ({ - orderData: json.result.map((order) => { return { ...order, key: order.COLI_ID } }), + orderList: json.result.map((order) => { return { ...order, key: order.COLI_ID } }), })) } else { throw new Error(json?.errmsg + ': ' + json.errcode) } }) - // .finally(() => setLoading(false)) - .catch(reason => { - throw new Error(reason.message) - }) }, fetchOrderDetail: async (colisn) => { - const { orderDetail, updateQuotation } = get() const json = await fetchJSON(`${API_HOST}/getorderinfo`, { colisn }) if (json.errcode === 0 && json.result.length > 0) { const orderResult = json.result[0] @@ -74,13 +69,29 @@ const useOrderStore = create((set, get) => ({ customerDetail: orderResult.contact.length > 0 ? orderResult.contact[0] : {}, lastQuotation: orderResult.quotes.length > 0 ? orderResult.quotes[0] : {}, quotationList: orderResult.quotes, - })) + })) } }, setOrderPropValue: async (colisn, propName, value) => { const json = await fetchJSON(`${API_HOST}/setorderstatus`, { colisn, stype: propName, svalue: value }) - console.info(json) + if (propName === 'orderlabel') { + set((state) => ({ + orderDetail: { + ...state.orderDetail, + tags: value + } + })) + } + + if (propName === 'orderstatus') { + set((state) => ({ + orderDetail: { + ...state.orderDetail, + states: value + } + })) + } }, })) diff --git a/src/views/Conversations/Components/CustomerProfile.jsx b/src/views/Conversations/Components/CustomerProfile.jsx index b59600b..36833ee 100644 --- a/src/views/Conversations/Components/CustomerProfile.jsx +++ b/src/views/Conversations/Components/CustomerProfile.jsx @@ -31,7 +31,6 @@ const CustomerProfile = (() => { }} variant='borderless' onSelect={(value) => { - console.info(value) setOrderPropValue(order_sn, 'orderlabel', value) }} value={orderDetail.tags} @@ -48,7 +47,6 @@ const CustomerProfile = (() => { }} variant='borderless' onSelect={(value) => { - console.info(value) setOrderPropValue(order_sn,'orderstatus', value) }} value={orderDetail.states} diff --git a/src/views/OrderFollow.jsx b/src/views/OrderFollow.jsx index a5aa68a..67bd124 100644 --- a/src/views/OrderFollow.jsx +++ b/src/views/OrderFollow.jsx @@ -204,7 +204,7 @@ function OrderCollapseTable({ formValues }) { ] const { notification } = App.useApp() const [loading, setLoading] = useState(false) - const { orderData, fetchOrderList } = useOrderStore() + const { orderList, fetchOrderList } = useOrderStore() const { loginUser } = useAuthStore() useEffect(() => { @@ -268,7 +268,7 @@ function OrderCollapseTable({ formValues }) { ['35', 'newsletter营销'], ]) - const groupOrderData = groupByParam(orderData, 'OPI_DEI_SN') + const groupOrderData = groupByParam(orderList, 'OPI_DEI_SN') const deptKeys = Object.keys(groupOrderData) const collapseItems = []