user.js 6.7 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. 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: 'open_task', title: __('抢单开关'), formatter: Table.api.formatter.toggle,
  33. searchList: {0: __('关'), 1: __('开')}
  34. },
  35. {field: 'is_limit_task', title: __('卡单开关'), formatter: Table.api.formatter.toggle,
  36. searchList: {0: __('关'), 1: __('开')}
  37. },
  38. {field: 'recharge', title: __('Recharge'), operate: false},
  39. {field: 'withdraw', title: __('Withdrawal'), operate: false},
  40. {field: 'bonus_sum', title: __('Income'), operate: false},
  41. {field: 'invitation_code', title: __('Invitation_code'), operate: false},
  42. {field: 'is_agent', title: __('Is_agent'), searchList: {1: __('Yes'), 0: __('No')}, formatter: Table.api.formatter.status},
  43. {field: 'user_type', title: __('User_type'), formatter: Table.api.formatter.toggle,
  44. searchList: {0: __('Dummy'), 1: __('Real person')}
  45. },
  46. {field: 'is_lock', title: __('Status'), formatter: Table.api.formatter.toggle,
  47. searchList: {0: __('Normal'), 1: __('Locking')}
  48. },
  49. {field: 'is_delete', title: __('是否删除'), searchList: {1: __('Yes'), 0: __('No')}, formatter: Table.api.formatter.status},
  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/moneylog/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',
  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',
  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. collection: function () {
  121. //收款
  122. Controller.api.bindevent();
  123. },
  124. edit: function () {
  125. Controller.api.bindevent();
  126. },
  127. api: {
  128. bindevent: function () {
  129. Form.api.bindevent($("form[role=form]"));
  130. }
  131. }
  132. };
  133. return Controller;
  134. });