|
@@ -251,6 +251,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
}
|
|
|
},
|
|
|
mounted(){
|
|
|
+ console.log(this.form)
|
|
|
Controller.api.bindevent();
|
|
|
},
|
|
|
filters:{
|
|
@@ -321,7 +322,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
}
|
|
|
}
|
|
|
spec.names.push({
|
|
|
- name:value
|
|
|
+ name:value,
|
|
|
+ temp_id:Date.now().toString(),
|
|
|
})
|
|
|
this.buildSku()
|
|
|
})
|
|
@@ -354,7 +356,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
*/
|
|
|
setTableList(){
|
|
|
let newList=[];
|
|
|
- this.getRowList(null,0,newList)
|
|
|
+ this.getRowList(null,0,newList,null)
|
|
|
this.form.sku=newList;
|
|
|
},
|
|
|
/**
|
|
@@ -362,28 +364,36 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
* @param specValues 多规格值通过逗号拼接组成每一行唯一值
|
|
|
* @param specIndex 规格索引
|
|
|
* @param newList 新表格数据
|
|
|
+ * @param temp_ids
|
|
|
*/
|
|
|
- getRowList(specValues,specIndex,newList){
|
|
|
+ getRowList(specValues,specIndex,newList,temp_ids){
|
|
|
if(specIndex<this.form.size.length){
|
|
|
this.form.size[specIndex].names.forEach((t)=>{
|
|
|
let newValues=(specValues===null?t.name:(specValues+","+t.name))
|
|
|
+ let new_temp_ids=(temp_ids===null?t.temp_id:(temp_ids+","+t.temp_id))
|
|
|
//当前规格值,一直往下规格值循环完
|
|
|
- this.getRowList(newValues,specIndex+1,newList)
|
|
|
+ this.getRowList(newValues,specIndex+1,newList,new_temp_ids)
|
|
|
})
|
|
|
//当添加新规格(第二个规格的时候)没有规格值时,默认一个空值
|
|
|
if(this.form.size[specIndex].names.length===0 && specValues!==null){
|
|
|
let newValues=specValues+","
|
|
|
- this.getRowList(newValues,specIndex+1,newList)
|
|
|
+ let new_temp_ids=temp_ids+","
|
|
|
+ this.getRowList(newValues,specIndex+1,newList,new_temp_ids)
|
|
|
}
|
|
|
}
|
|
|
//当最后规格的规格值循环到最后后添加行数据
|
|
|
else{
|
|
|
//判断表格行数据是否已经存在,存在直接添加不创建新行
|
|
|
let row = this.form.sku.find((r)=>{
|
|
|
- return r.specValues.split(',').sort().toString()===specValues.split(',').sort().toString()
|
|
|
+ //return r.specValues.split(',').sort().toString()===specValues.split(',').sort().toString()
|
|
|
+ let eq=r.temp_ids.split(',').sort().toString() === temp_ids.split(',').sort().toString()
|
|
|
+ return eq
|
|
|
});
|
|
|
- console.log('old',row)
|
|
|
if(row){
|
|
|
+ specValues.split(',').forEach((c,index)=>{
|
|
|
+ row["sku-"+index]=c
|
|
|
+ })
|
|
|
+ row.specValues=specValues
|
|
|
newList.push({...row})
|
|
|
}
|
|
|
else{
|
|
@@ -391,6 +401,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
row = {
|
|
|
size:specIndex,
|
|
|
specValues:specValues,
|
|
|
+ temp_ids:temp_ids,
|
|
|
num_stock:0,
|
|
|
num_stock_kill:0,
|
|
|
amount_cost:0,
|
|
@@ -415,7 +426,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|
|
}
|
|
|
],
|
|
|
}
|
|
|
- //console.log('row',row)
|
|
|
//通过规格值循环出规格值列数
|
|
|
specValues.split(',').forEach((c,index)=>{
|
|
|
row["sku-"+index]=c
|