user.js 7.0 KB

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