商品属性添加
parent
4fca053825
commit
8f4035206e
|
@ -125,9 +125,9 @@
|
|||
|
||||
<el-steps :active="active" finish-status="success">
|
||||
<el-step title="商品信息"></el-step>
|
||||
<el-step title="商品备注"></el-step>
|
||||
<el-step title="商品规格"></el-step>
|
||||
<el-step title="商品品类"></el-step>
|
||||
<el-step title="商品备注"></el-step>
|
||||
</el-steps>
|
||||
|
||||
|
||||
|
@ -360,11 +360,8 @@
|
|||
</div>
|
||||
|
||||
</el-card>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div v-if="active==4">
|
||||
<el-form-item label="商品备注">
|
||||
<editor v-model="form.remark" :min-height="192"/>
|
||||
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue