From ef0a52f6580c8f12d0e12206dc2b9a2b2ee55c14 Mon Sep 17 00:00:00 2001 From: xuan Date: Wed, 22 Mar 2023 17:06:11 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix(=E8=B4=AD=E7=89=A9=E8=BD=A6)?= =?UTF-8?q?:=20=E4=BF=AE=E5=A4=8D=E5=85=A8=E9=80=89=E6=97=B6=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/constant.ts | 4 +-- src/pages/shopping/index.tsx | 47 +++++++++++++++++++++++++++++++----- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/src/common/constant.ts b/src/common/constant.ts index 038e44e..c305c85 100644 --- a/src/common/constant.ts +++ b/src/common/constant.ts @@ -4,8 +4,8 @@ // export const BASE_URL = `http://10.0.0.5:50001/lymarket` // export const BASE_URL = `http://192.168.0.89:40001/lymarket` // export const BASE_URL = `http://192.168.1.165:40001/lymarket` // 王霞 -export const BASE_URL = 'https://test.zzfzyc.com/lymarket' // 测试环境 -// export const BASE_URL = 'https://pre.zzfzyc.com/lymarket' // 预发布 +// export const BASE_URL = 'https://test.zzfzyc.com/lymarket' // 测试环境 +export const BASE_URL = 'https://pre.zzfzyc.com/lymarket' // 预发布 // export const BASE_URL = `http://192.168.1.9:40001/lymarket` // 发 // export const BASE_URL = `http://192.168.1.9:50005/lymarket` // 发 // export const BASE_URL = `http://192.168.1.30:50001/lymarket` // 发 diff --git a/src/pages/shopping/index.tsx b/src/pages/shopping/index.tsx index 0d2eaaf..c17e1f3 100644 --- a/src/pages/shopping/index.tsx +++ b/src/pages/shopping/index.tsx @@ -13,11 +13,12 @@ import { ShoppingDispatchType, useShoppingDispatch, useShoppingState } from './c import { events } from './context/shoppingStore' import { dataLoadingStatus, debounce, getFilterData } from '@/common/util' import { ShoppingCartDeleteApi, ShoppingCartListApi } from '@/api/index' -import { formatPriceDiv } from '@/common/format' +import { formatMeterDiv, formatPriceDiv } from '@/common/format' import InfiniteScroll from '@/components/infiniteScroll' import IconText from '@/components/iconText' import Search from '@/components/search' import { alert, goLink, isEmptyObject } from '@/common/common' +import { EnumSaleMode } from '@/common/Enumerate' interface SearchOptions { short_name_or_phone?: string @@ -147,18 +148,38 @@ const ShoppingCartContainer: FC = () => { async success(res) { if (res.confirm) { alert.showLoading('删除中') + const checkedIds = checked.map(item => item.id) const res = await deleteApi({ - ids: checked.map(item => item.id).join(','), + ids: checkedIds.join(','), }) if (res.success) { alert.hideLoading() alert.success('删除成功') + console.log('colorStore?.[currentCheckedPurchaserId]', colorStore?.[currentCheckedPurchaserId]) + let goodsKind = colorStore?.[currentCheckedPurchaserId].goodsKind + if (goodsKind) { + goodsKind = Object.fromEntries( + Object.values(goodsKind).filter(value => !checkedIds.includes(value.id)) + .map(value => [ + value.id, + { + id: value.id, + estimate_amount: value.estimate_amount, + product_code: value.product_code, + product_color_code: value.product_color_code, + sale_mode: value.sale_mode, + count: value.count, + }, + ], + )) + } + console.log('goodsKind', goodsKind) // 清空多选 dispatch({ type: ShoppingDispatchType.UPDATE_CHANGED_CHECKBOX, data: { purchaserId: currentCheckedPurchaserId, - goodsKind: colorStore?.[currentCheckedPurchaserId].goodsKind, + goodsKind, multipleSelection: {}, }, }) @@ -177,10 +198,24 @@ const ShoppingCartContainer: FC = () => { } // 全选 const handleSelectAllCheckbox = (isSelectAll: boolean) => { - const targetGoodsKind = colorStore?.[currentCheckedPurchaserId].goodsKind - if (!targetGoodsKind) { return alert.error('请先选择客户') } + if (!currentCheckedPurchaserId) { return alert.error('请先选择客户') } - const tempObject = { ...targetGoodsKind } + const targetGoodsKind = shoppingCartData.list.find(item => item.purchaser_id === currentCheckedPurchaserId)?.[BackEndSaleModeListFieldMap[currentCheckedSaleMode]] + + const tempObject: Record = Object.fromEntries( + targetGoodsKind.map(item => [ + item?.id, + { + id: item?.id, + estimate_amount: item.estimate_amount, + product_code: item.product_code, + product_color_code: item.product_color_code, + sale_mode: item.sale_mode, + count: currentCheckedSaleMode === EnumSaleMode.Bulk ? item.roll : Number(formatMeterDiv(item.length)), + }, + ]), + ) + console.log('handleSelectAllCheckbox', tempObject) dispatch({ type: ShoppingDispatchType.UPDATE_CHANGED_CHECKBOX, data: {