user.js 6.5 KB

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