🐞 fix(购物车): 修复全选时删除失败的问题
This commit is contained in:
parent
af3aa008e4
commit
ef0a52f658
@ -4,8 +4,8 @@
|
||||
// export const BASE_URL = `http://10.0.0.5:50001/lymarket`
|
||||
// export const BASE_URL = `http://192.168.0.89:40001/lymarket`
|
||||
// export const BASE_URL = `http://192.168.1.165:40001/lymarket` // 王霞
|
||||
export const BASE_URL = 'https://test.zzfzyc.com/lymarket' // 测试环境
|
||||
// export const BASE_URL = 'https://pre.zzfzyc.com/lymarket' // 预发布
|
||||
// export const BASE_URL = 'https://test.zzfzyc.com/lymarket' // 测试环境
|
||||
export const BASE_URL = 'https://pre.zzfzyc.com/lymarket' // 预发布
|
||||
// export const BASE_URL = `http://192.168.1.9:40001/lymarket` // 发
|
||||
// export const BASE_URL = `http://192.168.1.9:50005/lymarket` // 发
|
||||
// export const BASE_URL = `http://192.168.1.30:50001/lymarket` // 发
|
||||
|
||||
@ -13,11 +13,12 @@ import { ShoppingDispatchType, useShoppingDispatch, useShoppingState } from './c
|
||||
import { events } from './context/shoppingStore'
|
||||
import { dataLoadingStatus, debounce, getFilterData } from '@/common/util'
|
||||
import { ShoppingCartDeleteApi, ShoppingCartListApi } from '@/api/index'
|
||||
import { formatPriceDiv } from '@/common/format'
|
||||
import { formatMeterDiv, formatPriceDiv } from '@/common/format'
|
||||
import InfiniteScroll from '@/components/infiniteScroll'
|
||||
import IconText from '@/components/iconText'
|
||||
import Search from '@/components/search'
|
||||
import { alert, goLink, isEmptyObject } from '@/common/common'
|
||||
import { EnumSaleMode } from '@/common/Enumerate'
|
||||
|
||||
interface SearchOptions {
|
||||
short_name_or_phone?: string
|
||||
@ -147,18 +148,38 @@ const ShoppingCartContainer: FC = () => {
|
||||
async success(res) {
|
||||
if (res.confirm) {
|
||||
alert.showLoading('删除中')
|
||||
const checkedIds = checked.map(item => item.id)
|
||||
const res = await deleteApi({
|
||||
ids: checked.map(item => item.id).join(','),
|
||||
ids: checkedIds.join(','),
|
||||
})
|
||||
if (res.success) {
|
||||
alert.hideLoading()
|
||||
alert.success('删除成功')
|
||||
console.log('colorStore?.[currentCheckedPurchaserId]', colorStore?.[currentCheckedPurchaserId])
|
||||
let goodsKind = colorStore?.[currentCheckedPurchaserId].goodsKind
|
||||
if (goodsKind) {
|
||||
goodsKind = Object.fromEntries(
|
||||
Object.values(goodsKind).filter(value => !checkedIds.includes(value.id))
|
||||
.map(value => [
|
||||
value.id,
|
||||
{
|
||||
id: value.id,
|
||||
estimate_amount: value.estimate_amount,
|
||||
product_code: value.product_code,
|
||||
product_color_code: value.product_color_code,
|
||||
sale_mode: value.sale_mode,
|
||||
count: value.count,
|
||||
},
|
||||
],
|
||||
))
|
||||
}
|
||||
console.log('goodsKind', goodsKind)
|
||||
// 清空多选
|
||||
dispatch({
|
||||
type: ShoppingDispatchType.UPDATE_CHANGED_CHECKBOX,
|
||||
data: {
|
||||
purchaserId: currentCheckedPurchaserId,
|
||||
goodsKind: colorStore?.[currentCheckedPurchaserId].goodsKind,
|
||||
goodsKind,
|
||||
multipleSelection: {},
|
||||
},
|
||||
})
|
||||
@ -177,10 +198,24 @@ const ShoppingCartContainer: FC = () => {
|
||||
}
|
||||
// 全选
|
||||
const handleSelectAllCheckbox = (isSelectAll: boolean) => {
|
||||
const targetGoodsKind = colorStore?.[currentCheckedPurchaserId].goodsKind
|
||||
if (!targetGoodsKind) { return alert.error('请先选择客户') }
|
||||
if (!currentCheckedPurchaserId) { return alert.error('请先选择客户') }
|
||||
|
||||
const tempObject = { ...targetGoodsKind }
|
||||
const targetGoodsKind = shoppingCartData.list.find(item => item.purchaser_id === currentCheckedPurchaserId)?.[BackEndSaleModeListFieldMap[currentCheckedSaleMode]]
|
||||
|
||||
const tempObject: Record<Goods['id'], Goods> = Object.fromEntries(
|
||||
targetGoodsKind.map(item => [
|
||||
item?.id,
|
||||
{
|
||||
id: item?.id,
|
||||
estimate_amount: item.estimate_amount,
|
||||
product_code: item.product_code,
|
||||
product_color_code: item.product_color_code,
|
||||
sale_mode: item.sale_mode,
|
||||
count: currentCheckedSaleMode === EnumSaleMode.Bulk ? item.roll : Number(formatMeterDiv(item.length)),
|
||||
},
|
||||
]),
|
||||
)
|
||||
console.log('handleSelectAllCheckbox', tempObject)
|
||||
dispatch({
|
||||
type: ShoppingDispatchType.UPDATE_CHANGED_CHECKBOX,
|
||||
data: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user