CheckCtrl.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. define(['app/app','common/services','service/Purc','service/SupportServices' ], function(app) {
  2. app.register.controller('CheckCtrl',['$scope', '$http', '$stateParams', '$rootScope','$filter','$location', 'ngTableParams','toaster', 'Ring', 'SupportUtil','CheckOper', 'Online','$modal','SessionService',function($scope, $http, $stateParams, $rootScope,$filter,$location, ngTableParams,toaster, Ring, SupportUtil,CheckOper, Online,$modal,SessionService){
  3. $scope.grid = [];
  4. $scope.whcode = SessionService.getCookie('defaultWhcode');
  5. $scope.tableParams = new ngTableParams({//已经采集完成的列表
  6. page: 1,
  7. count: 10,
  8. filter: { },
  9. sorting: { }
  10. }, {
  11. total: $scope.grid.length,
  12. getData: function ($defer, params) {
  13. var filteredData = params.filter() ?
  14. $filter('filter')($scope.grid, params.filter()) :
  15. data;
  16. var orderedData = params.sorting() ?
  17. $filter('orderBy')(filteredData, params.orderBy()) :
  18. data;
  19. params.total(orderedData.length); // set total for recalc pagination
  20. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  21. }
  22. });
  23. $scope.search = function (event){
  24. if(event.keyCode == 13 && $scope.prodcode && $scope.whcode){
  25. $scope.checkMM($scope.prodcode);
  26. }else if(event.keyCode == 13 && $scope.prodcode && !$scope.whcode){
  27. document.getElementById("whcode").focus();
  28. }else if(event.keyCode == 13){
  29. document.getElementById("prodcode").focus();
  30. }
  31. }
  32. $scope.checkMM = function(prodcode,whcode){
  33. if(prodcode){//列出该prodcode的barcode信息根据仓库、储位分组汇总结果
  34. CheckOper.checkMM({pr_code:prodcode,wh_code:whcode},{},function(data){
  35. if(data.exceptionInfo){
  36. toaster.pop('error', '查询失败',data.exceptionInfo);
  37. Ring.error();
  38. }else{
  39. $scope.grid = data.target;
  40. $scope.tableParams.reload();
  41. $scope.pr_detail = $scope.grid[0]['pr_detail'];
  42. $scope.pr_spec = $scope.grid[0]['pr_spec'];
  43. }
  44. //$scope.prodcode = '';
  45. //document.get = ElementById("prodcode").focus();
  46. },function(res){
  47. Ring.error();
  48. toaster.pop('error', '查询失败',res.data.exceptionInfo);
  49. })
  50. }
  51. };
  52. $scope.showMMDetail = function(item){//点击表格中的一行显示明细数据,供应商,批号,出厂日期之类的
  53. var data = {'pr_code':item.bar_prodcode,'wh_code':item.bar_whcode,'bar_location':item.bar_location};
  54. CheckOper.checkMMDetail({data:JSON.stringify(data)},{},function(data){
  55. if(data.exceptionInfo){
  56. toaster.pop('error', '查询失败',data.exceptionInfo);
  57. Ring.error();
  58. }else{
  59. $scope.items = data.target;
  60. $scope.items.pr_code = item.bar_prodcode;
  61. $scope.items.wh_code = item.bar_whcode;
  62. $scope.items.location = item.bar_location;
  63. $scope.tableParams.reload();
  64. var modalInstance = $modal.open({
  65. templateUrl: 'detailModalMM.html',
  66. controller: 'ModalInstanceCtrl',
  67. resolve: {
  68. items: function () {
  69. return $scope.items;
  70. }
  71. }
  72. });
  73. }
  74. },function(res){
  75. Ring.error();
  76. toaster.pop('error', '查询失败',res.data.exceptionInfo);
  77. })
  78. }
  79. //barcode条码库存
  80. $scope.searchBarcode = function (event){
  81. if(event.keyCode == 13 && $scope.barcode && $scope.whcode){
  82. $scope.checkBarcode($scope.barcode);
  83. }else if(event.keyCode == 13 && $scope.barcode && !$scope.whcode){
  84. document.getElementById("whcode").focus();
  85. }else if(event.keyCode == 13){
  86. document.getElementById("barcode").focus();
  87. }
  88. };
  89. $scope.checkBarcode = function(barcode,whcode){
  90. if(barcode){//列出该prodcode的barcode信息根据仓库、储位分组汇总结果
  91. CheckOper.checkBarcode({barcode:barcode,wh_code:whcode},{},function(data){
  92. if(data.exceptionInfo){
  93. toaster.pop('error', '查询失败',data.exceptionInfo);
  94. Ring.error();
  95. }else{
  96. $scope.barData = data.data;
  97. }
  98. },function(res){
  99. Ring.error();
  100. toaster.pop('error', '查询失败',res.data.exceptionInfo);
  101. });
  102. }
  103. };
  104. //包装箱号信息核查
  105. $scope.searchPackage = function (event){
  106. if(event.keyCode == 13 && $scope.outboxCode ){
  107. $scope.checkOutboxCode($scope.outboxCode);
  108. }else if(event.keyCode == 13){
  109. document.getElementById("outboxCode").focus();
  110. }
  111. };
  112. $scope.checkOutboxCode = function(outboxCode){//根据boxcode关联package 表信息
  113. CheckOper.checkPackage({outboxCode:outboxCode},{},function(data){
  114. if(data.exceptionInfo){
  115. toaster.pop('error', '查询失败',data.exceptionInfo);
  116. Ring.error();
  117. }else
  118. $scope.outBoxData = data.data;
  119. },function(res){
  120. Ring.error();
  121. toaster.pop('error', '查询失败',res.data.exceptionInfo);
  122. });
  123. };
  124. //工单完工品核查
  125. $scope.searchMakecode = function (event){
  126. if(event.keyCode == 13 && $scope.makeCode ){
  127. $scope.checkMakeCode($scope.makeCode);
  128. }else if(event.keyCode == 13){
  129. document.getElementById("makeCode").focus();
  130. }
  131. };
  132. $scope.checkMakeCode = function (makeCode){//根据makecode从makeserial关联ms_code,再从barcode表关联barcode
  133. CheckOper.checkMakeFin({makeCode:makeCode},{},function(data){
  134. if(data.exceptionInfo){
  135. toaster.pop('error', '查询失败',data.exceptionInfo);
  136. Ring.error();
  137. }else{
  138. $scope.grid = data.target;
  139. $scope.tableParams.reload();
  140. $scope.code = $scope.grid[0]["ma_code"];
  141. $scope.makeCode = '';
  142. document.getElementById("makeCode").focus();
  143. }
  144. },function(res){
  145. document.getElementById("makeCode").select();
  146. Ring.error();
  147. toaster.pop('error', '查询失败',res.data.exceptionInfo);
  148. });
  149. }
  150. //订单完工品核查
  151. $scope.searchSaleCode = function (event){
  152. if(event.keyCode == 13 && $scope.saleCode ){
  153. $scope.checkSaleCode($scope.saleCode);
  154. }else if(event.keyCode == 13){
  155. document.getElementById("saleCode").focus();
  156. }
  157. };
  158. $scope.checkSaleCode = function (saleCode){//根据makecode从makeserial关联ms_code,再从barcode表关联barcode
  159. CheckOper.checkOrderFin({saleCode:saleCode},{},function(data){
  160. if(data.exceptionInfo){
  161. toaster.pop('error', '查询失败',data.exceptionInfo);
  162. Ring.error();
  163. }else{
  164. $scope.grid = data.target;
  165. $scope.tableParams.reload();
  166. $scope.code = $scope.grid[0]["ma_salecode"];
  167. $scope.saleCode = '';
  168. }
  169. },function(res){
  170. Ring.error();
  171. toaster.pop('error', '查询失败',res.data.exceptionInfo);
  172. });
  173. }
  174. }]);
  175. });