Commit c7a2ed4a0bbacf2cf61319c21c002a143ef73a35

Authored by luowenfeng
1 parent 77a676ee

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

yudao-ui-admin/src/router/index.js
@@ -104,7 +104,7 @@ export const constantRoutes = [ @@ -104,7 +104,7 @@ export const constantRoutes = [
104 path: 'value/:propertyId(\\d+)', 104 path: 'value/:propertyId(\\d+)',
105 component: (resolve) => require(['@/views/mall/product/property/value'], resolve), 105 component: (resolve) => require(['@/views/mall/product/property/value'], resolve),
106 name: 'PropertyValue', 106 name: 'PropertyValue',
107 - meta: {title: '规格数据', icon: '', activeMenu: '/mall/property'} 107 + meta: {title: '规格数据', icon: '', activeMenu: '/product/property'}
108 } 108 }
109 ] 109 ]
110 }, { 110 }, {
@@ -130,6 +130,23 @@ export const constantRoutes = [ @@ -130,6 +130,23 @@ export const constantRoutes = [
130 } 130 }
131 ] 131 ]
132 }, { 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 + ]
  149 + }, {
133 path: '/bpm', 150 path: '/bpm',
134 component: Layout, 151 component: Layout,
135 hidden: true, 152 hidden: true,
yudao-ui-admin/src/views/mall/product/spu/index.vue
@@ -273,10 +273,6 @@ @@ -273,10 +273,6 @@
273 <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" 273 <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
274 @pagination="getList"/> 274 @pagination="getList"/>
275 275
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>  
280 </div> 276 </div>
281 </template> 277 </template>
282 278
@@ -284,20 +280,9 @@ @@ -284,20 +280,9 @@
284 import {deleteSpu, getSpuPage,} from "@/api/mall/product/spu"; 280 import {deleteSpu, getSpuPage,} from "@/api/mall/product/spu";
285 import {getProductCategoryList} from "@/api/mall/product/category"; 281 import {getProductCategoryList} from "@/api/mall/product/category";
286 import {getBrandList} from "@/api/mall/product/brand"; 282 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  
293 283
294 export default { 284 export default {
295 name: "Spu", 285 name: "Spu",
296 - components: {  
297 - Editor,  
298 - ImageUpload,  
299 - save,  
300 - },  
301 data() { 286 data() {
302 return { 287 return {
303 activeTabs: "all", 288 activeTabs: "all",
@@ -318,12 +303,6 @@ export default { @@ -318,12 +303,6 @@ export default {
318 total: 0, 303 total: 0,
319 // 商品spu列表 304 // 商品spu列表
320 list: [], 305 list: [],
321 - // 弹出层标题  
322 - title: "",  
323 - // 是否显示弹出层  
324 - open: false,  
325 - // 弹出层参数  
326 - dialogObj: {},  
327 dateRangeCreateTime: [], 306 dateRangeCreateTime: [],
328 // 查询参数 307 // 查询参数
329 queryParams: { 308 queryParams: {
@@ -341,7 +320,6 @@ export default { @@ -341,7 +320,6 @@ export default {
341 marketPriceMax: null, 320 marketPriceMax: null,
342 tabStatus: null, 321 tabStatus: null,
343 }, 322 },
344 - tagIndex: 0,  
345 }; 323 };
346 }, 324 },
347 created() { 325 created() {
@@ -383,12 +361,6 @@ export default { @@ -383,12 +361,6 @@ export default {
383 this.loading = false; 361 this.loading = false;
384 }); 362 });
385 }, 363 },
386 -  
387 - /** 取消按钮 */  
388 - cancel() {  
389 - this.open = false;  
390 - this.reset();  
391 - },  
392 /** 搜索按钮操作 */ 364 /** 搜索按钮操作 */
393 handleQuery() { 365 handleQuery() {
394 this.queryParams.pageNo = 1; 366 this.queryParams.pageNo = 1;
@@ -405,20 +377,11 @@ export default { @@ -405,20 +377,11 @@ export default {
405 }, 377 },
406 /** 新增按钮操作 */ 378 /** 新增按钮操作 */
407 handleAdd() { 379 handleAdd() {
408 - this.dialogObj = {};  
409 - this.open = true;  
410 - this.title = "添加商品spu"; 380 + this.$router.push({ name: 'SpuAdd'})
411 }, 381 },
412 /** 修改按钮操作 */ 382 /** 修改按钮操作 */
413 handleUpdate(row) { 383 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 }})
422 }, 385 },
423 /** 删除按钮操作 */ 386 /** 删除按钮操作 */
424 handleDelete(row) { 387 handleDelete(row) {
@@ -462,20 +425,6 @@ export default { @@ -462,20 +425,6 @@ export default {
462 margin-left: 10px; 425 margin-left: 10px;
463 } 426 }
464 427
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 -  
479 .product-info { 428 .product-info {
480 display: flex; 429 display: flex;
481 430
yudao-ui-admin/src/views/mall/product/spu/save.vue
@@ -217,9 +217,6 @@ export default { @@ -217,9 +217,6 @@ export default {
217 ImageUpload, 217 ImageUpload,
218 VideoUpload 218 VideoUpload
219 }, 219 },
220 - props: {  
221 - obj: Object  
222 - },  
223 data() { 220 data() {
224 return { 221 return {
225 activeSwitch: false, 222 activeSwitch: false,
@@ -281,8 +278,9 @@ export default { @@ -281,8 +278,9 @@ export default {
281 this.getListBrand(); 278 this.getListBrand();
282 this.getListCategory(); 279 this.getListCategory();
283 this.getPropertyPageList(); 280 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)
286 } 284 }
287 }, 285 },
288 methods: { 286 methods: {
@@ -353,8 +351,18 @@ export default { @@ -353,8 +351,18 @@ export default {
353 this.brandList = response.data; 351 this.brandList = response.data;
354 }); 352 });
355 }, 353 },
  354 + // 取消按钮
356 cancel() { 355 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 + })
358 }, 366 },
359 submit() { 367 submit() {
360 this.$refs[this.activeName].validate((valid) => { 368 this.$refs[this.activeName].validate((valid) => {
@@ -410,12 +418,16 @@ export default { @@ -410,12 +418,16 @@ export default {
410 if (form.id == null) { 418 if (form.id == null) {
411 createSpu(form).then((response) => { 419 createSpu(form).then((response) => {
412 this.$modal.msgSuccess("新增成功"); 420 this.$modal.msgSuccess("新增成功");
413 - this.$emit("closeDialog"); 421 + })
  422 + .then(()=>{
  423 + this.cancel();
414 }) 424 })
415 } else { 425 } else {
416 updateSpu(form).then((response) => { 426 updateSpu(form).then((response) => {
417 this.$modal.msgSuccess("修改成功"); 427 this.$modal.msgSuccess("修改成功");
418 - this.$emit("closeDialog"); 428 + })
  429 + .then(()=>{
  430 + this.cancel();
419 }) 431 })
420 } 432 }
421 }); 433 });
@@ -484,9 +496,8 @@ export default { @@ -484,9 +496,8 @@ export default {
484 </script> 496 </script>
485 497
486 <style lang="scss"> 498 <style lang="scss">
487 -.spec-dialog {  
488 - width: 400px;  
489 - height: 300px; 499 +.container{
  500 + padding: 20px;
490 } 501 }
491 502
492 .dynamic-spec { 503 .dynamic-spec {
@@ -531,11 +542,9 @@ export default { @@ -531,11 +542,9 @@ export default {
531 } 542 }
532 543
533 .tabs { 544 .tabs {
534 - height: 500px;  
535 border-bottom: 2px solid #f2f2f2; 545 border-bottom: 2px solid #f2f2f2;
536 546
537 .el-tab-pane { 547 .el-tab-pane {
538 - height: 445px;  
539 overflow-y: auto; 548 overflow-y: auto;
540 } 549 }
541 } 550 }