Authored by htoooth

add

... ... @@ -72,9 +72,8 @@ function getWashTip(sorId) {
}
function saveBaseProductInfo(product) {
return request.post(apiUrl.addProduct, {
params: product
}).then(result => result.data);
return request.post(apiUrl.addProduct, product)
.then(result => result.data);
}
export default {
... ...
... ... @@ -253,10 +253,10 @@
render(row, col, index) {
return `<div v-if="isExist(${index})">
<i-input
:value="table.data[${index}].factoryGoodsName"
v-model="row.factoryGoodsName"
placeholder="请输入..."
style="width: 100px"
@on-change="changeFactoryGoodsName($event,${index})">
@on-blur="changeFactoryGoodsName(row,${index})">
</i-input>
</div>`
}
... ... @@ -275,7 +275,12 @@
key: 'factoryCode',
render(row, col, index) {
return `<div v-if="isExist(${index})">
<i-input :value="table.data[${index}].factoryCode" placeholder="请输入..." style="width: 100px"></i-input>
<i-input
v-model="row.factoryCode"
@on-blur="changeFactoryCode(row, ${index})"
placeholder="请输入..."
style="width: 100px">
</i-input>
</div>`
}
},
... ... @@ -296,7 +301,11 @@
render(row, col, index) {
return `<div class='size-code'>
<div v-for="size,i in row.sizeCode" class="row-span">
<i-input :value="table.data[${index}].sizeCode.name" placeholder="请输入..." style="width: 100px"/>
<i-input
v-model="size.name"
@on-blur="changeSizeCode(row, ${index}, i)"
placeholder="请输入..."
style="width: 100px"/>
</div>
</div>`;
}
... ... @@ -329,9 +338,7 @@
},
methods: {
nextStep: function() {
console.log(this.product);
console.log(this.table);
this.submit();
this.step.value = 2;
// this.$router.push({name:'product.create.step3'})
},
... ... @@ -357,9 +364,20 @@
clickColor: function(color) {
this.addColor(color);
},
changeFactoryGoodsName: function(event, index) {
console.log(event.target.value);
this.table.data[index].factoryGoodsName = event.target.value;
changeFactoryGoodsName: function(row, index) {
this.table.data[index].factoryGoodsName = row.factoryGoodsName;
},
changeFactoryCode: function(row, index) {
this.table.data[index].factoryCode = row.factoryCode;
},
changeUploadFileSuccess: function(row, index) {
this.table.data[index].goodsColorImage = row.goodsColorImage;
},
changeUploadFileFail: function(row, index) {
},
changeSizeCode: function(row, rowIndex, sizeIndex) {
this.table.data[rowIndex].sizeCode[sizeIndex].name = row.sizeCode[sizeIndex].name;
},
clickDefault: function(index) {
let color = this.table.data[index];
... ... @@ -373,6 +391,7 @@
},
clickOperator: function(rowIndex, itemIndex) {
let rowColor = this.table.data[rowIndex];
rowColor.operator[itemIndex].value = rowColor.operator[itemIndex].value ? false:true;
},
clickGoodsYear: function(value) {
... ... @@ -513,14 +532,47 @@
return false;
},
submit: function() {
this.beforeSubmit();
api.saveBaseProductInfo(this.product).then((result) => {
if (result.code === 200) {
console.log(result.data);
console.log(result);
}
});
},
beforeSubmit: function() {
const handleColor = (color) => {
let newColor = makeColor();
newColor.goodsName = color.goodsName.name;
newColor.isDefault = color.goodsName.isDefault ? 'Y' : 'N';
newColor.factoryGoodsName = color.factoryGoodsName;
newColor.factoryCode = color.factoryCode;
newColor.goodsColorImage = color.goodsColorImage;
newColor.colorId = color.colorId;
let goodsSizeList = [];
color.operator.forEach((op, i) => {
if (!op.value) {
return;
}
let goodsSize = {};
goodsSize.sizeId = color.sizeId[i].id;
goodsSize.factoryCode = color.sizeCode[i].name;
goodsSizeList.push(goodsSize);
});
newColor.goodsSizeList = goodsSizeList;
return newColor;
}
this.product.sellerGoodsInfoStr = JSON.stringify(this.table.data.map(handleColor))
}
},
watch: {
... ...