add.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template> 
  2. <el-card class="form-container" shadow="never">
  3. <el-steps :active="active" finish-status="success" align-center>
  4. <el-step title="填写商品信息"></el-step>
  5. <el-step title="填写商品促销"></el-step>
  6. <el-step title="填写商品属性"></el-step>
  7. <el-step title="选择商品关联"></el-step>
  8. </el-steps>
  9. <add-product-info
  10. v-show="showStatus[0]"
  11. v-model="productParam"
  12. @nextStep="nextStep">
  13. </add-product-info>
  14. <add-product-sale
  15. v-show="showStatus[1]"
  16. v-model="productParam"
  17. @nextStep="nextStep"
  18. @prevStep="prevStep"
  19. >
  20. </add-product-sale>
  21. <add-product-attr
  22. v-show="showStatus[2]"
  23. v-model="productParam"
  24. @nextStep="nextStep"
  25. @prevStep="prevStep"
  26. >
  27. </add-product-attr>
  28. <add-product-relation
  29. v-show="showStatus[3]"
  30. v-model="productParam"
  31. @prevStep="prevStep"
  32. @finishCommit="finishCommit"
  33. >
  34. </add-product-relation>
  35. </el-card>
  36. </template>
  37. <script>
  38. import AddProductInfo from './components/addProductInfo';
  39. import AddProductSale from './components/addProductSale';
  40. import AddProductAttr from './components/addProductAttr';
  41. import AddProductRelation from './components/addProductRelation';
  42. import {createProduct} from '@/api/product';
  43. const defaultProductParam = {
  44. albumPics: '',
  45. brandId: null,
  46. brandName: '',
  47. deleteStatus: 0,
  48. description: '',
  49. detailDesc: '',
  50. detailHtml: '',
  51. detailMobileHtml: '',
  52. detailTitle: '',
  53. feightTemplateId: 0,
  54. flashPromotionCount: 0,
  55. flashPromotionId: 0,
  56. flashPromotionPrice: 0,
  57. flashPromotionSort: 0,
  58. giftPoint: 0,
  59. giftGrowth: 0,
  60. keywords: '',
  61. lowStock: 0,
  62. name: '',
  63. newStatus: 0,
  64. note: '',
  65. originalPrice: 0,
  66. pic: '',
  67. //会员价格{memberLevelId: 0,memberPrice: 0,memberLevelName: null}
  68. memberPriceList: [],
  69. //商品满减
  70. productFullReductionList: [{fullPrice: 0, reducePrice: 0}],
  71. //商品阶梯价格
  72. productLadderList: [{count: 0,discount: 0,price: 0}],
  73. previewStatus: 0,
  74. price: 0,
  75. productAttributeCategoryId: null,
  76. //商品属性相关{productAttributeId: 0, value: ''}
  77. productAttributeValueList: [],
  78. //商品sku库存信息{lowStock: 0, pic: '', price: 0, sale: 0, skuCode: '', sp1: '', sp2: '', sp3: '', stock: 0}
  79. skuStockList: [],
  80. //商品相关专题{subjectId: 0}
  81. subjectProductRelationList: [],
  82. //商品相关优选{prefrenceAreaId: 0}
  83. prefrenceAreaProductRelationList: [],
  84. productCategoryId: null,
  85. productCategoryName: '',
  86. productSn: '',
  87. promotionEndTime: '',
  88. promotionPerLimit: 0,
  89. promotionPrice: null,
  90. promotionStartTime: '',
  91. promotionType: 0,
  92. publishStatus: 0,
  93. recommandStatus: 0,
  94. sale: 0,
  95. serviceIds: '',
  96. sort: 0,
  97. stock: 0,
  98. subTitle: '',
  99. unit: '',
  100. usePointLimit: 0,
  101. verifyStatus: 0,
  102. weight: 0
  103. };
  104. export default {
  105. name: 'addProduct',
  106. components: {AddProductInfo, AddProductSale, AddProductAttr, AddProductRelation},
  107. data() {
  108. return {
  109. active: 0,
  110. productParam: Object.assign({}, defaultProductParam),
  111. showStatus: [true, false, false, false]
  112. }
  113. },
  114. methods: {
  115. hideAll() {
  116. for (let i = 0; i < this.showStatus.length; i++) {
  117. this.showStatus[i] = false;
  118. }
  119. },
  120. prevStep() {
  121. if (this.active > 0 && this.active < this.showStatus.length) {
  122. this.active--;
  123. this.hideAll();
  124. this.showStatus[this.active] = true;
  125. }
  126. },
  127. nextStep() {
  128. if (this.active < this.showStatus.length - 1) {
  129. this.active++;
  130. this.hideAll();
  131. this.showStatus[this.active] = true;
  132. }
  133. },
  134. finishCommit() {
  135. this.$confirm('是否要提交该产品', '提示', {
  136. confirmButtonText: '确定',
  137. cancelButtonText: '取消',
  138. type: 'warning'
  139. }).then(() => {
  140. createProduct(this.productParam).then(response=>{
  141. this.$message({
  142. type: 'success',
  143. message: '提交成功',
  144. duration:1000
  145. });
  146. location.reload();
  147. });
  148. })
  149. }
  150. }
  151. }
  152. </script>
  153. <style>
  154. .form-container {
  155. width: 800px;
  156. }
  157. </style>