reward.js 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: () => {
  4. const { reactive, onMounted, ref } = Vue
  5. const index = {
  6. setup() {
  7. const state = reactive({
  8. data: [],
  9. filter: {
  10. drawer: false,
  11. data: {
  12. buyer: { field: 'buyer_id', value: '' },
  13. agent: { field: 'agent_id', value: '' },
  14. 'order.order_sn': '',
  15. commission_time: [],
  16. status: '',
  17. },
  18. tools: {
  19. buyer: {
  20. type: 'tinputprepend',
  21. label: '下单用户',
  22. placeholder: '请输入查询内容',
  23. value: {
  24. field: 'buyer_id',
  25. value: '',
  26. },
  27. options: {
  28. data: [{
  29. label: '用户ID',
  30. value: 'buyer_id',
  31. },
  32. {
  33. label: '用户昵称',
  34. value: 'buyer.nickname',
  35. },
  36. {
  37. label: '用户手机号',
  38. value: 'buyer.mobile',
  39. }],
  40. }
  41. },
  42. agent: {
  43. type: 'tinputprepend',
  44. label: '结算分销商',
  45. placeholder: '请输入查询内容',
  46. value: {
  47. field: 'agent_id',
  48. value: '',
  49. },
  50. options: {
  51. data: [{
  52. label: '结算ID',
  53. value: 'agent_id',
  54. },
  55. {
  56. label: '结算昵称',
  57. value: 'agent.nickname',
  58. },
  59. {
  60. label: '结算手机号',
  61. value: 'agent.mobile',
  62. }],
  63. }
  64. },
  65. 'order.order_sn': {
  66. type: 'tinput',
  67. label: '订单号',
  68. placeholder: '请输入查询内容',
  69. value: '',
  70. },
  71. commission_time: {
  72. type: 'tdatetimerange',
  73. label: '分佣时间',
  74. value: [],
  75. },
  76. status: {
  77. type: 'tselect',
  78. label: '入账状态',
  79. value: '',
  80. options: {
  81. data: [{
  82. label: '已退回',
  83. value: '-2',
  84. },
  85. {
  86. label: '已取消',
  87. value: '-1',
  88. },
  89. {
  90. label: '未结算',
  91. value: '0',
  92. },
  93. {
  94. label: '已结算',
  95. value: '1',
  96. }],
  97. },
  98. },
  99. },
  100. condition: {},
  101. },
  102. statusStyle: {
  103. '-2': 'danger',
  104. '-1': 'warning',
  105. 0: 'info',
  106. 1: 'success',
  107. },
  108. })
  109. function getData() {
  110. let tempSearch = JSON.parse(JSON.stringify(state.filter.data));
  111. let search = composeFilter(tempSearch, {
  112. 'buyer.nickname': 'like',
  113. 'buyer.mobile': 'like',
  114. 'agent.nickname': 'like',
  115. 'agent.mobile': 'like',
  116. 'order.order_sn': 'like',
  117. commission_time: 'range',
  118. });
  119. Fast.api.ajax({
  120. url: 'shopro/commission/reward',
  121. type: 'GET',
  122. data: {
  123. page: pagination.page,
  124. list_rows: pagination.list_rows,
  125. ...search,
  126. },
  127. }, function (ret, res) {
  128. state.data = res.data.data
  129. pagination.total = res.data.total
  130. return false
  131. }, function (ret, res) { })
  132. }
  133. function onOpenFilter() {
  134. state.filter.drawer = true
  135. }
  136. function onChangeFilter() {
  137. pagination.page = 1
  138. getData()
  139. state.filter.drawer && (state.filter.drawer = false)
  140. }
  141. const pagination = reactive({
  142. page: 1,
  143. list_rows: 10,
  144. total: 0,
  145. })
  146. const exportLoading = ref(false);
  147. function onExport(type) {
  148. exportLoading.value = true;
  149. let tempSearch = JSON.parse(JSON.stringify(state.filter.data));
  150. let search = composeFilter(tempSearch, {
  151. 'buyer.nickname': 'like',
  152. 'buyer.mobile': 'like',
  153. 'agent.nickname': 'like',
  154. 'agent.mobile': 'like',
  155. 'order.order_sn': 'like',
  156. commission_time: 'range',
  157. });
  158. if (Config.save_type == 'download') {
  159. window.location.href = `${Config.moduleurl}/shopro/commission/reward/${type}?page=${pagination.page}&list_rows=${pagination.list_rows}&search=${search.search}`;
  160. exportLoading.value = false;
  161. } else if (Config.save_type == 'save') {
  162. Fast.api.ajax({
  163. url: `shopro/commission/reward/${type}`,
  164. type: 'GET',
  165. data: {
  166. page: pagination.page,
  167. list_rows: pagination.list_rows,
  168. ...search,
  169. },
  170. }, function (ret, res) {
  171. exportLoading.value = false;
  172. }, function (ret, res) { })
  173. }
  174. }
  175. onMounted(() => {
  176. getData()
  177. })
  178. return {
  179. state,
  180. getData,
  181. onOpenFilter,
  182. onChangeFilter,
  183. pagination,
  184. exportLoading,
  185. onExport,
  186. }
  187. }
  188. }
  189. createApp('index', index);
  190. },
  191. };
  192. return Controller;
  193. });