antiepidemic_putout.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. $(".btn-add").data("area", ["730px", "420px"]);
  5. // 初始化表格参数配置
  6. Table.api.init({
  7. extend: {
  8. index_url: 'antiepidemic_putout/index' + location.search,
  9. add_url: 'antiepidemic_putout/add',
  10. edit_url: 'antiepidemic_putout/edit',
  11. del_url: 'antiepidemic_putout/del',
  12. multi_url: 'antiepidemic_putout/multi',
  13. import_url: 'antiepidemic_putout/import',
  14. table: 'antiepidemic_putout',
  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: 'durg_archives_id_text', title: __('防疫品名称')},
  28. {field: 'unit_id1_text', title: __('单位')},
  29. {field: 'store_house_text', title: __('库房')},
  30. {field: 'durg_brand', title: __('Durg_brand'), operate: 'LIKE'},
  31. {field: 'specifications', title: __('Specifications'), operate: 'LIKE'},
  32. {field: 'put_out', title: __('Put_out')},
  33. {field: 'place', title: __('所在位置'), operate: 'LIKE'},
  34. {field: 'put_time', title: __('发放时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  35. //{field: 'people_id_text', title: __('Receive_id')},
  36. {field: 'admin_id_text', title: __('Admin_id')},
  37. {field: 'createtime', title: __('Createtime'), operate: 'LIKE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  38. //{field: 'updatetime', title: __('Updatetime'), operate: 'LIKE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  39. // {field: 'remark', title: __('Remark'), operate: 'LIKE'},
  40. ]
  41. ]
  42. });
  43. // 为表格绑定事件
  44. Table.api.bindevent(table);
  45. },
  46. add: function () {
  47. Controller.api.bindevent();
  48. Controller.api.events.getAmount();
  49. $("#c-durg_archives_id").on('change',function(){
  50. Controller.api.events.getAmount();
  51. });
  52. $("#c-put_out").on('change',function(){
  53. var max = $(this).data('max');
  54. if($(this).val()>max){
  55. Toastr.error("出库数量不能大于库存数量");
  56. $(this).val(max);
  57. }
  58. });
  59. $("#c-put_out").on('keyup',function(){
  60. var max = $(this).data('max');
  61. if($(this).val()>max){
  62. Toastr.error("出库数量不能大于库存数量");
  63. $(this).val(max);
  64. }
  65. });
  66. $("#c-people_id").data("params", function (obj) {
  67. var unit_id = $('#J_unitselect').val();
  68. return {"custom[unit_id][0]":"find_in_set","custom[unit_id][1]":unit_id};
  69. // return {custom: {unit_id: $("#J_unitselect").val()}};
  70. });
  71. $("#c-durg_archives_id").data("eSelect", function(){
  72. $.get('antiepidemic_putout/huoq',{id:$("#c-durg_archives_id").val()},function(res){
  73. $('#c-durg_brand').val(res.data.durg_brand);
  74. $('#c-specifications').val(res.data.specifications);
  75. $('#c-store_house').val(res.data.store_house);
  76. $('#c-unit_id1').val(res.data.unit_id);
  77. //console.log($("#c-durg_archives_id").val());
  78. });
  79. //后续操作
  80. });
  81. },
  82. edit: function () {
  83. Controller.api.events.getAmount();
  84. $("#c-durg_archives_id").on('change',function(){
  85. Controller.api.events.getAmount();
  86. });
  87. $("#c-put_out").on('change',function(){
  88. var max = $(this).data('max');
  89. if($(this).val()>max){
  90. Toastr.error("出库数量不能大于库存数量");
  91. $(this).val(max);
  92. }
  93. });
  94. $("#c-put_out").on('keyup',function(){
  95. var max = $(this).data('max');
  96. if($(this).val()>max){
  97. Toastr.error("出库数量不能大于库存数量");
  98. $(this).val(max);
  99. }
  100. });
  101. $("#c-people_id").data("params", function (obj) {
  102. var unit_id = $('#J_unitselect').val();
  103. return {"custom[unit_id][0]":"find_in_set","custom[unit_id][1]":unit_id};
  104. // return {custom: {unit_id: $("#J_unitselect").val()}};
  105. });
  106. Controller.api.bindevent();
  107. },
  108. api: {
  109. bindevent: function () {
  110. Form.api.bindevent($("form[role=form]"));
  111. },
  112. events: {
  113. getAmount:function(){
  114. $.get('antiepidemic_putout/getAmount',{durg_id:$("#c-durg_archives_id").val()},function(res){
  115. if($('#c-put_out').val() > res.data)$('#c-put_out').val(res.data);
  116. $('#c-put_out').data('max',res.data);
  117. });
  118. }
  119. }
  120. }
  121. };
  122. return Controller;
  123. });