feature(管理后台): 商品管理

This commit is contained in:
luowenfeng 2022-09-22 11:40:19 +08:00
parent 77a676ee07
commit c7a2ed4a0b
3 changed files with 42 additions and 67 deletions

View File

@ -104,7 +104,7 @@ export const constantRoutes = [
path: 'value/:propertyId(\\d+)', path: 'value/:propertyId(\\d+)',
component: (resolve) => require(['@/views/mall/product/property/value'], resolve), component: (resolve) => require(['@/views/mall/product/property/value'], resolve),
name: 'PropertyValue', name: 'PropertyValue',
meta: {title: '规格数据', icon: '', activeMenu: '/mall/property'} meta: {title: '规格数据', icon: '', activeMenu: '/product/property'}
} }
] ]
}, { }, {
@ -129,6 +129,23 @@ export const constantRoutes = [
meta: {title: '修改生成配置', activeMenu: '/infra/codegen'} meta: {title: '修改生成配置', activeMenu: '/infra/codegen'}
} }
] ]
}, {
path: '/spu',
component: Layout,
hidden: true,
children: [{
path: 'edit/:spuId(\\d+)',
component: (resolve) => require(['@/views/mall/product/spu/save'], resolve),
name: 'SpuEdit',
meta: {title: '修改商品', activeMenu: '/product/spu'}
},
{
path: 'add',
component: (resolve) => require(['@/views/mall/product/spu/save'], resolve),
name: 'SpuAdd',
meta: {title: '添加商品', activeMenu: '/product/spu'}
}
]
}, { }, {
path: '/bpm', path: '/bpm',
component: Layout, component: Layout,

View File

@ -273,10 +273,6 @@
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
@pagination="getList"/> @pagination="getList"/>
<el-dialog :title="title" :visible.sync="open" width="900px" append-to-body destroy-on-close
:close-on-click-modal="false">
<save @closeDialog="closeDialog" :obj="dialogObj" v-if="open"/>
</el-dialog>
</div> </div>
</template> </template>
@ -284,20 +280,9 @@
import {deleteSpu, getSpuPage,} from "@/api/mall/product/spu"; import {deleteSpu, getSpuPage,} from "@/api/mall/product/spu";
import {getProductCategoryList} from "@/api/mall/product/category"; import {getProductCategoryList} from "@/api/mall/product/category";
import {getBrandList} from "@/api/mall/product/brand"; import {getBrandList} from "@/api/mall/product/brand";
import Editor from "@/components/Editor";
import ImageUpload from "@/components/ImageUpload";
import save from "./save";
// 1. TODO @Luowenfenghttps://v5.niuteam.cn/shop/goods/addgoods.html
// 2. TODO
export default { export default {
name: "Spu", name: "Spu",
components: {
Editor,
ImageUpload,
save,
},
data() { data() {
return { return {
activeTabs: "all", activeTabs: "all",
@ -318,12 +303,6 @@ export default {
total: 0, total: 0,
// spu // spu
list: [], list: [],
//
title: "",
//
open: false,
//
dialogObj: {},
dateRangeCreateTime: [], dateRangeCreateTime: [],
// //
queryParams: { queryParams: {
@ -341,7 +320,6 @@ export default {
marketPriceMax: null, marketPriceMax: null,
tabStatus: null, tabStatus: null,
}, },
tagIndex: 0,
}; };
}, },
created() { created() {
@ -383,12 +361,6 @@ export default {
this.loading = false; this.loading = false;
}); });
}, },
/** 取消按钮 */
cancel() {
this.open = false;
this.reset();
},
/** 搜索按钮操作 */ /** 搜索按钮操作 */
handleQuery() { handleQuery() {
this.queryParams.pageNo = 1; this.queryParams.pageNo = 1;
@ -405,20 +377,11 @@ export default {
}, },
/** 新增按钮操作 */ /** 新增按钮操作 */
handleAdd() { handleAdd() {
this.dialogObj = {}; this.$router.push({ name: 'SpuAdd'})
this.open = true;
this.title = "添加商品spu";
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
this.dialogObj.id = row.id; this.$router.push({ name: 'SpuEdit', params: { spuId: row.id }})
this.open = true;
this.title = "修改商品spu";
},
closeDialog() {
this.dialogObj = {};
this.open = false;
this.getList()
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
@ -462,20 +425,6 @@ export default {
margin-left: 10px; margin-left: 10px;
} }
.button-new-tag {
margin-left: 10px;
height: 32px;
line-height: 30px;
padding-top: 0;
padding-bottom: 0;
}
.input-new-tag {
width: 90px;
margin-left: 10px;
vertical-align: bottom;
}
.product-info { .product-info {
display: flex; display: flex;

View File

@ -217,9 +217,6 @@ export default {
ImageUpload, ImageUpload,
VideoUpload VideoUpload
}, },
props: {
obj: Object
},
data() { data() {
return { return {
activeSwitch: false, activeSwitch: false,
@ -281,8 +278,9 @@ export default {
this.getListBrand(); this.getListBrand();
this.getListCategory(); this.getListCategory();
this.getPropertyPageList(); this.getPropertyPageList();
if (this.obj.id != null) { const spuId = this.$route.params && this.$route.params.spuId;
this.updateType(this.obj.id) if (spuId != null) {
this.updateType(spuId)
} }
}, },
methods: { methods: {
@ -353,8 +351,18 @@ export default {
this.brandList = response.data; this.brandList = response.data;
}); });
}, },
//
cancel() { cancel() {
this.$emit("closeDialog"); var currentView = this.$store.state.tagsView.visitedViews[0]
for (currentView of this.$store.state.tagsView.visitedViews) {
if (currentView.path === this.$route.path) {
break
}
}
this.$store.dispatch('tagsView/delView', currentView)
.then(() => {
this.$router.push("/product/spu")
})
}, },
submit() { submit() {
this.$refs[this.activeName].validate((valid) => { this.$refs[this.activeName].validate((valid) => {
@ -410,12 +418,16 @@ export default {
if (form.id == null) { if (form.id == null) {
createSpu(form).then((response) => { createSpu(form).then((response) => {
this.$modal.msgSuccess("新增成功"); this.$modal.msgSuccess("新增成功");
this.$emit("closeDialog"); })
.then(()=>{
this.cancel();
}) })
} else { } else {
updateSpu(form).then((response) => { updateSpu(form).then((response) => {
this.$modal.msgSuccess("修改成功"); this.$modal.msgSuccess("修改成功");
this.$emit("closeDialog"); })
.then(()=>{
this.cancel();
}) })
} }
}); });
@ -484,9 +496,8 @@ export default {
</script> </script>
<style lang="scss"> <style lang="scss">
.spec-dialog { .container{
width: 400px; padding: 20px;
height: 300px;
} }
.dynamic-spec { .dynamic-spec {
@ -531,11 +542,9 @@ export default {
} }
.tabs { .tabs {
height: 500px;
border-bottom: 2px solid #f2f2f2; border-bottom: 2px solid #f2f2f2;
.el-tab-pane { .el-tab-pane {
height: 445px;
overflow-y: auto; overflow-y: auto;
} }
} }