新增商品加入店铺时设置详细信息
This commit is contained in:
parent
22acdfa746
commit
9408cb41f0
@ -242,22 +242,22 @@
|
|||||||
showModel: false,
|
showModel: false,
|
||||||
showModelCode: '',
|
showModelCode: '',
|
||||||
goods: [
|
goods: [
|
||||||
// {
|
// {
|
||||||
// "id": 7,
|
// "id": 314,
|
||||||
// "store_name": "心心相印 纸面巾400张",
|
// "store_name": "面面森林厨房系列私房牛肉面",
|
||||||
// "bar_code": "6922868290895",
|
// "bar_code": "6974008060011",
|
||||||
// "manu_address": "",
|
// "manu_address": "",
|
||||||
// "price": "4.80",
|
// "price": "0.00",
|
||||||
// "stock": 9999999,
|
// "stock": 9999999,
|
||||||
// "image": "http://lihai001.oss-cn-chengdu.aliyuncs.com/def/2023-11-02/202311021740247976.jpg",
|
// "image": "http://lihai001.oss-cn-chengdu.aliyuncs.com/def/2023-11-18/202311181017131387.jpg",
|
||||||
// "slider_image": [
|
// "slider_image": [
|
||||||
// "https://lihai001.oss-cn-chengdu.aliyuncs.com/def/e4784202311041417185146.jpg"
|
// "http://lihai001.oss-cn-chengdu.aliyuncs.com/def/2023-11-18/202311181017131387.jpg"
|
||||||
// ],
|
// ],
|
||||||
// "spec": "****(企业未公开详细信息!)",
|
// "spec": "560克",
|
||||||
// "trademark": "****(企业未公开详细信息!)",
|
// "trademark": "面面",
|
||||||
// "manu_name": null,
|
// "manu_name": null,
|
||||||
// "note": "备注:经查,该厂商识别代码已在中国物品编码中心注册,但编码信息未按规定通报login_date:Jul 13 1998 12:00:00:000AM;valid_date:Jul 13 2020 12:00:00:000AM;"
|
// "note": ""
|
||||||
// },
|
// }
|
||||||
|
|
||||||
],
|
],
|
||||||
putGoods: { // 加入店铺信息
|
putGoods: { // 加入店铺信息
|
||||||
@ -288,7 +288,8 @@
|
|||||||
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
addGoods(item) {
|
addGoods(item={}) {
|
||||||
|
item = JSON.parse(JSON.stringify(item));
|
||||||
if(this.isNullImage(item.image)||
|
if(this.isNullImage(item.image)||
|
||||||
( this.isNullImage(item.slider_image[0]) && this.isNullImage(item.slider_image[1]) && this.isNullImage(item.slider_image[2]) )){
|
( this.isNullImage(item.slider_image[0]) && this.isNullImage(item.slider_image[1]) && this.isNullImage(item.slider_image[2]) )){
|
||||||
return Toast('请先上传商品图片后再加入店铺');
|
return Toast('请先上传商品图片后再加入店铺');
|
||||||
@ -308,9 +309,50 @@
|
|||||||
this.putGoods[key] = item[key];
|
this.putGoods[key] = item[key];
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
this.initShop(item);
|
||||||
this.addGoodsShow = true
|
// this.addGoodsShow = true
|
||||||
this.item = item
|
// this.item = item
|
||||||
|
},
|
||||||
|
initShop(item){
|
||||||
|
item.attr = [{
|
||||||
|
value: '规格',
|
||||||
|
detail: [item.spec]
|
||||||
|
}]
|
||||||
|
item.attrValue = [{
|
||||||
|
"detail": {
|
||||||
|
'规格': item.spec
|
||||||
|
},
|
||||||
|
"sku": item.spec,
|
||||||
|
"stock": 0,
|
||||||
|
"image": item.image,
|
||||||
|
"bar_code": item.bar_code,
|
||||||
|
"cost": "",
|
||||||
|
"ot_price": "",
|
||||||
|
"price": item.price,
|
||||||
|
"volume": "",
|
||||||
|
"weight": "",
|
||||||
|
}]
|
||||||
|
item.spec_type = 1;
|
||||||
|
item.import_id = item.id + '';
|
||||||
|
item.imageList = [item.image, ...item.slider_image];
|
||||||
|
item.content = {
|
||||||
|
title: '',
|
||||||
|
image: item.slider_image[0]?[item.slider_image[0]]:[]
|
||||||
|
}
|
||||||
|
delete item.id;
|
||||||
|
delete item.stock;
|
||||||
|
console.log({...item});
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/product/addGood/addGood?mer_id=42&import=1',
|
||||||
|
success: (e) => {
|
||||||
|
e.eventChannel.emit('importAttrValue', item);
|
||||||
|
uni.$once('importAttrValueOK', (e)=>{
|
||||||
|
this.goods = this.goods.filter(t=>{
|
||||||
|
return t.id!=e;
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
isNullImage(src){
|
isNullImage(src){
|
||||||
let flag = false;
|
let flag = false;
|
||||||
|
@ -204,6 +204,7 @@
|
|||||||
bar_code_dis: false,
|
bar_code_dis: false,
|
||||||
merId: '', //商户id
|
merId: '', //商户id
|
||||||
product_id: '', //商品id
|
product_id: '', //商品id
|
||||||
|
import: 0, //是否为导入商品
|
||||||
code: '', //商品条码
|
code: '', //商品条码
|
||||||
show: false, //是否预览图片
|
show: false, //是否预览图片
|
||||||
image: false, //预览的图
|
image: false, //预览的图
|
||||||
@ -255,11 +256,36 @@
|
|||||||
onLoad(opt) {
|
onLoad(opt) {
|
||||||
this.merId = Number(opt.mer_id);
|
this.merId = Number(opt.mer_id);
|
||||||
this.product_id = opt.product_id;
|
this.product_id = opt.product_id;
|
||||||
|
this.import = opt.import;
|
||||||
// if (!opt.product_id) this.showCommodity = true;
|
// if (!opt.product_id) this.showCommodity = true;
|
||||||
this.showCommodity = true;;
|
this.showCommodity = true;;
|
||||||
this.initData();
|
this.initData();
|
||||||
this.initClasiffy();
|
this.initClasiffy();
|
||||||
if(this.product_id){
|
if(this.import==1){
|
||||||
|
this.getOpenerEventChannel().once('importAttrValue', (e) => {
|
||||||
|
this.attrValue = e.attrValue;
|
||||||
|
uni.setStorageSync('attrValue', JSON.stringify(e.attrValue));
|
||||||
|
this.attr = e.attr;
|
||||||
|
uni.setStorageSync('attr', JSON.stringify(e.attr));
|
||||||
|
this.setFormData = Object.assign({}, this.setFormData, e);
|
||||||
|
this.$nextTick(()=>{
|
||||||
|
this.$refs.commodityRef?.setDatas({
|
||||||
|
addGoodsSecoundData: {
|
||||||
|
is_good: this.setFormData.is_good, // 是否推荐
|
||||||
|
is_gift_bag: this.setFormData.is_gift_bag,
|
||||||
|
sort: this.setFormData.sort,
|
||||||
|
once_count: this.setFormData.once_count, // 限购数量
|
||||||
|
video_link: this.setFormData.video_link,
|
||||||
|
},
|
||||||
|
goodsDis: {
|
||||||
|
store_name: this.setFormData.content?.title,
|
||||||
|
imageList: this.setFormData.content?.image
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else if(this.product_id){
|
||||||
this.initDataEditData();
|
this.initDataEditData();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -564,7 +590,25 @@
|
|||||||
postData.attrValue = [this.$refs.priceRef.singleSpecification];
|
postData.attrValue = [this.$refs.priceRef.singleSpecification];
|
||||||
}else postData.attrValue = this.setFormData.attrValue;
|
}else postData.attrValue = this.setFormData.attrValue;
|
||||||
postData.stock = postData.attrValue[0]?.stock||0;
|
postData.stock = postData.attrValue[0]?.stock||0;
|
||||||
// return console.log('商品数据', postData);
|
if(!postData.store_name||postData.store_name?.trim().length<=0)return Toast('请输入商品名称');
|
||||||
|
if(!postData.imageList||postData.imageList?.length<2)return Toast('请上传2张以上商品图片');
|
||||||
|
if(!postData.cate_name||postData.cate_name?.trim().length<=0)return Toast('请选择平台分类');
|
||||||
|
if(!postData.unit_name||postData.unit_name?.trim().length<=0)return Toast('请输入商品单位');
|
||||||
|
let userInfo = this.$store.state.app.userInfo;
|
||||||
|
if(typeof userInfo == 'string')userInfo= JSON.parse(userInfo);
|
||||||
|
let showFlag = '';
|
||||||
|
postData.attrValue.forEach(t=>{
|
||||||
|
if(userInfo?.mer_info?.type_code=="TypeSupplyChain" && (!t.procure_price||+t.procure_price<=0) ){
|
||||||
|
showFlag = '批发价不能小于0'
|
||||||
|
}
|
||||||
|
if(!t.price||+t.price<=0) showFlag = '零售价不能小于0';
|
||||||
|
if(!t.stock||+t.stock<=0) showFlag = '库存不能小于0';
|
||||||
|
if(!t.cost||+t.cost<=0) showFlag = '成本价不能小于0';
|
||||||
|
})
|
||||||
|
if(showFlag) {
|
||||||
|
if(this.setFormData.spec_type==1) showFlag+=', 请点击设置多规格设置';
|
||||||
|
return Toast(showFlag);
|
||||||
|
}
|
||||||
Loading();
|
Loading();
|
||||||
if (this.product_id) {
|
if (this.product_id) {
|
||||||
productUpdate(this.merId, this.product_id, postData)
|
productUpdate(this.merId, this.product_id, postData)
|
||||||
@ -589,7 +633,11 @@
|
|||||||
Modal('提交成功', '点击确定,返回商品管理', {
|
Modal('提交成功', '点击确定,返回商品管理', {
|
||||||
showCancel: false,
|
showCancel: false,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
uni.redirectTo({
|
if(this.import==1){
|
||||||
|
uni.$emit('importAttrValueOK', this.setFormData.import_id);
|
||||||
|
uni.navigateBack();
|
||||||
|
}
|
||||||
|
else uni.redirectTo({
|
||||||
url: '/pages/product/goodsOnSale/index?mer_id=' + this.merId
|
url: '/pages/product/goodsOnSale/index?mer_id=' + this.merId
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -343,19 +343,19 @@
|
|||||||
flag = false;
|
flag = false;
|
||||||
str = '规格不能为空';
|
str = '规格不能为空';
|
||||||
}
|
}
|
||||||
else if (!item.price) {
|
else if (!item.price||+item.price<=0) {
|
||||||
flag = false;
|
flag = false;
|
||||||
str = '零售价不能小于等于0';
|
str = '零售价不能小于等于0';
|
||||||
}
|
}
|
||||||
else if (!item.stock) {
|
else if (!item.stock||+item.stock<=0) {
|
||||||
flag = false;
|
flag = false;
|
||||||
str = '库存不能小于等于0';
|
str = '库存不能小于等于0';
|
||||||
}
|
}
|
||||||
else if (!item.cost) {
|
else if (!item.cost||+item.cost<=0) {
|
||||||
flag = false;
|
flag = false;
|
||||||
str = '成本价不能小于等于0';
|
str = '成本价不能小于等于0';
|
||||||
}
|
}
|
||||||
else if (!item.procure_price && this.userInfo.mer_info.type_code == 'TypeSupplyChain') {
|
else if ((!item.procure_price||+item.procure_price<=0) && this.userInfo.mer_info.type_code == 'TypeSupplyChain') {
|
||||||
flag = false;
|
flag = false;
|
||||||
str = '批发价不能小于等于0';
|
str = '批发价不能小于等于0';
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user