agent_price_edit.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <style>
  2. .agent_price_edit {
  3. border: 1px solid #EBEEF5;
  4. padding: 10px;
  5. }
  6. .agent_price_edit .bg {
  7. /* height: 44px;*/
  8. padding: 10px;
  9. background: #f8f8f8;
  10. }
  11. .agent_price_edit .del-img {
  12. height: 20px;
  13. width: 20px;
  14. cursor: pointer;
  15. }
  16. .agent_price_edit .img-box {
  17. position: relative;
  18. /* height: 100px;*/
  19. width: 100px;
  20. margin-top: 8px;
  21. border: 1px solid #EBEEF5;
  22. }
  23. .agent_price_edit .attr-jt {
  24. background: #ffffff;
  25. width: 6px;
  26. height: 6px;
  27. border-top: 1px solid rgb(235, 238, 245);
  28. border-right: 1px solid #EBEEF5;
  29. transform: rotate(-45deg);
  30. -o-transform: rotate(-45deg);
  31. -webkit-transform: rotate(-45deg);
  32. -moz-transform: rotate(-45deg);
  33. -ms-transform: rotate(-45deg);
  34. position: absolute;
  35. top: -5px;
  36. }
  37. .agent_price_edit .close {
  38. position: absolute;
  39. top: -4px;
  40. right: -4px;
  41. font-size: 16px;
  42. cursor: pointer;
  43. }
  44. .agent_price_edit .attr-list {
  45. display: inline-block;
  46. margin-right: 10px;
  47. margin-bottom: 10px;
  48. position: relative;
  49. cursor: move;
  50. }
  51. .label {
  52. text-align: right;
  53. }
  54. </style>
  55. <template id="agent_price_edit">
  56. <div class="agent_price_edit">
  57. <el-form ref="ruleForm" label-width="" size="small">
  58. <div v-for="(group, i) in value" :key="i" style="margin-bottom: 16px">
  59. <el-form-item label="" prop="is_filter" label-width="0">
  60. <div class="bg" style="display:flex;align-items: center;">
  61. <el-input type="text" placeholder="请输入数量" v-model.trim="group.start_num" size="mini" style="width:150px;margin:0 10px">
  62. <template slot="append">件</template>
  63. </el-input>
  64. <span class="label">~</span>
  65. <el-input type="text" placeholder="请输入数量" v-model.trim="group.end_num" size="mini" style="width:150px;margin:0 10px">
  66. <template slot="append">件</template>
  67. </el-input>
  68. <template>
  69. <el-input type="text" placeholder="请输入金额" v-model.trim="group.price" size="mini" style="width:150px;margin:0 10px">
  70. <template slot="append">元/件</template>
  71. </el-input>
  72. </template>
  73. <el-button @click="deleteAttrGroup(i)" class="bg" style="border: none;" icon="el-icon-delete"></el-button>
  74. </div>
  75. </el-form-item>
  76. </div>
  77. <div flex="dir:left cross:center" class="bg" v-if="isAddAttrGroups" style="padding: 10px;">
  78. <el-button @click="addAttrGroup()">添加价位</el-button>
  79. <span style="padding-left: 14px;color:#c9c9c9">注:最多可添加10个</span>
  80. </div>
  81. </el-form>
  82. </div>
  83. </template>
  84. <script>
  85. Vue.component('agent_price_edit', {
  86. template: '#agent_price_edit',
  87. props: {
  88. value: {
  89. type: Array,
  90. default: function () {
  91. return [];
  92. }
  93. },
  94. },
  95. data() {
  96. return {
  97. attrGroupMaxCount: 10, //可添加最大数量
  98. isAddAttrGroups: true, //添加按钮是否显示
  99. };
  100. },
  101. watch: {
  102. },
  103. mounted() {
  104. },
  105. methods: {
  106. // 添加表单组
  107. addAttrGroup() {
  108. var obj = {
  109. start_num:0,
  110. end_num:0,
  111. price:0,
  112. }
  113. this.value.push(obj);
  114. // 限制添加的规格组
  115. if (this.value.length === this.attrGroupMaxCount) {
  116. this.isAddAttrGroups = false;
  117. }
  118. },
  119. // 删除表单组
  120. deleteAttrGroup(index) {
  121. this.value.splice(index, 1);
  122. if (this.value.length < this.attrGroupMaxCount) {
  123. this.isAddAttrGroups = true;
  124. }
  125. // this.makeAttrGroup();
  126. },
  127. }
  128. });
  129. </script>