Commit d598f38eaabb72c9edd52c83e283f6a55f627b7b
1 parent
b800da6f7e
Exists in
master
servicios independiente
Showing
2 changed files
with
41 additions
and
10 deletions
Show diff stats
src/js/controller.js
| ... | ... | @@ -6,9 +6,10 @@ angular.module('focaModalDetalleCisternas') |
| 6 | 6 | 'idRemito', |
| 7 | 7 | 'focaModalService', |
| 8 | 8 | '$filter', |
| 9 | - 'focaLogisticaPedidoRutaService', | |
| 9 | + 'focaModalDetalleCisternasService', | |
| 10 | + 'fechaReparto', | |
| 10 | 11 | function($scope, $uibModalInstance, idVehiculo, idRemito, focaModalService, $filter, |
| 11 | - focaLogisticaPedidoRutaService | |
| 12 | + focaModalDetalleCisternasService, fechaReparto | |
| 12 | 13 | ) { |
| 13 | 14 | //seteo variables |
| 14 | 15 | $scope.cargandoDatos = true; |
| ... | ... | @@ -21,11 +22,15 @@ angular.module('focaModalDetalleCisternas') |
| 21 | 22 | $scope.aCargar = []; |
| 22 | 23 | var cisternaMovimientos = []; |
| 23 | 24 | var promesaRemito; |
| 24 | - var promesaVehiculo = focaLogisticaPedidoRutaService.obtenerVehiculoById(idVehiculo); | |
| 25 | - var promesaCisternas = focaLogisticaPedidoRutaService | |
| 25 | + | |
| 26 | + if(fechaReparto) { | |
| 27 | + focaModalDetalleCisternasService.fecha = fechaReparto; | |
| 28 | + } | |
| 29 | + var promesaVehiculo = focaModalDetalleCisternasService.obtenerVehiculoById(idVehiculo); | |
| 30 | + var promesaCisternas = focaModalDetalleCisternasService | |
| 26 | 31 | .obtenerCisternasPorFecha(idVehiculo); |
| 27 | 32 | if(idRemito !== -1) { |
| 28 | - promesaRemito = focaLogisticaPedidoRutaService.obtenerRemitoById(idRemito); | |
| 33 | + promesaRemito = focaModalDetalleCisternasService.obtenerRemitoById(idRemito); | |
| 29 | 34 | } |
| 30 | 35 | Promise.all([promesaVehiculo, promesaCisternas, promesaRemito]).then(function(res) { |
| 31 | 36 | $scope.cargandoDatos = false; |
| ... | ... | @@ -45,7 +50,7 @@ angular.module('focaModalDetalleCisternas') |
| 45 | 50 | var tieneUsuario = $scope.cisternas.filter(function(cisterna) { |
| 46 | 51 | if(cisterna.cisternaCarga && cisterna.cisternaCarga.idUsuarioProceso) { |
| 47 | 52 | return cisterna.cisternaCarga.idUsuarioProceso !== |
| 48 | - focaLogisticaPedidoRutaService.idUsuario; | |
| 53 | + focaModalDetalleCisternasService.idUsuario; | |
| 49 | 54 | } |
| 50 | 55 | }); |
| 51 | 56 | if(tieneUsuario.length) { |
| ... | ... | @@ -58,16 +63,16 @@ angular.module('focaModalDetalleCisternas') |
| 58 | 63 | $scope.cargando = true; |
| 59 | 64 | for(var i = 0; i < $scope.cisternasCarga.length; i++) { |
| 60 | 65 | $scope.cisternasCarga[i].idUsuarioProceso = |
| 61 | - focaLogisticaPedidoRutaService.idUsuario; | |
| 66 | + focaModalDetalleCisternasService.idUsuario; | |
| 62 | 67 | delete $scope.cisternasCarga[i].articulo; |
| 63 | 68 | } |
| 64 | 69 | var cisterna = { |
| 65 | 70 | cisternaMovimientos: cisternaMovimientos, |
| 66 | 71 | cisternaCargas: $scope.cisternasCarga, |
| 67 | 72 | idVehiculo: $scope.vehiculo.id, |
| 68 | - fechaReparto: focaLogisticaPedidoRutaService.fecha | |
| 73 | + fechaReparto: focaModalDetalleCisternasService.fecha | |
| 69 | 74 | }; |
| 70 | - focaLogisticaPedidoRutaService.guardarCisternas(cisterna, $scope.remito.id) | |
| 75 | + focaModalDetalleCisternasService.guardarCisternas(cisterna, $scope.remito.id) | |
| 71 | 76 | .then(function() { |
| 72 | 77 | focaModalService.alert('Cisternas cargadas con éxito').then(function() { |
| 73 | 78 | $scope.cargando = false; |
| ... | ... | @@ -90,7 +95,7 @@ angular.module('focaModalDetalleCisternas') |
| 90 | 95 | for(var i = 0; i < $scope.cisternas.length; i++) { |
| 91 | 96 | var cisterna = $scope.cisternas[i]; |
| 92 | 97 | var aCargar = parseFloat($scope.aCargar[i]); |
| 93 | - var fechaReparto = focaLogisticaPedidoRutaService.fecha; | |
| 98 | + var fechaReparto = focaModalDetalleCisternasService.fecha; | |
| 94 | 99 | //validaciones |
| 95 | 100 | if(!aCargar) { |
| 96 | 101 | continue; |
src/js/service.js
| ... | ... | @@ -0,0 +1,26 @@ |
| 1 | +angular.module('focaModalDetalleCisternas') | |
| 2 | + .factory('focaModalDetalleCisternasService', [ | |
| 3 | + '$http', | |
| 4 | + '$cookies', | |
| 5 | + 'API_ENDPOINT', | |
| 6 | + function($http, $cookies, API_ENDPOINT) { | |
| 7 | + var url = API_ENDPOINT.URL; | |
| 8 | + return { | |
| 9 | + idUsuario: $cookies.get('idUsuario'), | |
| 10 | + obtenerVehiculoById: function(idVehiculo) { | |
| 11 | + return $http.get(url + '/vehiculo/' + idVehiculo); | |
| 12 | + }, | |
| 13 | + obtenerRemitoById: function(idRemito) { | |
| 14 | + return $http.get(url + '/remito/obtener/' + idRemito); | |
| 15 | + }, | |
| 16 | + guardarCisternas: function(cisterna, idRemito) { | |
| 17 | + return $http.post(url + '/cisterna/guardar/cargar/' + | |
| 18 | + this.idUsuario + '/' + idRemito,cisterna); | |
| 19 | + }, | |
| 20 | + obtenerCisternasPorFecha: function(idVehiculo) { | |
| 21 | + return $http.post(url + '/cisterna/listar/fecha', | |
| 22 | + {idVehiculo: idVehiculo, fechaReparto: this.fecha}); | |
| 23 | + } | |
| 24 | + }; | |
| 25 | + } | |
| 26 | + ]); |