Commit 2452de534d32f4a9b55999110f5cf95958d47cf0
1 parent
f5040c914a
Exists in
master
and in
1 other branch
bug's
Showing
2 changed files
with
28 additions
and
9 deletions
Show diff stats
src/js/controller.js
... | ... | @@ -29,9 +29,11 @@ angular.module('focaModalDetalleCisternas') |
29 | 29 | var promesaVehiculo = focaModalDetalleCisternasService.obtenerVehiculoById(idVehiculo); |
30 | 30 | var promesaCisternas = focaModalDetalleCisternasService |
31 | 31 | .obtenerCisternasPorFecha(idVehiculo); |
32 | + | |
32 | 33 | if(idRemito !== -1) { |
33 | 34 | promesaRemito = focaModalDetalleCisternasService.obtenerRemitoById(idRemito); |
34 | 35 | } |
36 | + | |
35 | 37 | Promise.all([promesaVehiculo, promesaCisternas, promesaRemito]).then(function(res) { |
36 | 38 | if (idRemito !== -1 && !validarCargas(res[1].data, res[2].data)) { |
37 | 39 | var error = 'Los artículos del remito exceden la cantidad disponible del ' + |
... | ... | @@ -76,7 +78,9 @@ angular.module('focaModalDetalleCisternas') |
76 | 78 | } |
77 | 79 | $scope.$digest(); |
78 | 80 | }); |
81 | + | |
79 | 82 | $scope.aceptar = function() { |
83 | + | |
80 | 84 | $scope.cargando = true; |
81 | 85 | for(var i = 0; i < $scope.cisternasCarga.length; i++) { |
82 | 86 | $scope.cisternasCarga[i].idUsuarioProceso = |
... | ... | @@ -84,41 +88,51 @@ angular.module('focaModalDetalleCisternas') |
84 | 88 | delete $scope.cisternasCarga[i].articulo; |
85 | 89 | delete $scope.cisternasCarga[i].remitos; |
86 | 90 | } |
91 | + | |
87 | 92 | var cisterna = { |
88 | 93 | cisternaMovimientos: cisternaMovimientos, |
89 | 94 | cisternaCargas: $scope.cisternasCarga, |
90 | 95 | idVehiculo: $scope.vehiculo.id, |
91 | 96 | fechaReparto: focaModalDetalleCisternasService.fecha |
92 | 97 | }; |
98 | + | |
93 | 99 | if(!focaModalDetalleCisternasService.idUsuario) { |
94 | 100 | focaModalService.alert('No logeado como vendedor'); |
95 | 101 | $scope.cargando = false; |
96 | 102 | return; |
97 | 103 | } |
104 | + | |
98 | 105 | focaModalDetalleCisternasService.guardarCisternas(cisterna, $scope.remito.id) |
99 | 106 | .then(function() { |
107 | + | |
100 | 108 | $scope.cargando = false; |
101 | 109 | $uibModalInstance.close(); |
110 | + | |
102 | 111 | }).catch(function(error) { |
112 | + | |
103 | 113 | $scope.cargando = false; |
104 | 114 | $uibModalInstance.close(); |
115 | + | |
105 | 116 | if (error.status === 403) { |
106 | 117 | focaModalService.alert('ERROR: ' + error.data); |
107 | 118 | return; |
108 | 119 | } |
120 | + | |
109 | 121 | focaModalService.alert('Hubo un error al cargar las cisternas'); |
110 | 122 | }); |
111 | 123 | }; |
124 | + | |
112 | 125 | $scope.cancelar = function() { |
113 | 126 | $uibModalInstance.dismiss(); |
114 | 127 | }; |
128 | + | |
115 | 129 | $scope.cargarACisternas = function() { |
116 | 130 | for(var i = 0; i < $scope.cisternas.length; i++) { |
117 | 131 | var cisterna = $scope.cisternas[i]; |
118 | 132 | var aCargar = parseFloat($scope.aCargar[i]); |
119 | 133 | var fechaReparto = focaModalDetalleCisternasService.fecha; |
120 | 134 | //validaciones |
121 | - if(!aCargar) { | |
135 | + if(!aCargar || cisterna.disabled) { | |
122 | 136 | continue; |
123 | 137 | } |
124 | 138 | //cargar |
... | ... | @@ -178,20 +192,25 @@ angular.module('focaModalDetalleCisternas') |
178 | 192 | $scope.articuloSeleccionado = articulo; |
179 | 193 | $scope.cisternaDisponible(); |
180 | 194 | $scope.autoCompletar(); |
181 | - $scope.actualizarArticulo(); | |
195 | + // $scope.actualizarArticulo(); | |
182 | 196 | }; |
183 | 197 | |
184 | 198 | $scope.actualizarArticulo = function() { |
185 | 199 | $scope.articuloSeleccionado.cantidadCargada = 0; |
186 | 200 | for(var i = 0; i < $scope.aCargar.length; i++) { |
187 | - $scope.articuloSeleccionado.cantidadCargada += | |
201 | + if (!$scope.cisternas[i].disabled) { | |
202 | + | |
203 | + $scope.articuloSeleccionado.cantidadCargada += | |
188 | 204 | parseFloat($scope.aCargar[i]) || 0; |
205 | + } | |
189 | 206 | } |
190 | 207 | }; |
191 | 208 | |
192 | 209 | $scope.autoCompletar = function() { |
210 | + | |
193 | 211 | var arrayMismoProducto = []; |
194 | 212 | var arrayVacioProducto = []; |
213 | + | |
195 | 214 | for(var i = 0; i < $scope.cisternas.length; i++) { |
196 | 215 | var cisterna = $scope.cisternas[i]; |
197 | 216 | cisterna.posicion = i; |
... | ... | @@ -214,12 +233,12 @@ angular.module('focaModalDetalleCisternas') |
214 | 233 | for (var j = 0; j < cisternas.length; j++) { |
215 | 234 | var aCargar = $scope.articuloSeleccionado.cantidad - |
216 | 235 | ($scope.articuloSeleccionado.cantidadCargada || 0); |
217 | - | |
218 | - if(aCargar > cisternas[j].disponible) { | |
236 | + | |
237 | + if (aCargar > cisternas[j].disponible) { | |
219 | 238 | aCargar = cisternas[j].disponible; |
220 | 239 | } |
221 | - | |
222 | - if(aCargar > 0) { | |
240 | + | |
241 | + if (aCargar > 0) { | |
223 | 242 | $scope.aCargar[cisternas[j].posicion] = aCargar; |
224 | 243 | $scope.actualizarArticulo(); |
225 | 244 | } |
... | ... | @@ -232,7 +251,7 @@ angular.module('focaModalDetalleCisternas') |
232 | 251 | // $scope.cisternas[i].disabled = true; |
233 | 252 | // continue; |
234 | 253 | // } |
235 | - if($scope.cisternas[i].cisternaCarga && | |
254 | + if ($scope.cisternas[i].cisternaCarga && | |
236 | 255 | $scope.cisternas[i].cisternaCarga.idProducto && |
237 | 256 | $scope.articuloSeleccionado.idArticulo !== |
238 | 257 | $scope.cisternas[i].cisternaCarga.idProducto) |
src/views/foca-detalle-vehiculo.html
... | ... | @@ -101,7 +101,7 @@ |
101 | 101 | class="btn btn-outline-secondary" |
102 | 102 | ng-disabled="!cisterna.cisternaCarga.remitos.length" |
103 | 103 | ng-click="verRemitos(cisterna.cisternaCarga.remitos)"> |
104 | - <i class="fa fa-info" aria-hidden="true"></i> | |
104 | + <i class="fa fa-eye" aria-hidden="true"></i> | |
105 | 105 | </button> |
106 | 106 | </td> |
107 | 107 | </tr> |