room_signup.js 3.8 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: 'exam/room_signup/index' + location.search,
  8. add_url: 'exam/room_signup/add',
  9. edit_url: 'exam/room_signup/edit',
  10. del_url: 'exam/room_signup/del',
  11. multi_url: 'exam/room_signup/multi',
  12. import_url: 'exam/room_signup/import',
  13. table: 'exam_room_signup',
  14. }
  15. });
  16. var table = $("#table");
  17. // 在普通搜索渲染后
  18. table.on('post-common-search.bs.table', function (event, table) {
  19. let form = $("form", table.$commonsearch);
  20. $("input[name='user_id']", form).addClass("selectpage").data("source", "user/user/index").data("field", "nickname").data("orderBy", "id desc");
  21. $("input[name='room_id']", form).addClass("selectpage").data("source", "exam/room/index").data("orderBy", "id desc");
  22. Form.events.cxselect(form);
  23. Form.events.selectpage(form);
  24. });
  25. // 初始化表格
  26. table.bootstrapTable({
  27. url: $.fn.bootstrapTable.defaults.extend.index_url,
  28. pk: 'id',
  29. sortName: 'id',
  30. columns: [
  31. [
  32. {
  33. checkbox: true,
  34. formatter:function(value, row, index){
  35. if (row.status != 0) {
  36. console.log('checkbox', value, row, index, row.status, )
  37. return {
  38. disabled : true,
  39. }
  40. }
  41. }
  42. },
  43. {field: 'id', title: __('Id')},
  44. {field: 'room_id', title: __('Room_id'), visible: false},
  45. {field: 'room.name', title: __('Room.name'), operate: false},
  46. {field: 'user_id', title: __('User_id'), visible: false},
  47. {field: 'user.nickname', title: __('报名人昵称'), operate: false},
  48. {field: 'real_name', title: __('Real_name'), operate: 'LIKE'},
  49. {field: 'phone', title: __('Phone'), operate: 'LIKE'},
  50. {field: 'message', title: __('Message'), operate: false},
  51. {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
  52. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  53. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  54. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  55. ]
  56. ]
  57. });
  58. // 为表格绑定事件
  59. Table.api.bindevent(table);
  60. },
  61. add: function () {
  62. Controller.api.bindevent();
  63. },
  64. edit: function () {
  65. Controller.api.bindevent();
  66. },
  67. api: {
  68. bindevent: function () {
  69. Form.api.bindevent($("form[role=form]"));
  70. }
  71. }
  72. };
  73. return Controller;
  74. });