From e7e43c3c03edf5d5ae4df447d02ab748e4719aac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=90=91=E6=96=87=E5=8F=AF?= <1041367524@qq.com>
Date: Tue, 26 Apr 2022 17:06:19 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E5=95=86=E5=93=81=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/ElUploadImage.vue | 9 ++++++++-
src/views/sales/product/form/step1.vue | 5 ++++-
src/views/sales/product/index.vue | 8 +++++---
3 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/src/components/ElUploadImage.vue b/src/components/ElUploadImage.vue
index 0b7ce47..8fae89e 100644
--- a/src/components/ElUploadImage.vue
+++ b/src/components/ElUploadImage.vue
@@ -4,6 +4,7 @@
v-bind="props"
action=""
:before-upload="handleBeforeUpload"
+ :class="{ max: imgList.length === props.limit }"
:file-list="imgList"
:http-request="handleUpload"
list-type="picture-card"
@@ -136,4 +137,10 @@
return res + units[unit];
});
-
+
diff --git a/src/views/sales/product/form/step1.vue b/src/views/sales/product/form/step1.vue
index fcac0e8..6fe2fbd 100644
--- a/src/views/sales/product/form/step1.vue
+++ b/src/views/sales/product/form/step1.vue
@@ -103,6 +103,7 @@
const id = route.params.id;
if (id && id !== state.form.id) {
let res = await store.dispatch('product/detail', id);
+ res.pictureList = res.pictureList || [res.mainPicture];
Object.assign(state.form, res);
}
};
@@ -111,7 +112,9 @@
state.loading = true;
try {
await state.refsForm.validate();
- await store.dispatch('product/save', state.form);
+ let data = _.cloneDeep(state.form);
+ data.mainPicture = data.pictureList[0];
+ state.form.id = await store.dispatch('product/save', state.form);
router.push({
name: 'UpdateProduct',
params: {
diff --git a/src/views/sales/product/index.vue b/src/views/sales/product/index.vue
index a356cd6..a06864f 100644
--- a/src/views/sales/product/index.vue
+++ b/src/views/sales/product/index.vue
@@ -133,7 +133,7 @@
/* 删除 */
const handleRemove = (row) => {
- store.dispatch('product/remove', row.id);
+ store.dispatch('product/remove', [row.id]);
};
/* 查看详情 */
@@ -158,8 +158,10 @@
};
/* 上下架 */
- const handleEnabled = (row) => {
- console.info(row);
+ const handleEnabled = async (row) => {
+ loading.value = true;
+ await store.dispatch('product/save', row);
+ loading.value = false;
};
/* 列表配置 */