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);