user.js 6.9 KB

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