feat: 商品修改

feature/task1.0.0__0514__ch
向文可 2 years ago
parent ba983e3feb
commit e7e43c3c03

@ -4,6 +4,7 @@
v-bind="props" v-bind="props"
action="" action=""
:before-upload="handleBeforeUpload" :before-upload="handleBeforeUpload"
:class="{ max: imgList.length === props.limit }"
:file-list="imgList" :file-list="imgList"
:http-request="handleUpload" :http-request="handleUpload"
list-type="picture-card" list-type="picture-card"
@ -136,4 +137,10 @@
return res + units[unit]; return res + units[unit];
}); });
</script> </script>
<style lang="less" scoped></style> <style lang="less" scoped>
.max {
:deep(.el-upload) {
display: none;
}
}
</style>

@ -103,6 +103,7 @@
const id = route.params.id; const id = route.params.id;
if (id && id !== state.form.id) { if (id && id !== state.form.id) {
let res = await store.dispatch('product/detail', id); let res = await store.dispatch('product/detail', id);
res.pictureList = res.pictureList || [res.mainPicture];
Object.assign(state.form, res); Object.assign(state.form, res);
} }
}; };
@ -111,7 +112,9 @@
state.loading = true; state.loading = true;
try { try {
await state.refsForm.validate(); 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({ router.push({
name: 'UpdateProduct', name: 'UpdateProduct',
params: { params: {

@ -133,7 +133,7 @@
/* 删除 */ /* 删除 */
const handleRemove = (row) => { const handleRemove = (row) => {
store.dispatch('product/remove', row.id); store.dispatch('product/remove', [row.id]);
}; };
/* 查看详情 */ /* 查看详情 */
@ -158,8 +158,10 @@
}; };
/* 上下架 */ /* 上下架 */
const handleEnabled = (row) => { const handleEnabled = async (row) => {
console.info(row); loading.value = true;
await store.dispatch('product/save', row);
loading.value = false;
}; };
/* 列表配置 */ /* 列表配置 */

Loading…
Cancel
Save