user.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. extend: 'data-area=\'["80%","80%"]\'',
  57. url: 'trade/money_log/index',
  58. refresh: true
  59. },{
  60. name: "clear",
  61. text: __('Clear'),
  62. classname: 'btn btn-xs btn-danger btn-magic btn-ajax',
  63. url: 'user/user/clear',
  64. visible: function (row) {
  65. if(row.task_num > 0) return true;
  66. return false;
  67. },
  68. refresh: true
  69. },{
  70. name: "team",
  71. text: __('Team'),
  72. classname: 'btn btn-xs btn-success btn-magic btn-dialog',
  73. url: 'user/team/index',
  74. extend: 'data-area=\'["80%","80%"]\'',
  75. refresh: true
  76. },{
  77. name: "edit",
  78. text: __('Edit'),
  79. classname: 'btn btn-xs btn-warning btn-magic btn-dialog',
  80. url: 'user/user/edit',
  81. refresh: true
  82. },{
  83. name: "del",
  84. text: __('Del'),
  85. classname: 'btn btn-xs btn-danger btn-magic btn-ajax',
  86. confirm: __('Confirm review'),
  87. url: 'user/user/del',
  88. refresh: true
  89. }],
  90. events: Table.api.events.operate, formatter: Table.api.formatter.operate
  91. }
  92. ]
  93. ]
  94. });
  95. // 为表格绑定事件
  96. Table.api.bindevent(table);
  97. //余额
  98. $(document).on('click','.btn-balance',function () {
  99. var ids = Table.api.selectedids(table);
  100. Fast.api.open($.fn.bootstrapTable.defaults.extend.balance_url + "?ids=" + ids, __('Balance'))
  101. });
  102. //卡单
  103. $(document).on('click','.btn-cardslip',function () {
  104. var ids = Table.api.selectedids(table);
  105. Fast.api.open($.fn.bootstrapTable.defaults.extend.cardslip_url + "?ids=" + ids, __('Card slip'))
  106. });
  107. //收款
  108. $(document).on('click','.btn-collection',function () {
  109. var ids = Table.api.selectedids(table);
  110. Fast.api.open($.fn.bootstrapTable.defaults.extend.collection_url + "?ids=" + ids, __('Collection'))
  111. });
  112. },
  113. balance: function () {
  114. //余额
  115. Controller.api.bindevent();
  116. },
  117. cardslip: function () {
  118. //卡单
  119. Controller.api.bindevent();
  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. });