From d3e8fe6c960451cc16ddc5bc1b1725e21abffcb9 Mon Sep 17 00:00:00 2001 From: weipengfei <2187978347@qq.com> Date: Thu, 18 Jan 2024 17:43:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/app.js | 4 +- manifest.json | 4 +- pages/product/addGood/addGood_supply.vue | 141 ++++++++++++------ .../addGood/components/price_supply.vue | 14 +- pages/product/addGood/specGood.vue | 8 +- 5 files changed, 107 insertions(+), 64 deletions(-) diff --git a/config/app.js b/config/app.js index 479ac47..d94b1a2 100644 --- a/config/app.js +++ b/config/app.js @@ -9,8 +9,8 @@ let httpApiThree let wsApi // 在打包之前请检查当前环境是否正确 -const env = 'dev'; // 开发 -// const env = 'prod'; // 生产 +// const env = 'dev'; // 开发 +const env = 'prod'; // 生产 // const env = 'prew'; // 预上线 switch (env) { diff --git a/manifest.json b/manifest.json index c0948a9..fc992aa 100644 --- a/manifest.json +++ b/manifest.json @@ -2,8 +2,8 @@ "name" : "惠农商户平台", "appid" : "__UNI__1EE148C", "description" : "", - "versionName" : "1.0.9", - "versionCode" : 109, + "versionName" : "1.1.2", + "versionCode" : 112, "transformPx" : false, /* 5+App特有相关 */ "app-plus" : { diff --git a/pages/product/addGood/addGood_supply.vue b/pages/product/addGood/addGood_supply.vue index 4fe76b3..119c71e 100644 --- a/pages/product/addGood/addGood_supply.vue +++ b/pages/product/addGood/addGood_supply.vue @@ -70,9 +70,9 @@ @@ -107,13 +107,22 @@ - - - - - + + + + + + + + + + + + 添加规格 + + + @@ -238,12 +247,16 @@ code: '', //商品条码 show: false, //是否预览图片 image: false, //预览的图 + showDelete: false, // 删除规格弹窗 + deleteIndex: 0, setFormData: { store_name: '', imageList: [], - attrValue: [], + attrValue: [ + {} + ], cate_name: '', //平台名称 - unit_name: '', //商品单位 + unit_name: '', //商品规格 cate_id: '', // 平台分类id mer_cate_id: '', // 店铺分类 mer_cate_name: '', // 店铺分类名称 @@ -370,6 +383,22 @@ } }, methods: { + // 追加规格 + pushAttrValue(index){ + let obj = JSON.parse(JSON.stringify(this.$refs['priceRef'][index].singleSpecification)); + obj.sku = ''; + this.setFormData.attrValue.push(obj); + }, + // 预删除 + deleteByIndex(index) { + this.deleteIndex = +index; + this.showDelete = true; + }, + // 删除规格 + deleteAttr() { + this.setFormData.attrValue[this.deleteIndex].is_d_show = true; + this.showDelete = false; + }, // 查询详情数据 initDataEditData() { this.setFormData = { @@ -387,7 +416,7 @@ cate_name: '', // 平台名称 mer_cate_id: '', // 店铺分类 mer_cate_name: '', // 店铺分类名称 - unit_name: '', // 商品单位 + unit_name: '', // 商品规格 spec_type: '0', // 0.默认规格 1:自定义规格 attr: [], // 商品规格 specifica: '', // 商品规格名称 @@ -419,23 +448,9 @@ if (res.data.content && typeof res.data.content == 'string') res.data.content = JSON.parse(res.data .content); this.setFormData.once_min_count <= 0 ? this.setFormData.once_min_count = '' : null; - if(res.data.attr.length==1&&res.data.attr[0].value=='单位'&&res.data.attr[0].detail.length==2){ // 供应链默认规格时页面改成默认规格 + if(res.data.attr.length==1&&res.data.attr[0].value=='规格'){ // 供应链默认规格时页面改成默认规格 this.setFormData.spec_type = 0; } - if(res.data.attr.length==1&&res.data.attr[0].value=='单位'){ - if(res.data.attrValue[0].sku=='件'||res.data.attrValue[1].sku=='个') { - this.tips1 = '提供给B端商户'; - this.tips2 = '提供给C端用户'; - } - else if(res.data.attrValue[0].sku=='个'||res.data.attrValue[1].sku=='件') { - this.tips1 = '提供给C端用户'; - this.tips2 = '提供给B端商户'; - } - else { - this.tips1 = ''; - this.tips2 = ''; - } - } //向组件注入数据 this.$nextTick(() => { this.$refs.commodityRef.setDatas({ @@ -452,10 +467,10 @@ } }) // 默认规格 - if (this.setFormData.spec_type == 0) { - this.$refs.priceRef.setDatas(res.data.attrValue[0]); - this.$refs.priceRef2.setDatas(res.data.attrValue[1]); - } + // if (this.setFormData.spec_type == 0) { + // this.$refs.priceRef.setDatas(res.data.attrValue[0]); + // this.$refs.priceRef2.setDatas(res.data.attrValue[1]); + // } }) editGoodsDetils.temp && (this.setFormData.tempName = editGoodsDetils.temp.name); hideLoading(); @@ -636,9 +651,9 @@ // return console.log('商品规格', this.setFormData.spec_type); console.log('是否推荐', this.$refs.commodityRef.addGoodsSecoundData); console.log('商品详情', this.$refs.commodityRef.goodsDis, this.$refs.commodityRef.store_name); - if (this.setFormData.spec_type == 0) { - console.log('价格库存', this.$refs.priceRef.singleSpecification); - } + // if (this.setFormData.spec_type == 0) { + // console.log('价格库存', this.$refs.priceRef.singleSpecification); + // } let postData = { ...this.setFormData, ...this.$refs.commodityRef.addGoodsSecoundData, @@ -649,21 +664,30 @@ video_link: this.$refs.commodityRef.addGoodsSecoundData.video_link, }; if (this.setFormData.spec_type == 0) { - postData.attrValue = [this.$refs.priceRef.singleSpecification, this.$refs.priceRef2.singleSpecification]; + // console.log(this.$refs.priceRef); + let listarr = []; + this.$refs.priceRef.forEach((item, index)=>{ + if(!this.setFormData.attrValue[index].is_d_show){ + // console.log(item.singleSpecification, index); + listarr.push(item.singleSpecification); + } + }) + postData.attrValue = listarr; } else postData.attrValue = this.setFormData.attrValue; postData.stock = postData.attrValue[0]?.stock || 0; 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('请输入商品单位'); + // 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' + showFlag = '结算价不能小于0' } if (!t.price || +t.price <= 0) showFlag = '零售价不能小于0'; + if (!t.single_number || +t.single_number <= 0) showFlag = '零售价不能小于0'; if (!t.stock || +t.stock <= 0) showFlag = '库存不能小于0'; // if (!t.cost || +t.cost <= 0) showFlag = '成本价不能小于0'; }) @@ -675,20 +699,18 @@ if(this.setFormData.spec_type == 0){ postData.unit_name = '无' postData.attr = [{ - value: '单位', - detail: [ - postData.attrValue[0].sku, - postData.attrValue[1].sku, - ] + value: '规格', + detail: [] }] - postData.attrValue[0].detail = { - "单位": postData.attrValue[0].sku - }, - postData.attrValue[1].detail = { - "单位": postData.attrValue[1].sku - }, + postData.attr[0].detail = postData.attrValue.map(item=>item.sku); + postData.attrValue.forEach(item=>{ + item.detail = { + "规格": item.sku + } + }) postData.spec_type = 1; //供应链商家必须使用多规格 } + if(postData.attrValue.length==0)return Toast('请填写规格') if (this.product_id) { productUpdate(this.merId, this.product_id, postData) .then(res => { @@ -736,7 +758,9 @@ changeSpecType2() { this.showSpecType = false; this.setFormData.spec_type = this.spec_type + ''; - this.setFormData.attrValue = []; + this.setFormData.attrValue = [ + {} + ]; this.setFormData.attr = []; }, // 跳转自定义规格页面 @@ -772,4 +796,23 @@ height: 20px; margin: 30px auto; } + + .head_close { + position: relative; + + .delete_btn { + position: absolute; + top: -15rpx; + right: 10rpx; + width: 40rpx; + height: 40rpx; + display: flex; + justify-content: center; + align-items: center; + background-color: red; + color: #fff; + border-radius: 50%; + } + + } \ No newline at end of file diff --git a/pages/product/addGood/components/price_supply.vue b/pages/product/addGood/components/price_supply.vue index b53315a..24a973a 100644 --- a/pages/product/addGood/components/price_supply.vue +++ b/pages/product/addGood/components/price_supply.vue @@ -34,10 +34,11 @@ cost: '', // 成本价 stock: '', // 库存 ot_price: '', // 市场价 - procure_price: '', // 批发价 + procure_price: '', // 结算价 bar_code: '', // 商品条码 weight: '', // 重量 volume: '', // 体积 + single_number: '', // 单件数量 // image: '', extension_one: '', extension_two: '' @@ -46,10 +47,10 @@ formList: [ { id: 0, - label: '单位', + label: '规格', type: 'input', model: 'sku', - holder: '请填写单位', + holder: '请填写规格名称', require: true, }, { id: 1, @@ -146,15 +147,14 @@ // this.singleSpecification = this.$props.datas; // this.$set(this, 'singleSpecification', this.$props.datas); Object.keys(this.singleSpecification).forEach((key)=>{ - this.singleSpecification[key] = this.$props.datas[key] + this.singleSpecification[key] = this.$props.datas[key] || '' }) } - console.log(this.singleSpecification.sku); - if(!this.singleSpecification.sku) this.singleSpecification.sku = this.$props.sku + ''; + // console.log(this.singleSpecification.sku); let userInfo = this.$store.state.app.userInfo; if(typeof userInfo == 'string') userInfo = JSON.parse(userInfo); - // 市级供应链才需填写批发价 + // 市级供应链才需填写结算价 // if(userInfo.mer_info?.type_code=="TypeSupplyChain"){ // let list = [] // this.formList = [...list, ...this.formList] diff --git a/pages/product/addGood/specGood.vue b/pages/product/addGood/specGood.vue index a5a355f..3e6d3d3 100644 --- a/pages/product/addGood/specGood.vue +++ b/pages/product/addGood/specGood.vue @@ -416,10 +416,10 @@ flag = false; str = '库存不能小于等于0'; } - else if (!item.cost||+item.cost<=0) { - flag = false; - str = '成本价不能小于等于0'; - } + // else if (!item.cost||+item.cost<=0) { + // flag = false; + // str = '成本价不能小于等于0'; + // } else if ((!item.procure_price||+item.procure_price<=0) && this.userInfo.mer_info.type_code == 'TypeSupplyChain') { flag = false; str = '批发价不能小于等于0';