.ficed
This commit is contained in:
parent
515b6afe62
commit
5025f22c96
@ -18,8 +18,8 @@
|
||||
<div class="spec-value-input-del" @click="handleDelSpecValue(item, specValue)"><el-icon>
|
||||
<Close />
|
||||
</el-icon></div>
|
||||
<el-input v-model="specValue.specValueName" @change="handleChangeSepcValue(item, specValue)"
|
||||
class="spec-value-input" placeholder="规格值名称" clearable />
|
||||
<el-input v-model="specValue.specValueName" @change="handleChangeSepcValue()" class="spec-value-input"
|
||||
placeholder="规格值名称" clearable />
|
||||
</div>
|
||||
</div>
|
||||
<el-link type="primary" v-if="isAddSpecValueMax" @click="handleAddSpecValue(item)">添加规格值</el-link>
|
||||
@ -112,11 +112,9 @@ const goodsSpecList = ref([
|
||||
const skuList = ref([
|
||||
])
|
||||
|
||||
|
||||
/** sku列表参数 */
|
||||
const newList = ref([])
|
||||
const newData = ref([])
|
||||
const tableData7 = ref([])
|
||||
const spanArr = ref([])
|
||||
const spanArr1 = ref([])
|
||||
const pos = ref("")
|
||||
@ -130,32 +128,26 @@ const pos1 = ref("")
|
||||
//处理数据(拆分规格组里的规格值为数组)
|
||||
const processing = () => {
|
||||
newData.value = [];
|
||||
for (let i = 0; i < goodsSpecList.value.length; i++) {
|
||||
var newlist = [];
|
||||
for (
|
||||
let index = 0;
|
||||
index < goodsSpecList.value[i].props.length;
|
||||
index++
|
||||
) {
|
||||
newlist.push(goodsSpecList.value[i].props[index].specValueName);
|
||||
}
|
||||
this.newData.push(newlist);
|
||||
}
|
||||
console.log(this.newData, '各规格组中的规格值');
|
||||
goodsSpecList.value.forEach((item) => {
|
||||
const prop = item.props.map((prop) => prop.specValueName);
|
||||
newData.value.push(prop);
|
||||
});
|
||||
console.log(newData.value, '各规格组中的规格值');
|
||||
getList();
|
||||
}
|
||||
|
||||
|
||||
//转换数据
|
||||
const getList = () => {
|
||||
tableData7.value = [];
|
||||
newList.value = this.descartes(newData.value);
|
||||
skuList.value = [];
|
||||
newList.value = descartes(newData.value);
|
||||
console.log(newList.value, '笛卡尔积处理过后的数据');
|
||||
for (let index = 0; index < newList.value.length; index++) {
|
||||
this.tableData7.push({
|
||||
specValue: newList.value[index][0],
|
||||
specSecondValue: newList.value[index][1],
|
||||
specThirdValue: newList.value[index][2],
|
||||
newList.value.forEach((item) => {
|
||||
console.log(item, 'item数据');
|
||||
skuList.value.push({
|
||||
specValue: Array.isArray(item) ? item[0] : item,
|
||||
specSecondValue: Array.isArray(item) ? item[1] : null,
|
||||
specThirdValue: Array.isArray(item) ? item[2] : null,
|
||||
goodsGuid: 0,
|
||||
specValueName: "",
|
||||
goodsSkuImg: "",
|
||||
@ -166,10 +158,10 @@ const getList = () => {
|
||||
goodsSkuWeight: 0,
|
||||
goodsSkuProps: ""
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
getSpanArr(this.tableData7);
|
||||
console.log(this.tableData7, '表格中的数据');
|
||||
getSpanArr(skuList.value);
|
||||
console.log(skuList.value, '表格中的数据');
|
||||
}
|
||||
|
||||
|
||||
@ -210,7 +202,7 @@ const getSpanArr = (data) => {
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log(this.spanArr, '排序Arr');
|
||||
console.log(spanArr.value, '排序Arr');
|
||||
}
|
||||
|
||||
|
||||
@ -330,9 +322,20 @@ function handleChangeSepc(item, idx) {
|
||||
return; // 停止执行后续代码
|
||||
}
|
||||
|
||||
let propValue = ""
|
||||
if (idx === 0) {
|
||||
propValue = "specValue"
|
||||
}
|
||||
if (idx === 1) {
|
||||
propValue = "specSecondValue"
|
||||
}
|
||||
if (idx === 2) {
|
||||
propValue = "specThirdValue"
|
||||
}
|
||||
|
||||
// 添加动态表头
|
||||
let column = {
|
||||
prop: 'specValue',
|
||||
prop: propValue,
|
||||
label: item.specName,
|
||||
width: '100',
|
||||
key: idx
|
||||
@ -353,7 +356,7 @@ function handleDelSpec(item) {
|
||||
}
|
||||
|
||||
|
||||
// 输出对应的表头
|
||||
// 删除对应的表头
|
||||
skuColumns.value = skuColumns.value.filter(column => column.label !== item.specName);
|
||||
|
||||
// 删除对应的sku
|
||||
@ -381,44 +384,10 @@ function handleAddSpecValue(item) {
|
||||
|
||||
|
||||
// 修改规格值
|
||||
function handleChangeSepcValue(item, specValue) {
|
||||
|
||||
let firstSpecValue = ""
|
||||
let secondSpecValue = ""
|
||||
let thirdSpecValue = ""
|
||||
|
||||
console.log(item, 'item喵喵喵喵喵喵');
|
||||
// goodsSpecList.value.map((item,index) => {
|
||||
// if(item.key === 0){
|
||||
// firstSpecValue = specValue.specValueName
|
||||
// }
|
||||
// if(item.key === 1){
|
||||
// secondSpecValue = specValue.specValueName
|
||||
// }
|
||||
// if(item.key === 2){
|
||||
// thirdSpecValue = specValue.specValueName
|
||||
// }
|
||||
// })
|
||||
function handleChangeSepcValue(e) {
|
||||
|
||||
// 添加sku
|
||||
let sku = {
|
||||
specValue: firstSpecValue,
|
||||
specSecondValue: secondSpecValue,
|
||||
specThirdValue: thirdSpecValue,
|
||||
goodsGuid: 0,
|
||||
specValueName: "",
|
||||
goodsSkuImg: "",
|
||||
goodsSkuSkuCode: 0,
|
||||
goodsSkuPrice: 0,
|
||||
goodsSkuLinePrice: 0,
|
||||
goodsSkuStockNum: 0,
|
||||
goodsSkuWeight: 0,
|
||||
goodsSkuProps: ""
|
||||
}
|
||||
skuList.value.push(sku)
|
||||
|
||||
console.log(skuList.value, 'asdasd-------------');
|
||||
|
||||
processing()
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user