Commit 09d136ebfffdc2e246545b1b97a112fbf1bfc9ca
1 parent
c5841810a1
Exists in
master
and in
2 other branches
aplico número de orden
Showing
1 changed file
with
43 additions
and
10 deletions
Show diff stats
src/js/controller.js
... | ... | @@ -8,10 +8,12 @@ angular.module('focaModalDetalleCisternas') |
8 | 8 | '$filter', |
9 | 9 | 'focaModalDetalleCisternasService', |
10 | 10 | 'fechaReparto', |
11 | + 'orden', | |
11 | 12 | function($scope, $uibModalInstance, idVehiculo, idRemito, focaModalService, $filter, |
12 | - focaModalDetalleCisternasService, fechaReparto | |
13 | + focaModalDetalleCisternasService, fechaReparto, orden | |
13 | 14 | ) { |
14 | 15 | //seteo variables |
16 | + $scope.orden = orden; | |
15 | 17 | $scope.cargandoDatos = true; |
16 | 18 | $scope.idRemito = idRemito; |
17 | 19 | $scope.articulos = []; |
... | ... | @@ -30,7 +32,7 @@ angular.module('focaModalDetalleCisternas') |
30 | 32 | var promesaCisternas = focaModalDetalleCisternasService |
31 | 33 | .obtenerCisternasPorFecha(idVehiculo); |
32 | 34 | |
33 | - if(idRemito !== -1) { | |
35 | + if (idRemito !== -1) { | |
34 | 36 | promesaRemito = focaModalDetalleCisternasService.obtenerRemitoById(idRemito); |
35 | 37 | } |
36 | 38 | |
... | ... | @@ -51,7 +53,9 @@ angular.module('focaModalDetalleCisternas') |
51 | 53 | $scope.vehiculo = res[0].data; |
52 | 54 | $scope.cisternas = res[1].data; |
53 | 55 | |
54 | - if(!$scope.cisternas.length) { | |
56 | + aplicarOrden($scope.cisternas, $scope.orden); | |
57 | + | |
58 | + if (!$scope.cisternas.length) { | |
55 | 59 | focaModalService.alert('El vehículo no tiene cisternas') |
56 | 60 | .then(function () { |
57 | 61 | $uibModalInstance.dismiss(); |
... | ... | @@ -68,14 +72,22 @@ angular.module('focaModalDetalleCisternas') |
68 | 72 | |
69 | 73 | $scope.remito = res[2].data; |
70 | 74 | |
71 | - if($scope.remito.idUsuarioProceso) { | |
75 | + if ($scope.remito.idUsuarioProceso) { | |
76 | + | |
77 | + focaModalService.alert('Remito ya asignado').then(function() { | |
72 | 78 | |
73 | - $uibModalInstance.dismiss(focaModalService.alert('Remito ya asignado')); | |
79 | + $uibModalInstance.dismiss(); | |
80 | + }); | |
74 | 81 | } |
75 | 82 | |
76 | 83 | $scope.articulos = $scope.remito.articulosRemito; |
77 | - if(!$scope.articulos.length) { | |
78 | - $uibModalInstance.dismiss(focaModalService.alert('El remito no tiene articulos')); | |
84 | + | |
85 | + if (!$scope.articulos.length) { | |
86 | + | |
87 | + focaModalService.alert('El remito no tiene articulos').then(function() { | |
88 | + | |
89 | + $uibModalInstance.dismiss(); | |
90 | + }) | |
79 | 91 | return; |
80 | 92 | } |
81 | 93 | |
... | ... | @@ -142,7 +154,7 @@ angular.module('focaModalDetalleCisternas') |
142 | 154 | |
143 | 155 | $scope.cargarACisternas = function() { |
144 | 156 | |
145 | - for(var i = 0; i < $scope.cisternas.length; i++) { | |
157 | + for (var i = 0; i < $scope.cisternas.length; i++) { | |
146 | 158 | var cisterna = $scope.cisternas[i]; |
147 | 159 | var aCargar = parseFloat($scope.aCargar[i]); |
148 | 160 | var fechaReparto = focaModalDetalleCisternasService.fecha; |
... | ... | @@ -235,9 +247,9 @@ angular.module('focaModalDetalleCisternas') |
235 | 247 | for (var i = 0; i < $scope.cisternas.length; i++) { |
236 | 248 | var cisterna = $scope.cisternas[i]; |
237 | 249 | cisterna.posicion = i; |
238 | - console.info(i, cisterna.posicion); | |
250 | + | |
239 | 251 | if (!cisterna.disabled && cisterna.disponible > 0) { |
240 | - if (cisterna.cisternaCarga) { | |
252 | + if (cisterna.cisternaCarga.idProducto) { | |
241 | 253 | arrayMismoProducto.push(cisterna); |
242 | 254 | } else { |
243 | 255 | arrayVacioProducto.push(cisterna); |
... | ... | @@ -360,11 +372,32 @@ angular.module('focaModalDetalleCisternas') |
360 | 372 | } |
361 | 373 | ] |
362 | 374 | }; |
375 | + | |
363 | 376 | focaModalService.modal(parametrosModal).then(function(transportista) { |
364 | 377 | $scope.selectVehiculo(transportista.COD, transportista.NOM); |
365 | 378 | }); |
366 | 379 | }; |
380 | + | |
381 | + function aplicarOrden(cisternas, orden) { | |
382 | + | |
383 | + cisternas.forEach(function (cisterna) { | |
384 | + | |
385 | + if (!cisterna.cisternaCarga) { | |
386 | + cisterna.cisternaCarga = { orden: orden }; | |
387 | + cisterna.disponible = cisterna.capacidad; | |
388 | + } | |
389 | + | |
390 | + if (cisterna.cisternaCarga.orden != orden) { | |
391 | + cisterna.cisternaCarga = { orden: orden }; | |
392 | + cisterna.disponible = cisterna.capacidad; | |
393 | + } | |
394 | + | |
395 | + }); | |
396 | + | |
397 | + } | |
398 | + | |
367 | 399 | function validarCargas(cis, remito) { |
400 | + | |
368 | 401 | var result = true; |
369 | 402 | var cisternas = angular.copy(cis); |
370 | 403 | var articulos = angular.copy(remito.articulosRemito); |