userstudent.js 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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: 'userstudent/index' + location.search,
  8. add_url: 'userstudent/add',
  9. edit_url: 'userstudent/edit',
  10. del_url: 'userstudent/del',
  11. multi_url: 'userstudent/multi',
  12. import_url: 'userstudent/import',
  13. table: 'user_student',
  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: 'user_id', title: __('User_id')},
  29. {field: 'user.username', title: __('User.username'), operate: 'LIKE'},
  30. {field: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'},
  31. {field: 'realname', title: __('Realname'), operate: 'LIKE'},
  32. {field: 'gender', title: __('Gender'), searchList: {"1":__('Gender 1'),"0":__('Gender 0')}, formatter: Table.api.formatter.normal},
  33. {field: 'age', title: __('Age')},
  34. // {field: 'school_id', title: __('School_id')},
  35. {field: 'school.schoolname', title: __('School.schoolname'), operate: 'LIKE'},
  36. // {field: 'grade_id', title: __('Grade_id')},
  37. {field: 'grade.gradename', title: __('Grade.gradename'), operate: 'LIKE'},
  38. // {field: 'classes_id', title: __('Classes_id')},
  39. {field: 'classes.classname', title: __('Classes.classname'), operate: 'LIKE'},
  40. {field: 'idcard', title: __('Idcard'), operate: 'LIKE'},
  41. // {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
  42. {field: 'stu_mobile', title: __('Stu_mobile'), operate: 'LIKE'},
  43. {field: 'is_default', title: __('Is_default'), searchList: {"1":__('Is_default 1'),"0":__('Is_default 0')}, formatter: Table.api.formatter.normal},
  44. {field: 'remark', title: __('Remark'), operate: 'LIKE'},
  45. // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  46. ]
  47. ]
  48. });
  49. // 为表格绑定事件
  50. Table.api.bindevent(table);
  51. },
  52. add: function () {
  53. Controller.api.bindevent();
  54. },
  55. edit: function () {
  56. Controller.api.bindevent();
  57. },
  58. api: {
  59. bindevent: function () {
  60. Form.api.bindevent($("form[role=form]"));
  61. }
  62. }
  63. };
  64. return Controller;
  65. });
  66. $("#c-grade_id").data("params", function (obj) {
  67. return {
  68. custom: {school_id: $("#c-school_id").val()}
  69. };
  70. });
  71. $("#c-classes_id").data("params", function (obj) {
  72. return {
  73. custom: {grade_id: $("#c-grade_id").val()}
  74. };
  75. });
  76. $(document).on("change","#c-school_id",function(){
  77. $("#c-grade_id").selectPageClear();
  78. $("#c-classes_id").selectPageClear();
  79. })
  80. $(document).on("change","#c-grade_id",function(){
  81. $("#c-classes_id").selectPageClear();
  82. })