admin.js 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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: 'auth/admin/index',
  8. add_url: 'auth/admin/add',
  9. edit_url: 'auth/admin/edit',
  10. del_url: 'auth/admin/del',
  11. multi_url: 'auth/admin/multi',
  12. },
  13. showToggle: false,
  14. showColumns: false,
  15. visible: false,
  16. commonSearch: false,
  17. showExport: false
  18. });
  19. var table = $("#table");
  20. // 初始化表格
  21. if(Config.admin.id==1){
  22. table.bootstrapTable({
  23. url: $.fn.bootstrapTable.defaults.extend.index_url,
  24. columns: [
  25. [
  26. {field: 'state', checkbox: true, },
  27. {field: 'id', title: 'ID'},
  28. {field: 'username', title: __('Username')},
  29. {field: 'nickname', title: __('Nickname')},
  30. {field: 'groups_text', title: __('Group'), operate:false, formatter: Table.api.formatter.label},
  31. {field: 'email', title: __('Email')},
  32. {field: 'mobile', title: __('Mobile')},
  33. {field: 'status', title: __("Status"), formatter: Table.api.formatter.status},
  34. {field: 'logintime', title: __('Login time'), formatter: Table.api.formatter.datetime},
  35. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: function (value, row, index) {
  36. if(row.id == Config.admin.id){
  37. return '';
  38. }
  39. return Table.api.formatter.operate.call(this, value, row, index);
  40. }}
  41. ]
  42. ]
  43. });
  44. }else{
  45. table.bootstrapTable({
  46. url: $.fn.bootstrapTable.defaults.extend.index_url,
  47. columns: [
  48. [
  49. {field: 'state', checkbox: true, },
  50. {field: 'id', title: 'ID'},
  51. {field: 'username', title: __('Username')},
  52. {field: 'nickname', title: __('Nickname')},
  53. {field: 'groups_text', title: __('Group'), operate:false, formatter: Table.api.formatter.label},
  54. {field: 'email', title: __('Email')},
  55. {field: 'mobile', title: __('Mobile')},
  56. {field: 'status', title: __("Status"), formatter: Table.api.formatter.status},
  57. {field: 'logintime', title: __('Login time'), formatter: Table.api.formatter.datetime}
  58. ]
  59. ]
  60. });
  61. }
  62. // 为表格绑定事件
  63. Table.api.bindevent(table);
  64. },
  65. add: function () {
  66. Form.api.bindevent($("form[role=form]"));
  67. },
  68. edit: function () {
  69. Form.api.bindevent($("form[role=form]"));
  70. }
  71. };
  72. return Controller;
  73. });