From 37af798e8b611ed04c2607a2435a854e3af2789b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=96=87=E5=8F=AF?= <1041367524@qq.com> Date: Thu, 26 May 2022 15:44:14 +0800 Subject: [PATCH] fix: BUG --- src/store/modules/sales/product.js | 21 +++++++++++---------- src/views/sales/product/form/step1.vue | 20 +++++++++++--------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/store/modules/sales/product.js b/src/store/modules/sales/product.js index ad9b843..cd3bcbd 100644 --- a/src/store/modules/sales/product.js +++ b/src/store/modules/sales/product.js @@ -112,24 +112,25 @@ const actions = { if (data.limit === 0) { delete data.singleBuyLimit; } - data.virtualProductModifyDTOList = [ - ...data.fileList.map((item) => { - return { - shipType: 1, - shipContent: item, - }; - }), - { + data.virtualProductModifyDTOList = data.fileList.map((item) => { + return { + shipType: 1, + shipContent: item, + }; + }); + if (data.autoSend) { + data.virtualProductModifyDTOList.push({ shipType: 2, shipContent: data.autoSend, - }, - ]; + }); + } let res = await save(data); if (res) { ElMessage.success('保存成功'); dispatch('search'); } else { ElMessage.error('保存失败'); + res = null; } return res; }, diff --git a/src/views/sales/product/form/step1.vue b/src/views/sales/product/form/step1.vue index c3cc4ab..68340ca 100644 --- a/src/views/sales/product/form/step1.vue +++ b/src/views/sales/product/form/step1.vue @@ -80,7 +80,7 @@ form: { id: null, categoryId: null, - productType: 2, + productType: 1, name: null, remark: null, isRecommend: false, @@ -143,14 +143,16 @@ let data = _.cloneDeep(state.form); data.mainPicture = data.pictureList[0]; state.form.id = await store.dispatch('product/save', state.form); - unref(state.refsForm).resetFields(); - router.push({ - name: 'UpdateProduct', - params: { - id: route.params.id || state.form.id, - step: 2, - }, - }); + if (state.form.id) { + unref(state.refsForm).resetFields(); + router.push({ + name: 'UpdateProduct', + params: { + id: route.params.id || state.form.id, + step: 2, + }, + }); + } } catch (e) { console.info('取消保存', e); }