user.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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: 'LIKE'},
  54. {field: 'jewel', title: __('Jewel'), operate: 'LIKE'},
  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:Config.isCoolList, formatter: Table.api.formatter.status},
  61. {field: 'is_manager', title: __('Is_manager'), searchList:Config.isManagerList, formatter: Table.api.formatter.status},
  62. {field: 'is_stealth', title: __('Is_stealth'), searchList:Config.isStealthList, 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: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: {normal: __('Normal'), hidden: __('Hidden')}},
  68. {
  69. field: 'operate', title: __('Operate'), buttons: [
  70. {
  71. name: 'infocheck',
  72. title: __('信息审核'),
  73. classname: 'btn btn-xs btn-warning btn-dialog',
  74. icon: 'fa fa-leaf',
  75. url: 'user/user/infoCheck',
  76. visible: function (row) {
  77. if ((row.pre_nickname != '' && row.pre_nickname != row.nickname) || (row.pre_avatar != '' && row.pre_avatar != row.avatar)) {
  78. return true;
  79. } else {
  80. return false;
  81. }
  82. }
  83. },{
  84. name: 'detail',
  85. title: __('查看详情'),
  86. classname: 'btn btn-xs btn-primary btn-dialog',
  87. icon: 'fa fa-list',
  88. url: 'user/user/detail',
  89. }, {
  90. name: 'addjewel',
  91. title: __('充值'),
  92. classname: 'btn btn-xs btn-info btn-dialog',
  93. icon: 'fa fa-diamond',
  94. url: 'user/user/addJewel',
  95. },
  96. ], table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate
  97. }
  98. ]
  99. ]
  100. });
  101. // 为表格绑定事件
  102. Table.api.bindevent(table);
  103. table.off('dbl-click-row.bs.table');
  104. },
  105. add: function () {
  106. Controller.api.bindevent();
  107. },
  108. edit: function () {
  109. Controller.api.bindevent();
  110. },
  111. detail: function () {
  112. Controller.api.bindevent();
  113. },
  114. infocheck: function () {
  115. Controller.api.bindevent();
  116. },
  117. addjewel: function () {
  118. Controller.api.bindevent();
  119. },
  120. api: {
  121. bindevent: function () {
  122. Form.api.bindevent($("form[role=form]"));
  123. }
  124. }
  125. };
  126. return Controller;
  127. });