From 3658ca25a72f4e3065f5319fd91640a7e02f6dfe Mon Sep 17 00:00:00 2001 From: xuan Date: Mon, 20 Feb 2023 11:27:08 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix(ID1001240):=20=E3=80=90?= =?UTF-8?q?=E5=86=85=E9=83=A8=E5=95=86=E5=9F=8E=E3=80=91-=E8=B4=AD?= =?UTF-8?q?=E7=89=A9=E9=A1=B5=E9=9D=A2{-=E5=88=97=E8=A1=A8}=EF=BC=9A?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E9=87=8D=E5=A4=8D=E5=AE=A2=E6=88=B7=E9=A1=B9?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【【内部商城】-购物页面{-列表}:出现重复客户项的问题】 https://www.tapd.cn/53459131/bugtrace/bugs/view/1153459131001001240 --- src/common/constant.ts | 4 +- .../components/shoppingCartItem/index.tsx | 78 ++++++------------- 2 files changed, 24 insertions(+), 58 deletions(-) diff --git a/src/common/constant.ts b/src/common/constant.ts index f195e5f..850aed6 100644 --- a/src/common/constant.ts +++ b/src/common/constant.ts @@ -1,4 +1,4 @@ -// export const BASE_URL = CURRENT_BASE_URL +export const BASE_URL = CURRENT_BASE_URL // export const BASE_URL = `http://192.168.0.75:50001/lymarket` // export const BASE_URL = `http://192.168.0.89:50001/lymarket` // export const BASE_URL = `http://10.0.0.5:50001/lymarket` @@ -15,7 +15,7 @@ // export const BASE_URL = 'http://192.168.1.7:50002/lymarket' // 添 // export const BASE_URL = 'http://192.168.1.42:50002/lymarket' // 杰 // export const BASE_URL = `http://192.168.1.95:40001/lymarket` // 华 -export const BASE_URL = 'http://192.168.1.28:50001/lymarket' // 婷 +// export const BASE_URL = 'http://192.168.1.28:50001/lymarket' // 婷 // CDN // 生成密钥 diff --git a/src/pages/shopping/components/shoppingCartItem/index.tsx b/src/pages/shopping/components/shoppingCartItem/index.tsx index 9471941..2e5c9cb 100644 --- a/src/pages/shopping/components/shoppingCartItem/index.tsx +++ b/src/pages/shopping/components/shoppingCartItem/index.tsx @@ -66,48 +66,13 @@ interface GoodsListPropType { } const GoodsList = (props: GoodsListPropType) => { const { itemData, selected, isPending, startTransition, multipleSelection } = props - console.log('rerender component GoodsList', props) + console.log('rerender component GoodsList', props, props.itemData?.purchaser_name) // const prevMultipleSelection = useRef(multipleSelection) const currentSelected = useRef(null) const dispatch = useShoppingDispatch() const [component, setComponent] = useState(null) - // 使用 produce 更新特定的 ColorKindItem - // const updateSpecifiedComponent = () => { - // let newId - // if (multipleSelection && prevMultipleSelection.current !== multipleSelection) { - // for (const key in multipleSelection) { - // if (!prevMultipleSelection.current?.hasOwnProperty(key)) { - // newId = key - // break - // } - // } - // } - // console.log('multipleSelection==+>', multipleSelection) - // console.log('currentSelected', currentSelected.current, selected) - // console.log('component', component) - // if (component) { - // if (itemData?.[BackEndSaleModeListFieldMap[selected]].length !== 0) { - // setComponent(produce(component, (draft) => { - // console.log('prev', component) - // const index = (draft as unknown as any[]).findIndex(item => item.key === newId) - // console.log('index', index) - // if (index !== -1) { - // const item = itemData?.[BackEndSaleModeListFieldMap[selected]].find((item) => { - // return item.id === Number(newId) - // }) - // console.log('item', item, newId) - // draft![index] = - // } - // })) - // } - // else { - // setComponent(暂无数据) - // } - // } - // prevMultipleSelection.current = multipleSelection - // } // 更新 GoodsList 组件 const updateComponent = () => { setComponent( @@ -194,9 +159,11 @@ interface PropsType { const ShoppingCartItem: FC = (props) => { const { state } = props - console.log('rerender component ShoppingCartItem', props) + console.log('rerender component ShoppingCartItem', props, props.itemData?.purchaser_name) const currentItemData = useRef(props.itemData) + // 即使更新 useRef 的数据 不然拿到的还是旧数据 + currentItemData.current = props.itemData const [itemData, setItemData] = usePropsValue({ value: currentItemData.current, @@ -279,11 +246,7 @@ const ShoppingCartItem: FC = (props) => { }, [colorStore, currentCheckedPurchaserId, selected, itemData]) const { fetchData } = ShoppingCartListApi() - useEffect(() => { - if (itemData?.purchaser_id === 1709) { - console.log('useEffect multipleSelection', multipleSelection, colorStore) - } - }, [itemData, multipleSelection, colorStore]) + // 更新当前客户的多选项 const updatePurchaserMultipleSelection = (purchaserId: number, payload: Goods, operationType: OperationType, goodsId: number) => { console.log('delete', colorStore, purchaserId) @@ -391,9 +354,11 @@ const ShoppingCartItem: FC = (props) => { {itemData?.purchaser_name} - - {itemData?.sale_user_name} - + { + itemData?.sale_user_name && + {itemData?.sale_user_name} + + } @@ -468,19 +433,20 @@ const withStateSlice = (comp, slice) => { const MemoComp = memo(comp, (prevProps, nextProps) => { let needMemo = true if (JSON.stringify(prevProps.itemData) !== JSON.stringify(nextProps.itemData)) { + console.log('itemData 有变化') needMemo = false } - // if (prevProps.itemData.purchaser_name === 'JENNIE') { - // console.log('------withStateSlice props-------') - // console.log('withStateSlice props prevProps', prevProps) - // console.log('withStateSlice props prevProps comparison itemData', prevProps.itemData === nextProps.itemData) - // console.log('withStateSlice props nextProps', nextProps) - // console.log('withStateSlice props prevProps comparison multipleSelection', prevProps.state.multipleSelection === nextProps.state.multipleSelection) - // console.log('withStateSlice props prevProps comparison currentCheckedPurchaserId', prevProps.state.currentCheckedPurchaserId === nextProps.state.currentCheckedPurchaserId) - // console.log('withStateSlice props prevProps comparison Observer', prevProps.state.Observer === nextProps.state.Observer) - // console.log('withStateSlice props prevProps comparison state', prevProps.state === nextProps.state) - // console.log('------withStateSlice props-------') - // } + if (prevProps.itemData.purchaser_name === '皮特织业') { + console.log('------withStateSlice props-------') + console.log('withStateSlice props prevProps', prevProps) + console.log('withStateSlice props prevProps comparison itemData', prevProps.itemData === nextProps.itemData) + console.log('withStateSlice props nextProps', nextProps) + console.log('withStateSlice props prevProps comparison multipleSelection', prevProps.state.multipleSelection === nextProps.state.multipleSelection) + console.log('withStateSlice props prevProps comparison currentCheckedPurchaserId', prevProps.state.currentCheckedPurchaserId === nextProps.state.currentCheckedPurchaserId) + console.log('withStateSlice props prevProps comparison Observer', prevProps.state.Observer === nextProps.state.Observer) + console.log('withStateSlice props prevProps comparison state', prevProps.state === nextProps.state) + console.log('------withStateSlice props-------') + } if (prevProps.state.Observer !== nextProps.state.Observer) { console.log('Observer 有变化') needMemo = false