🐞 fix(ID1001585): 【内部商城】-功能{-购物车}:选择全部删除面料,提示无法删除面料
【【内部商城】-功能{-购物车}:选择全部删除面料,提示无法删除面料】 https://www.tapd.cn/53459131/bugtrace/bugs/view/1153459131001001585
This commit is contained in:
parent
e56f538244
commit
af3aa008e4
@ -167,7 +167,7 @@ const ShoppingCartItem: FC<PropsType> = (props) => {
|
|||||||
console.log('rerender component ShoppingCartItem', props, props.itemData?.purchaser_name)
|
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 的数据 不然拿到的还是旧数据
|
// 及时更新 useRef 的数据 不然拿到的还是旧数据
|
||||||
currentItemData.current = props.itemData
|
currentItemData.current = props.itemData
|
||||||
|
|
||||||
const [itemData, setItemData] = usePropsValue({
|
const [itemData, setItemData] = usePropsValue({
|
||||||
@ -254,43 +254,47 @@ const ShoppingCartItem: FC<PropsType> = (props) => {
|
|||||||
|
|
||||||
// 更新当前客户的多选项
|
// 更新当前客户的多选项
|
||||||
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)
|
if (itemData?.purchaser_id === purchaserId) {
|
||||||
if (operationType === 'add') {
|
console.log('updatePurchaserMultipleSelection', colorStore, purchaserId)
|
||||||
const multipleSelection = {
|
if (operationType === 'add') {
|
||||||
...colorStore?.[purchaserId]?.multipleSelection,
|
const multipleSelection = {
|
||||||
[goodsId]: payload,
|
...colorStore?.[purchaserId]?.multipleSelection,
|
||||||
|
[goodsId]: payload,
|
||||||
|
}
|
||||||
|
dispatch({
|
||||||
|
type: ShoppingDispatchType.UPDATE_CHANGED_CHECKBOX,
|
||||||
|
data: {
|
||||||
|
purchaserId,
|
||||||
|
multipleSelection,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
// 全选标识
|
||||||
|
if (itemData?.[BackEndSaleModeListFieldMap[selected]].length === Object.keys(multipleSelection).length) {
|
||||||
|
dispatch({ type: ShoppingDispatchType.UPDATE_MULTIPLE_SELECTION_STATUS, data: true })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
dispatch({
|
else if (operationType === 'delete') {
|
||||||
type: ShoppingDispatchType.UPDATE_CHANGED_CHECKBOX,
|
const temp = { ...colorStore?.[purchaserId]?.multipleSelection }
|
||||||
data: {
|
delete temp?.[goodsId]
|
||||||
purchaserId,
|
dispatch({
|
||||||
multipleSelection,
|
type: ShoppingDispatchType.UPDATE_CHANGED_CHECKBOX,
|
||||||
},
|
data: {
|
||||||
})
|
purchaserId,
|
||||||
// 全选标识
|
multipleSelection: temp,
|
||||||
if (currentItemData.current?.purchaser_id === purchaserId && currentItemData.current?.[BackEndSaleModeListFieldMap[selected]].length === Object.keys(multipleSelection).length) {
|
},
|
||||||
dispatch({ type: ShoppingDispatchType.UPDATE_MULTIPLE_SELECTION_STATUS, data: true })
|
})
|
||||||
|
dispatch({ type: ShoppingDispatchType.UPDATE_MULTIPLE_SELECTION_STATUS, data: false })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (operationType === 'delete') {
|
|
||||||
const temp = { ...colorStore?.[purchaserId]?.multipleSelection }
|
|
||||||
delete temp?.[goodsId]
|
|
||||||
dispatch({
|
|
||||||
type: ShoppingDispatchType.UPDATE_CHANGED_CHECKBOX,
|
|
||||||
data: {
|
|
||||||
purchaserId,
|
|
||||||
multipleSelection: temp,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
dispatch({ type: ShoppingDispatchType.UPDATE_MULTIPLE_SELECTION_STATUS, data: false })
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleOtherHighLight = (purchaserId: number) => {
|
const handleOtherHighLight = (purchaserId: number, deletedItemData: any) => {
|
||||||
console.log('handleOtherHighLight', purchaserId, currentCheckedPurchaserId)
|
if (purchaserId === itemData?.purchaser_id) {
|
||||||
if (purchaserId === currentCheckedPurchaserId) {
|
// 当前订单类型还有数据,跳过
|
||||||
|
if (deletedItemData?.[BackEndSaleModeListFieldMap[selected]].length !== 0) { return }
|
||||||
|
// 当前订单类型没有数据,高亮其他订单类型
|
||||||
for (let i = 0; i < BackEndSaleModeListField.length; i++) {
|
for (let i = 0; i < BackEndSaleModeListField.length; i++) {
|
||||||
if (itemData?.[BackEndSaleModeListFieldMap[i]].length !== 0) {
|
if (deletedItemData?.[BackEndSaleModeListFieldMap[i]].length !== 0) {
|
||||||
// 控制高亮
|
// 控制高亮
|
||||||
onSelectOrderType(i)
|
onSelectOrderType(i)
|
||||||
return
|
return
|
||||||
|
|||||||
@ -162,8 +162,9 @@ const ShoppingCartContainer: FC = () => {
|
|||||||
multipleSelection: {},
|
multipleSelection: {},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
fetchData(searchOptions)
|
const deleted = await fetchData(searchOptions)
|
||||||
events.trigger('handleOtherHighLight', currentCheckedPurchaserId)
|
|
||||||
|
events.trigger('handleOtherHighLight', currentCheckedPurchaserId, deleted.data.list.find(item => item.purchaser_id === currentCheckedPurchaserId))
|
||||||
// Observer.notify(currentCheckedPurchaserId)
|
// Observer.notify(currentCheckedPurchaserId)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user