From 531aa855d2f3cc3e45ef2866c96ea0c783db3a7e Mon Sep 17 00:00:00 2001 From: liushiwei <499672082@qq.com> Date: Tue, 8 Aug 2023 02:01:34 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/view/CopyProduct.vue | 174 ++++++++++++++++++++++++++++++--------- 1 file changed, 134 insertions(+), 40 deletions(-) diff --git a/src/view/CopyProduct.vue b/src/view/CopyProduct.vue index eecb193..4e295e5 100644 --- a/src/view/CopyProduct.vue +++ b/src/view/CopyProduct.vue @@ -12,8 +12,8 @@ @@ -87,7 +149,7 @@ import { Message } from 'element-ui' dlgShow: false, productTableData: [], - productPage: {page: 1, pageSize: 10, total: 0}, + productPage: {page: 1, pageSize: 10, mallId: '', productName: '', productSkcIds: '', total: 0}, productColConfigs: [ { type: "selection", width: '70px', align: 'left', fixed: 'left'}, { prop: 'productSpu', label: 'SPU ID', align: 'left' }, @@ -95,12 +157,20 @@ import { Message } from 'element-ui' { prop: 'productName', label: '商品名称', align: 'left' }, { prop: 'createTime', label: '创建时间', align: 'left' } ], + + mallDlgShow: false, productIds: [], + form: { + targetMallId: '' + } } }, created () { this.getList() + if (this.$store.state.mallList.length > 0) { + this.productPage.mallId = this.$store.state.mallList[0].mallId + } }, methods: { @@ -159,11 +229,21 @@ import { Message } from 'element-ui' }) }, getProductList() { + let params = {}; + params.page = this.productPage.page; + params.pageSize = this.productPage.pageSize; + if (this.productPage.productName) { + params.productName = this.productPage.productName + } + if (this.productPage.productSkcIds) { + params.productSkcIds = this.productPage.productSkcIds.split(',') + } sendChromeAPIMessage({ url: 'bg-visage-mms/product/skc/pageQuery', needMallId: true, + mallId: this.productPage.mallId, data: { - ...this.productPage + ...params }}).then((res) => { if (res.errorCode == 1000000) { this.productPage.total = res.result.total @@ -187,11 +267,11 @@ import { Message } from 'element-ui' }, saveProduct() { if (this.productIds.length <= 0) { - alert('请选择商品'); + Message.error('请选择商品'); return; } this.productIds.map((productSpu, index) => { - sendChromeAPIMessage({ + setTimeout(sendChromeAPIMessage({ url: 'bg-visage-mms/product/query', needMallId: true, data: { @@ -200,8 +280,12 @@ import { Message } from 'element-ui' }}).then((res) => { if (res.errorCode == 1000000) { let content = transform(res.result) + let mallInfo = this.$store.state.mallList.filter(item => { + return item.mallId == this.productPage.mallId + }) this.$http.post('/api/product/add', { - mallName: this.$store.state.mallName, + mallId: mallInfo[0].mallId, + mallName: mallInfo[0].mallName, productSpu: res.result.productId, productName: res.result.productName, content: content @@ -214,42 +298,52 @@ import { Message } from 'element-ui' } }) } - }) + }), 200 * index) }) }, - addToDraft() { + beforeAddToDraft() { if (this.ids.length <= 0) { - alert('请选择商品模板'); + Message.error('请选择商品模板'); return; } - this.ids.map((id, index) => { - let product = this.tableData.filter((item) => { - return item.id == id - }) - setTimeout(() => { - sendChromeAPIMessage({ - url: 'bg-visage-mms/product/draft/add', - needMallId: true, - data: { - catId: 26117 - }}).then((res) => { - if (res.errorCode == 1000000) { - let draftId = res.result.productDraftId - let content = JSON.parse(product[0].content) - content.productDraftId = draftId + this.mallDlgShow = true + }, + addToDraft() { + this.$refs.form.validate((valid) => { + if (valid) { + this.ids.map((id, index) => { + let product = this.tableData.filter((item) => { + return item.id == id + }) + setTimeout(() => { sendChromeAPIMessage({ - url: 'bg-visage-mms/product/draft/save', + url: 'bg-visage-mms/product/draft/add', needMallId: true, + mallId: this.form.targetMallId, data: { - ...content + catId: 26117 }}).then((res) => { if (res.errorCode == 1000000) { - Message.success("商品【" + product[0].productName + "】成功添加到草稿箱") + let draftId = res.result.productDraftId + let content = JSON.parse(product[0].content) + content.productDraftId = draftId + sendChromeAPIMessage({ + url: 'bg-visage-mms/product/draft/save', + needMallId: true, + mallId: this.form.targetMallId, + data: { + ...content + }}).then((res) => { + if (res.errorCode == 1000000) { + Message.success("商品【" + product[0].productName + "】成功添加到草稿箱") + } + }) } }) - } + }, 1000*index) }) - }, 1000*index) + this.mallDlgShow = false + } }) } }