user.js 6.3 KB

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