From ed596fdfe840b37e7af7ebdbfc665f1967a844c9 Mon Sep 17 00:00:00 2001 From: zhaochencheng Date: Mon, 2 Jan 2023 19:10:13 +0800 Subject: [PATCH] =?UTF-8?q?sku=E5=88=B7=E6=96=B0=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=90=8E=E4=BB=8D=E8=83=BD=E6=8B=BF=E5=88=B0=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/pms/product/AddProduct.vue | 34 ++++++++++++++++------------ 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/views/pms/product/AddProduct.vue b/src/views/pms/product/AddProduct.vue index 3f22013..6a30f11 100644 --- a/src/views/pms/product/AddProduct.vue +++ b/src/views/pms/product/AddProduct.vue @@ -65,6 +65,7 @@ + 刷新列表 @@ -118,6 +119,7 @@ export default { data() { return { form: {}, + skuList:[], productAttr: [ { name: '颜色', @@ -130,12 +132,21 @@ export default { maxOptionNum: 44 } }, - computed: { - skuList() { + created() { + const {id} = this.$route.query + if (id) { + this.getInfo(id); + } + }, + methods: { + refreshSku(preSkus){ let skus = []; let skuMap = new Map() - if(this.form.skuList){ - this.form.skuList.forEach(sku=>{ + if(preSkus){ + this.skuList=preSkus + } + if(this.skuList){ + this.skuList.forEach(sku=>{ skuMap.set(sku.spData,sku) }) } @@ -173,16 +184,9 @@ export default { } }) - return skus - } - }, - created() { - const {id} = this.$route.query - if (id) { - this.getInfo(id); - } - }, - methods: { + this.form.productAttr = JSON.stringify(this.productAttr) + this.skuList= skus + }, getInfo(id) { getPmsProduct(id).then(response => { const {albumPics } = response @@ -193,13 +197,13 @@ export default { if(this.form.productAttr){ this.productAttr =JSON.parse(this.form.productAttr) } + this.refreshSku(this.form.skuList) }); }, /** 提交按钮 */ submitForm() { this.$refs["form"].validate(valid => { if (valid) { - this.form.productAttr = JSON.stringify(this.productAttr) this.form.skuList = this.skuList if(this.form.categoryId && Array.isArray(this.form.categoryId)){ this.form.categoryId = this.form.categoryId.pop()