From 9dcf9e614288985311f6a5ad9da6cdd9fa091114 Mon Sep 17 00:00:00 2001 From: macro Date: Sat, 29 Feb 2020 16:28:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81SKU=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product/components/ProductAttrDetail.vue | 125 ++++++++++++------ .../pms/product/components/ProductDetail.vue | 2 +- src/views/pms/product/index.vue | 11 +- 3 files changed, 88 insertions(+), 50 deletions(-) diff --git a/src/views/pms/product/components/ProductAttrDetail.vue b/src/views/pms/product/components/ProductAttrDetail.vue index 89bcd72..f9b1f24 100644 --- a/src/views/pms/product/components/ProductAttrDetail.vue +++ b/src/views/pms/product/components/ProductAttrDetail.vue @@ -100,6 +100,11 @@ style="margin-top: 20px" @click="handleSyncProductSkuPrice">同步价格 + 同步库存 + @@ -325,30 +330,33 @@ }, //获取选中的属性值 getEditAttrValues(index) { - let values = []; + let values = new Set(); if (index === 0) { for (let i = 0; i < this.value.skuStockList.length; i++) { let sku = this.value.skuStockList[i]; - if (sku.sp1 != null && values.indexOf(sku.sp1) === -1) { - values.push(sku.sp1); + let spData = JSON.parse(sku.spData); + if (spData!= null && spData.length>=1) { + values.add(spData[0].value); } } } else if (index === 1) { for (let i = 0; i < this.value.skuStockList.length; i++) { let sku = this.value.skuStockList[i]; - if (sku.sp2 != null && values.indexOf(sku.sp2) === -1) { - values.push(sku.sp2); + let spData = JSON.parse(sku.spData); + if (spData!= null && spData.length>=2) { + values.add(spData[1].value); } } } else { for (let i = 0; i < this.value.skuStockList.length; i++) { let sku = this.value.skuStockList[i]; - if (sku.sp3 != null && values.indexOf(sku.sp3) === -1) { - values.push(sku.sp3); + let spData = JSON.parse(sku.spData); + if (spData!= null && spData.length>=3) { + values.add(spData[2].value); } } } - return values; + return Array.from(values); }, //获取属性的值 getEditParamValue(id){ @@ -390,12 +398,11 @@ this.selectProductAttr[idx].options.splice(index, 1); }, getProductSkuSp(row, index) { - if (index === 0) { - return row.sp1; - } else if (index === 1) { - return row.sp2; - } else { - return row.sp3; + let spData = JSON.parse(row.spData); + if(spData!=null&&index { if(this.value.skuStockList!==null&&this.value.skuStockList.length>0){ + let tempSkuList = []; + tempSkuList = tempSkuList.concat(tempSkuList,this.value.skuStockList); let price=this.value.skuStockList[0].price; - for(let i=0;i { + if(this.value.skuStockList!==null&&this.value.skuStockList.length>0){ + let tempSkuList = []; + tempSkuList = tempSkuList.concat(tempSkuList,this.value.skuStockList); + let stock=this.value.skuStockList[0].stock; + let lowStock=this.value.skuStockList[0].lowStock; + for(let i=0;i