From 8dbedbcf38c3da5b72c6ec3c558030d9cb22a568 Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Wed, 7 Aug 2024 09:38:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=A0=E9=99=A4=E4=BB=B7=E6=A0=BC?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E5=90=8C=E6=97=B6=E6=9B=B4=E6=96=B0=20State?= =?UTF-8?q?=20=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/Products/Index.js | 18 +++++++++++++----- .../products/Detail/ProductInfoQuotation.jsx | 1 - 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/stores/Products/Index.js b/src/stores/Products/Index.js index e868754..b22dd87 100644 --- a/src/stores/Products/Index.js +++ b/src/stores/Products/Index.js @@ -3,7 +3,7 @@ import { devtools } from 'zustand/middleware'; import dayjs from 'dayjs' import { fetchJSON, postForm, postJSON } from '@/utils/request'; import { HT_HOST } from '@/config'; -import { groupBy, isEmpty, generateId } from '@/utils/commons'; +import { groupBy, generateId } from '@/utils/commons'; export const searchAgencyAction = async (param) => { const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/products_search`, param); @@ -287,15 +287,23 @@ export const useProductsStore = create( }, deleteQuotation: (quotaionId) => { - const { quotationList } = get() + const { editingProduct, quotationList, agencyProducts } = get() + const productTypeId = editingProduct.info.product_type_id; const newList = quotationList.filter(q => { return q.id != quotaionId }) deleteQuotationAction(quotaionId) - set(() => ({ - // 还要设置回 product.quotaion 对象 + + set({ + agencyProducts: { + ...agencyProducts, + [productTypeId]: [{ + ...editingProduct, + quotation: newList + }] + }, quotationList: newList - })) + }) }, // side effects diff --git a/src/views/products/Detail/ProductInfoQuotation.jsx b/src/views/products/Detail/ProductInfoQuotation.jsx index bf59a0a..c21b744 100644 --- a/src/views/products/Detail/ProductInfoQuotation.jsx +++ b/src/views/products/Detail/ProductInfoQuotation.jsx @@ -5,7 +5,6 @@ import { CloseOutlined, StarTwoTone, PlusOutlined, ExclamationCircleFilled } fro import { useDatePresets } from '@/hooks/useDatePresets' import dayjs from 'dayjs' import useProductsStore from '@/stores/Products/Index' -import { generateId } from '@/utils/commons' const { RangePicker } = DatePicker