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="deposit_presale"
  15. ref="appGoods"
  16. :is_show="0"
  17. :rule="rule"
  18. :goods-head="false"
  19. :status_change_text="statusChangeText"
  20. >
  21. </group-com-goods>
  22. </el-card>
  23. </div>
  24. <script>
  25. const app = new Vue({
  26. el: '#app',
  27. data() {
  28. return {
  29. rule: {
  30. is_alone_buy: [
  31. {required: true, message: '请选择是否允许单独购买', trigger: 'change'},
  32. ],
  33. end_at: [
  34. {required: true, message: '请选择定金预售结束时间', trigger: 'change'},
  35. ],
  36. limit_num: [
  37. {required: true, message: '请输入定金预售次数限制', trigger: 'change'},
  38. ],
  39. },
  40. isGroupsRestrictions: true,
  41. isBuyNumRestrictions: true,
  42. statusChangeText: '定金预售商品至少需要添加一个定金预售组,商品才可上架。'
  43. }
  44. },
  45. methods: {
  46. handlePreview(e) {
  47. const price = Number(e.price);
  48. const attr = e.attr;
  49. let arr = [];
  50. attr.map(v => {
  51. arr.push(Number(v.price));
  52. });
  53. let max = Math.max.apply(null, arr);
  54. let min = Math.min.apply(null, arr);
  55. let actualPrice = -1;
  56. let type = 'text-price';
  57. if (max > min && min >= 0) {
  58. actualPrice = min + '-' + max;
  59. } else if (max == min && min >= 0) {
  60. actualPrice = min;
  61. } else if (price > 0) {
  62. actualPrice = price;
  63. } else if (price == 0) {
  64. actualPrice = '免费';
  65. type = '';
  66. }
  67. this.previewData = Object.assign({},e,{
  68. actualPrice,
  69. tType:type,
  70. });
  71. },
  72. goodsSuccess(detail) {
  73. this.form = Object.assign(this.form, detail.plugin);
  74. },
  75. itemChecked(type) {
  76. if (type === 1) {
  77. this.form.limit_num = this.isGroupsRestrictions ? -1 : 0
  78. }
  79. },
  80. },
  81. mounted(){
  82. }
  83. })
  84. </script>