picking.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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: 'picking/index' + location.search,
  8. add_url: 'picking/add',
  9. edit_url: 'picking/edit',
  10. del_url: 'picking/del',
  11. multi_url: 'picking/multi',
  12. table: 'picking',
  13. }
  14. });
  15. var table = $("#table");
  16. // 初始化表格
  17. table.bootstrapTable({
  18. url: $.fn.bootstrapTable.defaults.extend.index_url,
  19. pk: 'id',
  20. sortName: 'id',
  21. columns: [
  22. [
  23. {checkbox: true},
  24. {field: 'id', title: __('Id')},
  25. {field: 'picking', title: __('领料单编码')},
  26. {field: 'order', title: __('工单编号')},
  27. {field: 'matter', title: __('原墨名称')},
  28. {field: 'code', title: __('存货编码')},
  29. {field: 'weight', title: __('重量(kg)')},
  30. {field: 'create', title: __('创建时间')},
  31. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  32. ]
  33. ],
  34. showToggle:false,
  35. showColumns:false,
  36. showExport:false,
  37. // search: false,
  38. commonSearch: false,
  39. //可以控制是否默认显示搜索单表,false则隐藏,默认为false
  40. searchFormVisible: false,
  41. });
  42. // 为表格绑定事件
  43. Table.api.bindevent(table);
  44. },
  45. add: function () {
  46. Controller.api.bindevent();
  47. },
  48. edit: function () {
  49. Controller.api.bindevent();
  50. },
  51. order: function () {
  52. // 初始化表格参数配置
  53. Table.api.init({
  54. extend: {
  55. index_url: 'picking/order' + location.search,
  56. add_url: 'picking/add',
  57. table: 'picking',
  58. }
  59. });
  60. var table = $("#table");
  61. var calcTableHeight = function () {
  62. return Math.max(300, $(window).height() - table.offset().top - 30);
  63. };
  64. // 初始化表格
  65. table.bootstrapTable({
  66. url: $.fn.bootstrapTable.defaults.extend.index_url,
  67. pk: 'id',
  68. sortName: 'Gy0_sbbh',
  69. height: calcTableHeight(),
  70. columns: [
  71. [
  72. {checkbox: true,},
  73. {field: 'Gd_gdbh', title: __('工单编号'),},
  74. {field: 'Gd_cpmc', title: __('产品名称'),operate:false},
  75. {field: 'gd_statu', title: __('工单状态'),operate:false},
  76. {field: 'Gy0_sbbh', title: __('机台')},
  77. {field: 'Gy0_sj1', title: __('生产时间安排(开始)'),operate:false},
  78. {field: 'Gy0_sj2', title: __('生产时间安排(结束)'),operate:false},
  79. // {field: 'operate', title: __('操作'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  80. ]
  81. ],
  82. showToggle:false,
  83. showColumns:false,
  84. showExport:false,
  85. // search: false,
  86. // commonSearch: false,
  87. //可以控制是否默认显示搜索单表,false则隐藏,默认为false
  88. // searchFormVisible: false,
  89. pageSize: 50,
  90. });
  91. $(window).on('resize', function () {
  92. table.bootstrapTable('resetView', {height: calcTableHeight()});
  93. });
  94. table.on('load-success.bs.table', function () {
  95. table.bootstrapTable('resetView', {height: calcTableHeight()});
  96. });
  97. var openPickingDialog = function (ids) {
  98. Fast.api.ajax({
  99. url: 'picking/checkPicking',
  100. data: {temp: ids}
  101. }, function () {
  102. Fast.config.openArea = ['100%', '100%'];
  103. Fast.api.open("Picking/picking?temp=" + ids, "生成领料单", {});
  104. });
  105. };
  106. $("#button").on("click",function(){
  107. var temp=table.bootstrapTable('getSelections');
  108. var ids = '';
  109. for (i=0;i<temp.length;i++){
  110. ids += temp[i].id+',';
  111. }
  112. if (ids == ''){
  113. Toastr.error('请先选择要生成领料单的工单');
  114. return false;
  115. }
  116. openPickingDialog(ids);
  117. });
  118. $("#urgent").on("click",function () {
  119. var html = '';
  120. html+= '<div className="form-group" style="margin-left: 15px;margin-top: 15px;">';
  121. html+= '<label className="control-label col-xs-12 col-sm-2">请输入工单号(多个工单请用英文逗号隔开):</label>';
  122. html+= '<div className="col-xs-12 col-sm-8"><input className="form-control" id="order" name="" type="text" value="" data-rule="number" style="width: 350px"> </div>';
  123. html+= '<div class="form-group layer-footer" style="margin: 50px 0 0 50px"><button type="submit" class="btn btn-success btn-embossed sure" style="margin-left: 90px;">确定</button></div>';
  124. html+= '</div>';
  125. layer.open({
  126. type: 1,
  127. skin: 'layui-layer-rim', //加上边框
  128. area: ['420px', '240px'], //宽高
  129. content: html
  130. })
  131. })
  132. $(document).on('click','.sure',function (){
  133. var order = document.getElementById('order').value;
  134. if (order == ''){
  135. return false;
  136. }
  137. layer.close(layer.index);
  138. openPickingDialog(order);
  139. })
  140. // 为表格绑定事件
  141. Table.api.bindevent(table);
  142. },
  143. api: {
  144. bindevent: function () {
  145. Form.api.bindevent($("form[role=form]"));
  146. }
  147. }
  148. };
  149. return Controller;
  150. });