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