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