fix: 修复更新数据可能有skudata不存在报错
This commit is contained in:
parent
72fddad3eb
commit
a1b5a468a9
|
|
@ -341,7 +341,8 @@ export const useCartsStore = defineStore("carts", () => {
|
|||
sendMessage('edit', { ...data, pack_number });
|
||||
}
|
||||
function updateTag(key: string, val: any, cart: CartsState = selCart.value) {
|
||||
if (cart.number * 1 < cart.skuData.suitNum * 1) {
|
||||
const skuData = cart.skuData || { suitNum: 1 }
|
||||
if (cart.number * 1 < skuData.suitNum * 1) {
|
||||
return sendMessage('del', cart);
|
||||
}
|
||||
console.log(key, val)
|
||||
|
|
@ -578,32 +579,28 @@ export const useCartsStore = defineStore("carts", () => {
|
|||
const giftIndex = giftList.value.findIndex((item) => item.id === newCart.id)
|
||||
const cartItem = list.value[index] || { is_gift: false };
|
||||
const giftItem = giftList.value[giftIndex];
|
||||
if (isSelGift.value) {
|
||||
|
||||
if (giftItem) {
|
||||
//操作赠菜
|
||||
if (newCart.is_gift != giftItem.is_gift) {
|
||||
//修改了赠菜状态
|
||||
if (!newCart.is_gift) {
|
||||
giftList.value.splice(giftIndex, 1)
|
||||
list.value.push({ ...giftItem, ...newCart })
|
||||
selListIndex.value = -1
|
||||
} else {
|
||||
giftList.value[giftIndex] = { ...giftItem, ...newCart }
|
||||
}
|
||||
ElMessage.success(msg.message || '修改成功')
|
||||
return
|
||||
}
|
||||
if (!isSelGift.value) {
|
||||
if (cartItem) {
|
||||
//操作非赠菜
|
||||
if (newCart.is_gift != cartItem.is_gift) {
|
||||
if (newCart.is_gift) {
|
||||
list.value.splice(index, 1)
|
||||
giftList.value.push({ ...cartItem, ...newCart })
|
||||
selListIndex.value = -1
|
||||
} else {
|
||||
list.value[index] = { ...cartItem, ...newCart }
|
||||
}
|
||||
ElMessage.success(msg.message || '修改成功')
|
||||
return
|
||||
}
|
||||
|
||||
ElMessage.success(msg.message || '修改成功')
|
||||
}
|
||||
if (msg.operate_type === "manage_del") {
|
||||
const cartId = Array.isArray(msg.data) ? msg.data[0].id : msg.data.id
|
||||
|
|
|
|||
Loading…
Reference in New Issue