daily_education.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. $(".btn-add").data("area",["1024px","600px"]);
  5. // 初始化表格参数配置
  6. Table.api.init({
  7. extend: {
  8. index_url: 'daily_education/index' + location.search,
  9. add_url: 'daily_education/add',
  10. edit_url: 'daily_education/edit',
  11. del_url: 'daily_education/del',
  12. multi_url: 'daily_education/multi',
  13. import_url: 'daily_education/import',
  14. table: 'daily_education',
  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: __('序号')},
  27. {field: 'test_name', title: __('Test_name'), operate: 'LIKE'},
  28. {field: 'test_name1', title: __('Test_name1'), operate: 'LIKE'},
  29. {field: 'should_be_to', title: '应到', operate: 'LIKE'},
  30. {field: 'actual_arrival', title: '实到', operate: 'LIKE'},
  31. {field: 'people_name', title: '主持人', operate: 'LIKE'},
  32. {field: 'topic', title: '教育题目', operate: 'LIKE'},
  33. {field: 'education_id_text', title: '教育类别', operate: 'LIKE'},
  34. {field: 'address', title: '地点', operate: 'LIKE'},
  35. {field: 'time', title: __('Time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  36. {field: 'people_name1', title: __('People_name1'), operate: 'LIKE'},
  37. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  38. ]
  39. ]
  40. });
  41. // 为表格绑定事件
  42. Table.api.bindevent(table);
  43. table.on('post-body.bs.table',function(){
  44. $(".btn-editone").data("area",["1024px","600px"]);
  45. })
  46. },
  47. add: function () {
  48. Controller.api.bindevent();
  49. Controller.api.events.getpeople();
  50. $("#c-test_id").on('change',function(){
  51. Controller.api.events.getpeople();
  52. });
  53. $("#c-actual_arrival").on('change',function(){
  54. var max = $('#c-should_be_to').data('max');
  55. if($(this).val()>max){
  56. Toastr.error("该数量不能大于单位总人数");
  57. $(this).val(max);
  58. }
  59. });
  60. $("#c-actual_arrival").on('keyup',function(){
  61. var max = $('#c-should_be_to').data('max');
  62. if($(this).val()>max){
  63. Toastr.error("该数量不能大于单位总人数");
  64. $(this).val(max);
  65. }
  66. });
  67. },
  68. edit: function () {
  69. Controller.api.bindevent();
  70. Controller.api.events.getpeople();
  71. $("#c-test_id").on('change',function(){
  72. Controller.api.events.getpeople();
  73. });
  74. $("#c-actual_arrival").on('change',function(){
  75. var max = $('#c-should_be_to').data('max');
  76. if($(this).val()>max){
  77. Toastr.error("该数量不能大于单位总人数");
  78. $(this).val(max);
  79. }
  80. });
  81. $("#c-actual_arrival").on('keyup',function(){
  82. var max = $('#c-should_be_to').data('max');
  83. if($(this).val()>max){
  84. Toastr.error("该数量不能大于单位总人数");
  85. $(this).val(max);
  86. }
  87. });
  88. },
  89. api: {
  90. bindevent: function () {
  91. Form.api.bindevent($("form[role=form]"));
  92. },
  93. events: {
  94. getpeople:function(){
  95. $.get('daily_education/huoq',{unit_id:$("#c-test_id").val()},function(res){
  96. $('#c-should_be_to').val(res.data);
  97. $('#c-should_be_to').data('max',res.data);
  98. });
  99. }
  100. }
  101. }
  102. };
  103. return Controller;
  104. });