From e0de46c46954e5673ec8afaa3c076899b0b1826e Mon Sep 17 00:00:00 2001 From: xuan Date: Mon, 31 Oct 2022 12:48:08 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix(=E8=B4=AD=E7=89=A9=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2):=20=E4=BF=AE=E5=A4=8D=E8=B4=AD=E7=89=A9=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E5=86=8D=E6=AC=A1=E5=88=A0=E9=99=A4=E5=95=86=E5=93=81?= =?UTF-8?q?=E6=97=B6=E8=AF=B7=E6=B1=82=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/shoppingCartItem/index.tsx | 26 ++++++++++++------- src/pages/shopping/index.tsx | 11 +++++++- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/pages/shopping/components/shoppingCartItem/index.tsx b/src/pages/shopping/components/shoppingCartItem/index.tsx index 9af7f46..c448f41 100644 --- a/src/pages/shopping/components/shoppingCartItem/index.tsx +++ b/src/pages/shopping/components/shoppingCartItem/index.tsx @@ -157,6 +157,11 @@ let ShoppingCartItem: FC = props => { }) console.log('res===>', res) if (res.success) { + // 转成 对象形式 + // 4562: { + // id: 4562, + // ... + // } const newGoodsKind = Object.fromEntries( res.data[0]?.[BackEndSaleModeListFieldMap[selected]].map(item => [ item?.id, @@ -176,17 +181,18 @@ let ShoppingCartItem: FC = props => { purchaserId: id, goodsKind: newGoodsKind, multipleSelection: Object.fromEntries( - Object.keys(multipleSelection!).map(id => [ - id, - { + Object.keys(multipleSelection!) + .map(id => [ id, - estimate_amount: newGoodsKind[id].estimate_amount, - product_code: newGoodsKind[id].product_code, - product_color_code: newGoodsKind[id].product_color_code, - sale_mode: newGoodsKind[id].sale_mode, - count: selected === EnumSaleMode.Bulk ? newGoodsKind[id].roll : Number(formatMeterDiv(newGoodsKind[id].length)), - }, - ]), + { + id, + estimate_amount: newGoodsKind[id].estimate_amount, + product_code: newGoodsKind[id].product_code, + product_color_code: newGoodsKind[id].product_color_code, + sale_mode: newGoodsKind[id].sale_mode, + count: selected === EnumSaleMode.Bulk ? newGoodsKind[id].roll : Number(formatMeterDiv(newGoodsKind[id].length)), + }, + ]), ), }, }) diff --git a/src/pages/shopping/index.tsx b/src/pages/shopping/index.tsx index 7306914..c4b94bd 100644 --- a/src/pages/shopping/index.tsx +++ b/src/pages/shopping/index.tsx @@ -151,7 +151,7 @@ const ShoppingCartContainer: FC = () => { // 批量某个客户的删除商品 const handleDelete = async () => { - const multipleSelection = colorStore?.[currentCheckedPurchaserId]?.['multipleSelection'] + const multipleSelection = colorStore?.[currentCheckedPurchaserId].multipleSelection let checked: Goods[] = Object.values(multipleSelection!) if (checked.length === 0) { return Taro.showToast({ title: '请选择商品', icon: 'error' }) @@ -166,6 +166,15 @@ const ShoppingCartContainer: FC = () => { }) if (res.success) { alert.success('删除成功') + // 清空多选 + dispatch({ + type: ShoppingDispatchType.UPDATE_CHANGED_CHECKBOX, + data: { + purchaserId: currentCheckedPurchaserId, + goodsKind: colorStore?.[currentCheckedPurchaserId].goodsKind, + multipleSelection: {}, + }, + }) fetchData(searchOptions) // Observer.notify(currentCheckedPurchaserId) } else {