user.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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: 'id',
  22. columns: [
  23. [
  24. {checkbox: true},
  25. {field: 'id', title: __('Id'), operate: false},
  26. {field: 'agent', title: __('Group_id'), operate: false},
  27. {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
  28. {field: 'parent_name', title: __('Parent_id'), operate: false},
  29. {field: 'balance', title: __('Balance'), operate: false},
  30. {field: 'freeze', title: __('Freeze'), operate: false},
  31. {field: 'task_num', title: __('Task'), operate: false},
  32. {field: 'id', title: __('Recharge'), operate: false},
  33. {field: 'id', title: __('Withdrawal'), operate: false},
  34. {field: 'id', title: __('Income'), operate: false},
  35. {field: 'invitation_code', title: __('Invitation_code'), operate: false},
  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. name: "clear",
  53. text: __('Clear'),
  54. classname: 'btn btn-xs btn-danger btn-magic btn-ajax',
  55. url: 'user/user/clear',
  56. visible: function (row) {
  57. if(row.task_num > 0) return true;
  58. return false;
  59. },
  60. refresh: true
  61. },{
  62. name: "team",
  63. text: __('Team'),
  64. classname: 'btn btn-xs btn-success btn-magic btn-dialog',
  65. url: 'user/team/index',
  66. extend: 'data-area=\'["80%","80%"]\'',
  67. refresh: true
  68. },{
  69. name: "edit",
  70. text: __('Edit'),
  71. classname: 'btn btn-xs btn-warning btn-magic btn-dialog',
  72. url: 'user/user/edit',
  73. refresh: true
  74. },{
  75. name: "del",
  76. text: __('Del'),
  77. classname: 'btn btn-xs btn-danger btn-magic btn-ajax',
  78. confirm: __('Confirm review'),
  79. url: 'user/user/del',
  80. refresh: true
  81. }],
  82. events: Table.api.events.operate, formatter: Table.api.formatter.operate
  83. }
  84. ]
  85. ]
  86. });
  87. // 为表格绑定事件
  88. Table.api.bindevent(table);
  89. //余额
  90. $(document).on('click','.btn-balance',function () {
  91. var ids = Table.api.selectedids(table);
  92. Fast.api.open($.fn.bootstrapTable.defaults.extend.balance_url + "?ids=" + ids, __('Balance'))
  93. });
  94. //卡单
  95. $(document).on('click','.btn-cardslip',function () {
  96. var ids = Table.api.selectedids(table);
  97. Fast.api.open($.fn.bootstrapTable.defaults.extend.cardslip_url + "?ids=" + ids, __('Card slip'))
  98. });
  99. //收款
  100. $(document).on('click','.btn-collection',function () {
  101. var ids = Table.api.selectedids(table);
  102. Fast.api.open($.fn.bootstrapTable.defaults.extend.collection_url + "?ids=" + ids, __('Collection'))
  103. });
  104. },
  105. balance: function () {
  106. //余额
  107. Controller.api.bindevent();
  108. },
  109. cardslip: function () {
  110. //卡单
  111. Controller.api.bindevent();
  112. },
  113. collection: function () {
  114. //收款
  115. Controller.api.bindevent();
  116. },
  117. edit: function () {
  118. Controller.api.bindevent();
  119. },
  120. api: {
  121. bindevent: function () {
  122. Form.api.bindevent($("form[role=form]"));
  123. }
  124. }
  125. };
  126. return Controller;
  127. });