Authored by htoooth

fix

... ... @@ -18,6 +18,7 @@
:show-upload-list="false"
:data="{bucket: 'goodsimg'}"
:on-success="handleSuccess"
:on-error="handleError"
:default-file-list="defaultList"
:format="['jpg','jpeg','png']"
:max-size="2048"
... ... @@ -69,6 +70,10 @@ export default {
this.$emit('on-success', this.id, file);
},
handleError(){
this.$Notice.error('上传失败');
this.$emit('on-error', this.id, error);
},
handleFormatError(file) {
this.$Notice.warning({
title: '文件格式不正确',
... ...
import getProduct from './product-service';
const handleGoods = (goods) => {
let newGoods = {};
... ... @@ -70,12 +68,6 @@ const handleGoods = (goods) => {
const handleColorImage = (product) => {
let colorsObj = {};
colorsObj.productSkn = product.productSkn;
let findDefaultSkcIndex = product.goods.findIndex(c => c.isDefault === 'Y');
colorsObj.productSkc = findDefaultSkcIndex !== -1 ? product.goods[findDefaultSkcIndex].productSkc : '';
colorsObj.goodsImagesBoList = product.goods.reduce((total, cur) => {
total = total.concat(cur.goodsImage.filter(g => g.imageUrl));
return total;
... ... @@ -86,6 +78,5 @@ const handleColorImage = (product) => {
export default {
handleGoods,
handleColorImage,
getProduct
handleColorImage
};
... ...
/**
* Created by TaoHuang on 2017/4/26.
*/
import api from '../api';
function getProduct(skn) {
return api.getProductAllInfo(skn).then((result) => {
return result.data;
});
}
export default getProduct;
... ... @@ -128,7 +128,12 @@
<Row>
<div class="ivu-form-item ivu-form-item-required">
<label class="ivu-form-item-label" style="width: 70px;">尺寸</label>
<div :class="{'product-table-error': table.showValidateSize}" style="margin-left: 70px;">
<div :class="{
'ivu-form-item-content': true,
'product-table-error': table.showValidateSize
}"
style="margin-left: 70px;"
>
<Checkbox-group v-model='table.selectedSizes'>
<Checkbox v-for="size in sizes" :key="size" :label="size.id" >
<span>{{size.sizeName}}</span>
... ...
... ... @@ -718,7 +718,7 @@ export default {
newGoods.colorId = goods.colorId;
newGoods.factoryGoodsName = goods.factoryGoodsName;
newGoods.goodsColorImage = {
value: service.getAbsoluteUrl(goodsImage.goodsColorImage),
value: goodsImage.goodsColorImage,
showValidate: false,
validate: false
};
... ... @@ -992,6 +992,7 @@ export default {
let errors = [];
this.table.data.forEach((color) => {
console.log(color);
if (!color.goodsColorImage.value) {
color.goodsColorImage.showValidate = true;
color.goodsColorImage.validate = true;
... ... @@ -1051,13 +1052,17 @@ export default {
return newColor;
},
handleSize: function(color) {
return color.sizeId.map((s, i) => {
let sizeId = s.id;
let productSku = s.productSku;
return color.sizeId.reduce((total, cur, i) => {
if (color.sizeCode[i].name) {
let sizeId = cur.id;
let productSku = cur.productSku;
let factoryCode = color.sizeCode[i].name;
return {sizeId, factoryCode, productSku};
});
total.push({sizeId, factoryCode, productSku});
}
return total;
}, []);
},
handleImage: function() {
return service.handleEditColorImage(this.product);
... ...
... ... @@ -96,33 +96,9 @@ const handleGoodsImage = (goodsColorInfo) => {
return newGoods;
};
const handleColorImage = (product) => {
let colorsObj = {};
colorsObj.productSkn = product.productSkn;
let findDefaultSkcIndex = product.goods.findIndex(c => c.isDefault === 'Y');
colorsObj.productSkc = findDefaultSkcIndex !== -1 ? product.goods[findDefaultSkcIndex].productSkc : '';
colorsObj.goodsImagesBoList = product.goods.reduce((total, cur) => {
total = total.concat(cur.goodsImage.filter(g => g.imageUrl));
return total;
}, []);
return colorsObj;
};
const handleEditColorImage = (product) => {
let colorsObj = {};
colorsObj.productSkn = product.productSkn;
let findDefaultSkcIndex = product.goods.findIndex(c => c.isDefault === 'Y');
// TODO: 新增主推还没有处理
colorsObj.productSkc = findDefaultSkcIndex !== -1 ? product.goods[findDefaultSkcIndex].productSkc : '';
colorsObj.goodsImagesBoList = product.goods.reduce((total, cur) => {
total = total.concat(cur.goodsImage.filter(g => g.imageUrl));
return total;
... ... @@ -131,30 +107,9 @@ const handleEditColorImage = (product) => {
return colorsObj;
};
function getAbsoluteUrl(url) {
if (!url) {
return null;
}
let urlArr = url.split('/'),
stag = urlArr[urlArr.length - 1].substr(0, 2),
domain = `static.yhbimg.com/goodsimg`;
url = domain + url;
if (stag === '01') {
return `//img11.${url}`;
} else if (stag === '03') {
return `//flv01.${url}`;
} else {
return `//img12.${url}`;
}
}
export default {
handleGoods,
handleColorImage,
getProduct,
getAbsoluteUrl,
handleGoodsImage,
handleEditColorImage
};
... ...