com-community.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template id="com-community">
  2. <div class="com-community">
  3. <el-card class="edit-card" shadow="never">
  4. <div slot="header" class="clearfix">
  5. <div class="card-title">团长自提<span class="card-sub-title"></span></div>
  6. </div>
  7. <el-form :model="form" size="small" label-width="150px">
  8. <el-tabs v-model="activeName" @tab-click="handleClick">
  9. <el-tab-pane v-for="(config,key) in form" :label="commission_type_map[key]" :name="key" :key="key">
  10. <el-form-item label="是否参与自提奖励" prop="enable">
  11. <el-switch :active-value="1" :inactive-value="0" v-model="config.enable"></el-switch>
  12. <div class="tips-text" >开启后,该商品才参与全局配置的社区团购奖励</div>
  13. </el-form-item>
  14. <template v-if="config.enable == 1">
  15. <el-form-item label="是否独立设置" prop="is_alone">
  16. <el-switch :active-value="1" :inactive-value="0" v-model="config.is_alone"></el-switch>
  17. <div class="tips-text" >开启后,该商品按独立设置的奖励分出,不受其它位置的配置影响</div>
  18. </el-form-item>
  19. <el-form-item label="类型" prop="is_percent">
  20. <el-radio-group v-model="config.is_percent">
  21. <el-radio :label="0" class="grid-content bg-purple">百分比</el-radio>
  22. <el-radio :label="1" class="grid-content bg-purple">固定{{commission_type_map[config.commission_type]}}</el-radio>
  23. </el-radio-group>
  24. </el-form-item>
  25. <el-form-item label="计算方式" class='reward_diy_label' prop="calculate_type">
  26. <el-radio-group v-model="config.calculate_type">
  27. <el-radio :label="0">实际支付金额</el-radio>
  28. </el-radio-group>
  29. <br/>
  30. <div class="tips-text" style="line-height: 24px;">
  31. 如团长奖励设置为百分比这按这里的计算方式进行计算
  32. </div>
  33. </el-form-item>
  34. <el-form-item label="赠送数额" prop="give_num">
  35. <el-input style="width:200px;" v-model="config.give_num" type="number" placeholder="请输入数额">
  36. <template slot="append" v-if="config.is_percent == 0">%</template>
  37. <template slot="append" v-if="config.is_percent == 1">{{commission_type_map[config.commission_type]}}</template>
  38. </el-input>
  39. </el-form-item>
  40. </template>
  41. </el-tab-pane>
  42. </el-tabs>
  43. </el-form>
  44. </el-card>
  45. </div>
  46. </template>
  47. <script>
  48. Vue.component('com-community', {
  49. template: "#com-community",
  50. props: {
  51. setting: {
  52. type: Object,
  53. default: () => {
  54. return {};
  55. }
  56. },
  57. commission_type_map: {
  58. type: Object,
  59. default: () => {
  60. return {};
  61. }
  62. }
  63. },
  64. data() {
  65. return {
  66. activeName: 'commission',
  67. form: {
  68. commission: {
  69. enable: 0,
  70. is_alone: 0,
  71. is_percent: 0,
  72. give_num: 0,
  73. calculate_type: 0,
  74. commission_type: 'commission',
  75. item_type: 'goods',
  76. },
  77. score: {
  78. enable: 0,
  79. is_alone: 0,
  80. is_percent: 0,
  81. give_num: 0,
  82. calculate_type: 0,
  83. commission_type: 'score',
  84. item_type: 'goods',
  85. },
  86. },
  87. }
  88. },
  89. mounted() {
  90. },
  91. watch: {
  92. setting: {
  93. deep: true,
  94. immediate: true,
  95. handler(value) {
  96. if (!isEmpty(value)) {
  97. this.form = value;
  98. }
  99. }
  100. },
  101. // commission_type_map: {
  102. // deep: true,
  103. // immediate: true,
  104. // handler(value) {
  105. // if (!isEmpty(value)) {
  106. // let self = this;
  107. // // 初始化赋值
  108. // for (let name in self.commission_type_map) {
  109. // let setting = isEmpty(self.form[name]) ? {} : self.form[name];
  110. // if (Object.keys(setting).length <= 0) {
  111. // self.install = {
  112. // enable: isEmpty(self.form[name]) ? 1 : self.form[name].enable,
  113. // is_alone: isEmpty(self.form[name]) ? 0 : self.form[name].is_alone,
  114. // is_percent: isEmpty(self.form[name]) ? 0 : self.form[name].is_percent,
  115. // give_num: isEmpty(self.form[name]) ? 0 : self.form[name].give_num,
  116. // commission_type: name,
  117. // item_type: isEmpty(self.form[name]) ? 'goods' : self.form[name].item_type,
  118. // };
  119. // this.$set(self.form, name, JSON.parse(JSON.stringify(self.install)));
  120. // }
  121. // },
  122. form: {
  123. deep: true,
  124. immediate: true,
  125. handler(value) {
  126. this.$emit("change", JSON.stringify(value), "Community");
  127. }
  128. },
  129. },
  130. methods: {
  131. loadData() {
  132. this.cardLoading = true;
  133. request({
  134. params: {
  135. r: 'community/community-goods/get-mode-setting',
  136. id: getQuery('id'),
  137. },
  138. method: 'get'
  139. }).then(e => {
  140. this.cardLoading = false;
  141. if (e.data.code == 0) {
  142. this.levels = e.data.data.levels;
  143. } else {
  144. this.$message.error(e.data.msg);
  145. }
  146. }).catch(e => {
  147. console.log(e);
  148. });
  149. },
  150. handleSelectionChange() {},
  151. handleClick(tab, event) {
  152. console.log(tab, event);
  153. }
  154. }
  155. });
  156. </script>