user.js 7.5 KB

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