com-double-copy.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. <template id="com-double-copy">
  2. <div class="com-double-copy">
  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">
  8. <el-tabs v-model="activeName" @tab-click="handleClick">
  9. <el-tab-pane v-for="(config,key) in form" :label="commission_type_map2[key]" v-if="commission_type_map2[key]" :name="key" :key="key">
  10. <el-form-item label="是否参与二二复制" prop="is_partake">
  11. <el-switch :active-value="1" :inactive-value="0" v-model="config.is_partake"></el-switch>
  12. </el-form-item>
  13. <el-form-item label="独立设置分红" prop="is_enable" v-if="config.is_partake == 1">
  14. <el-switch :active-value="1" :inactive-value="0" v-model="config.is_enable"></el-switch>
  15. </el-form-item>
  16. <el-row :gutter="24" v-if="config.is_enable == 1 && config.is_partake == 1">
  17. <el-col :span="24">
  18. <el-card shadow="always">
  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"
  23. class="grid-content bg-purple">固定{{commission_type_map2[config.commission_type]}}</el-radio>
  24. </el-radio-group>
  25. </el-form-item>
  26. <el-form-item>
  27. <template v-if="config.settings == 0 || is_attr == 0">
  28. <el-table ref="normal" :data="level_arr.DoubleCopy" border stripe
  29. style="width: 100%;" @selection-change="handleSelectionChange">
  30. <el-table-column width="100" label="等级名称" prop="name"></el-table-column>
  31. <el-table-column label="直推奖" width="300">
  32. <template slot-scope="scope">
  33. <el-input type="text"
  34. v-model="config.detail[scope.row.level].first_prize"
  35. @input="firstPrizeViolationNumInput($event, key, scope.row.level)">
  36. <template slot="append"
  37. v-if="config.is_percent == 0">%</template>
  38. <template slot="append" v-if="config.is_percent == 1">
  39. <template
  40. v-if="config.commission_type == 'commission'">元</template>
  41. <template
  42. v-if="config.commission_type == 'score'">{{commission_type_map2[config.commission_type]}}</template>
  43. </template>
  44. </el-input>
  45. </template>
  46. </el-table-column>
  47. <el-table-column label="间推奖" width="300">
  48. <template slot-scope="scope">
  49. <el-input type="text"
  50. v-model="config.detail[scope.row.level].indirect_prize"
  51. @input="indirectPrizeViolationNumInput($event, key, scope.row.level)">
  52. <template slot="append"
  53. v-if="config.is_percent == 0">%</template>
  54. <template slot="append" v-if="config.is_percent == 1">
  55. <template
  56. v-if="config.commission_type == 'commission'">元</template>
  57. <template
  58. v-if="config.commission_type == 'score'">{{commission_type_map2[config.commission_type]}}</template>
  59. </template>
  60. </el-input>
  61. </template>
  62. </el-table-column>
  63. <el-table-column label="平台补贴" width="300">
  64. <template slot-scope="scope">
  65. <el-input type="text"
  66. v-model="config.detail[scope.row.level].second_prize"
  67. @input="secondPrizeViolationNumInput($event, key, scope.row.level)">
  68. <template slot="append"
  69. v-if="config.is_percent == 0">%</template>
  70. <template slot="append" v-if="config.is_percent == 1">
  71. <template
  72. v-if="config.commission_type == 'commission'">元</template>
  73. <template
  74. v-if="config.commission_type == 'score'">{{commission_type_map2[config.commission_type]}}</template>
  75. </template>
  76. </el-input>
  77. </template>
  78. </el-table-column>
  79. <el-table-column label="培育奖" width="300">
  80. <template slot-scope="scope">
  81. <el-input type="text"
  82. v-model="config.detail[scope.row.level].equal_prize"
  83. @input="peerAwardPrizeViolationNumInput($event, key, scope.row.level)">
  84. <template slot="append"
  85. v-if="config.is_percent == 0">%</template>
  86. <template slot="append" v-if="config.is_percent == 1">
  87. <template
  88. v-if="config.commission_type == 'commission'">元</template>
  89. <template
  90. v-if="config.commission_type == 'score'">{{commission_type_map2[config.commission_type]}}</template>
  91. </template>
  92. </el-input>
  93. </template>
  94. </el-table-column>
  95. <el-table-column label="津贴奖" width="300">
  96. <template slot-scope="scope">
  97. <el-input type="text"
  98. v-model="config.detail[scope.row.level].allowance_price"
  99. @input="allowancePrizeViolationNumInput($event, key, scope.row.level)">
  100. <template slot="append"
  101. v-if="config.is_percent == 0">%</template>
  102. <template slot="append" v-if="config.is_percent == 1">
  103. <template
  104. v-if="config.commission_type == 'commission'">元</template>
  105. <template
  106. v-if="config.commission_type == 'score'">{{commission_type_map2[config.commission_type]}}</template>
  107. </template>
  108. </el-input>
  109. </template>
  110. </el-table-column>
  111. <el-table-column label="平级奖" width="300">
  112. <template slot-scope="scope">
  113. <el-input type="text"
  114. v-model="config.detail[scope.row.level].equal_level_prize"
  115. @input="peerAwardLevelPrizeViolationNumInput($event, key, scope.row.level)">
  116. <template slot="append"
  117. v-if="config.is_percent == 0">%</template>
  118. <template slot="append" v-if="config.is_percent == 1">
  119. <template
  120. v-if="config.commission_type == 'commission'">元</template>
  121. <template
  122. v-if="config.commission_type == 'score'">{{commission_type_map2[config.commission_type]}}</template>
  123. </template>
  124. </el-input>
  125. </template>
  126. </el-table-column>
  127. <el-table-column label="复购奖" width="300">
  128. <template slot-scope="scope">
  129. <el-input type="text"
  130. v-model="config.detail[scope.row.level].repurchase_prize"
  131. @input="peerRepurchasePrizeViolationNumInput($event, key, scope.row.level)">
  132. <template slot="append"
  133. v-if="config.is_percent == 0">%</template>
  134. <template slot="append" v-if="config.is_percent == 1">
  135. <template
  136. v-if="config.commission_type == 'commission'">元</template>
  137. <template
  138. v-if="config.commission_type == 'score'">{{commission_type_map2[config.commission_type]}}</template>
  139. </template>
  140. </el-input>
  141. </template>
  142. </el-table-column>
  143. </el-table>
  144. </template>
  145. </el-form-item>
  146. </el-card>
  147. </el-col>
  148. </el-row>
  149. </el-tab-pane>
  150. </el-tabs>
  151. </el-form>
  152. </el-card>
  153. </div>
  154. </template>
  155. <script>
  156. Vue.component('com-double-copy', {
  157. template: "#com-double-copy",
  158. props: {
  159. is_show_additional_score: {
  160. type: Number,
  161. default: 0
  162. },
  163. level_arr: {
  164. type: Object,
  165. default: () => {
  166. return {};
  167. }
  168. },
  169. setting: {
  170. type: Object,
  171. default: () => {
  172. return {};
  173. }
  174. },
  175. commission_type_map: {
  176. type: Object,
  177. default: () => {
  178. return {};
  179. }
  180. },
  181. commission_type_map2: {
  182. type: Object,
  183. default: () => {
  184. return { commission: "佣金", score:"积分" };
  185. }
  186. },
  187. },
  188. data() {
  189. return {
  190. activeName: 'commission',
  191. form: {
  192. },
  193. is_attr: 0,
  194. install: {// 初始化数据
  195. is_enable: 0,
  196. is_partake: 0,
  197. is_percent: 0,
  198. item_type: 'goods',
  199. commission_type: 'commission',
  200. settings: 0,
  201. detail: {}
  202. },
  203. copy_commission_type: {}
  204. }
  205. },
  206. mounted() {
  207. this.getCurrencyText()
  208. },
  209. watch: {
  210. setting: {
  211. deep: true,
  212. immediate: true,
  213. handler(value) {
  214. if (!isEmpty(value)) {
  215. this.form = value;
  216. }
  217. }
  218. },
  219. level_arr: {
  220. deep: true,
  221. immediate: true,
  222. handler(value) {
  223. if (this.is_show_additional_score == 1) {
  224. this.commission_type_map2['additional_score'] = '额外积分'
  225. }
  226. // alert(123)
  227. if (!isEmpty(value)) {
  228. let self = this;
  229. var data = value.DoubleCopy;
  230. // 初始化赋值
  231. for (let name in self.commission_type_map2) {
  232. let detail = {};
  233. var prize = isEmpty(self.form[name]) ? {} : self.form[name].detail;
  234. Object.keys(data).forEach(function (key) {
  235. var formKey = data[key].level;
  236. Object.assign(detail, {
  237. [formKey]: {
  238. level: data[key].level,
  239. first_prize: !isEmpty(prize[formKey]) ? prize[formKey].first_prize : 0,
  240. indirect_prize: !isEmpty(prize[formKey]) ? prize[formKey].indirect_prize : 0,
  241. second_prize: !isEmpty(prize[formKey]) ? prize[formKey].second_prize : 0,
  242. equal_prize: !isEmpty(prize[formKey]) ? prize[formKey].equal_prize : 0,
  243. allowance_price: !isEmpty(prize[formKey]) ? prize[formKey].allowance_price : 0,
  244. equal_level_prize: !isEmpty(prize[formKey]) ? prize[formKey].equal_level_prize : 0,
  245. repurchase_prize: !isEmpty(prize[formKey]) ? prize[formKey].repurchase_prize : 0,
  246. }
  247. });
  248. });
  249. self.install = {
  250. is_partake: isEmpty(self.form[name]) ? 0 : self.form[name].is_partake,
  251. is_enable: isEmpty(self.form[name]) ? 0 : self.form[name].is_enable,
  252. is_percent: isEmpty(self.form[name]) ? 0 : self.form[name].is_percent,
  253. item_type: isEmpty(self.form[name]) ? 'goods' : self.form[name].item_type,
  254. commission_type: name,
  255. detail: detail
  256. };
  257. this.$set(self.form, name, JSON.parse(JSON.stringify(self.install)));
  258. }
  259. }
  260. }
  261. },
  262. form: {
  263. deep: true,
  264. immediate: true,
  265. handler(value) {
  266. this.$emit("change", JSON.stringify(value), "DoubleCopy");
  267. }
  268. },
  269. commission_type_map2: {
  270. deep: true,
  271. immediate: true,
  272. handler(value) {
  273. this.copy_commission_type = value
  274. }
  275. }
  276. },
  277. methods: {
  278. handleSelectionChange() { },
  279. handleClick(tab, event) {
  280. console.log(tab, event);
  281. },
  282. //检测当前输入的违规次数--输入的时候
  283. firstPrizeViolationNumInput(value, v_key, level) {
  284. this.form[v_key].detail[level].first_prize = numberHandle(value, 2, 2);
  285. },
  286. //检测当前输入的违规次数--输入的时候
  287. indirectPrizeViolationNumInput(value, v_key, level) {
  288. this.form[v_key].detail[level].indirect_prize = numberHandle(value, 2, 2);
  289. },
  290. //检测当前输入的违规次数--输入的时候
  291. secondPrizeViolationNumInput(value, v_key, level) {
  292. this.form[v_key].detail[level].second_prize = numberHandle(value, 2, 2);
  293. },
  294. //检测当前输入的违规次数--输入的时候
  295. peerAwardPrizeViolationNumInput(value, v_key, level) {
  296. this.form[v_key].detail[level].equal_prize = numberHandle(value, 2, 2);
  297. },
  298. allowancePrizeViolationNumInput(value, v_key, level) {
  299. this.form[v_key].detail[level].equal_prize = numberHandle(value, 2, 2);
  300. },
  301. //检测当前输入的违规次数--输入的时候
  302. peerAwardLevelPrizeViolationNumInput(value, v_key, level) {
  303. this.form[v_key].detail[level].equal_level_prize = numberHandle(value, 2, 2);
  304. },
  305. //检测当前输入的违规次数--输入的时候
  306. peerRepurchasePrizeViolationNumInput(value, v_key, level) {
  307. this.form[v_key].detail[level].repurchase_prize = numberHandle(value, 2, 2);
  308. },
  309. getCurrencyText() {
  310. request({
  311. params: {
  312. r: 'mall/setting/get-currency-text',
  313. currency: Object.keys(this.copy_commission_type)
  314. },
  315. method: 'get',
  316. }).then(e => {
  317. if (e.data.code == 0) {
  318. let data = e.data.data
  319. for (let key in this.copy_commission_type) {
  320. if(key in data) {
  321. this.copy_commission_type[key] = data[key];
  322. }
  323. }
  324. }
  325. })
  326. },
  327. }
  328. });
  329. </script>