team.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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/team/index'+ location.search +'&user_id='+Config.user_id,
  8. table: 'user_team',
  9. }
  10. });
  11. var table = $("#table");
  12. // 初始化表格
  13. table.bootstrapTable({
  14. url: $.fn.bootstrapTable.defaults.extend.index_url,
  15. pk: 'a.id',
  16. sortName: 'a.id',
  17. searchFormVisible: true,
  18. columns: [
  19. [
  20. {checkbox: true},
  21. {field: 'id', title: __('Id'), operate: false},
  22. {field: 'mobile', title: __('Mobile'), operate: 'Like'},
  23. {field: 'balance', title: __('Balance'), operate: false},
  24. {field: 'bonus_sum', title: __('Bonus sum'), operate: false},
  25. {field: 'parent_name', title: __('Parent id'),operate: false},
  26. {field: 'recharge', title: __('Recharge'), operate: false},
  27. {field: 'withdraw', title: __('Withdraw'), operate: false},
  28. {field: 'distance', title: __('Level'), formatter: function(value, row, index) {
  29. return value + __('Grade');
  30. }, operate: false,cellStyle: function () {
  31. return {css: {"color":"#18bc9c", 'font-weight':'550'}}}
  32. },
  33. {field: 'create_time', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  34. {field: 'operate', title: __('Operate'), table: table,
  35. buttons: [
  36. {
  37. name: "account",
  38. text: __('Account'),
  39. classname: 'btn btn-xs btn-info btn-magic btn-dialog',
  40. url: function(row){ return 'trade/moneylog/index/ids/'+row.id},
  41. refresh: true
  42. },{
  43. name: "ban",
  44. text: __('Ban'),
  45. classname: 'btn btn-xs btn-danger btn-magic btn-ajax',
  46. url: function(row){ return 'user/team/lock/ids/'+row.id},
  47. visible: function (row) {
  48. if(row.is_lock == 0) return true;
  49. return false;
  50. },
  51. refresh: true
  52. },{
  53. name: "banteam",
  54. text: __('Ban team'),
  55. classname: 'btn btn-xs btn-warning btn-magic btn-ajax',
  56. url: function(row){ return 'user/team/lockAll/ids/'+row.id},
  57. refresh: true
  58. }],
  59. events: Table.api.events.operate, formatter: Table.api.formatter.operate
  60. }]
  61. ],
  62. });
  63. // 为表格绑定事件
  64. Table.api.bindevent(table);
  65. $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
  66. var typeStr = $(this).attr("href").replace('#', '');
  67. var options = table.bootstrapTable('getOptions');
  68. options.pageNumber = 1;
  69. options.queryParams = function (params) {
  70. params.distance = typeStr;
  71. return params;
  72. };
  73. table.bootstrapTable('refresh', {});
  74. return false;
  75. });
  76. },
  77. account: function () {
  78. Controller.api.bindevent();
  79. },
  80. edit: function () {
  81. Controller.api.bindevent();
  82. },
  83. api: {
  84. bindevent: function () {
  85. Form.api.bindevent($("form[role=form]"));
  86. }
  87. }
  88. };
  89. return Controller;
  90. });