🐞 fix(ID1001585): 【内部商城】-功能{-购物车}:选择全部删除面料,提示无法删除面料

【【内部商城】-功能{-购物车}:选择全部删除面料,提示无法删除面料】 https://www.tapd.cn/53459131/bugtrace/bugs/view/1153459131001001585
This commit is contained in:
xuan 2023-03-22 15:48:11 +08:00
parent e56f538244
commit af3aa008e4
2 changed files with 39 additions and 34 deletions

View File

@ -167,7 +167,7 @@ const ShoppingCartItem: FC<PropsType> = (props) => {
console.log('rerender component ShoppingCartItem', props, props.itemData?.purchaser_name)
const currentItemData = useRef<ShoppingCartData | undefined>(props.itemData)
// 即使更新 useRef 的数据 不然拿到的还是旧数据
// 及时更新 useRef 的数据 不然拿到的还是旧数据
currentItemData.current = props.itemData
const [itemData, setItemData] = usePropsValue({
@ -254,43 +254,47 @@ const ShoppingCartItem: FC<PropsType> = (props) => {
// 更新当前客户的多选项
const updatePurchaserMultipleSelection = (purchaserId: number, payload: Goods, operationType: OperationType, goodsId: number) => {
console.log('delete', colorStore, purchaserId)
if (operationType === 'add') {
const multipleSelection = {
...colorStore?.[purchaserId]?.multipleSelection,
[goodsId]: payload,
if (itemData?.purchaser_id === purchaserId) {
console.log('updatePurchaserMultipleSelection', colorStore, purchaserId)
if (operationType === 'add') {
const multipleSelection = {
...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({
type: ShoppingDispatchType.UPDATE_CHANGED_CHECKBOX,
data: {
purchaserId,
multipleSelection,
},
})
// 全选标识
if (currentItemData.current?.purchaser_id === purchaserId && currentItemData.current?.[BackEndSaleModeListFieldMap[selected]].length === Object.keys(multipleSelection).length) {
dispatch({ type: ShoppingDispatchType.UPDATE_MULTIPLE_SELECTION_STATUS, data: true })
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 })
}
}
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) => {
console.log('handleOtherHighLight', purchaserId, currentCheckedPurchaserId)
if (purchaserId === currentCheckedPurchaserId) {
const handleOtherHighLight = (purchaserId: number, deletedItemData: any) => {
if (purchaserId === itemData?.purchaser_id) {
// 当前订单类型还有数据,跳过
if (deletedItemData?.[BackEndSaleModeListFieldMap[selected]].length !== 0) { return }
// 当前订单类型没有数据,高亮其他订单类型
for (let i = 0; i < BackEndSaleModeListField.length; i++) {
if (itemData?.[BackEndSaleModeListFieldMap[i]].length !== 0) {
if (deletedItemData?.[BackEndSaleModeListFieldMap[i]].length !== 0) {
// 控制高亮
onSelectOrderType(i)
return

View File

@ -162,8 +162,9 @@ const ShoppingCartContainer: FC = () => {
multipleSelection: {},
},
})
fetchData(searchOptions)
events.trigger('handleOtherHighLight', currentCheckedPurchaserId)
const deleted = await fetchData(searchOptions)
events.trigger('handleOtherHighLight', currentCheckedPurchaserId, deleted.data.list.find(item => item.purchaser_id === currentCheckedPurchaserId))
// Observer.notify(currentCheckedPurchaserId)
}
else {