Authored by 陈峰

Merge branch 'release/1.0' of http://git.yoho.cn/fe/yoho-shop-manage into release/1.0

... ... @@ -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 = {};
newGoods.productId = goods.productId;
newGoods.productSkc = goods.productSkc;
newGoods.productSkn = goods.productSkn;
newGoods.factoryGoodsName = goods.factoryGoodsName;
newGoods.goodsName = goods.goodsName;
newGoods.isDefault = goods.isDefault;
// 数组的意义:
// 0商品正面图
// 1商品反面图
// 2模特图
// 3男生频道封面图
// 4女生频道封面图
newGoods.goodsImage = [{ //0
angle: 0,
genderCover: 0,
imageUrl: goods.goodsColorImage,
isDefault: 'Y',
orderBy: 0,
productSkn: goods.productSkn,
productSkc: goods.productSkc,
status: 1
}, { //1
angle: 0,
genderCover: 0,
imageUrl: '',
isDefault: 'N',
orderBy: 0,
productSkn: goods.productSkn,
productSkc: goods.productSkc,
status: 1
}, { //2
angle: 0,
genderCover: 0,
imageUrl: '',
isDefault: 'Y',
orderBy: 0,
productSkn: goods.productSkn,
productSkc: goods.productSkc,
status: 1
}, { //3
angle: 0,
genderCover: 1,
imageUrl: '',
isDefault: 'Y',
orderBy: 0,
productSkn: goods.productSkn,
productSkc: goods.productSkc,
status: 1
}, { //4
angle: 0,
genderCover: 2,
imageUrl: '',
isDefault: 'Y',
orderBy: 0,
productSkn: goods.productSkn,
productSkc: goods.productSkc,
status: 1
}];
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;
};
export default {
handleGoods,
handleColorImage,
getProduct
};
/**
* 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;
... ... @@ -58,7 +58,7 @@
<script>
import api from '../api';
import api from 'product-create/api';
export default {
props: ['step', 'product'],
... ...
... ... @@ -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>
... ... @@ -183,8 +188,8 @@
<script>
import api from '../api';
import service from '../service';
import api from 'product-create/api';
import service from 'product-create/service';
const _ = require('lodash');
import Age from './age';
... ...
... ... @@ -212,9 +212,9 @@
<script>
import ProductUpload from '../../../../components/global/common/drag-file-upload';
import api from '../api';
import service from '../service';
import api from 'product-create/api';
import service from 'product-create/service';
import serial from 'product-create/serialize';
export default {
props: ['step', 'product'],
... ... @@ -287,43 +287,13 @@ export default {
return result;
},
handleRelation: function() {
return this.render.productStandardRelationStr.reduce((total, r) => {
if (r.model) {
total.push({
standardId: r.attributeId,
standardVal: r.attributeName,
parameterMakeId: r.inputType === 'checkbox' ? r.model.join(',') : r.model
});
}
return total;
}, []);
return serial.handleRelation(this.render.productStandardRelationStr)
},
handleOne: function() {
return this.render.attributeProValuesOne.reduce((total, r) => {
if (r.model) {
total.push({
attributeId: r.attributeId,
productSkn: this.product.productSkn,
attributeValueId: r.inputType === 'checkbox' ? r.model.join(',') : r.model
});
}
return total;
}, []);
return serial.handleOne(this.product.productSkn, this.render.attributeProValuesOne);
},
handleTwo: function() {
return this.render.attributeProValuesTwo.reduce((total, r) => {
if (r.model || r.model.length !== 0) {
total.push({
attributeId: r.attributeId,
productSkn: this.product.productSkn,
attributeValueId: r.inputType === 'checkbox' ? r.model.join(',') : r.model
});
}
return total;
}, []);
return serial.handleTwo(this.product.productSkn, this.render.attributeProValuesTwo);
},
handleMaterial: function() {
return this.render.productMaterial.model.join(',');
... ...
let apiUrl = {
brand: '/platform/getSellerBrandInfo',
sort: '/platform/getSellerSortInfo',
color: '/platform/querySellerProductColors',
size: '/platform/querySortSize',
addProduct: '/platform/addProduct',
params: '/platform/queryProductParamBySortId',
attr: '/platform/selectAttributes',
material: '/platform/querySellerProductMaterial',
updateNetInfo: '/platform/updateSellerProductNetSaleInfo',
updateProduct: '/platform/updateProduct',
getProduct: '/platform/getProduct'
};
const request = require('axios');
/**
* 获得店铺关联品牌
*/
function getBrand() {
return request.get(apiUrl.brand).then((result) => result.data);
}
/**
* 根据品牌获得品类信息
* @param brandId
* @param level 可选参数:1, 2, 3
* @param sortId 父级sortId
*/
function getSort(brandId, level, sortId) {
let opts = {
brandId: brandId,
level: level
};
if (sortId) {
Object.assign(opts, {sortId});
}
return request.get(apiUrl.sort, {
params: opts
}).then((result) => result.data);
}
/**
* 获得品牌所支持的所有颜色
*/
function getColor() {
return request.get(apiUrl.color).then((result) => result.data);
}
/**
* 获得品类下所支持的尺码
* @param smallSortId
*/
function getSize(smallSortId) {
return request.get(apiUrl.size, {
params: {
sortId: smallSortId
}
}).then(result => result.data);
}
/**
* 获得品类支持的商品相关参数
* @param sortId
*/
function getProductParams(sortId) {
return request.get(apiUrl.params, {
params: {
sortId
}
}).then(result => result.data);
}
/**
* 获得品类的属性
* @param sorId
*/
function getProductAttribute(sortId) {
const saleType = 2;
const displayPosition = 3;
return request.get(apiUrl.attr, {
params: {
categoryId: sortId,
saleType,
displayPosition
}
}).then(result => result.data);
}
/**
* 获得商品风格
* @param sortId
*/
function getProductStyle(sortId) {
const saleType = 2;
const displayPosition = 2;
return request.get(apiUrl.attr, {
params: {
categoryId: sortId,
saleType,
displayPosition
}
}).then(result => result.data);
}
/**
* 获得品类下的所有材质
* @param sortId 第一级sort
*/
function getMaterial(maxSortId) {
return request.get(apiUrl.material, {
params: {
maxSortId: maxSortId
}
}).then(result => result.data);
}
/**
* 获得所有属性
* @param smallSortId
* @param maxSortId
*/
function addModelAttr(attr) {
attr.model = attr.inputType === 'checkbox' ? [] : '';
return attr;
}
function getAllAttr(smallSortId, maxSortId) {
return Promise.all([
getProductParams(smallSortId).then(r => r.data).then(r => r.map(addModelAttr)),
getProductAttribute(smallSortId).then(r => r.data).then(r => r.map(addModelAttr)),
getProductStyle(smallSortId).then(r => r.data).then(r => r.map(addModelAttr)),
getMaterial(maxSortId).then(r => r.data).then(r => addModelAttr(r)),
]);
}
/**
* 更新商品网销信息
* @param info
*/
function updateNetInfo(info) {
return request.post(apiUrl.updateNetInfo, info)
.then(result => result.data);
}
/**
* 保存商品基本信息
* @param product
*/
function saveBaseProductInfo(product) {
return request.post(apiUrl.addProduct, product)
.then(result => result.data);
}
/**
* 查询商品所以有信息,包括网销信息
* @param skn
*/
function getProductAllInfo(skn) {
return request.get(apiUrl.getProduct, {
params: {
productSkn: skn
}
}).then(result => result.data);
}
/**
* 更新商品信息,包括基础信息和网销信息
* @param product
*/
function updateProductAllInfo(product) {
return request.post(apiUrl.updateProduct, product)
.then(result => result.data);
}
export default {
getBrand,
getSort,
getColor,
getSize,
getProductParams,
getProductAttribute,
getMaterial,
getProductStyle,
getAllAttr,
updateNetInfo,
saveBaseProductInfo,
getProductAllInfo,
updateProductAllInfo
};
... ... @@ -341,8 +341,9 @@ import Season from './views/season';
import Gender from './views/gender';
import GoodsSeason from './views/goods-season';
import service from './service';
import api from './api';
import service from 'product-create/service';
import api from 'product-create/api';
import serial from 'product-create/serialize';
const _ = require('lodash');
const Fn = require('lodash/fp');
... ... @@ -718,7 +719,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
};
... ... @@ -1051,59 +1052,29 @@ export default {
return newColor;
},
handleSize: function(color) {
return color.sizeId.map((s, i) => {
let sizeId = s.id;
let productSku = s.productSku;
let factoryCode = color.sizeCode[i].name;
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);
},
handleRelation: function() {
return this.render.productStandardRelationStr.reduce((total, r) => {
if (r.model) {
total.push({
standardId: r.attributeId,
standardVal: r.attributeName,
parameterMakeId: r.model.join(',')
});
}
return total;
}, []);
return serial.handleRelation(this.render.productStandardRelationStr);
},
handleOne: function() {
return this.render.attributeProValuesOne.reduce((total, r) => {
let str = _.isArray(r.model) ? r.model.join(',') : r.model;
if (str) {
total.push({
attributeId: r.attributeId,
productSkn: this.product.productSkn,
attributeValueId: str
});
}
return total;
}, []);
return serial.handleOne(this.product.productSkn, this.render.attributeProValuesOne);
},
handleTwo: function() {
return this.render.attributeProValuesTwo.reduce((total, r) => {
let str = _.isArray(r.model) ? r.model.join(',') : r.model;
if (str) {
total.push({
attributeId: r.attributeId,
productSkn: this.product.productSkn,
attributeValueId: str
});
}
return total;
}, []);
return serial.handleTwo(this.product.productSkn, this.render.attributeProValuesTwo);
},
},
components: {
... ...
/**
* 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;
... ... @@ -214,9 +214,7 @@ let tableCols = [
render: function(row, column, index) {
return `<div class="action-btn-row">
<i-button type="primary" size="small" @click="editSize(row.productSkn)">尺码维护</i-button>
<i-button v-if="row._disabled" type="primary" size="small"
@click="editProduct(${row.productSkn})" disabled>内容编辑</i-button>
<i-button v-else type="primary" size="small" @click="editProduct(${row.productSkn})">内容编辑</i-button>
<i-button type="primary" size="small" @click="editProduct(${row.productSkn})">内容编辑</i-button>
</div>
<div class="btn-row-space">
<i-button v-if="row._disabled" type="success" size="small"
... ...
... ... @@ -2,7 +2,7 @@
<LayoutBody>
<LayoutFilter>
<FilterItem :label="filters.sknCode.label">
<Input v-model.trim.trim="filters.sknCode.model"
<Input v-model.trim="filters.sknCode.model"
:placeholder="filters.sknCode.holder"></Input>
</FilterItem>
<FilterItem :label="filters.prodCode.label">
... ...
... ... @@ -131,7 +131,7 @@ let tableCols = [
title: '商品信息',
key: 'info',
align: 'center',
render(row, column, index) {
render(row) {
return `<cell-info
:skn="row.productSkn"
:product-name="row.productName"
... ... @@ -175,7 +175,7 @@ let tableCols = [
title: '审核状态',
key: 'verify',
align: 'center',
render(row, column, index) {
render(row) {
return `${auditStatus[row.auditStatus]}`
}
},
... ... @@ -184,12 +184,10 @@ let tableCols = [
key: 'action',
width: 180,
align: 'center',
render: function(row, column, index) {
render: function(row) {
return `<div class="action-btn-row">
<i-button type="primary" size="small" @click="editSize(row.productSkn)">尺码维护</i-button>
<i-button v-if="row._disabled" type="primary" size="small"
@click="editProduct(${row.productSkn})" disabled>内容编辑</i-button>
<i-button v-else type="primary" size="small" @click="editProduct(${row.productSkn})">内容编辑</i-button>
<i-button type="primary" size="small" @click="editProduct(${row.productSkn})">内容编辑</i-button>
</div>
<div class="btn-row-space">
<i-button v-if="row._disabled" type="error" size="small"
... ...
/**
* Created by TaoHuang on 2017/5/4.
*/
let apiUrl = {
brand: '/platform/getSellerBrandInfo',
... ... @@ -155,7 +158,7 @@ function updateNetInfo(info) {
*/
function saveBaseProductInfo(product) {
return request.post(apiUrl.addProduct, product)
.then(result => result.data);
.then(result => result.data);
}
/**
... ... @@ -193,4 +196,4 @@ export default {
saveBaseProductInfo,
getProductAllInfo,
updateProductAllInfo
};
};
\ No newline at end of file
... ...
/**
* Created by TaoHuang on 2017/5/4.
*/
const _ = require('lodash');
const handleRelation = (oneValuesObj = []) => {
return oneValuesObj.reduce((total, r) => {
let str = _.isArray(r.model) ? r.model.join(',') : r.model;
if (str) {
total.push({
standardId: r.attributeId,
standardVal: r.attributeName,
parameterMakeId: str
});
}
return total;
}, []);
};
const handleValue = (skn, valueObj = []) => {
return valueObj.reduce((total, r) => {
let str = _.isArray(r.model) ? r.model.join(',') : r.model;
if (str) {
total.push({
attributeId: r.attributeId,
productSkn: skn,
attributeValueId: str
});
}
return total;
}, []);
};
export default {
handleOne: handleValue,
handleTwo: handleValue,
handleRelation
}
... ...
/**
* Created by TaoHuang on 2017/5/4.
*/
import getProduct from './product-service';
import api from './api';
const _ = require('lodash');
const handleGoods = (goods) => {
let newGoods = {};
newGoods.productId = goods.productId;
newGoods.productSkc = goods.productSkc;
newGoods.productSkn = goods.productSkn;
newGoods.factoryGoodsName = goods.factoryGoodsName;
... ... @@ -40,7 +44,7 @@ const handleGoods = (goods) => {
angle: 0,
genderCover: 0,
imageUrl: '',
isDefault: 'N',
isDefault: 'Y',
orderBy: 0,
productSkn: goods.productSkn,
productSkc: goods.productSkc,
... ... @@ -49,7 +53,7 @@ const handleGoods = (goods) => {
angle: 0,
genderCover: 1,
imageUrl: '',
isDefault: 'N',
isDefault: 'Y',
orderBy: 0,
productSkn: goods.productSkn,
productSkc: goods.productSkc,
... ... @@ -58,7 +62,7 @@ const handleGoods = (goods) => {
angle: 0,
genderCover: 2,
imageUrl: '',
isDefault: 'N',
isDefault: 'Y',
orderBy: 0,
productSkn: goods.productSkn,
productSkc: goods.productSkc,
... ... @@ -68,6 +72,17 @@ const handleGoods = (goods) => {
return newGoods;
};
const handleColorImage = (product) => {
let colorsObj = {};
colorsObj.goodsImagesBoList = product.goods.reduce((total, cur) => {
total = total.concat(cur.goodsImage.filter(g => g.imageUrl));
return total;
}, []);
return colorsObj;
};
const handleGoodsImage = (goodsColorInfo) => {
let image0 = {genderCover: 0, isDefault: 'Y'}; // 0商品正面图
let image3 = {genderCover: 1, isDefault: 'N'}; // 3男生频道封面图
... ... @@ -96,33 +111,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 +122,16 @@ 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}`;
}
function getProduct(skn) {
return api.getProductAllInfo(skn).then((result) => {
return result.data;
});
}
export default {
handleGoods,
handleColorImage,
getProduct,
getAbsoluteUrl,
handleGoodsImage,
handleEditColorImage
};
handleEditColorImage,
getProduct
};
\ No newline at end of file
... ...