daily_training_registration.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. $(".btn-add").data("area",["1000px","480px"]);
  6. Table.api.init({
  7. extend: {
  8. index_url: 'daily_training_registration/index' + location.search,
  9. add_url: 'daily_training_registration/add',
  10. edit_url: 'daily_training_registration/edit',
  11. del_url: 'daily_training_registration/del',
  12. multi_url: 'daily_training_registration/multi',
  13. import_url: 'daily_training_registration/import',
  14. table: 'daily_training_registration',
  15. }
  16. });
  17. var table = $("#table");
  18. // 初始化表格
  19. table.bootstrapTable({
  20. url: $.fn.bootstrapTable.defaults.extend.index_url,
  21. pk: 'id',
  22. sortName: 'id',
  23. columns: [
  24. [
  25. {checkbox: true},
  26. {field: 'order_number', title: __('Id')},
  27. {field: 'test_name', title: __('Test_name'), operate: 'LIKE'},
  28. {field: 'leader_name', title: __('Leader_name'), operate: 'LIKE'},
  29. {field: 'drill_id_text', title: '训练类别', operate: 'LIKE'},
  30. {field: 'subjects', title: __('Subjects'), operate: 'LIKE'},
  31. {field: 'organization_name', title: __('Organization_name'), operate: 'LIKE'},
  32. {field: 'enter_count', title: __('Enter_count')},
  33. {field: 'drill_duration', title: __('Drill_duration')},
  34. {field: 'drill_time', title: __('Drill_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  35. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  36. ]
  37. ]
  38. });
  39. // 为表格绑定事件
  40. Table.api.bindevent(table);
  41. table.on('post-body.bs.table',function(){
  42. $(".btn-editone").data("area",["1000px","480px"]);
  43. })
  44. },
  45. add: function () {
  46. Controller.api.bindevent();
  47. Controller.api.events.getpeople();
  48. $("#c-test_id").on('change',function(){
  49. Controller.api.events.getpeople();
  50. });
  51. $("#c-enter_count").on('change',function(){
  52. var max = $(this).data('max');
  53. if($(this).val()>max){
  54. Toastr.error("该数量不能大于单位总人数");
  55. $(this).val(max);
  56. }
  57. });
  58. $("#c-enter_count").on('keyup',function(){
  59. var max = $(this).data('max');
  60. if($(this).val()>max){
  61. Toastr.error("该数量不能大于单位总人数");
  62. $(this).val(max);
  63. }
  64. });
  65. },
  66. edit: function () {
  67. Controller.api.bindevent();
  68. Controller.api.events.getpeople();
  69. $("#c-test_id").on('change',function(){
  70. Controller.api.events.getpeople();
  71. });
  72. $("#c-enter_count").on('change',function(){
  73. var max = $(this).data('max');
  74. if($(this).val()>max){
  75. Toastr.error("该数量不能大于单位总人数");
  76. $(this).val(max);
  77. }
  78. });
  79. $("#c-enter_count").on('keyup',function(){
  80. var max = $(this).data('max');
  81. if($(this).val()>max){
  82. Toastr.error("该数量不能大于单位总人数");
  83. $(this).val(max);
  84. }
  85. });
  86. },
  87. api: {
  88. bindevent: function () {
  89. Form.api.bindevent($("form[role=form]"));
  90. },
  91. events: {
  92. getpeople:function(){
  93. $.get('daily_training_registration/huoq',{unit_id:$("#c-test_id").val()},function(res){
  94. if($('#c-enter_count').val() > res.data)$('#c-enter_count').val(res.data);
  95. $('#c-enter_count').data('max',res.data);
  96. });
  97. }
  98. }
  99. }
  100. };
  101. return Controller;
  102. });