🐞 fix(购物页面): 修复购物页面再次删除商品时请求错误的问题

This commit is contained in:
xuan 2022-10-31 12:48:08 +08:00
parent 159e0b9d56
commit e0de46c469
2 changed files with 26 additions and 11 deletions

View File

@ -157,6 +157,11 @@ let ShoppingCartItem: FC<PropsType> = props => {
}) })
console.log('res===>', res) console.log('res===>', res)
if (res.success) { if (res.success) {
// 转成 对象形式
// 4562: {
// id: 4562,
// ...
// }
const newGoodsKind = Object.fromEntries( const newGoodsKind = Object.fromEntries(
res.data[0]?.[BackEndSaleModeListFieldMap[selected]].map(item => [ res.data[0]?.[BackEndSaleModeListFieldMap[selected]].map(item => [
item?.id, item?.id,
@ -176,7 +181,8 @@ let ShoppingCartItem: FC<PropsType> = props => {
purchaserId: id, purchaserId: id,
goodsKind: newGoodsKind, goodsKind: newGoodsKind,
multipleSelection: Object.fromEntries( multipleSelection: Object.fromEntries(
Object.keys(multipleSelection!).map(id => [ Object.keys(multipleSelection!)
.map(id => [
id, id,
{ {
id, id,

View File

@ -151,7 +151,7 @@ const ShoppingCartContainer: FC<InternalContainer> = () => {
// 批量某个客户的删除商品 // 批量某个客户的删除商品
const handleDelete = async () => { const handleDelete = async () => {
const multipleSelection = colorStore?.[currentCheckedPurchaserId]?.['multipleSelection'] const multipleSelection = colorStore?.[currentCheckedPurchaserId].multipleSelection
let checked: Goods[] = Object.values(multipleSelection!) let checked: Goods[] = Object.values(multipleSelection!)
if (checked.length === 0) { if (checked.length === 0) {
return Taro.showToast({ title: '请选择商品', icon: 'error' }) return Taro.showToast({ title: '请选择商品', icon: 'error' })
@ -166,6 +166,15 @@ const ShoppingCartContainer: FC<InternalContainer> = () => {
}) })
if (res.success) { if (res.success) {
alert.success('删除成功') alert.success('删除成功')
// 清空多选
dispatch({
type: ShoppingDispatchType.UPDATE_CHANGED_CHECKBOX,
data: {
purchaserId: currentCheckedPurchaserId,
goodsKind: colorStore?.[currentCheckedPurchaserId].goodsKind,
multipleSelection: {},
},
})
fetchData(searchOptions) fetchData(searchOptions)
// Observer.notify(currentCheckedPurchaserId) // Observer.notify(currentCheckedPurchaserId)
} else { } else {