From 8f4035206ee34f36bdcc335fe0a75d99b1864cf8 Mon Sep 17 00:00:00 2001 From: 2812875475 <2812875475@qq.com> Date: Fri, 22 Mar 2024 09:46:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E5=B1=9E=E6=80=A7=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/product/productInfo/index.vue | 132 +++++++++++++++++------- 1 file changed, 92 insertions(+), 40 deletions(-) diff --git a/src/views/product/productInfo/index.vue b/src/views/product/productInfo/index.vue index 2b60cde..ae202e5 100644 --- a/src/views/product/productInfo/index.vue +++ b/src/views/product/productInfo/index.vue @@ -125,9 +125,9 @@ - + @@ -360,11 +360,8 @@ - - -
@@ -475,44 +472,51 @@ export default { ruleId: null, brandId: null, }, + skuList1 : [], // 表单参数 form: { - ruleId:[], - skuList:[], - templateAttributeGroupList:[], - attributeCheckedList:[], - templateAttributeList:[], + sku:"", + mianType:'', + parentType:'', + type:'', + specification:"", + groupList:"", + attributeList:"", + persionList:"", }, // 表单校验 rules: { name: [ - {required: true, message: "商品名称不能为空", trigger: "blur"} + // {required: true, message: "商品名称不能为空", trigger: "blur"} + // ], + // introduction: [ + // {required: true, message: "商品描述不能为空", trigger: "blur"} + // ], + // mainType: [ + // {required: true, message: "主类型不能为空", trigger: "change"} + // ], + // parentType: [ + // {required: true, message: "父类型不能为空", trigger: "change"} + // ], + // type: [ + // {required: true, message: "商品类型不能为空", trigger: "change"} + // ], + // image: [ + // {required: true, message: "商品图片不能为空", trigger: "blur"} + // ], + // carouselImages: [ + // {required: true, message: "商品轮播图不能为空", trigger: "blur"} + // ], + // status: [ + // {required: true, message: "商品状态不能为空", trigger: "change"} + // ], + // remark: [ + // {required: true, message: "备注不能为空", trigger: "blur"} ], - introduction: [ - {required: true, message: "商品描述不能为空", trigger: "blur"} - ], - mainType: [ - {required: true, message: "主类型不能为空", trigger: "change"} - ], - parentType: [ - {required: true, message: "父类型不能为空", trigger: "change"} - ], - type: [ - {required: true, message: "商品类型不能为空", trigger: "change"} - ], - image: [ - {required: true, message: "商品图片不能为空", trigger: "blur"} - ], - carouselImages: [ - {required: true, message: "商品轮播图不能为空", trigger: "blur"} - ], - status: [ - {required: true, message: "商品状态不能为空", trigger: "change"} - ], - remark: [ - {required: true, message: "备注不能为空", trigger: "blur"} - ], - } + }, + a:[], + b:[], + c:[], }; }, watch: { @@ -606,12 +610,35 @@ export default { ruleList.forEach(value => { for (let continuousIndex = 0; continuousIndex < continuousSize; continuousIndex++) { this.skuList[counter++]["prop" + currentIndex] = value; + console.log(value) } }) } } + // 生成所有可能的SKU组合 + const generateSkuCombinations = (currentIndex, currentCombination) => { + if (currentIndex === ruleAttrList.length) { + // 所有属性都已经组合完毕,将组合结果添加到skuList + this.skuList1.push(currentCombination); + return; + } + + const { ruleList } = ruleAttrList[currentIndex]; + for (let value of ruleList) { + generateSkuCombinations(currentIndex + 1, currentCombination + value); + } + }; + + // 从第一个属性开始生成组合 + generateSkuCombinations(0, ''); + + // 打印结果 + this.skuList1.forEach(sku => { + console.log(sku); + }); + }, handleCheckedCitiesChange() { let attributeId = this.attributeIdCheckedList @@ -753,11 +780,36 @@ export default { this.getList(); }); } else { - this.form.templateAttributeGroupList=this.categoryCommonElement.templateAttributeGroupList - this.form.attributeCheckedList=this.attributeCheckedList - this.form.skuList=this.skuList - this.form.templateAttributeList=this.categoryCommonElement.templateAttributeList - + console.log(this.categoryCommonElement) + this.categoryCommonElement.templateAttributeGroupList.forEach( + templateAttributeGroup=>{ + templateAttributeGroup.attributeList.forEach( + attribute=>{ + this.a+=(attribute.id+"-"+attribute.name+"-"+attribute.value+",") + } + ) + } + ) + this.categoryCommonElement.templateAttributeList.forEach( + templateAttributeGroup=>{ + this.b+=(templateAttributeGroup.id+"-"+templateAttributeGroup.name+"-"+templateAttributeGroup.value+",") + } + ) + this.attributeCheckedList.forEach( + attributeChecked=>{ + this.c+=(attributeChecked.id+"-"+attributeChecked.name+"-"+attributeChecked.value) + } + ) + console.log(this.a) + console.log(this.b) + console.log(this.c) + this.form.sku=this.skuList1 + this.form.specification=this.oneSettingValue + // this.form.categoryList=this.a.concat(this.b).concat(this.c) + this.form.groupList=this.a + this.form.attributeList=this.b + this.form.persionList=this.c + console.log(this.form) addInfo(this.form).then(response => { this.$modal.msgSuccess("新增成功"); this.open = false;