user.js 4.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. searchFormVisible: true,
  22. fixedColumns: true,
  23. fixedRightNumber: 2,
  24. columns: [
  25. [
  26. {checkbox: true},
  27. {field: 'id', title: __('Id'), sortable: true},
  28. // {field: 'group.name', title: __('Group')},
  29. // {field: 'username', title: __('Username'), operate: 'LIKE'},
  30. {field: 'nickname', title: __('Nickname'), operate: 'LIKE'},
  31. // {field: 'email', title: __('Email'), operate: 'LIKE'},
  32. {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
  33. {field: 'avatar', title: __('Avatar'), events: Table.api.events.image, formatter: Table.api.formatter.image, operate: false},
  34. // {field: 'level', title: __('Level'), operate: 'BETWEEN', sortable: true},
  35. // {field: 'gender', title: __('Gender'), visible: false, searchList: {1: __('Male'), 0: __('Female')}},
  36. // {field: 'score', title: __('Score'), operate: 'BETWEEN', sortable: true},
  37. // {field: 'money', title: __('余额'), operate: false},
  38. {field: 'successions', title: __('Successions'), visible: false, operate: 'BETWEEN', sortable: true},
  39. {field: 'maxsuccessions', title: __('Maxsuccessions'), visible: false, operate: 'BETWEEN', sortable: true},
  40. {field: 'logintime', title: __('Logintime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
  41. {field: 'loginip', title: __('Loginip'), formatter: Table.api.formatter.search},
  42. {field: 'jointime', title: __('Jointime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
  43. {field: 'joinip', title: __('Joinip'), formatter: Table.api.formatter.search},
  44. {field: 'realname', title: __('真实姓名'), operate: 'LIKE'},
  45. // {field: 'idcard', title: __('身份证号'), operate: 'LIKE'},
  46. // {field: 'gender', title: __('Gender'), searchList: {1: __('男'), 2: __('女')}, formatter: Table.api.formatter.status,
  47. // custom: {1:'success', "2": 'info'}
  48. // },
  49. {field: 'birthday', title: __('生日'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
  50. /*{field: 'experiencelevel', title: __('体验会员ID')},
  51. {field: 'experiencetime', title: __('体验会员到期时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
  52. {field: 'maxlevel', title: __('实际有效会员ID')},
  53. {field: 'freenumber', title: __('会员免费参加活动次数')},*/
  54. // {field: 'is_auth', title: __('实名认证状态'), formatter: Table.api.formatter.status, searchList: {"1":'待审核',"2":'通过','3':'拒绝'},
  55. // custom: {2:'success',3:'danger'}},
  56. {field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: {"1":__('Status 1'),"2":__('Status 2')},
  57. custom: {1:'success',2:'danger'}},
  58. // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  59. ]
  60. ]
  61. });
  62. // 为表格绑定事件
  63. Table.api.bindevent(table);
  64. },
  65. add: function () {
  66. Controller.api.bindevent();
  67. },
  68. edit: function () {
  69. Controller.api.bindevent();
  70. },
  71. api: {
  72. bindevent: function () {
  73. Form.api.bindevent($("form[role=form]"));
  74. }
  75. }
  76. };
  77. return Controller;
  78. });