From 3302fca0527fc8596665ca73c4ba2ae71302dd71 Mon Sep 17 00:00:00 2001 From: qijq <624811160@qq.com> Date: Tue, 12 Aug 2025 13:25:41 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BF=AE=E5=A4=8D=E5=95=86=E5=93=81?= =?UTF-8?q?=E7=BC=96=E8=BE=91BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/warehouse/manage/addAndEditProduct.vue | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/java-mall-app-shop-admin/pages/warehouse/manage/addAndEditProduct.vue b/java-mall-app-shop-admin/pages/warehouse/manage/addAndEditProduct.vue index 342dec7..232517d 100644 --- a/java-mall-app-shop-admin/pages/warehouse/manage/addAndEditProduct.vue +++ b/java-mall-app-shop-admin/pages/warehouse/manage/addAndEditProduct.vue @@ -726,6 +726,7 @@ export default { // 1. 解析产品规格模板 this.productSpec = this.productInfoByPid.shop_product_info.product_spec; + try { this.productSpec = JSON.parse(this.productSpec); if (!Array.isArray(this.productSpec)) { @@ -801,9 +802,15 @@ export default { return item; // 如果没有匹配项,返回原 item }); + this.cheboxList = this.specificationInfoList.map( + (item) => item.spec_item_id + ); + if (this.specificationInfoList.length == 0) { this.specificationInfoList = this.selectCommodisItems; + this.cheboxList = []; } + console.log(this.specificationInfoList); } catch (e) { console.error("解析productSpec失败:", e); @@ -916,9 +923,9 @@ export default { main_color_img: mainMColorimg.toString(), }; - if (this.cheboxList.length > 0 || this.productSpec.length > 0) { - console.log(this.cheboxList, this.productSpec); + // 判断取消勾选后的场景 + if (this.cheboxList.length > 0) { obj.product_spec = JSON.stringify([ { id: item.spec_id, @@ -968,8 +975,7 @@ export default { }); var productSpec = this.productSpec; - - if (this.cheboxList.length > 0 || productSpec.length > 0) { + if (this.cheboxList.length > 0) { productSpec = this.specificationInfoList.reduce((acc, item) => { const existingSpec = acc.find((spec) => spec.id === item.spec_id); @@ -993,6 +999,8 @@ export default { return acc; }, []); + } else { + productSpec = []; } console.log(this.form.product_param);