🐞 fix(ID1001240): 【内部商城】-购物页面{-列表}:出现重复客户项的问题

【【内部商城】-购物页面{-列表}:出现重复客户项的问题】 https://www.tapd.cn/53459131/bugtrace/bugs/view/1153459131001001240
This commit is contained in:
xuan 2023-02-20 11:27:08 +08:00
parent 5eff74a9a1
commit 3658ca25a7
2 changed files with 24 additions and 58 deletions

View File

@ -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.75:50001/lymarket`
// export const BASE_URL = `http://192.168.0.89:50001/lymarket` // export const BASE_URL = `http://192.168.0.89:50001/lymarket`
// export const BASE_URL = `http://10.0.0.5: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.7:50002/lymarket' // 添
// export const BASE_URL = 'http://192.168.1.42: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.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 // CDN
// 生成密钥 // 生成密钥

View File

@ -66,48 +66,13 @@ interface GoodsListPropType {
} }
const GoodsList = (props: GoodsListPropType) => { const GoodsList = (props: GoodsListPropType) => {
const { itemData, selected, isPending, startTransition, multipleSelection } = props 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 prevMultipleSelection = useRef(multipleSelection)
const currentSelected = useRef<EnumSaleMode | null>(null) const currentSelected = useRef<EnumSaleMode | null>(null)
const dispatch = useShoppingDispatch() const dispatch = useShoppingDispatch()
const [component, setComponent] = useState<JSX.Element | null>(null) const [component, setComponent] = useState<JSX.Element | null>(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] = <ColorKindItem checked={multipleSelection?.hasOwnProperty(newId)} purchaserId={itemData?.purchaser_id} key={newId} itemData={item}></ColorKindItem>
// }
// }))
// }
// else {
// setComponent(<View className={styles.noList}>暂无数据</View>)
// }
// }
// prevMultipleSelection.current = multipleSelection
// }
// 更新 GoodsList 组件 // 更新 GoodsList 组件
const updateComponent = () => { const updateComponent = () => {
setComponent( setComponent(
@ -194,9 +159,11 @@ interface PropsType {
const ShoppingCartItem: FC<PropsType> = (props) => { const ShoppingCartItem: FC<PropsType> = (props) => {
const { state } = props const { state } = props
console.log('rerender component ShoppingCartItem', props) console.log('rerender component ShoppingCartItem', props, props.itemData?.purchaser_name)
const currentItemData = useRef<ShoppingCartData | undefined>(props.itemData) const currentItemData = useRef<ShoppingCartData | undefined>(props.itemData)
// 即使更新 useRef 的数据 不然拿到的还是旧数据
currentItemData.current = props.itemData
const [itemData, setItemData] = usePropsValue({ const [itemData, setItemData] = usePropsValue({
value: currentItemData.current, value: currentItemData.current,
@ -279,11 +246,7 @@ const ShoppingCartItem: FC<PropsType> = (props) => {
}, [colorStore, currentCheckedPurchaserId, selected, itemData]) }, [colorStore, currentCheckedPurchaserId, selected, itemData])
const { fetchData } = ShoppingCartListApi() 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) => { const updatePurchaserMultipleSelection = (purchaserId: number, payload: Goods, operationType: OperationType, goodsId: number) => {
console.log('delete', colorStore, purchaserId) console.log('delete', colorStore, purchaserId)
@ -391,9 +354,11 @@ const ShoppingCartItem: FC<PropsType> = (props) => {
<View className={styles.topItem}> <View className={styles.topItem}>
<View className="flex-row items-center"> <View className="flex-row items-center">
<View className={styles.topTitle}>{itemData?.purchaser_name}</View> <View className={styles.topTitle}>{itemData?.purchaser_name}</View>
<Tag type="info" size="normal" circle customStyle={{ backgroundColor: '#f0f0f0', borderColor: 'transparent' }} plain> {
{itemData?.sale_user_name} itemData?.sale_user_name && <Tag type="info" size="normal" circle customStyle={{ backgroundColor: '#f0f0f0', borderColor: 'transparent' }} plain>
</Tag> {itemData?.sale_user_name}
</Tag>
}
</View> </View>
<View className={styles.summary}> <View className={styles.summary}>
<Text> <Text>
@ -468,19 +433,20 @@ const withStateSlice = (comp, slice) => {
const MemoComp = memo(comp, (prevProps, nextProps) => { const MemoComp = memo(comp, (prevProps, nextProps) => {
let needMemo = true let needMemo = true
if (JSON.stringify(prevProps.itemData) !== JSON.stringify(nextProps.itemData)) { if (JSON.stringify(prevProps.itemData) !== JSON.stringify(nextProps.itemData)) {
console.log('itemData 有变化')
needMemo = false needMemo = false
} }
// if (prevProps.itemData.purchaser_name === 'JENNIE') { if (prevProps.itemData.purchaser_name === '皮特织业') {
// console.log('------withStateSlice props-------') console.log('------withStateSlice props-------')
// console.log('withStateSlice props prevProps', prevProps) console.log('withStateSlice props prevProps', prevProps)
// console.log('withStateSlice props prevProps comparison itemData', prevProps.itemData === nextProps.itemData) console.log('withStateSlice props prevProps comparison itemData', prevProps.itemData === nextProps.itemData)
// console.log('withStateSlice props nextProps', nextProps) 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 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 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 Observer', prevProps.state.Observer === nextProps.state.Observer)
// console.log('withStateSlice props prevProps comparison state', prevProps.state === nextProps.state) console.log('withStateSlice props prevProps comparison state', prevProps.state === nextProps.state)
// console.log('------withStateSlice props-------') console.log('------withStateSlice props-------')
// } }
if (prevProps.state.Observer !== nextProps.state.Observer) { if (prevProps.state.Observer !== nextProps.state.Observer) {
console.log('Observer 有变化') console.log('Observer 有变化')
needMemo = false needMemo = false