user.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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' + location.search,
  8. add_url: 'user/user/add',
  9. edit_url: 'user/user/edit',
  10. // del_url: 'user/user/del',
  11. multi_url: 'user/user/multi',
  12. import_url: 'user/user/import',
  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: 'id',
  22. fixedColumns: true,
  23. fixedRightNumber: 1,
  24. columns: [
  25. [
  26. {checkbox: true},
  27. {field: 'id', title: __('Id')},
  28. // {field: 'group_id', title: __('Group_id')},
  29. {field: 'group.name', title: __('Group.name'), operate: 'LIKE'},
  30. {field: 'username', title: __('Username'), operate: 'LIKE'},
  31. {field: 'nickname', title: __('Nickname'), operate: 'LIKE'},
  32. // {field: 'password', title: __('Password'), operate: 'LIKE'},
  33. // {field: 'salt', title: __('Salt'), operate: 'LIKE'},
  34. // {field: 'email', title: __('Email'), operate: 'LIKE'},
  35. {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
  36. {field: 'avatar', title: __('Avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
  37. // {field: 'level', title: __('Level')},
  38. // {field: 'gender', title: __('Gender')},
  39. // {field: 'birthday', title: __('Birthday'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  40. // {field: 'bio', title: __('Bio'), operate: 'LIKE'},
  41. // {field: 'money', title: __('Money'), operate:'BETWEEN'},
  42. // {field: 'score', title: __('Score')},
  43. // {field: 'successions', title: __('Successions')},
  44. // {field: 'maxsuccessions', title: __('Maxsuccessions')},
  45. {field: 'prevtime', title: __('Prevtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  46. // {field: 'logintime', title: __('Logintime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  47. {field: 'loginip', title: __('Loginip'), operate: 'LIKE'},
  48. // {field: 'loginfailure', title: __('Loginfailure')},
  49. // {field: 'joinip', title: __('Joinip'), operate: 'LIKE'},
  50. {field: 'jointime', title: __('Jointime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  51. // {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  52. // {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  53. // {field: 'token', title: __('Token'), operate: 'LIKE'},
  54. {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1')}, formatter: Table.api.formatter.status},
  55. // {field: 'verification', title: __('Verification'), operate: 'LIKE'},
  56. // {field: 'mini_openid', title: __('Mini_openid'), operate: 'LIKE'},
  57. // {field: 'mini_sessionkey', title: __('Mini_sessionkey'), operate: 'LIKE'},
  58. // {field: 'unionid', title: __('Unionid'), operate: 'LIKE'},
  59. // {field: 'introcode', title: __('Introcode'), operate: 'LIKE'},
  60. {field: 'intro_uid', title: __('Intro_uid')},
  61. {field: 'operate', title: __('Operate'), table: table,
  62. buttons:[
  63. {
  64. name:'dtqrcode',
  65. text:'地推码',
  66. title:'地推码',
  67. icon:'fa fa-exclamation-circle',
  68. classname:'btn btn-xs btn-danger btn-dialog',
  69. url:'user/user/dtqrcode/id/{ids}',
  70. extend:'data-area=["50%","80%"]',
  71. target:'_self',
  72. refresh:true,
  73. hidden:function($row){
  74. if($row.group_id == 3){
  75. return false;
  76. }
  77. return true;
  78. }
  79. }
  80. ],
  81. events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  82. ]
  83. ]
  84. });
  85. // 为表格绑定事件
  86. Table.api.bindevent(table);
  87. },
  88. add: function () {
  89. Controller.api.bindevent();
  90. },
  91. edit: function () {
  92. Controller.api.bindevent();
  93. },
  94. dtqrcode: function () {
  95. // Controller.api.bindevent();
  96. },
  97. api: {
  98. bindevent: function () {
  99. Form.api.bindevent($("form[role=form]"));
  100. }
  101. }
  102. };
  103. return Controller;
  104. });