consume_putout.js 4.6 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", ["720px", "520px"]);
  5. // 初始化表格参数配置
  6. Table.api.init({
  7. extend: {
  8. index_url: 'consume_putout/index' + location.search,
  9. add_url: 'consume_putout/add',
  10. edit_url: 'consume_putout/edit',
  11. del_url: 'consume_putout/del',
  12. multi_url: 'consume_putout/multi',
  13. import_url: 'consume_putout/import',
  14. table: 'consume_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: 'number', title: __('出库编号')},
  28. {field: 'durg_archives_id_text', title: __('耗材名称')},
  29. {field: 'unit_id_text', title: __('单位'), operate: 'LIKE'},
  30. {field: 'store_house_text', title: __('库房'), operate: 'LIKE'},
  31. {field: 'durg_brand', title: __('品牌'), operate: 'LIKE'},
  32. {field: 'manufacturer', title: __('生产厂商'), operate: 'LIKE'},
  33. {field: 'specifications', title: __('规格'), operate: 'LIKE'},
  34. {field: 'put_out', title: __('Put_out')},
  35. {field: 'place', title: __('Place'), operate: 'LIKE'},
  36. {field: 'purpose', title: __('Purpose'), operate: 'LIKE'},
  37. {field: 'admin_id_text', title: __('Admin_id')},
  38. {field: 'put_time', title: __('Put_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  39. ]
  40. ]
  41. });
  42. // 为表格绑定事件
  43. Table.api.bindevent(table);
  44. table.on('post-body.bs.table', function () {
  45. $(".btn-editone").data("area", ["720px", "520px"]);
  46. })
  47. },
  48. add: function () {
  49. $("#c-receive_id").data("params", function (obj) {
  50. // console.log($(this).attr('id'))
  51. var unit_id = $('#J_unitselect').val();
  52. return {"custom[unit_id][0]":"in","custom[unit_id][1]":unit_id};
  53. });
  54. Controller.api.bindevent();
  55. Controller.api.events.getAmount();
  56. $("#c-durg_archives_id").on('change',function(){
  57. Controller.api.events.getAmount();
  58. });
  59. $("#c-put_out").on('change',function(){
  60. var max = $(this).data('max');
  61. if($(this).val()>max){
  62. Toastr.error("出库数量不能大于库存数量");
  63. $(this).val(max);
  64. }
  65. });
  66. $("#c-put_out").on('keyup',function(){
  67. var max = $(this).data('max');
  68. if($(this).val()>max){
  69. Toastr.error("出库数量不能大于库存数量");
  70. $(this).val(max);
  71. }
  72. });
  73. $("#c-durg_archives_id").data("eSelect", function(){
  74. $.get('consume_putout/huoq',{id:$("#c-durg_archives_id").val()},function(res){
  75. $('#durg_brand').val(res.data.durg_brand);
  76. $('#manufacturer').val(res.data.manufacturer);
  77. $('#specifications').val(res.data.specifications);
  78. $('#product_introduction').val(res.data.product_introduction);
  79. $('#unit_id').val(res.data.unit_id);
  80. $('#store_house').val(res.data.store_house);
  81. //console.log($("#c-durg_archives_id").val());
  82. });
  83. //后续操作
  84. });
  85. },
  86. edit: function () {
  87. Controller.api.bindevent();
  88. },
  89. api: {
  90. bindevent: function () {
  91. Form.api.bindevent($("form[role=form]"));
  92. },
  93. events: {
  94. getAmount:function(){
  95. $.get('consume_putout/getAmount',{durg_id:$("#c-durg_archives_id").val()},function(res){
  96. if($('#c-put_out').val() > res.data)$('#c-put_out').val(res.data);
  97. $('#c-put_out').data('max',res.data);
  98. });
  99. }
  100. }
  101. }
  102. };
  103. return Controller;
  104. });