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: {