info.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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: 'teacher/info/index',
  8. add_url: 'teacher/info/add',
  9. edit_url: 'teacher/info/edit',
  10. del_url: 'teacher/info/del',
  11. // multi_url: 'auth/admin/multi',
  12. }
  13. });
  14. var table = $("#table");
  15. //在表格内容渲染完成后回调的事件
  16. table.on('post-body.bs.table', function (e, json) {
  17. $("tbody tr[data-index]", this).each(function () {
  18. if (parseInt($("td:eq(1)", this).text()) == Config.admin.id) {
  19. $("input[type=checkbox]", this).prop("disabled", true);
  20. }
  21. });
  22. });
  23. // 初始化表格
  24. table.bootstrapTable({
  25. url: $.fn.bootstrapTable.defaults.extend.index_url,
  26. searchFormVisible:true,
  27. search:false,
  28. showExport:false,
  29. showToggle:false,
  30. showColumns: false,
  31. columns: [
  32. [
  33. {field: 'state', checkbox: true, },
  34. // {field: 'id', title: '编号'},
  35. {field: 'username', title: __('Username'),operate: 'like'},
  36. {field: 'nickname', title: __('Nickname'),operate: 'like'},
  37. // {field: 'groups_text', title: __('Group'), operate:false, formatter: Table.api.formatter.label},
  38. // {field: 'email', title: __('Email')},
  39. {field: 'mobile', title: __('Mobile'),operate: 'like'},
  40. {field: 'status', title: __("Status"), searchList: {"normal":__('Normal'),"hidden":__('Hidden')}, formatter: Table.api.formatter.status},
  41. {field: 'createtime', title: __('Create time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
  42. {
  43. field: 'operate', title: __('Operate'), table: table,
  44. formatter: Table.api.formatter.buttons,
  45. buttons: [
  46. {
  47. name: 'dispatch',
  48. text: '编辑',
  49. icon: 'fa fa-pencil',
  50. title: '编辑',
  51. classname: 'btn btn-success btn-xs btn-magic btn-dialog',
  52. url: 'teacher/info/edit',
  53. },
  54. // {
  55. // name: 'dispatch',
  56. // text: '删除',
  57. // icon: 'fa fa-trash',
  58. // title: '删除',
  59. // classname: 'btn btn-danger btn-xs btn-magic btn-ajax',
  60. // url: 'teacher/info/del',
  61. // confirm: '确定要删除吗?',
  62. // success: function (data, ret) {
  63. // $(".btn-refresh").trigger("click");
  64. // },
  65. // error: function (data, ret) {
  66. // Layer.alert(ret.msg);
  67. // return false;
  68. // }
  69. // }
  70. ],
  71. // events: Table.api.events.operate,
  72. // formatter: function (value, row, index) {
  73. // if(row.id == Config.admin.id){
  74. // return '';
  75. // }
  76. // return Table.api.formatter.operate.call(this, value, row, index);
  77. // }}
  78. }
  79. ]
  80. ]
  81. });
  82. // 为表格绑定事件
  83. Table.api.bindevent(table);
  84. },
  85. add: function () {
  86. Form.api.bindevent($("form[role=form]"));
  87. },
  88. edit: function () {
  89. Form.api.bindevent($("form[role=form]"));
  90. }
  91. };
  92. return Controller;
  93. });