user.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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: 'username', title: __('Username'), operate: 'LIKE'},
  30. {field: 'nickname', title: __('Nickname'), operate: 'LIKE'},
  31. {field: 'password', title: __('Password'), operate: 'LIKE'},
  32. {field: 'salt', title: __('Salt'), operate: 'LIKE'},
  33. {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
  34. {field: 'avatar', title: __('Avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
  35. {field: 'gender', title: __('Gender'), searchList: {"1":__('Gender 1'),"0":__('Gender 0')}, formatter: Table.api.formatter.normal},
  36. {field: 'birthday', title: __('Birthday')},
  37. {field: 'bio', title: __('Bio'), operate: 'LIKE'},
  38. {field: 'successions', title: __('Successions')},
  39. {field: 'maxsuccessions', title: __('Maxsuccessions')},
  40. {field: 'prevtime', title: __('Prevtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  41. {field: 'logintime', title: __('Logintime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  42. {field: 'loginip', title: __('Loginip'), operate: 'LIKE'},
  43. {field: 'loginfailure', title: __('Loginfailure')},
  44. {field: 'joinip', title: __('Joinip'), operate: 'LIKE'},
  45. {field: 'jointime', title: __('Jointime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  46. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  47. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  48. {field: 'token', title: __('Token'), operate: 'LIKE'},
  49. {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"0":__('Status 0'),"-1":__('Status -1')}, formatter: Table.api.formatter.status},
  50. {field: 'idcard_status', title: __('Idcard_status'), searchList: {"-1":__('Idcard_status -1'),"0":__('Idcard_status 0'),"1":__('Idcard_status 1'),"2":__('Idcard_status 2'),"3":__('Idcard_status 3')}, formatter: Table.api.formatter.status},
  51. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  52. ]
  53. ]
  54. });
  55. // 为表格绑定事件
  56. Table.api.bindevent(table);
  57. },
  58. add: function () {
  59. Controller.api.bindevent();
  60. },
  61. edit: function () {
  62. Controller.api.bindevent();
  63. },
  64. api: {
  65. bindevent: function () {
  66. Form.api.bindevent($("form[role=form]"));
  67. }
  68. }
  69. };
  70. return Controller;
  71. });