From 6da2117f17e06d59f078ff14f18918b170e6e37d Mon Sep 17 00:00:00 2001 From: Xulinchuan <2026734208@qq.com> Date: Wed, 25 Jun 2025 14:17:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=AD=E7=89=A9=E8=BD=A6=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/shoppingCarts/shoppingCarts.vue | 52 +++++++++++++------ 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/sub-operation-service/src/views/shoppingCarts/shoppingCarts.vue b/sub-operation-service/src/views/shoppingCarts/shoppingCarts.vue index 6fda116..6e54887 100644 --- a/sub-operation-service/src/views/shoppingCarts/shoppingCarts.vue +++ b/sub-operation-service/src/views/shoppingCarts/shoppingCarts.vue @@ -55,7 +55,7 @@
-
{{ g.netWeightInfoVO.goodSpecs }}
+
{{ g.netWeightInfoVO?.goodSpecs }}
{{ (g.price * g.quantity).toFixed(2) }}
@@ -171,28 +171,46 @@ const pagination = (value) => { }; function addIsCheckProperty(data) { + if (!data) return; + if (Array.isArray(data)) { data.forEach((item) => { - item.ischeck = false; // 为当前层级添加属性 - if (item.cartDetails) { - // 处理子集 - addIsCheckProperty(item.cartDetails); - } - if (item.records) { - // 处理父级(如存在嵌套结构) - addIsCheckProperty(item.records); - } + item.ischeck = false; + // 只处理明确知道的嵌套属性,避免无限递归 + item.cartDetails && addIsCheckProperty(item.cartDetails); + item.records && addIsCheckProperty(item.records); }); - } else if (typeof data === 'object' && data !== null) { + } else if (typeof data === 'object') { data.ischeck = false; - for (let key in data) { - if (typeof data[key] === 'object') { - addIsCheckProperty(data[key]); // 递归处理嵌套对象 - } - } + // 不自动遍历所有属性,只处理已知的特定属性 + data.cartDetails && addIsCheckProperty(data.cartDetails); + data.records && addIsCheckProperty(data.records); } } +// function addIsCheckProperty(data) { +// if (Array.isArray(data)) { +// data.forEach((item) => { +// item.ischeck = false; // 为当前层级添加属性 +// if (item.cartDetails) { +// // 处理子集 +// addIsCheckProperty(item.cartDetails); +// } +// if (item.records) { +// // 处理父级(如存在嵌套结构) +// addIsCheckProperty(item.records); +// } +// }); +// } else if (typeof data === 'object' && data !== null) { +// data.ischeck = false; +// for (let key in data) { +// if (typeof data[key] === 'object') { +// addIsCheckProperty(data[key]); // 递归处理嵌套对象 +// } +// } +// } +// } + const numberChange = (value, index, indexg) => { console.log(value, index, indexg); setGoodsCount({ goodsId: data.value[index].cartDetails[indexg].id, count: value }); @@ -612,6 +630,7 @@ function removeCheckedItems(data) { } .price { font-weight: 400; + width: 200px; } .total { font-weight: 700; @@ -623,6 +642,7 @@ function removeCheckedItems(data) { .good-del { font-size: 16px; color: $color-999; + width: 44px; } } }