user.js 6.8 KB

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