com-boss-bonus.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <?php
  2. use common\helpers\ComponentHelper;
  3. //自定义公共方法
  4. ComponentHelper::loadComponentView('common-js', dirname(__DIR__) . '/components');
  5. ?>
  6. <template id="com-boss-bonus">
  7. <div class="com-boss-bonus">
  8. <el-card class="edit-card" shadow="never">
  9. <div slot="header" class="clearfix">
  10. <div class="card-title">刮刮卡2+1<span class="card-sub-title"></span></div>
  11. </div>
  12. <el-form :model="form" size="small">
  13. <el-tabs v-model="activeName" @tab-click="handleClick">
  14. <el-tab-pane v-for="(config,key) in form" :label="commission_type_map2[key]" :name="key" :key="key">
  15. <el-form-item label="是否参与刮刮卡2+1" prop="is_partake">
  16. <el-switch :active-value="1" :inactive-value="0" v-model="config.is_partake"></el-switch>
  17. </el-form-item>
  18. <el-form-item label="独立设置分红" prop="is_enable" v-if="config.is_partake == 1">
  19. <el-switch :active-value="1" :inactive-value="0" v-model="config.is_enable"></el-switch>
  20. </el-form-item>
  21. <el-row :gutter="24" v-if="config.is_enable == 1 && config.is_partake == 1">
  22. <el-col :span="24">
  23. <el-card shadow="always">
  24. <el-form-item label="奖励类型" prop="is_percent">
  25. <el-radio-group v-model="config.is_percent">
  26. <el-radio :label="0" class="grid-content bg-purple">百分比</el-radio>
  27. <el-radio :label="1" class="grid-content bg-purple">固定{{commission_type_map2[config.commission_type]}}</el-radio>
  28. </el-radio-group>
  29. </el-form-item>
  30. <el-form-item>
  31. <template v-if="config.settings == 0 || is_attr == 0">
  32. <el-table ref="normal" :data="level_arr.Scratch" border stripe style="width: 100%;" @selection-change="handleSelectionChange">
  33. <el-table-column width="100" label="等级名称" prop="name"></el-table-column>
  34. <el-table-column label="直推奖" width="300" v-if="levels>=1">
  35. <template slot-scope="scope">
  36. <el-input type="text"
  37. v-model="config.detail[scope.row.level].first_prize"
  38. @input="firstPrizeViolationNumInput($event, key, scope.row.level)"
  39. >
  40. <template slot="append" v-if="config.is_percent == 0">%</template>
  41. <template slot="append" v-if="config.is_percent == 1">
  42. <template v-if="config.commission_type == 'commission'">元</template>
  43. <template v-if="config.commission_type == 'score'">{{commission_type_map2[config.commission_type]}}</template>
  44. </template>
  45. </el-input>
  46. </template>
  47. </el-table-column>
  48. <el-table-column label="团队奖" width="300" v-if="levels>=2">
  49. <template slot-scope="scope">
  50. <el-input type="text"
  51. v-model="config.detail[scope.row.level].second_prize"
  52. @input="secondPrizeViolationNumInput($event, key, scope.row.level)"
  53. >
  54. <template slot="append" v-if="config.is_percent == 0">%</template>
  55. <template slot="append" v-if="config.is_percent == 1">
  56. <template v-if="config.commission_type == 'commission'">元</template>
  57. <template v-if="config.commission_type == 'score'">{{commission_type_map2[config.commission_type]}}</template>
  58. </template>
  59. </el-input>
  60. </template>
  61. </el-table-column>
  62. <el-table-column label="三级奖励" width="300" v-if="levels>=3">
  63. <template slot-scope="scope">
  64. <el-input type="text"
  65. v-model="config.detail[scope.row.level].third_prize"
  66. @input="thirdPrizeViolationNumInput($event, key, scope.row.level)"
  67. >
  68. <template slot="append" v-if="config.is_percent == 0">%</template>
  69. <template slot="append" v-if="config.is_percent == 1">
  70. <template v-if="config.commission_type == 'commission'">元</template>
  71. <template v-if="config.commission_type == 'score'">{{commission_type_map2[config.commission_type]}}</template>
  72. </template>
  73. </el-input>
  74. </template>
  75. </el-table-column>
  76. <!-- <el-table-column label="团队奖" width="300" >-->
  77. <!-- <template slot-scope="scope">-->
  78. <!-- <el-input type="number" v-model="config.detail[scope.row.level].team_prize" onkeyup="value=toNumber(value,2)">-->
  79. <!-- <template slot="append" v-if="config.is_percent == 0">%</template>-->
  80. <!-- <template slot="append" v-if="config.is_percent == 1">-->
  81. <!-- <template v-if="config.commission_type == 'commission'">元</template>-->
  82. <!-- <template v-if="config.commission_type == 'score'">{{commission_type_map2[config.commission_type]}}</template>-->
  83. <!-- </template>-->
  84. <!-- </el-input>-->
  85. <!-- </template>-->
  86. <!-- </el-table-column>-->
  87. <el-table-column label="平级奖" width="300" >
  88. <template slot-scope="scope">
  89. <el-input type="text"
  90. v-model="config.detail[scope.row.level].peer_award_prize"
  91. @input="peerAwardPrizeViolationNumInput($event, key, scope.row.level)"
  92. >
  93. <template slot="append" v-if="config.is_percent == 0">%</template>
  94. <template slot="append" v-if="config.is_percent == 1">
  95. <template v-if="config.commission_type == 'commission'">元</template>
  96. <template v-if="config.commission_type == 'score'">{{commission_type_map2[config.commission_type]}}</template>
  97. </template>
  98. </el-input>
  99. </template>
  100. </el-table-column>
  101. </el-table>
  102. </template>
  103. </el-form-item>
  104. </el-card>
  105. </el-col>
  106. </el-row>
  107. </el-tab-pane>
  108. </el-tabs>
  109. </el-form>
  110. </el-card>
  111. </div>
  112. </template>
  113. <script>
  114. Vue.component('com-boss-bonus', {
  115. template: "#com-boss-bonus",
  116. props: {
  117. level_arr: {
  118. type: Object,
  119. default: () => {
  120. return {};
  121. }
  122. },
  123. setting: {
  124. type: Object,
  125. default: () => {
  126. return {};
  127. }
  128. },
  129. commission_type_map:{
  130. type: Object,
  131. default: () => {
  132. return {};
  133. }
  134. },
  135. commission_type_map2:{
  136. type: Object,
  137. default: () => {
  138. return {commission: "佣金"};
  139. }
  140. }
  141. },
  142. data() {
  143. return {
  144. levels:2,
  145. activeName: 'commission',
  146. form: {
  147. },
  148. is_attr:0,
  149. install: {// 初始化数据
  150. is_enable: 0,
  151. is_partake: 0,
  152. is_percent:0,
  153. item_type: 'goods',
  154. commission_type: '',
  155. settings: 0,
  156. detail: {}
  157. }
  158. }
  159. },
  160. mounted() {
  161. this.loadData();
  162. console.info(this.form,111);
  163. },
  164. watch: {
  165. setting: {
  166. deep:true,
  167. immediate: true,
  168. handler(value){
  169. if (!isEmpty(value)) {
  170. this.form = value;
  171. }
  172. }
  173. },
  174. level_arr: {
  175. deep:true,
  176. immediate: true,
  177. handler(value){
  178. if (!isEmpty(value)) {
  179. let self = this;
  180. var data = value.Scratch;
  181. // 初始化赋值
  182. for (let name in self.commission_type_map2) {
  183. let detail = {};
  184. var prize = isEmpty(self.form[name]) ? {} : self.form[name].detail;
  185. Object.keys(data).forEach(function (key) {
  186. var formKey = data[key].level;
  187. Object.assign(detail, {
  188. [formKey]: {
  189. level: data[key].level,
  190. first_prize:!isEmpty(prize[formKey]) ? prize[formKey].first_prize : 0,
  191. second_prize:!isEmpty(prize[formKey]) ? prize[formKey].second_prize : 0,
  192. third_prize:!isEmpty(prize[formKey]) ? prize[formKey].third_prize : 0,
  193. team_prize:!isEmpty(prize[formKey]) ? prize[formKey].team_prize : 0,
  194. peer_award_prize:!isEmpty(prize[formKey]) ? prize[formKey].peer_award_prize : 0,
  195. }
  196. });
  197. });
  198. self.install = {
  199. is_partake: isEmpty(self.form[name]) ? 0 : self.form[name].is_partake,
  200. is_enable: isEmpty(self.form[name]) ? 0 : self.form[name].is_enable,
  201. is_percent: isEmpty(self.form[name]) ? 0 : self.form[name].is_percent,
  202. item_type: isEmpty(self.form[name]) ? 'goods' : self.form[name].item_type,
  203. commission_type: name,
  204. detail: detail
  205. };
  206. this.$set(self.form,name,JSON.parse(JSON.stringify(self.install)));
  207. }
  208. }
  209. }
  210. },
  211. form:{
  212. deep:true,
  213. immediate: true,
  214. handler(value){
  215. this.$emit("change",JSON.stringify(value), "Scratch");
  216. }
  217. },
  218. },
  219. methods:{
  220. loadData() {
  221. this.cardLoading = true;
  222. request({
  223. params: {
  224. r: 'boss-bonus/setting/config-setting',
  225. id: getQuery('id'),
  226. },
  227. method: 'get'
  228. }).then(e => {
  229. this.cardLoading = false;
  230. if (e.data.code == 0) {
  231. this.levels = e.data.data.levels;
  232. } else {
  233. this.$message.error(e.data.msg);
  234. }
  235. }).catch(e => {
  236. console.log(e);
  237. });
  238. },
  239. handleSelectionChange(){},
  240. handleClick(tab, event) {
  241. console.log(tab, event);
  242. },
  243. //检测当前输入的违规次数--输入的时候
  244. firstPrizeViolationNumInput(value, v_key, level) {
  245. this.form[v_key].detail[level].first_prize = numberHandle(value, 2, 2);
  246. },
  247. //检测当前输入的违规次数--输入的时候
  248. secondPrizeViolationNumInput(value, v_key, level) {
  249. this.form[v_key].detail[level].second_prize = numberHandle(value, 2, 2);
  250. },
  251. //检测当前输入的违规次数--输入的时候
  252. thirdPrizeViolationNumInput(value, v_key, level) {
  253. this.form[v_key].detail[level].third_prize = numberHandle(value, 2, 2);
  254. },
  255. //检测当前输入的违规次数--输入的时候
  256. peerAwardPrizeViolationNumInput(value, v_key, level) {
  257. this.form[v_key].detail[level].peer_award_prize = numberHandle(value, 2, 2);
  258. },
  259. }
  260. });
  261. </script>