user.js 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. del_url: 'user/user/del',
  11. multi_url: 'user/user/multi',
  12. table: 'user',
  13. }
  14. });
  15. var table = $("#table");
  16. // 初始化表格
  17. table.bootstrapTable({
  18. url: $.fn.bootstrapTable.defaults.extend.index_url,
  19. pk: 'id',
  20. sortName: 'user.id',
  21. columns: [
  22. [
  23. {checkbox: true},
  24. {field: 'id', title: __('Id'), sortable: true},
  25. {field: 'group.name', title: __('Group')},
  26. {field: 'username', title: __('Username'), operate: 'LIKE'},
  27. {field: 'nickname', title: __('Nickname'), operate: 'LIKE'},
  28. {field: 'email', title: __('Email'), operate: 'LIKE'},
  29. {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
  30. {field: 'avatar', title: __('Avatar'), events: Table.api.events.image, formatter: Table.api.formatter.image, operate: false},
  31. {field: 'level', title: __('Level'), operate: 'BETWEEN', sortable: true},
  32. {field: 'gender', title: __('Gender'), visible: false, searchList: {1: __('Male'), 0: __('Female')}},
  33. {field: 'score', title: __('Score'), operate: 'BETWEEN', sortable: true},
  34. {field: 'successions', title: __('Successions'), visible: false, operate: 'BETWEEN', sortable: true},
  35. {field: 'maxsuccessions', title: __('Maxsuccessions'), visible: false, operate: 'BETWEEN', sortable: true},
  36. {field: 'logintime', title: __('Logintime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
  37. {field: 'loginip', title: __('Loginip'), formatter: Table.api.formatter.search},
  38. {field: 'jointime', title: __('Jointime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
  39. {field: 'joinip', title: __('Joinip'), formatter: Table.api.formatter.search},
  40. {field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: {normal: __('Normal'), hidden: __('Hidden')}},
  41. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  42. ]
  43. ]
  44. });
  45. // 为表格绑定事件
  46. Table.api.bindevent(table);
  47. },
  48. add: function () {
  49. Controller.api.bindevent();
  50. },
  51. edit: function () {
  52. Controller.api.bindevent();
  53. },
  54. api: {
  55. bindevent: function () {
  56. Form.api.bindevent($("form[role=form]"));
  57. }
  58. }
  59. };
  60. return Controller;
  61. });