reward.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. var orderIndex = new Vue({
  5. el: "#orderIndex",
  6. data() {
  7. return {
  8. orderList: [],
  9. currentPage: 1,
  10. totalPage: 0,
  11. offset: 0,
  12. limit: 10,
  13. searchStatusOption: [{
  14. value: 'all',
  15. label: "全部"
  16. }, {
  17. value: '-1',
  18. label: "已退回"
  19. }, {
  20. value: '0',
  21. label: "未入账"
  22. }, {
  23. value: '1',
  24. label: "已入账"
  25. }],
  26. searchForm: {
  27. form_1_key: "buyer_id",
  28. form_1_value: "",
  29. form_2_key: "agent_id",
  30. form_2_value: "",
  31. order_sn: "",
  32. createtime: "",
  33. status: "all",
  34. id: ''
  35. },
  36. searchFormInit: {
  37. form_1_key: "buyer_id",
  38. form_1_value: "",
  39. form_2_key: "agent_id",
  40. form_2_value: "",
  41. order_sn: "",
  42. createtime: "",
  43. status: "all",
  44. id: ''
  45. },
  46. searchOp: {
  47. buyer_id: "=",
  48. buyer_nickname: "like",
  49. buyer_mobile: "like",
  50. agent_id: "=",
  51. agent_nickname: "like",
  52. agent_mobile: "like",
  53. order_sn: "like",
  54. createtime: "range",
  55. status: "=",
  56. id: '='
  57. },
  58. dashboard: {
  59. total: 0,
  60. commission_total: 0,
  61. commissioned_total: 0,
  62. delay_total: 0,
  63. commission_back_total: 0,
  64. },
  65. isAjax: false
  66. }
  67. },
  68. mounted() {
  69. if (new URLSearchParams(location.search).get('agent_id')) {
  70. this.searchForm.form_2_key = 'agent_id';
  71. this.searchForm.form_2_value = new URLSearchParams(location.search).get('agent_id');
  72. if (new URLSearchParams(location.search).get('status')) {
  73. this.searchForm.status = new URLSearchParams(location.search).get('status');
  74. }
  75. } else if (new URLSearchParams(location.search).get('id')) {
  76. this.searchForm.id = new URLSearchParams(location.search).get('id');
  77. this.searchFormInit.id = new URLSearchParams(location.search).get('id');
  78. } else {
  79. this.searchForm.createtime = [];
  80. let start = `${moment(new Date()).format('YYYY-MM')}-01 00:00:00`;
  81. let end = `${moment(new Date()).format('YYYY-MM-DD HH:mm:ss')}`;
  82. this.searchForm.createtime.push(start)
  83. this.searchForm.createtime.push(end);
  84. this.searchFormInit.createtime = this.searchForm.createtime;
  85. }
  86. this.reqOrderList()
  87. },
  88. methods: {
  89. reqOrderList() {
  90. var that = this;
  91. that.isAjax = true;
  92. let filter = {}
  93. let op = {}
  94. for (key in that.searchForm) {
  95. if (key == 'form_1_value') {
  96. if (that.searchForm[key] != '') {
  97. filter[that.searchForm.form_1_key] = that.searchForm[key];
  98. }
  99. } else if (key == 'form_2_value') {
  100. if (that.searchForm[key] != '') {
  101. filter[that.searchForm.form_2_key] = that.searchForm[key];
  102. }
  103. } else if (key == 'createtime') {
  104. if (that.searchForm[key]) {
  105. if (that.searchForm[key].length > 0) {
  106. filter[key] = that.searchForm[key].join(' - ');
  107. }
  108. }
  109. } else if (key == 'order_sn' || key == 'status' || key == 'id') {
  110. if (that.searchForm[key] != '' && that.searchForm[key] != 'all') {
  111. filter[key] = that.searchForm[key];
  112. }
  113. }
  114. }
  115. for (key in filter) {
  116. op[key] = that.searchOp[key]
  117. }
  118. Fast.api.ajax({
  119. url: 'shopro/commission/reward/index',
  120. loading: false,
  121. type: 'GET',
  122. data: {
  123. filter: JSON.stringify(filter),
  124. op: JSON.stringify(op),
  125. offset: that.offset,
  126. limit: that.limit,
  127. }
  128. }, function (ret, res) {
  129. that.orderList = res.data.rows;
  130. that.totalPage = res.data.total;
  131. that.dashboard.total = res.data.total;
  132. that.dashboard.commission_total = res.data.commission_total;
  133. that.dashboard.commissioned_total = res.data.commissioned_total;
  134. that.dashboard.delay_total = res.data.delay_total;
  135. that.dashboard.commission_back_total = res.data.commission_back_total
  136. that.isAjax = false;
  137. return false;
  138. }, function (ret, res) {
  139. that.isAjax = false;
  140. })
  141. },
  142. commissionLevelFilter(level) {
  143. switch (level) {
  144. case 0:
  145. return '自购'
  146. break;
  147. case 1:
  148. return '一级分销'
  149. break;
  150. case 2:
  151. return '二级分销'
  152. break;
  153. case 3:
  154. return '三级分销'
  155. break;
  156. }
  157. },
  158. goDetail(id) {
  159. let that = this;
  160. Fast.api.open('shopro/order/order/detail?id=' + id, "查看详情", {
  161. callback() {
  162. that.reqOrderList()
  163. }
  164. });
  165. },
  166. operation(type, id) {
  167. let that = this;
  168. switch (type) {
  169. case 'edit':
  170. Fast.api.open('shopro/commission/agent/profile?id=' + id, '查看', {
  171. callback() {
  172. that.reqOrderList();
  173. }
  174. })
  175. break;
  176. }
  177. },
  178. screenEmpty() {
  179. this.searchForm = JSON.parse(JSON.stringify(this.searchFormInit))
  180. },
  181. handleSelectionChange(val) {
  182. this.multipleSelection = val;
  183. },
  184. //分页(更换页面显示条数)
  185. handleSizeChange(val) {
  186. this.offset = 0
  187. this.limit = val
  188. this.currentPage = 1;
  189. this.reqOrderList()
  190. },
  191. //当前是第几页
  192. handleCurrentChange(val) {
  193. this.offset = (val - 1) * this.limit;
  194. this.currentPage = 1;
  195. this.reqOrderList()
  196. },
  197. openCommissonOrder(order) {
  198. Fast.api.open(`shopro/commission/order/index?order_sn=${order.order_sn}`, '查看订单', {
  199. callback() {
  200. that.reqOrderList();
  201. }
  202. })
  203. },
  204. rewardStatusClass(status) {
  205. switch (status) {
  206. case -2:
  207. return 'shopro-status-info'
  208. break;
  209. case -1:
  210. return 'shopro-status-error'
  211. break;
  212. case 0:
  213. return 'shopro-status-warning'
  214. break;
  215. case 1:
  216. return 'shopro-status-success'
  217. break;
  218. }
  219. }
  220. },
  221. })
  222. },
  223. };
  224. return Controller;
  225. });