diff --git a/pages/nongKe/gather/select_warehouse.vue b/pages/nongKe/gather/select_warehouse.vue index ff1bd72..98db7d2 100644 --- a/pages/nongKe/gather/select_warehouse.vue +++ b/pages/nongKe/gather/select_warehouse.vue @@ -242,22 +242,22 @@ showModel: false, showModelCode: '', goods: [ - // { - // "id": 7, - // "store_name": "心心相印 纸面巾400张", - // "bar_code": "6922868290895", + // { + // "id": 314, + // "store_name": "面面森林厨房系列私房牛肉面", + // "bar_code": "6974008060011", // "manu_address": "", - // "price": "4.80", + // "price": "0.00", // "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": [ - // "https://lihai001.oss-cn-chengdu.aliyuncs.com/def/e4784202311041417185146.jpg" + // "http://lihai001.oss-cn-chengdu.aliyuncs.com/def/2023-11-18/202311181017131387.jpg" // ], - // "spec": "****(企业未公开详细信息!)", - // "trademark": "****(企业未公开详细信息!)", + // "spec": "560克", + // "trademark": "面面", // "manu_name": null, - // "note": "备注:经查,该厂商识别代码已在中国物品编码中心注册,但编码信息未按规定通报login_date:Jul 13 1998 12:00:00:000AM;valid_date:Jul 13 2020 12:00:00:000AM;" - // }, + // "note": "" + // } ], putGoods: { // 加入店铺信息 @@ -288,7 +288,8 @@ }, methods: { - addGoods(item) { + addGoods(item={}) { + item = JSON.parse(JSON.stringify(item)); if(this.isNullImage(item.image)|| ( this.isNullImage(item.slider_image[0]) && this.isNullImage(item.slider_image[1]) && this.isNullImage(item.slider_image[2]) )){ return Toast('请先上传商品图片后再加入店铺'); @@ -308,9 +309,50 @@ this.putGoods[key] = item[key]; } }) - - this.addGoodsShow = true - this.item = item + this.initShop(item); + // this.addGoodsShow = true + // 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){ let flag = false; diff --git a/pages/product/addGood/addGood.vue b/pages/product/addGood/addGood.vue index 4722576..3ecdb77 100644 --- a/pages/product/addGood/addGood.vue +++ b/pages/product/addGood/addGood.vue @@ -204,6 +204,7 @@ bar_code_dis: false, merId: '', //商户id product_id: '', //商品id + import: 0, //是否为导入商品 code: '', //商品条码 show: false, //是否预览图片 image: false, //预览的图 @@ -255,11 +256,36 @@ onLoad(opt) { this.merId = Number(opt.mer_id); this.product_id = opt.product_id; + this.import = opt.import; // if (!opt.product_id) this.showCommodity = true; this.showCommodity = true;; this.initData(); 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(); } }, @@ -564,7 +590,25 @@ postData.attrValue = [this.$refs.priceRef.singleSpecification]; }else postData.attrValue = this.setFormData.attrValue; 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(); if (this.product_id) { productUpdate(this.merId, this.product_id, postData) @@ -589,7 +633,11 @@ Modal('提交成功', '点击确定,返回商品管理', { showCancel: false, }).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 }) }) diff --git a/pages/product/addGood/specGood.vue b/pages/product/addGood/specGood.vue index 06de8a7..06ded00 100644 --- a/pages/product/addGood/specGood.vue +++ b/pages/product/addGood/specGood.vue @@ -343,19 +343,19 @@ flag = false; str = '规格不能为空'; } - else if (!item.price) { + else if (!item.price||+item.price<=0) { flag = false; str = '零售价不能小于等于0'; } - else if (!item.stock) { + else if (!item.stock||+item.stock<=0) { flag = false; str = '库存不能小于等于0'; } - else if (!item.cost) { + else if (!item.cost||+item.cost<=0) { flag = false; 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; str = '批发价不能小于等于0'; }