com-operation-center.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template id="com-operation-center">
  2. <div class="com-operation-center">
  3. <el-card class="edit-card" shadow="never">
  4. <el-form :model="form" size="small">
  5. <el-tabs v-model="activeName" @tab-click="handleClick">
  6. <el-tab-pane v-for="(config,key) in form" :label="commission_type_map2[key]" :name="key" :key="key">
  7. <el-form-item label="是否参与运营中心" prop="is_partake">
  8. <el-switch :active-value="1" :inactive-value="0" v-model="config.is_partake"></el-switch>
  9. </el-form-item>
  10. <el-form-item label="是否独立设置" prop="is_enable" v-if="config.is_partake == 1">
  11. <el-switch :active-value="1" :inactive-value="0" v-model="config.is_enable"></el-switch>
  12. </el-form-item>
  13. <el-row :gutter="24" v-if="config.is_enable == 1 && config.is_partake == 1">
  14. <el-col :span="24">
  15. <el-card shadow="always">
  16. <el-form-item label="奖励类型" prop="is_percent">
  17. <el-radio-group v-model="config.is_percent">
  18. <el-radio :label="0" class="grid-content bg-purple">百分比</el-radio>
  19. <el-radio :label="1" class="grid-content bg-purple">固定金额</el-radio>
  20. </el-radio-group>
  21. </el-form-item>
  22. <el-form-item>
  23. <template v-if="config.settings == 0 || is_attr == 0">
  24. <el-table ref="normal" :data="level_arr.OperationCenter" border stripe
  25. style="width: 100%;" @selection-change="handleSelectionChange">
  26. <el-table-column width="100" label="等级名称" prop="name"></el-table-column>
  27. <el-table-column label="直推奖" width="300">
  28. <template slot-scope="scope">
  29. <el-input type="text" v-model="config.detail[scope.row.level].commission1_value" onInput="value=toNumber(value,2)">
  30. <template slot="append" v-if="config.is_percent == 0">%</template>
  31. <template slot="append" v-if="config.is_percent == 1">元</template>
  32. </el-input>
  33. </template>
  34. </el-table-column>
  35. <el-table-column label="间推奖" width="300">
  36. <template slot-scope="scope">
  37. <el-input type="text" v-model="config.detail[scope.row.level].commission2_value" onInput="value=toNumber(value,2)">
  38. <template slot="append" v-if="config.is_percent == 0">%</template>
  39. <template slot="append" v-if="config.is_percent == 1">元</template>
  40. </el-input>
  41. </template>
  42. </el-table-column>
  43. </el-table>
  44. </template>
  45. </el-form-item>
  46. </el-card>
  47. </el-col>
  48. </el-row>
  49. </el-tab-pane>
  50. </el-tabs>
  51. </el-form>
  52. </el-card>
  53. </div>
  54. </template>
  55. <script>
  56. Vue.component('com-operation-center', {
  57. template: "#com-operation-center",
  58. props: {
  59. level_arr: {
  60. type: Object,
  61. default: () => {
  62. return {};
  63. }
  64. },
  65. setting: {
  66. type: Object,
  67. default: () => {
  68. return {};
  69. }
  70. },
  71. commission_type_map2: {
  72. type: Object,
  73. default: () => {
  74. return { commission: "佣金" };
  75. }
  76. },
  77. },
  78. data() {
  79. return {
  80. activeName: 'commission',
  81. form: {
  82. },
  83. is_attr: 0,
  84. install: {// 初始化数据
  85. is_enable: 0,
  86. is_partake: 1,
  87. is_percent: 0,
  88. item_type: 'goods',
  89. commission_type: 'commission',
  90. settings: 0,
  91. detail: {}
  92. },
  93. }
  94. },
  95. mounted() {
  96. },
  97. watch: {
  98. setting: {
  99. deep: true,
  100. immediate: true,
  101. handler(value) {
  102. if (!isEmpty(value)) {
  103. this.form = value;
  104. }
  105. }
  106. },
  107. level_arr: {
  108. deep: true,
  109. immediate: true,
  110. handler(value) {
  111. if (!isEmpty(value)) {
  112. let self = this;
  113. var data = value.OperationCenter;
  114. // 初始化赋值
  115. for (let name in self.commission_type_map2) {
  116. let detail = {};
  117. var prize = isEmpty(self.form[name]) ? {} : self.form[name].detail;
  118. Object.keys(data).forEach(function (key) {
  119. var formKey = data[key].level;
  120. Object.assign(detail, {
  121. [formKey]: {
  122. level: data[key].level,
  123. commission1_value: !isEmpty(prize[formKey]) ? prize[formKey].commission1_value : 0,
  124. commission2_value: !isEmpty(prize[formKey]) ? prize[formKey].commission2_value : 0,
  125. }
  126. });
  127. });
  128. self.install = {
  129. is_partake: isEmpty(self.form[name]) ? 1 : self.form[name].is_partake,
  130. is_enable: isEmpty(self.form[name]) ? 0 : self.form[name].is_enable,
  131. is_percent: isEmpty(self.form[name]) ? 0 : self.form[name].is_percent,
  132. item_type: isEmpty(self.form[name]) ? 'goods' : self.form[name].item_type,
  133. commission_type: name,
  134. detail: detail
  135. };
  136. this.$set(self.form, name, JSON.parse(JSON.stringify(self.install)));
  137. }
  138. }
  139. }
  140. },
  141. form: {
  142. deep: true,
  143. immediate: true,
  144. handler(value) {
  145. this.$emit("change", JSON.stringify(value), "OperationCenter");
  146. }
  147. },
  148. },
  149. methods: {
  150. handleSelectionChange() { },
  151. handleClick(tab, event) {
  152. console.log(tab, event);
  153. },
  154. }
  155. });
  156. </script>