商品规格回显
parent
8520ca21ea
commit
c24b09d95a
|
@ -335,6 +335,7 @@
|
||||||
<el-table
|
<el-table
|
||||||
:data="skuList"
|
:data="skuList"
|
||||||
border
|
border
|
||||||
|
max-height="500"
|
||||||
style="width: 100%">
|
style="width: 100%">
|
||||||
<el-table-column v-for="title in titleList" :prop="title.prop" :label="title.label">
|
<el-table-column v-for="title in titleList" :prop="title.prop" :label="title.label">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
|
@ -410,7 +411,14 @@ export default {
|
||||||
brandId: null,
|
brandId: null,
|
||||||
},
|
},
|
||||||
// 表单参数
|
// 表单参数
|
||||||
form: {},
|
form: {
|
||||||
|
mianType: '',
|
||||||
|
parentType: '',
|
||||||
|
type:'',
|
||||||
|
image: '',
|
||||||
|
price: '',
|
||||||
|
stock: ''
|
||||||
|
},
|
||||||
// 表单校验
|
// 表单校验
|
||||||
rules: {
|
rules: {
|
||||||
name: [
|
name: [
|
||||||
|
@ -495,7 +503,6 @@ export default {
|
||||||
},
|
},
|
||||||
"form.type": {
|
"form.type": {
|
||||||
handler(value) {
|
handler(value) {
|
||||||
console.log(value)
|
|
||||||
if (value != null){
|
if (value != null){
|
||||||
getTemplateAttribute(value).then(response => {
|
getTemplateAttribute(value).then(response => {
|
||||||
const {data} = response;
|
const {data} = response;
|
||||||
|
@ -515,6 +522,7 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
oneSetting(){
|
oneSetting(){
|
||||||
this.skuList.forEach(skuInfo => {
|
this.skuList.forEach(skuInfo => {
|
||||||
|
console.log(skuInfo)
|
||||||
skuInfo.image = this.oneSettingForm.image;
|
skuInfo.image = this.oneSettingForm.image;
|
||||||
skuInfo.stock = this.oneSettingForm.stock;
|
skuInfo.stock = this.oneSettingForm.stock;
|
||||||
skuInfo.price = this.oneSettingForm.price;
|
skuInfo.price = this.oneSettingForm.price;
|
||||||
|
@ -523,7 +531,11 @@ export default {
|
||||||
changeRule(ruleId){
|
changeRule(ruleId){
|
||||||
this.titleList = []
|
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;
|
||||||
|
|
||||||
|
console.log(ruleInfo)
|
||||||
|
console.log(ruleAttrList)
|
||||||
let skuTotal = 1;
|
let skuTotal = 1;
|
||||||
for (let ruleAttrListKey in ruleAttrList) {
|
for (let ruleAttrListKey in ruleAttrList) {
|
||||||
let ruleAttrInfo = ruleAttrList[ruleAttrListKey];
|
let ruleAttrInfo = ruleAttrList[ruleAttrListKey];
|
||||||
|
@ -534,7 +546,6 @@ export default {
|
||||||
skuTotal = skuTotal * ruleAttrInfo.valueList.length;
|
skuTotal = skuTotal * ruleAttrInfo.valueList.length;
|
||||||
}
|
}
|
||||||
this.titleList.push(...this.templateTitleList) ;
|
this.titleList.push(...this.templateTitleList) ;
|
||||||
console.log(this.titleList);
|
|
||||||
this.skuList = [];
|
this.skuList = [];
|
||||||
for (let i = 0; i < skuTotal; i++) {
|
for (let i = 0; i < skuTotal; i++) {
|
||||||
this.skuList.push(
|
this.skuList.push(
|
||||||
|
@ -626,7 +637,6 @@ export default {
|
||||||
listCategory().then(response => {
|
listCategory().then(response => {
|
||||||
this.categoryOptions = [];
|
this.categoryOptions = [];
|
||||||
this.categoryOptions = this.handleTree(response.data, "id", "parentId");
|
this.categoryOptions = this.handleTree(response.data, "id", "parentId");
|
||||||
console.log(this.categoryOptions)
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
remoteSearchBrandList(queryValue){
|
remoteSearchBrandList(queryValue){
|
||||||
|
@ -640,7 +650,7 @@ export default {
|
||||||
next() {
|
next() {
|
||||||
let isValidate = true;
|
let isValidate = true;
|
||||||
this.$refs["form"].validateField(this.rulesTemplateMap[this.stepNumber],(valid) => {
|
this.$refs["form"].validateField(this.rulesTemplateMap[this.stepNumber],(valid) => {
|
||||||
console.log(valid)
|
|
||||||
if (valid) {
|
if (valid) {
|
||||||
isValidate = false;
|
isValidate = false;
|
||||||
}
|
}
|
||||||
|
@ -713,24 +723,69 @@ export default {
|
||||||
handleUpdate(row) {
|
handleUpdate(row) {
|
||||||
this.reset();
|
this.reset();
|
||||||
const id = row.id || this.ids
|
const id = row.id || this.ids
|
||||||
|
|
||||||
getInfo(id).then(response => {
|
getInfo(id).then(response => {
|
||||||
|
|
||||||
|
console.log(response)
|
||||||
this.form = response.data;
|
this.form = response.data;
|
||||||
|
|
||||||
|
this.initCategoryTree()
|
||||||
|
this.form.mianType=parseInt(response.data.mianType)
|
||||||
|
this.form.type=parseInt(response.data.type)
|
||||||
|
|
||||||
|
this.oneSettingForm = response.data.productSkuModel
|
||||||
|
this.changeRule(response.data.ruleId)
|
||||||
|
this.oneSetting()
|
||||||
this.open = true;
|
this.open = true;
|
||||||
this.title = "修改商品信息";
|
this.title = "修改商品信息";
|
||||||
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/** 提交按钮 */
|
/** 提交按钮 */
|
||||||
submitForm() {
|
submitForm() {
|
||||||
this.$refs["form"].validate(valid => {
|
this.$refs["form"].validate(valid => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
let attrValueList = [];
|
||||||
|
for (const templateAttributeGroup of this.categoryCommonElement.templateAttributeGroupList) {
|
||||||
|
templateAttributeGroup.attributeList.map(attribute => attrValueList.push({id: attribute.id, value: attribute.value}))
|
||||||
|
}
|
||||||
|
|
||||||
|
this.categoryCommonElement.templateAttributeList.map(attribute => attrValueList.push({id: attribute.id, value: attribute.value}))
|
||||||
|
this.attributeCheckedList.map(attribute => attrValueList.push({id: attribute.id, value: attribute.value}))
|
||||||
|
let ruleInfo = this.ruleList.find(ruleInfo => ruleInfo.id === this.form.ruleId);
|
||||||
|
const {ruleAttrList} = ruleInfo;
|
||||||
|
let ruleAttrSize = ruleAttrList.length;
|
||||||
|
let productSkuList = this.skuList.map(skuInfo => {
|
||||||
|
let sku = "";
|
||||||
|
for (let index = 0; ; index++) {
|
||||||
|
sku += skuInfo["prop"+index];
|
||||||
|
if (index+1 >= ruleAttrSize){
|
||||||
|
break;
|
||||||
|
}else {
|
||||||
|
sku += "-";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
sku: sku,
|
||||||
|
image: skuInfo.image,
|
||||||
|
stock: skuInfo.stock,
|
||||||
|
price: skuInfo.price
|
||||||
|
}
|
||||||
|
})
|
||||||
|
let productAddReq = {
|
||||||
|
projectAddModel: this.form,
|
||||||
|
attrValueList: attrValueList,
|
||||||
|
productSkuList: productSkuList
|
||||||
|
};
|
||||||
|
console.log(productAddReq)
|
||||||
if (this.form.id != null) {
|
if (this.form.id != null) {
|
||||||
updateInfo(this.form).then(response => {
|
updateInfo(productAddReq).then(response => {
|
||||||
this.$modal.msgSuccess("修改成功");
|
this.$modal.msgSuccess("修改成功");
|
||||||
this.open = false;
|
this.open = false;
|
||||||
this.getList();
|
this.getList();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
addInfo(this.form).then(response => {
|
addInfo(productAddReq).then(response => {
|
||||||
this.$modal.msgSuccess("新增成功");
|
this.$modal.msgSuccess("新增成功");
|
||||||
this.open = false;
|
this.open = false;
|
||||||
this.getList();
|
this.getList();
|
||||||
|
|
Loading…
Reference in New Issue