Skip to content

Commit 9e4f0a8

Browse files
committed
feature(管理后台): 商品管理
1 parent b5eff71 commit 9e4f0a8

File tree

3 files changed

+42
-67
lines changed

3 files changed

+42
-67
lines changed

src/router/index.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export const constantRoutes = [
104104
path: 'value/:propertyId(\\d+)',
105105
component: (resolve) => require(['@/views/mall/product/property/value'], resolve),
106106
name: 'PropertyValue',
107-
meta: {title: '规格数据', icon: '', activeMenu: '/mall/property'}
107+
meta: {title: '规格数据', icon: '', activeMenu: '/product/property'}
108108
}
109109
]
110110
}, {
@@ -129,6 +129,23 @@ export const constantRoutes = [
129129
meta: {title: '修改生成配置', activeMenu: '/infra/codegen'}
130130
}
131131
]
132+
}, {
133+
path: '/spu',
134+
component: Layout,
135+
hidden: true,
136+
children: [{
137+
path: 'edit/:spuId(\\d+)',
138+
component: (resolve) => require(['@/views/mall/product/spu/save'], resolve),
139+
name: 'SpuEdit',
140+
meta: {title: '修改商品', activeMenu: '/product/spu'}
141+
},
142+
{
143+
path: 'add',
144+
component: (resolve) => require(['@/views/mall/product/spu/save'], resolve),
145+
name: 'SpuAdd',
146+
meta: {title: '添加商品', activeMenu: '/product/spu'}
147+
}
148+
]
132149
}, {
133150
path: '/bpm',
134151
component: Layout,

src/views/mall/product/spu/index.vue

Lines changed: 2 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -273,31 +273,16 @@
273273
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
274274
@pagination="getList"/>
275275

276-
<el-dialog :title="title" :visible.sync="open" width="900px" append-to-body destroy-on-close
277-
:close-on-click-modal="false">
278-
<save @closeDialog="closeDialog" :obj="dialogObj" v-if="open"/>
279-
</el-dialog>
280276
</div>
281277
</template>
282278

283279
<script>
284280
import {deleteSpu, getSpuPage,} from "@/api/mall/product/spu";
285281
import {getProductCategoryList} from "@/api/mall/product/category";
286282
import {getBrandList} from "@/api/mall/product/brand";
287-
import Editor from "@/components/Editor";
288-
import ImageUpload from "@/components/ImageUpload";
289-
import save from "./save";
290-
291-
// 1. TODO @Luowenfeng:商品的添加、修改,走一个单独的页面,不走弹窗;https://v5.niuteam.cn/shop/goods/addgoods.html
292-
// 2. TODO
293283
294284
export default {
295285
name: "Spu",
296-
components: {
297-
Editor,
298-
ImageUpload,
299-
save,
300-
},
301286
data() {
302287
return {
303288
activeTabs: "all",
@@ -318,12 +303,6 @@ export default {
318303
total: 0,
319304
// 商品spu列表
320305
list: [],
321-
// 弹出层标题
322-
title: "",
323-
// 是否显示弹出层
324-
open: false,
325-
// 弹出层参数
326-
dialogObj: {},
327306
dateRangeCreateTime: [],
328307
// 查询参数
329308
queryParams: {
@@ -341,7 +320,6 @@ export default {
341320
marketPriceMax: null,
342321
tabStatus: null,
343322
},
344-
tagIndex: 0,
345323
};
346324
},
347325
created() {
@@ -383,12 +361,6 @@ export default {
383361
this.loading = false;
384362
});
385363
},
386-
387-
/** 取消按钮 */
388-
cancel() {
389-
this.open = false;
390-
this.reset();
391-
},
392364
/** 搜索按钮操作 */
393365
handleQuery() {
394366
this.queryParams.pageNo = 1;
@@ -405,20 +377,11 @@ export default {
405377
},
406378
/** 新增按钮操作 */
407379
handleAdd() {
408-
this.dialogObj = {};
409-
this.open = true;
410-
this.title = "添加商品spu";
380+
this.$router.push({ name: 'SpuAdd'})
411381
},
412382
/** 修改按钮操作 */
413383
handleUpdate(row) {
414-
this.dialogObj.id = row.id;
415-
this.open = true;
416-
this.title = "修改商品spu";
417-
},
418-
closeDialog() {
419-
this.dialogObj = {};
420-
this.open = false;
421-
this.getList()
384+
this.$router.push({ name: 'SpuEdit', params: { spuId: row.id }})
422385
},
423386
/** 删除按钮操作 */
424387
handleDelete(row) {
@@ -462,20 +425,6 @@ export default {
462425
margin-left: 10px;
463426
}
464427
465-
.button-new-tag {
466-
margin-left: 10px;
467-
height: 32px;
468-
line-height: 30px;
469-
padding-top: 0;
470-
padding-bottom: 0;
471-
}
472-
473-
.input-new-tag {
474-
width: 90px;
475-
margin-left: 10px;
476-
vertical-align: bottom;
477-
}
478-
479428
.product-info {
480429
display: flex;
481430

src/views/mall/product/spu/save.vue

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,6 @@ export default {
217217
ImageUpload,
218218
VideoUpload
219219
},
220-
props: {
221-
obj: Object
222-
},
223220
data() {
224221
return {
225222
activeSwitch: false,
@@ -281,8 +278,9 @@ export default {
281278
this.getListBrand();
282279
this.getListCategory();
283280
this.getPropertyPageList();
284-
if (this.obj.id != null) {
285-
this.updateType(this.obj.id)
281+
const spuId = this.$route.params && this.$route.params.spuId;
282+
if (spuId != null) {
283+
this.updateType(spuId)
286284
}
287285
},
288286
methods: {
@@ -353,8 +351,18 @@ export default {
353351
this.brandList = response.data;
354352
});
355353
},
354+
// 取消按钮
356355
cancel() {
357-
this.$emit("closeDialog");
356+
var currentView = this.$store.state.tagsView.visitedViews[0]
357+
for (currentView of this.$store.state.tagsView.visitedViews) {
358+
if (currentView.path === this.$route.path) {
359+
break
360+
}
361+
}
362+
this.$store.dispatch('tagsView/delView', currentView)
363+
.then(() => {
364+
this.$router.push("/product/spu")
365+
})
358366
},
359367
submit() {
360368
this.$refs[this.activeName].validate((valid) => {
@@ -410,12 +418,16 @@ export default {
410418
if (form.id == null) {
411419
createSpu(form).then((response) => {
412420
this.$modal.msgSuccess("新增成功");
413-
this.$emit("closeDialog");
421+
})
422+
.then(()=>{
423+
this.cancel();
414424
})
415425
} else {
416426
updateSpu(form).then((response) => {
417427
this.$modal.msgSuccess("修改成功");
418-
this.$emit("closeDialog");
428+
})
429+
.then(()=>{
430+
this.cancel();
419431
})
420432
}
421433
});
@@ -484,9 +496,8 @@ export default {
484496
</script>
485497

486498
<style lang="scss">
487-
.spec-dialog {
488-
width: 400px;
489-
height: 300px;
499+
.container{
500+
padding: 20px;
490501
}
491502
492503
.dynamic-spec {
@@ -531,11 +542,9 @@ export default {
531542
}
532543
533544
.tabs {
534-
height: 500px;
535545
border-bottom: 2px solid #f2f2f2;
536546
537547
.el-tab-pane {
538-
height: 445px;
539548
overflow-y: auto;
540549
}
541550
}

0 commit comments

Comments
 (0)