spu 修改页面展示

pull/2/head
franky 2022-07-06 17:06:19 +08:00
parent ed56c71ba1
commit f3c83488a3
1 changed files with 560 additions and 459 deletions

View File

@ -244,7 +244,8 @@
<el-table-column <el-table-column
label="操作"> label="操作">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="text" size="small" @click="changeSkuStatus(`${scope.$index}`)" v-if="scope.row.status===0"> <el-button type="text" size="small" @click="changeSkuStatus(`${scope.$index}`)"
v-if="scope.row.status===0">
正常 正常
</el-button> </el-button>
<el-button type="text" size="small" @click="changeSkuStatus(`${scope.$index}`)" v-else></el-button> <el-button type="text" size="small" @click="changeSkuStatus(`${scope.$index}`)" v-else></el-button>
@ -319,6 +320,7 @@
propertyId: '', propertyId: '',
selectValues: [], selectValues: [],
selectValueIds: [], selectValueIds: [],
selectObect:[],
}, },
skuTags: [], skuTags: [],
propName: { propName: {
@ -388,7 +390,8 @@
created() { created() {
this.getList(); this.getList();
this.getPropertyPageList();
this.getListCategory();
}, },
methods: { methods: {
getTableSpecData() { getTableSpecData() {
@ -434,22 +437,40 @@
let skus = this.unUseTags.map(function (item, index) { let skus = this.unUseTags.map(function (item, index) {
return item.name return item.name
}); });
console.log("skus=="+JSON.stringify(skus))
let index = skus.indexOf(this.addTagInput.name); let index = skus.indexOf(this.addTagInput.name);
console.log("index=="+index)
console.log("skus[index].id=="+this.unUseTags[index].id)
console.log("this.unUseTags[index].propertyValueList=="+JSON.stringify(this.unUseTags[index].propertyValueList))
this.addTagInput.propertyId = this.unUseTags[index].id; this.addTagInput.propertyId = this.unUseTags[index].id;
for (let i = 0; i < this.addTagInput.selectValues.length; i++) { for (let i = 0; i < this.addTagInput.selectValues.length; i++) {
for (let j = 0; j < this.unUseTags[index].propertyValueList.length; j++) { for (let j = 0; j < this.unUseTags[index].propertyValueList.length; j++) {
if (this.addTagInput.selectValues[i] === this.unUseTags[index].propertyValueList[j].name) { if (this.addTagInput.selectValues[i] === this.unUseTags[index].propertyValueList[j].name) {
this.addTagInput.selectValueIds.push(this.unUseTags[index].propertyValueList[j].id) this.addTagInput.selectValueIds.push(this.unUseTags[index].propertyValueList[j].id)
this.addTagInput.selectObect.push({
id:this.unUseTags[index].propertyValueList[j].id,
name:this.unUseTags[index].propertyValueList[j].name,
})
} }
} }
} }
let addTagInput = JSON.parse(JSON.stringify(this.addTagInput)) let addTagInput = JSON.parse(JSON.stringify(this.addTagInput))
console.log("addTagInput=="+JSON.stringify(addTagInput))
this.skuTags.push(addTagInput); this.skuTags.push(addTagInput);
// if (this.skuTags.length > 1) {
this.skuTags = this.skuTags.sort((a, b) => a.propertyId - b.propertyId);
this.skuTags.forEach(function (item,index) {
item.selectObect = item.selectObect.sort((a, b) => a.id - b.id)
})
for (let i = 0; i <this.skuTags.length ; i++) {
let selectValueIds=[];
let selectValues=[];
for (let j = 0; j < this.skuTags[i].selectObect.length; j++) {
selectValueIds.push(this.skuTags[i].selectObect[j].id);
selectValues.push(this.skuTags[i].selectObect[j].name);
}
this.skuTags[i].selectValues = selectValues;
this.skuTags[i].selectValueIds = selectValueIds;
}
this.unUseTags.splice(index, 1); this.unUseTags.splice(index, 1);
this.isShowTagInput = false; this.isShowTagInput = false;
this.getTable(); this.getTable();
@ -467,19 +488,19 @@
propertyIds.push(skuTags[i].propertyId); propertyIds.push(skuTags[i].propertyId);
propertyNames.push(skuTags[i].name); propertyNames.push(skuTags[i].name);
} }
let skuAll = sku1s.reduce((x, y) => { let skuAll = sku1s.reduce((x, y) => {
let arr = []; let arr = [];
x.forEach(m => y.forEach(y => arr.push(m.concat([y])))) x.forEach(m => y.forEach(y => arr.push(m.concat([y]))))
return arr; return arr;
}, [[]]) }, [[]])
console.log(skuAll);
let skuIdAll = skuIds.reduce((x, y) => { let skuIdAll = skuIds.reduce((x, y) => {
let arr = []; let arr = [];
x.forEach(m => y.forEach(y => arr.push(m.concat([y])))) x.forEach(m => y.forEach(y => arr.push(m.concat([y]))))
return arr; return arr;
}, [[]]) }, [[]])
console.log(skuIdAll);
for (let i = 0; i < skuAll.length; i++) { for (let i = 0; i < skuAll.length; i++) {
let han = { let han = {
propertyNames: propertyNames, propertyNames: propertyNames,
@ -508,7 +529,6 @@
} }
}) })
console.log("this.skus=="+JSON.stringify(this.form.skus))
}, },
hideTagInput() { hideTagInput() {
this.isShowTagInput = false; this.isShowTagInput = false;
@ -517,6 +537,7 @@
propertyId: '', propertyId: '',
selectValues: [], selectValues: [],
selectValueIds: [], selectValueIds: [],
selectObect: [],
}; };
}, },
shopTagInput() { shopTagInput() {
@ -529,6 +550,7 @@
propertyId: '', propertyId: '',
selectValues: [], selectValues: [],
selectValueIds: [], selectValueIds: [],
selectObect: [],
}; };
}, },
// //
@ -558,7 +580,6 @@
return item return item
}) })
this.allhistoryTags = JSON.parse(JSON.stringify(this.unUseTags)); this.allhistoryTags = JSON.parse(JSON.stringify(this.unUseTags));
console.log(this.propertyPageList)
}); });
}, },
/** 查询分类 */ /** 查询分类 */
@ -625,7 +646,6 @@
this.reset(); this.reset();
this.open = true; this.open = true;
this.title = "添加商品spu"; this.title = "添加商品spu";
this.getListCategory();
this.getPropertyPageList(); this.getPropertyPageList();
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
@ -633,7 +653,6 @@
this.reset(); this.reset();
const id = row.id; const id = row.id;
getSpu(id).then(response => { getSpu(id).then(response => {
console.log(">>>>>> response.data:" + JSON.stringify(response.data))
let dataSpu = response.data; let dataSpu = response.data;
this.form = { this.form = {
id: dataSpu.id, id: dataSpu.id,
@ -649,17 +668,99 @@
quantity: dataSpu.quantity, quantity: dataSpu.quantity,
status: dataSpu.status, status: dataSpu.status,
isShowTagInput: undefined, isShowTagInput: undefined,
skus:dataSpu.skus skus: [],
skusList: dataSpu.skus,
productPropertyViews: dataSpu.productPropertyViews,
// skus:dataSpu.productSkuRespVOS, // skus:dataSpu.productSkuRespVOS,
}; };
this.getDataHandle();
this.open = true; this.open = true;
this.title = "修改商品spu"; this.title = "修改商品spu";
}); });
}, },
getDataHandle() {
let that = this;
let productPropertyViews = JSON.parse(JSON.stringify(this.form.productPropertyViews));
productPropertyViews = productPropertyViews.sort((a, b) => a.propertyId - b.propertyId);
productPropertyViews.forEach(item => {
item.propertyValues = item.propertyValues.sort((a, b) => a.v1 - b.v1);
})
let skuIds = [];
for (let i = 0; i < productPropertyViews.length; i++) {
let han = {
name: productPropertyViews[i].name,
propertyId: productPropertyViews[i].propertyId,
selectValues: [],
selectValueIds: [],
}
for (let j = 0; j < productPropertyViews[i].propertyValues.length; j++) {
han.selectValues.push(productPropertyViews[i].propertyValues[j].v2);
han.selectValueIds.push(productPropertyViews[i].propertyValues[j].v1);
}
skuIds.push(han)
}
this.skuTags = skuIds;
this.unUseTags = this.allhistoryTags.filter((v) =>
skuIds.every((val) => val.name != v.name)
)
this.getHandleTable();
},
getHandleTable() {
this.form.skus = [];
let skuTags = JSON.parse(JSON.stringify(this.skuTags));
let sku1s = [];
let skuIds = [];
let propertyIds = [];
let propertyNames = [];
for (let i = 0; i < skuTags.length; i++) {
sku1s.push(skuTags[i].selectValues);
skuIds.push(skuTags[i].selectValueIds);
propertyIds.push(skuTags[i].propertyId);
propertyNames.push(skuTags[i].name);
}
let skuAll = sku1s.reduce((x, y) => {
let arr = [];
x.forEach(m => y.forEach(y => arr.push(m.concat([y]))))
return arr;
}, [[]])
let skuIdAll = skuIds.reduce((x, y) => {
let arr = [];
x.forEach(m => y.forEach(y => arr.push(m.concat([y]))))
return arr;
}, [[]])
for (let i = 0; i < skuAll.length; i++) {
let han = {
propertyNames: propertyNames,
propertyIds: propertyIds,
propertyChildNames: skuAll[i],
propertyChildIds: skuIdAll[i],
properties: this.form.skusList[i].properties,
picUrl: this.form.skusList[i].picUrl,
costPrice: this.form.skusList[i].costPrice,
originalPrice: this.form.skusList[i].originalPrice,
spuId: this.form.skusList[i].spuId,
prodName: this.form.skusList[i].prodName,
price: this.form.skusList[i].price,
barCode: this.form.skusList[i].barCode,
status: this.form.skusList[i].status,
}
this.form.skus.push(han);
}
this.form.skus.forEach(x => {
x.properties = [];
for (let i = 0; i < x.propertyIds.length; i++) {
x.properties.push({
propertyId: x.propertyIds[i],
valueId: x.propertyChildIds[i]
})
}
})
},
/** 提交按钮 */ /** 提交按钮 */
submitForm() { submitForm() {
console.log(this.form.picUrls.split(','));
this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
if (!valid) { if (!valid) {