user.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. add_url: 'user/user/add',
  9. edit_url: 'user/user/edit',
  10. multi_url: 'user/user/multi',
  11. infocheck_url: 'user/user/infocheck',
  12. addjewel_url: 'user/user/add_jewel',
  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: 'user.id',
  22. columns: [
  23. [
  24. {checkbox: true},
  25. {field: 'id', title: __('Id'), sortable: true},
  26. {field: 'u_id', title: __('Uid'), sortable: true},
  27. {field: 'avatar', title: __('Avatar'), events: Table.api.events.image, formatter: Table.api.formatter.image, operate: false},
  28. {field: 'nickname', title: __('Nickname'), operate: 'LIKE'},
  29. {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
  30. // {field: '查看', title: __('下级用户'), formatter: function(value, row, index){
  31. // return '<a href="usererji/index?parent_id='+row.id+'" ' +
  32. // 'class="label label-info jump" style="cursor: pointer" ' +
  33. // 'data-toggle="tooltip" title="查看下级用户">查看</a>';
  34. // }},
  35. // {field: 'preuser.u_id', title: __('上级代理ID')},
  36. // {field: 'preuser.nickname', title: __('上级代理昵称'), formatter: function(value, row, index){
  37. // if(!value) {
  38. // return "平台";
  39. // } else {
  40. // return value;
  41. // }
  42. // }},
  43. // {field: 'auth.realname', title: __('真实姓名')},
  44. // {field: 'auth.idcard', title: __('身份证号')},
  45. // {field: 'chargetime', title: __('最近一次充值时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
  46. // {field: 'onlinetime', title: __('最近一次上线时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
  47. // {field: 'chargecount', title: __('总充值金额')},
  48. // {field: 'rebatecount', title: __('总获得返利金额')},
  49. {field: 'gender', title: __('Gender'), searchList: {1: __('Male'), 0: __('Female')}, formatter: Table.api.formatter.normal},
  50. // {field: 'age', title: __('Age'), operate: 'LIKE'},
  51. // {field: 'level', title: __('Level'), operate: 'BETWEEN', sortable: true},
  52. // {field: 'empirical', title: __('Empirical'), operate: 'LIKE'},
  53. {field: 'money', title: __('Money'), operate: 'RANGE', sortable: true, width:100},
  54. {field: 'jewel', title: __('Jewel'), operate: 'RANGE', sortable: true, width:100},
  55. // {field: 'sound_coin', title: __('Sound_coin'), operate: 'LIKE'},
  56. // {field: 'noble.name', title: __('Noble'), operate: 'LIKE'},
  57. // {field: 'noble_duetime', title: __('NobleDuetime'), formatter: Table.api.formatter.datetime, operate: 'RANGE'},
  58. {field: 'age.name', title: __('Age_id'), operate: false},
  59. {field: 'constellation.name', title: __('Constellation_id'), operate: false},
  60. {field: 'is_cool', title: __('Is_cool'), searchList:{'0': __('Is_cool 0'), '1':__('Is_cool 1')}, formatter: Table.api.formatter.status},
  61. {field: 'is_manager', title: __('Is_manager'), searchList:{'0' : __('Is_manager 0'), '1':__('Is_manager 1')}, formatter: Table.api.formatter.status},
  62. {field: 'is_stealth', title: __('Is_stealth'), searchList:{'0' :__('Is_stealth 0'), '1' :__('Is_stealth 1')}, formatter: Table.api.formatter.status},
  63. {field: 'logintime', title: __('Logintime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
  64. {field: 'loginip', title: __('Loginip'), formatter: Table.api.formatter.search},
  65. {field: 'createtime', title: __('Jointime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
  66. {field: 'joinip', title: __('Joinip'), formatter: Table.api.formatter.search},
  67. {field: 'need_check', title: __('Need_check'), searchList:{'0':__('Need_check 0'), '1' :__('Need_check 1')}, formatter: Table.api.formatter.status},
  68. {field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: {normal: __('Normal'), hidden: __('Hidden')}},
  69. {
  70. field: 'operate', title: __('Operate'), buttons: [
  71. {
  72. name: 'infocheck',
  73. title: __('信息审核'),
  74. classname: 'btn btn-xs btn-warning btn-dialog',
  75. icon: 'fa fa-leaf',
  76. url: 'user/user/infoCheck',
  77. visible: function (row) {
  78. if ((row.pre_nickname != '' && row.pre_nickname != row.nickname) || (row.pre_avatar != '' && row.pre_avatar != row.avatar)) {
  79. return true;
  80. } else {
  81. return false;
  82. }
  83. }
  84. },{
  85. name: 'detail',
  86. title: __('查看详情'),
  87. classname: 'btn btn-xs btn-primary btn-dialog',
  88. icon: 'fa fa-list',
  89. url: 'user/user/detail',
  90. }, {
  91. name: 'addjewel',
  92. title: __('充值'),
  93. classname: 'btn btn-xs btn-info btn-dialog',
  94. icon: 'fa fa-diamond',
  95. url: 'user/user/addJewel',
  96. },
  97. ], table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate
  98. }
  99. ]
  100. ]
  101. });
  102. // 为表格绑定事件
  103. Table.api.bindevent(table);
  104. table.off('dbl-click-row.bs.table');
  105. },
  106. add: function () {
  107. Controller.api.bindevent();
  108. },
  109. edit: function () {
  110. Controller.api.bindevent();
  111. },
  112. detail: function () {
  113. Controller.api.bindevent();
  114. },
  115. infocheck: function () {
  116. Controller.api.bindevent();
  117. },
  118. addjewel: function () {
  119. Controller.api.bindevent();
  120. },
  121. api: {
  122. bindevent: function () {
  123. Form.api.bindevent($("form[role=form]"));
  124. }
  125. }
  126. };
  127. return Controller;
  128. });