add.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <!-- 引一个当前组件 -->
  2. <?php
  3. use common\helpers\ComponentHelper;
  4. ComponentHelper::loadComponentView('group-com-goods', dirname(__DIR__) . '/components');
  5. ?>
  6. <div id="app">
  7. <el-card shadow="never" style="border:0;min-width: 1200px;" body-style="background-color: #f3f3f3;padding: 0 0;">
  8. <div slot="header">
  9. <el-breadcrumb separator="/">
  10. <el-breadcrumb-item><span style="color: #409EFF;cursor: pointer">添加拼团商品</span></el-breadcrumb-item>
  11. </el-breadcrumb>
  12. </div>
  13. <!-- 这里是引用的内部组件-和vue一样的套路 -->
  14. <group-com-goods sign="group_buy"
  15. ref="appGoods"
  16. :is_attr="1"
  17. :is_show="0"
  18. :rule="rule"
  19. :goods-head="false"
  20. :status_change_text="statusChangeText"
  21. >
  22. </group-com-goods>
  23. </el-card>
  24. </div>
  25. <script>
  26. const app = new Vue({
  27. el: '#app',
  28. data() {
  29. return {
  30. rule: {
  31. is_alone_buy: [
  32. {required: true, message: '请选择是否允许单独购买', trigger: 'change'},
  33. ],
  34. end_at: [
  35. {required: true, message: '请选择拼团结束时间', trigger: 'change'},
  36. ],
  37. limit_num: [
  38. {required: true, message: '请输入拼团次数限制', trigger: 'change'},
  39. ],
  40. },
  41. isGroupsRestrictions: true,
  42. isBuyNumRestrictions: true,
  43. statusChangeText: '拼团商品至少需要添加一个拼团组,商品才可上架。'
  44. }
  45. },
  46. methods: {
  47. handlePreview(e) {
  48. const price = Number(e.price);
  49. const attr = e.attr;
  50. let arr = [];
  51. attr.map(v => {
  52. arr.push(Number(v.price));
  53. });
  54. let max = Math.max.apply(null, arr);
  55. let min = Math.min.apply(null, arr);
  56. let actualPrice = -1;
  57. let type = 'text-price';
  58. if (max > min && min >= 0) {
  59. actualPrice = min + '-' + max;
  60. } else if (max == min && min >= 0) {
  61. actualPrice = min;
  62. } else if (price > 0) {
  63. actualPrice = price;
  64. } else if (price == 0) {
  65. actualPrice = '免费';
  66. type = '';
  67. }
  68. this.previewData = Object.assign({},e,{
  69. actualPrice,
  70. tType:type,
  71. });
  72. },
  73. goodsSuccess(detail) {
  74. this.form = Object.assign(this.form, detail.plugin);
  75. },
  76. itemChecked(type) {
  77. if (type === 1) {
  78. this.form.limit_num = this.isGroupsRestrictions ? -1 : 0
  79. }
  80. },
  81. },
  82. mounted(){
  83. }
  84. })
  85. </script>