From 6ecdb549384a58cf4b04b0506295783db23875d3 Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Wed, 14 Aug 2024 09:16:48 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E4=BB=B7=E6=A0=BC=E5=90=8E=E7=AB=AF=E5=88=A0=E9=99=A4=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/Products/Index.js | 41 +++++++++++-------- .../products/Detail/ProductInfoQuotation.jsx | 10 ++--- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/src/stores/Products/Index.js b/src/stores/Products/Index.js index 618fb05..94c3cc2 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, generateId } from '@/utils/commons'; +import { groupBy, generateId, isEmpty } from '@/utils/commons'; export const searchAgencyAction = async (param) => { const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/products_search`, param); @@ -287,29 +287,34 @@ export const useProductsStore = create( return mergedList }, - deleteQuotationById: async(quotaionId) => { + deleteQuotation: async(quotation) => { const { editingProduct, quotationList, agencyProducts } = get() const productTypeId = editingProduct.info.product_type_id; + const quotationId = quotation.id const newList = quotationList.filter(q => { - return q.id != quotaionId + return q.key != quotation.key }) - const { result, success } = await deleteQuotationAction(quotaionId) - - if (success) { - set({ - agencyProducts: { - ...agencyProducts, - [productTypeId]: [{ - ...editingProduct, - quotation: newList - }] - }, - quotationList: newList - }) - return Promise.resolve(result) + set({ + agencyProducts: { + ...agencyProducts, + [productTypeId]: [{ + ...editingProduct, + quotation: newList + }] + }, + quotationList: newList + }) + + if (isEmpty(quotationId)) { + return Promise.resolve(newList) } else { - return Promise.reject(result) + const { result, success } = await deleteQuotationAction(quotationId) + if (success) { + return Promise.resolve(result) + } else { + return Promise.reject(result) + } } }, diff --git a/src/views/products/Detail/ProductInfoQuotation.jsx b/src/views/products/Detail/ProductInfoQuotation.jsx index f4b45df..940bb6b 100644 --- a/src/views/products/Detail/ProductInfoQuotation.jsx +++ b/src/views/products/Detail/ProductInfoQuotation.jsx @@ -144,8 +144,8 @@ const ProductInfoQuotation = ({ editable, ...props }) => { const datePresets = useDatePresets() - const [quotationList, newEmptyQuotation, appendQuotationList, saveOrUpdateQuotation, deleteQuotationById] = - useProductsStore((state) => [state.quotationList, state.newEmptyQuotation, state.appendQuotationList, state.saveOrUpdateQuotation, state.deleteQuotationById]) + const [quotationList, newEmptyQuotation, appendQuotationList, saveOrUpdateQuotation, deleteQuotation] = + useProductsStore((state) => [state.quotationList, state.newEmptyQuotation, state.appendQuotationList, state.saveOrUpdateQuotation, state.deleteQuotation]) const triggerChange = (changedValue) => { onChange?.( @@ -180,13 +180,13 @@ const ProductInfoQuotation = ({ editable, ...props }) => { setBatchSetupModalOpen(false) } - const onDeleteQuotation = (quotationId) => { + const onDeleteQuotation = (quotation) => { modal.confirm({ title: '请确认', icon: , content: '你要删除这条价格吗?', onOk() { - deleteQuotationById(quotationId) + deleteQuotation(quotation) .catch(ex => { notification.error({ message: 'Notification', @@ -236,7 +236,7 @@ const ProductInfoQuotation = ({ editable, ...props }) => { return ( - + ) }, From f33dfa2415c323679ef71a6ce6eaa950dd0de71b Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Wed, 14 Aug 2024 09:36:17 +0800 Subject: [PATCH 2/6] =?UTF-8?q?fix:=20=E6=96=B0=E5=A2=9E=E4=BB=B7=E6=A0=BC?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E9=BB=98=E8=AE=A4=E5=91=A8=E6=9C=AB=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/Products/Index.js | 2 +- src/views/products/Detail/ProductInfoQuotation.jsx | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/stores/Products/Index.js b/src/stores/Products/Index.js index 94c3cc2..add4d20 100644 --- a/src/stores/Products/Index.js +++ b/src/stores/Products/Index.js @@ -184,7 +184,7 @@ export const useProductsStore = create( dayjs().startOf('M'), dayjs().endOf('M') ], - weekdayList: ['5', '6'], + weekdayList: [], fresh: true // 标识是否是新记录,新记录才用添加列表 }), diff --git a/src/views/products/Detail/ProductInfoQuotation.jsx b/src/views/products/Detail/ProductInfoQuotation.jsx index 940bb6b..db85504 100644 --- a/src/views/products/Detail/ProductInfoQuotation.jsx +++ b/src/views/products/Detail/ProductInfoQuotation.jsx @@ -19,8 +19,6 @@ const batchSetupInitialValues = { 'unitId': '0', 'currency': 'RMB', 'weekend': [ - '5', - '6' ], 'priceList': [ { @@ -65,8 +63,6 @@ const batchSetupInitialValues = { 'unitId': '0', 'currency': 'RMB', 'weekend': [ - '5', - '6' ], 'priceList': [ { @@ -122,8 +118,6 @@ const defaultDefinitionValue = { 'unitId': '0', 'currency': 'RMB', 'weekend': [ - '5', - '6' ], 'priceList': [ defaultPriceValue From d65c12cb2c67d0c831510d50c5bedd54ac31b526 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Wed, 14 Aug 2024 10:01:51 +0800 Subject: [PATCH 3/6] =?UTF-8?q?fix:=20=E6=96=B0=E5=A2=9E=E4=BA=A7=E5=93=81?= =?UTF-8?q?:=20=E5=90=8D=E7=A7=B0=E5=A1=AB=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/products/Detail/NewProductModal.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/views/products/Detail/NewProductModal.jsx b/src/views/products/Detail/NewProductModal.jsx index 3319910..aa1f60b 100644 --- a/src/views/products/Detail/NewProductModal.jsx +++ b/src/views/products/Detail/NewProductModal.jsx @@ -75,6 +75,7 @@ export const NewProductModal = ({ initialValues }) => { const handelAddProduct = (param) => { const copyNewProduct = structuredClone(newProduct); copyNewProduct.info.title = param.title; + copyNewProduct.info.product_title = param.title; copyNewProduct.info.product_type_id = productsTypesMapVal[param.products_type.value].value; copyNewProduct.info.product_type_name = productsTypesMapVal[param.products_type.value].label; copyNewProduct.lgc_details[0].lgc = language; From 20bd547fd646d9836efb77fe7f49233da9540b49 Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Wed, 14 Aug 2024 10:16:34 +0800 Subject: [PATCH 4/6] 2.0.0-beta.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1154d5e..1806dcd 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "global-highlights-hub", "private": true, - "version": "2.0.0-beta.2", + "version": "2.0.0-beta.3", "type": "module", "scripts": { "dev": "vite", From 910c6c02af382fd173da53bc2cb27c1917a3c7c6 Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Wed, 14 Aug 2024 13:42:00 +0800 Subject: [PATCH 5/6] =?UTF-8?q?fix:=20=E5=88=A0=E9=99=A4=E4=BB=B7=E6=A0=BC?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E4=BA=A7=E5=93=81=E5=8F=AA=E5=89=A9=E4=B8=80?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/Products/Index.js | 38 ++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/stores/Products/Index.js b/src/stores/Products/Index.js index add4d20..6e489f5 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, generateId, isEmpty } from '@/utils/commons'; +import { groupBy, generateId, isNotEmpty } from '@/utils/commons'; export const searchAgencyAction = async (param) => { const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/products_search`, param); @@ -291,31 +291,39 @@ export const useProductsStore = create( const { editingProduct, quotationList, agencyProducts } = get() const productTypeId = editingProduct.info.product_type_id; const quotationId = quotation.id - const newList = quotationList.filter(q => { + const newQuotationList = quotationList.filter(q => { return q.key != quotation.key }) + const newProductList = agencyProducts[productTypeId].map(p => { + if (p.info.id == editingProduct.info.id) { + return { + ...editingProduct, + quotation: newQuotationList + } + } else { + return p + } + }) + set({ agencyProducts: { ...agencyProducts, - [productTypeId]: [{ - ...editingProduct, - quotation: newList - }] + [productTypeId]: newProductList }, - quotationList: newList + quotationList: newQuotationList }) - if (isEmpty(quotationId)) { - return Promise.resolve(newList) - } else { - const { result, success } = await deleteQuotationAction(quotationId) - if (success) { - return Promise.resolve(result) - } else { - return Promise.reject(result) + let promiseDelete = Promise.resolve(newQuotationList) + + if (isNotEmpty(quotationId)) { + const { result, success } = await deleteQuotationAction('quotationId') + if (!success) { + promiseDelete = Promise.reject(result) } } + + return promiseDelete }, // side effects From 2f7184d83747d72981951770a4025b0334d94b80 Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Wed, 14 Aug 2024 13:45:09 +0800 Subject: [PATCH 6/6] =?UTF-8?q?fix:=20=E5=8F=96=E6=B6=88=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=BB=B7=E6=A0=BC=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/Products/Index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stores/Products/Index.js b/src/stores/Products/Index.js index 6e489f5..42395ba 100644 --- a/src/stores/Products/Index.js +++ b/src/stores/Products/Index.js @@ -317,7 +317,7 @@ export const useProductsStore = create( let promiseDelete = Promise.resolve(newQuotationList) if (isNotEmpty(quotationId)) { - const { result, success } = await deleteQuotationAction('quotationId') + const { result, success } = await deleteQuotationAction(quotationId) if (!success) { promiseDelete = Promise.reject(result) }