商品规格SKU生成
parent
761682671e
commit
4dbed1ab30
|
@ -411,7 +411,7 @@ export default {
|
||||||
templateAttributeList: [],
|
templateAttributeList: [],
|
||||||
attributeList: []
|
attributeList: []
|
||||||
},
|
},
|
||||||
titleList: [
|
templateTitleList: [
|
||||||
{
|
{
|
||||||
"label":"商品库存",
|
"label":"商品库存",
|
||||||
"prop":"stock"
|
"prop":"stock"
|
||||||
|
@ -423,13 +423,8 @@ export default {
|
||||||
"prop":"image"
|
"prop":"image"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
skuList: [
|
titleList: [],
|
||||||
{
|
skuList: []
|
||||||
"image": "123",
|
|
||||||
"price": 85.62,
|
|
||||||
"stock": 236
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
@ -467,16 +462,51 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
changeRule(ruleId){
|
changeRule(ruleId){
|
||||||
|
this.titleList = []
|
||||||
let ruleInfo = this.ruleList.find(ruleInfo => ruleInfo.id === ruleId);
|
let ruleInfo = this.ruleList.find(ruleInfo => ruleInfo.id === ruleId);
|
||||||
const {ruleAttrList} = ruleInfo;
|
const {ruleAttrList} = ruleInfo;
|
||||||
|
let skuTotal = 1;
|
||||||
for (let ruleAttrListKey in ruleAttrList) {
|
for (let ruleAttrListKey in ruleAttrList) {
|
||||||
let ruleAttrInfo = ruleAttrList[ruleAttrListKey];
|
let ruleAttrInfo = ruleAttrList[ruleAttrListKey];
|
||||||
this.titleList.push({
|
this.titleList.push({
|
||||||
"label":ruleAttrInfo.name,
|
"label":ruleAttrInfo.name,
|
||||||
"prop":"stock"
|
"prop":"prop"+ruleAttrListKey
|
||||||
})
|
})
|
||||||
|
skuTotal = skuTotal * ruleAttrInfo.valueList.length;
|
||||||
|
}
|
||||||
|
this.titleList.push(...this.templateTitleList) ;
|
||||||
|
console.log(this.titleList);
|
||||||
|
this.skuList = [];
|
||||||
|
for (let i = 0; i < skuTotal; i++) {
|
||||||
|
this.skuList.push(
|
||||||
|
{
|
||||||
|
"image": "123",
|
||||||
|
"price": 85.62,
|
||||||
|
"stock": 236
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// currentIndex 当前下标
|
||||||
|
for (let currentIndex in ruleAttrList) {
|
||||||
|
let ruleAttrInfo = ruleAttrList[currentIndex];
|
||||||
|
// 连续出现次数 循环出现次数
|
||||||
|
let continuousSize = 1, forSize = 1;
|
||||||
|
for (let continuousIndex = parseInt(currentIndex) + 1 ; continuousIndex < ruleAttrList.length ; continuousIndex++ ){
|
||||||
|
continuousSize = continuousSize * ruleAttrList[continuousIndex].valueList.length;
|
||||||
|
}
|
||||||
|
for (let forIndex = parseInt(currentIndex) - 1; forIndex >= 0; forIndex--){
|
||||||
|
forSize = forSize * ruleAttrList[forIndex].valueList.length
|
||||||
|
}
|
||||||
|
console.log(`${ruleAttrInfo.name} 规格 连续出现次数:${continuousSize} 循环出现次数:${forSize}`)
|
||||||
|
for (let forIndex = 0; forIndex < forSize; forIndex++) {
|
||||||
|
const {valueList} = ruleAttrInfo;
|
||||||
|
valueList.forEach(value => {
|
||||||
|
for (let continuousIndex = 0; continuousIndex < continuousSize; continuousIndex++) {
|
||||||
|
this.skuList
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
console.log(ruleInfo);
|
|
||||||
},
|
},
|
||||||
saveCustomAttribute(){
|
saveCustomAttribute(){
|
||||||
addAttribute({"code": this.customAttributeForm.code, "name": this.customAttributeForm.name}).then(response => {
|
addAttribute({"code": this.customAttributeForm.code, "name": this.customAttributeForm.name}).then(response => {
|
||||||
|
|
Loading…
Reference in New Issue