user.js 5.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. multi_url: 'user/user/multi',
  10. table: 'user',
  11. }
  12. });
  13. var table = $("#table");
  14. // 初始化表格
  15. table.bootstrapTable({
  16. url: $.fn.bootstrapTable.defaults.extend.index_url,
  17. pk: 'id',
  18. sortName: 'user.id',
  19. columns: [
  20. [
  21. {checkbox: true},
  22. {field: 'id', title: __('Id'), sortable: true},
  23. {field: 'u_id', title: __('Uid'), sortable: true},
  24. {field: 'avatar', title: __('Avatar'), events: Table.api.events.image, formatter: Table.api.formatter.image, operate: false},
  25. {field: 'nickname', title: __('Nickname'), operate: 'LIKE'},
  26. {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
  27. // {field: '查看', title: __('下级用户'), formatter: function(value, row, index){
  28. // return '<a href="usererji/index?parent_id='+row.id+'" ' +
  29. // 'class="label label-info jump" style="cursor: pointer" ' +
  30. // 'data-toggle="tooltip" title="查看下级用户">查看</a>';
  31. // }},
  32. // {field: 'preuser.u_id', title: __('上级代理ID')},
  33. // {field: 'preuser.nickname', title: __('上级代理昵称'), formatter: function(value, row, index){
  34. // if(!value) {
  35. // return "平台";
  36. // } else {
  37. // return value;
  38. // }
  39. // }},
  40. // {field: 'auth.realname', title: __('真实姓名')},
  41. // {field: 'auth.idcard', title: __('身份证号')},
  42. // {field: 'chargetime', title: __('最近一次充值时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
  43. // {field: 'onlinetime', title: __('最近一次上线时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
  44. // {field: 'chargecount', title: __('总充值金额')},
  45. // {field: 'rebatecount', title: __('总获得返利金额')},
  46. //{field: 'gender', title: __('Gender'), searchList: {1: __('Male'), 0: __('Female')}, formatter: Table.api.formatter.normal},
  47. // {field: 'age', title: __('Age'), operate: 'LIKE'},
  48. // {field: 'level', title: __('Level'), operate: 'BETWEEN', sortable: true},
  49. // {field: 'empirical', title: __('Empirical'), operate: 'LIKE'},
  50. // {field: 'money', title: __('Money'), operate: 'LIKE'},
  51. // {field: 'jewel', title: __('Jewel'), operate: 'LIKE'},
  52. // {field: 'sound_coin', title: __('Sound_coin'), operate: 'LIKE'},
  53. // {field: 'noble.name', title: __('Noble'), operate: 'LIKE'},
  54. // {field: 'noble_duetime', title: __('NobleDuetime'), formatter: Table.api.formatter.datetime, operate: 'RANGE'},
  55. {field: 'logintime', title: __('Logintime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
  56. {field: 'loginip', title: __('Loginip'), formatter: Table.api.formatter.search},
  57. {field: 'createtime', title: __('Jointime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
  58. {field: 'joinip', title: __('Joinip'), formatter: Table.api.formatter.search},
  59. {field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: {normal: __('Normal'), hidden: __('Hidden')}},
  60. {
  61. field: 'operate', title: __('Operate'), buttons: [
  62. {
  63. name: 'detail',
  64. title: __('查看详情'),
  65. classname: 'btn btn-xs btn-primary btn-dialog',
  66. icon: 'fa fa-list',
  67. url: 'user/user/detail',
  68. },
  69. ], table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate
  70. }
  71. ]
  72. ]
  73. });
  74. // 为表格绑定事件
  75. Table.api.bindevent(table);
  76. table.off('dbl-click-row.bs.table');
  77. },
  78. add: function () {
  79. Controller.api.bindevent();
  80. },
  81. edit: function () {
  82. Controller.api.bindevent();
  83. },
  84. detail: function () {
  85. Controller.api.bindevent();
  86. },
  87. api: {
  88. bindevent: function () {
  89. Form.api.bindevent($("form[role=form]"));
  90. }
  91. }
  92. };
  93. return Controller;
  94. });