LocationTransferCtrl.js 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. define(['app/app','common/services','service/Purc','service/SupportServices' ], function(app) {
  2. app.register.controller('LocationTransferCtrl',['$scope', '$http', '$stateParams', '$rootScope','$filter','$location', 'ngTableParams','toaster', 'Ring', 'SupportUtil','LocaTransOper', 'Online','$modal','SessionService',function($scope, $http, $stateParams, $rootScope,$filter,$location, ngTableParams,toaster, Ring, SupportUtil,LocaTransOper, Online,$modal,SessionService){
  3. $scope.grid = [];
  4. $scope.whcode = SessionService.getCookie('defaultWhcode');
  5. setTimeout( function(){
  6. try{
  7. document.getElementById("whcode").focus();
  8. } catch(e){}
  9. }, 200);
  10. $scope.tableParams = new ngTableParams({//待转移储位批次列表
  11. page: 1,
  12. count: 10,
  13. filter: { },
  14. sorting: { }
  15. }, {
  16. total: $scope.grid.length,
  17. getData: function ($defer, params) {
  18. var filteredData = params.filter() ?
  19. $filter('filter')($scope.grid, params.filter()) :data;
  20. var orderedData = params.sorting() ?
  21. $filter('orderBy')(filteredData, params.orderBy()) :data;
  22. params.total(orderedData.length); // set total for recalc pagination
  23. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  24. }
  25. });
  26. $scope.confirm = function (){
  27. if($scope.grid.length>0){
  28. if($scope.grid[0].bar_whcode != $scope.whcode){
  29. alert("不允许操作与上次不同的仓库!");
  30. return ;
  31. }
  32. }
  33. if(!$scope.barcode && !$scope.outboxcode){
  34. document.getElementById("barcode").focus();
  35. alert("请输入条码号或者外箱号!");
  36. return ;
  37. }else if($scope.barcode){
  38. if(SupportUtil.contains(JSON.stringify($scope.grid),$scope.barcode ,"bar_code")){
  39. alert("条码号重复!");
  40. return ;
  41. }
  42. LocaTransOper.get({whcode:$scope.whcode,bar_code:$scope.barcode},function(data){
  43. if(data.exceptionInfo){
  44. toaster.pop('error', data.exceptionInfo);
  45. Ring.error();
  46. }else{
  47. $scope.grid.push(data.data);
  48. $scope.barcode='';
  49. document.getElementById("barcode").focus();
  50. $scope.tableParams.reload();
  51. }
  52. },function(res){
  53. toaster.pop('error',res.data.exceptionInfo);
  54. });
  55. }else if($scope.outboxcode){
  56. if(SupportUtil.contains($scope.grid,$scope.outboxcode ,"pa_outboxcode")){
  57. alert("外箱号重复!");
  58. return ;
  59. }
  60. LocaTransOper.get({whcode:$scope.whcode,outboxCode:$scope.outboxcode},function(data){
  61. if(data.exceptionInfo){
  62. toaster.pop('error', data.exceptionInfo);
  63. Ring.error();
  64. }else{
  65. $scope.grid.push(data.data);
  66. $scope.outboxcode='';
  67. document.getElementById("outboxcode").focus();
  68. $scope.tableParams.reload();
  69. }
  70. },function(res){
  71. Ring.error();
  72. toaster.pop('error',res.data.exceptionInfo);
  73. });
  74. }
  75. };
  76. $scope.transfer = function(){
  77. LocaTransOper.locaTransfer({data:$scope.grid,location:$scope.new_location},{},function(data){
  78. if(data.exceptionInfo){
  79. toaster.pop('error', data.exceptionInfo);
  80. Ring.error();
  81. }else{
  82. Ring.success();
  83. toaster.pop('success',"转移成功!");
  84. }
  85. },function(res){});
  86. }
  87. }]);
  88. });