user.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend: {
  7. index_url: 'user/user/index',
  8. add_url: 'user/user/add',
  9. edit_url: 'user/user/edit',
  10. del_url: 'user/user/del',
  11. multi_url: 'user/user/multi',
  12. balance_url: 'user/user/balance',
  13. cardslip_url: 'user/user/cardslip',
  14. collection_url: 'user/user/collection',
  15. table: 'user',
  16. }
  17. });
  18. var table = $("#table");
  19. // 初始化表格
  20. table.bootstrapTable({
  21. url: $.fn.bootstrapTable.defaults.extend.index_url,
  22. pk: 'id',
  23. sortName: 'id',
  24. columns: [
  25. [
  26. {checkbox: true},
  27. {field: 'id', title: __('Id'), operate: false},
  28. {field: 'mobile', title: __('Group_id'), operate: false, formatter: function(value, row, index) {
  29. if (row.agent.mobile)
  30. return row.agent.code +'-'+row.agent.mobile;
  31. else
  32. return '';
  33. }},
  34. {field: 'mobile', title: __('Mobile'), operate: 'LIKE', formatter: function(value, row, index) {
  35. return row.code +'-'+row.mobile;
  36. }},
  37. {field: 'parent.mobile', title: __('Parent_id'), operate: false},
  38. {field: 'balance', title: __('Balance'), operate: false},
  39. {field: 'freeze', title: __('Freeze'), operate: false},
  40. {field: 'task_num', title: __('Task'), operate: false},
  41. {field: 'open_task', title: __('抢单开关'), formatter: Table.api.formatter.toggle,
  42. searchList: {0: __('关'), 1: __('开')}
  43. },
  44. {field: 'recharge', title: __('Recharge'), operate: false},
  45. {field: 'withdraw', title: __('Withdrawal'), operate: false},
  46. {field: 'bonus_sum', title: __('累计收益'), operate: false},
  47. {field: 'id', title: __('Income'), operate: false, formatter: function(value, row, index) {
  48. return row.recharge - row.withdraw;
  49. }},
  50. {field: 'invitation_code', title: __('Invitation_code'), operate: false},
  51. {field: 'is_agent', title: __('Is_agent'), searchList: {1: __('Yes'), 0: __('No')}, formatter: Table.api.formatter.toggle},
  52. {field: 'user_type', title: __('User_type'), formatter: Table.api.formatter.toggle,
  53. searchList: {0: __('Dummy'), 1: __('Real person')}
  54. },
  55. {field: 'is_lock', title: __('锁定'), formatter: Table.api.formatter.toggle,
  56. searchList: {0: __('Normal'), 1: __('Locking')}
  57. },
  58. {field: 'operate', title: __('Operate'), table: table,
  59. buttons: [
  60. {
  61. name: "account",
  62. text: __('Account change'),
  63. classname: 'btn btn-xs btn-info btn-magic btn-dialog',
  64. url: 'trade/money_log/index',
  65. refresh: true
  66. },{
  67. name: "clear",
  68. text: __('Clear'),
  69. classname: 'btn btn-xs btn-danger btn-magic btn-ajax',
  70. url: 'user/user/clear',
  71. visible: function (row) {
  72. if(row.task_num > 0) return true;
  73. return false;
  74. },
  75. refresh: true
  76. },{
  77. name: "team",
  78. text: __('Team'),
  79. classname: 'btn btn-xs btn-success btn-magic btn-dialog',
  80. url: 'user/team/index',
  81. extend: 'data-area=\'["80%","80%"]\'',
  82. refresh: true
  83. },{
  84. name: "edit",
  85. text: __('Edit'),
  86. classname: 'btn btn-xs btn-warning btn-magic btn-dialog',
  87. url: 'user/user/edit/ids/{id}',
  88. refresh: true
  89. },{
  90. name: "del",
  91. text: __('Del'),
  92. classname: 'btn btn-xs btn-danger btn-magic btn-ajax',
  93. confirm: __('Confirm review'),
  94. url: 'user/user/del/ids/{id}',
  95. refresh: true
  96. }],
  97. events: Table.api.events.operate, formatter: Table.api.formatter.operate
  98. }
  99. ]
  100. ]
  101. });
  102. // 为表格绑定事件
  103. Table.api.bindevent(table);
  104. //余额
  105. $(document).on('click','.btn-balance',function () {
  106. var ids = Table.api.selectedids(table);
  107. Fast.api.open($.fn.bootstrapTable.defaults.extend.balance_url + "?ids=" + ids, __('Balance'))
  108. });
  109. //卡单
  110. $(document).on('click','.btn-cardslip',function () {
  111. var ids = Table.api.selectedids(table);
  112. Fast.api.open($.fn.bootstrapTable.defaults.extend.cardslip_url + "?ids=" + ids, __('Card slip'))
  113. });
  114. //收款
  115. $(document).on('click','.btn-collection',function () {
  116. var ids = Table.api.selectedids(table);
  117. Fast.api.open($.fn.bootstrapTable.defaults.extend.collection_url + "?ids=" + ids, __('Collection'))
  118. });
  119. },
  120. balance: function () {
  121. //余额
  122. Controller.api.bindevent();
  123. },
  124. cardslip: function () {
  125. //卡单
  126. Controller.api.bindevent();
  127. //一键清空
  128. $(document).on('click','.btn-clear',function () {
  129. $('.form-horizontal .form-control').attr('value', '')
  130. });
  131. },
  132. collection: function () {
  133. //收款
  134. Controller.api.bindevent();
  135. },
  136. add: function () {
  137. Controller.api.bindevent();
  138. },
  139. edit: function () {
  140. Controller.api.bindevent();
  141. },
  142. api: {
  143. bindevent: function () {
  144. Form.api.bindevent($("form[role=form]"));
  145. }
  146. }
  147. };
  148. return Controller;
  149. });