ProductDetail.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. <product-info-detail
  10. v-show="showStatus[0]"
  11. v-model="productParam"
  12. @nextStep="nextStep">
  13. </product-info-detail>
  14. <product-sale-detail
  15. v-show="showStatus[1]"
  16. v-model="productParam"
  17. @nextStep="nextStep"
  18. @prevStep="prevStep"
  19. >
  20. </product-sale-detail>
  21. <product-attr-detail
  22. v-show="showStatus[2]"
  23. v-model="productParam"
  24. @nextStep="nextStep"
  25. @prevStep="prevStep"
  26. >
  27. </product-attr-detail>
  28. <product-relation-detail
  29. v-show="showStatus[3]"
  30. v-model="productParam"
  31. @prevStep="prevStep"
  32. @finishCommit="finishCommit"
  33. >
  34. </product-relation-detail>
  35. </el-card>
  36. </template>
  37. <script>
  38. import ProductInfoDetail from './ProductInfoDetail';
  39. import ProductSaleDetail from './ProductSaleDetail';
  40. import ProductAttrDetail from './ProductAttrDetail';
  41. import ProductRelationDetail from './ProductRelationDetail';
  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: 'ProductDetail',
  106. components: {ProductInfoDetail, ProductSaleDetail, ProductAttrDetail, ProductRelationDetail},
  107. props: {
  108. isEdit: {
  109. type: Boolean,
  110. default: false
  111. }
  112. },
  113. data() {
  114. return {
  115. active: 0,
  116. productParam: Object.assign({}, defaultProductParam),
  117. showStatus: [true, false, false, false]
  118. }
  119. },
  120. methods: {
  121. hideAll() {
  122. for (let i = 0; i < this.showStatus.length; i++) {
  123. this.showStatus[i] = false;
  124. }
  125. },
  126. prevStep() {
  127. if (this.active > 0 && this.active < this.showStatus.length) {
  128. this.active--;
  129. this.hideAll();
  130. this.showStatus[this.active] = true;
  131. }
  132. },
  133. nextStep() {
  134. if (this.active < this.showStatus.length - 1) {
  135. this.active++;
  136. this.hideAll();
  137. this.showStatus[this.active] = true;
  138. }
  139. },
  140. finishCommit() {
  141. this.$confirm('是否要提交该产品', '提示', {
  142. confirmButtonText: '确定',
  143. cancelButtonText: '取消',
  144. type: 'warning'
  145. }).then(() => {
  146. createProduct(this.productParam).then(response=>{
  147. this.$message({
  148. type: 'success',
  149. message: '提交成功',
  150. duration:1000
  151. });
  152. location.reload();
  153. });
  154. })
  155. }
  156. }
  157. }
  158. </script>
  159. <style>
  160. .form-container {
  161. width: 800px;
  162. }
  163. </style>