Commit 2ed71aa8da577fd94e117fabcb66b49cd78e6903
Exists in
master
and in
2 other branches
Merge branch 'master' into 'master'
Master(efernandez) See merge request !18
Showing
5 changed files
Show diff stats
src/js/controller.js
... | ... | @@ -34,9 +34,10 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo |
34 | 34 | focaBotoneraLateralService.showPausar(false); |
35 | 35 | focaBotoneraLateralService.showGuardar(false); |
36 | 36 | |
37 | - focaLogisticaPedidoRutaService.getVehiculosByIdUsuario().then(function(res) { | |
38 | - $scope.vehiculos = res.data; | |
39 | - }); | |
37 | + // TODO: obtener vehiculos con remitos cargados para esa fecha que no han sido confirmados | |
38 | + // focaLogisticaPedidoRutaService.getVehiculosByIdUsuario().then(function(res) { | |
39 | + // $scope.vehiculos = res.data; | |
40 | + // }); | |
40 | 41 | |
41 | 42 | $scope.general = function() { |
42 | 43 | $scope.idVendedor = 0; |
... | ... | @@ -49,6 +50,10 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo |
49 | 50 | }; |
50 | 51 | |
51 | 52 | $scope.cargar = function(idVehiculo, punto) { |
53 | + if(!$scope.fechaReparto) { | |
54 | + focaModalService.alert('elija primero una fecha de reparto'); | |
55 | + return; | |
56 | + } | |
52 | 57 | var idRemito; |
53 | 58 | if(punto === -1) { |
54 | 59 | idRemito = -1; |
... | ... | @@ -63,7 +68,8 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo |
63 | 68 | size: 'lg', |
64 | 69 | resolve: { |
65 | 70 | idVehiculo: function() {return idVehiculo;}, |
66 | - idRemito: function() {return idRemito;} | |
71 | + idRemito: function() {return idRemito;}, | |
72 | + fechaReparto: function() {return $scope.fechaReparto;} | |
67 | 73 | } |
68 | 74 | } |
69 | 75 | ); |
... | ... | @@ -177,6 +183,7 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo |
177 | 183 | label: 'Fecha:', |
178 | 184 | valor: fecha.toLocaleDateString() |
179 | 185 | }); |
186 | + $scope.fechaReparto = fecha; | |
180 | 187 | }); |
181 | 188 | }; |
182 | 189 |
src/js/controllerDetalleVehiculo.js
... | ... | @@ -7,27 +7,33 @@ angular.module('focaLogisticaPedidoRuta') |
7 | 7 | 'focaModalService', |
8 | 8 | '$filter', |
9 | 9 | 'focaLogisticaPedidoRutaService', |
10 | + 'fechaReparto', | |
10 | 11 | function($scope, $uibModalInstance, idVehiculo, idRemito, focaModalService, $filter, |
11 | - focaLogisticaPedidoRutaService | |
12 | + focaLogisticaPedidoRutaService, fechaReparto | |
12 | 13 | ) { |
13 | 14 | //seteo variables |
14 | 15 | $scope.cargandoDatos = true; |
15 | 16 | $scope.idRemito = idRemito; |
16 | 17 | $scope.articulos = []; |
17 | 18 | $scope.vehiculo = {}; |
19 | + $scope.cisternas = []; | |
20 | + $scope.cisternasCarga = []; | |
18 | 21 | $scope.remito = {}; |
19 | 22 | $scope.aCargar = []; |
20 | 23 | var cisternaMovimientos = []; |
21 | - var promesaVehiculo = focaLogisticaPedidoRutaService.obtenerVehiculoById(idVehiculo); | |
22 | 24 | var promesaRemito; |
25 | + var promesaVehiculo = focaLogisticaPedidoRutaService.obtenerVehiculoById(idVehiculo); | |
26 | + var promesaCisternas = focaLogisticaPedidoRutaService | |
27 | + .obtenerCisternasPorFecha(idVehiculo, fechaReparto); | |
23 | 28 | if(idRemito !== -1) { |
24 | 29 | promesaRemito = focaLogisticaPedidoRutaService.obtenerRemitoById(idRemito); |
25 | 30 | } |
26 | - Promise.all([promesaVehiculo, promesaRemito]).then(function(res) { | |
31 | + Promise.all([promesaVehiculo, promesaCisternas, promesaRemito]).then(function(res) { | |
27 | 32 | $scope.cargandoDatos = false; |
28 | 33 | $scope.vehiculo = res[0].data; |
29 | - if(!res[1]) return; | |
30 | - $scope.remito = res[1].data; | |
34 | + $scope.cisternas = res[1].data; | |
35 | + if(!res[2]) return; | |
36 | + $scope.remito = res[2].data; | |
31 | 37 | if($scope.remito.idUsuarioProceso) { |
32 | 38 | focaModalService.alert('Remito ya asignado'); |
33 | 39 | $uibModalInstance.close(); |
... | ... | @@ -37,14 +43,12 @@ angular.module('focaLogisticaPedidoRuta') |
37 | 43 | }); |
38 | 44 | $scope.aceptar = function() { |
39 | 45 | $scope.cargando = true; |
40 | - var cisternaCargas = []; | |
41 | - for (var i = 0; i < $scope.vehiculo.cisternas.length; i++) { | |
42 | - delete $scope.vehiculo.cisternas[i].cisternaCarga.articulo; | |
43 | - cisternaCargas.push($scope.vehiculo.cisternas[i].cisternaCarga); | |
46 | + for(var i = 0; i < $scope.cisternasCarga.length; i++) { | |
47 | + delete $scope.cisternasCarga[i].articulo; | |
44 | 48 | } |
45 | 49 | var cisterna = { |
46 | 50 | cisternaMovimientos: cisternaMovimientos, |
47 | - cisternaCargas: cisternaCargas, | |
51 | + cisternaCargas: $scope.cisternasCarga, | |
48 | 52 | idVehiculo: $scope.vehiculo.id |
49 | 53 | }; |
50 | 54 | focaLogisticaPedidoRutaService.guardarCisternas(cisterna, $scope.remito.id) |
... | ... | @@ -69,19 +73,14 @@ angular.module('focaLogisticaPedidoRuta') |
69 | 73 | $scope.cancelar = function() { |
70 | 74 | $uibModalInstance.close(); |
71 | 75 | }; |
72 | - $scope.cargarACisternas = function(vehiculo) { | |
73 | - for(var i = 0; i < vehiculo.cisternas.length; i++) { | |
74 | - var cisterna = vehiculo.cisternas[i]; | |
76 | + $scope.cargarACisternas = function() { | |
77 | + for(var i = 0; i < $scope.cisternas.length; i++) { | |
78 | + var cisterna = $scope.cisternas[i]; | |
75 | 79 | var aCargar = parseFloat($scope.aCargar[i]); |
76 | 80 | //validaciones |
77 | 81 | if(!aCargar) { |
78 | 82 | continue; |
79 | 83 | } |
80 | - if(aCargar > cisterna.disponible) { | |
81 | - focaModalService.alert('La cantidad cargada supera la capacidad de la' + | |
82 | - 'cisterna ' + cisterna.codigo); | |
83 | - return; | |
84 | - } | |
85 | 84 | //cargar |
86 | 85 | if(cisterna.cisternaCarga.cantidad) { |
87 | 86 | cisterna.cisternaCarga.cantidad += aCargar; |
... | ... | @@ -107,6 +106,9 @@ angular.module('focaLogisticaPedidoRuta') |
107 | 106 | idCisternaCarga: cisterna.cisternaCarga.id, |
108 | 107 | idRemito: $scope.remito.id |
109 | 108 | }; |
109 | + cisterna.cisternaCarga.fechaReparto = fechaReparto; | |
110 | + cisterna.cisternaCarga.idCisterna = cisterna.id; | |
111 | + $scope.cisternasCarga.push(cisterna.cisternaCarga); | |
110 | 112 | cisternaMovimientos.push(cisternaMovimiento); |
111 | 113 | } |
112 | 114 | var articuloSiguiente = $scope.articulos.filter( |
... | ... | @@ -131,7 +133,7 @@ angular.module('focaLogisticaPedidoRuta') |
131 | 133 | }; |
132 | 134 | $scope.seleccionarArticulo = function(articulo) { |
133 | 135 | $scope.articuloSeleccionado = articulo; |
134 | - $scope.cisternaDisabled(); | |
136 | + $scope.cisternaDisponible(); | |
135 | 137 | $scope.autoCompletar(); |
136 | 138 | $scope.actualizarArticulo(); |
137 | 139 | }; |
... | ... | @@ -144,21 +146,24 @@ angular.module('focaLogisticaPedidoRuta') |
144 | 146 | }; |
145 | 147 | $scope.autoCompletar = function() { |
146 | 148 | $scope.aCargar = []; |
147 | - var disponible = $filter('filter')($scope.vehiculo.cisternas, {disabled: false}); | |
148 | - var index = $scope.vehiculo.cisternas.indexOf(disponible[0]); | |
149 | + var disponible = $filter('filter')($scope.cisternas, {disabled: false}); | |
150 | + var index = $scope.cisternas.indexOf(disponible[0]); | |
149 | 151 | $scope.aCargar[index] = $scope.articuloSeleccionado.cantidad; |
150 | 152 | }; |
151 | - $scope.cisternaDisabled = function() { | |
152 | - for(var i = 0; i < $scope.vehiculo.cisternas.length; i++) { | |
153 | - var cisterna = $scope.vehiculo.cisternas[i]; | |
154 | - if(!$scope.articuloSeleccionado || ($scope.articuloSeleccionado.idArticulo !== | |
155 | - cisterna.cisternaCarga.idProducto && cisterna.cisternaCarga.idProducto) || | |
156 | - !$scope.tieneArticulosPendientes()|| $scope.articuloSeleccionado.cantidad > | |
157 | - cisterna.disponible) { | |
158 | - cisterna.disabled = true; | |
159 | - }else { | |
160 | - cisterna.disabled = false; | |
161 | - } | |
153 | + $scope.cisternaDisponible = function() { | |
154 | + for(var i = 0; i < $scope.cisternas.length; i++) { | |
155 | + if($scope.articuloSeleccionado.cantidad > $scope.cisternas[i].disponible) { | |
156 | + $scope.cisternas[i].disabled = true; | |
157 | + continue; | |
158 | + } | |
159 | + if($scope.cisternas[i].cisternaCarga.idProducto && | |
160 | + $scope.articuloSeleccionado.idArticulo !== | |
161 | + $scope.cisternas[i].cisternaCarga.idProducto) | |
162 | + { | |
163 | + $scope.cisternas[i].disabled = true; | |
164 | + continue; | |
165 | + } | |
166 | + $scope.cisternas[i].disabled = false; | |
162 | 167 | } |
163 | 168 | }; |
164 | 169 | $scope.rellenarInput = function(input) { |
... | ... | @@ -192,6 +197,7 @@ angular.module('focaLogisticaPedidoRuta') |
192 | 197 | return filter.cargado === true; |
193 | 198 | }); |
194 | 199 | if(articulosDescargados.length === $scope.articulos.length) { |
200 | + $scope.aCargar = []; | |
195 | 201 | return false; |
196 | 202 | } |
197 | 203 | return true; |
src/js/service.js
... | ... | @@ -68,6 +68,10 @@ angular.module('focaLogisticaPedidoRuta') |
68 | 68 | }, |
69 | 69 | getVehiculosByIdUsuario: function() { |
70 | 70 | return $http.get(API_ENDPOINT.URL + '/vehiculo/usuario/' + this.idUsuario); |
71 | + }, | |
72 | + obtenerCisternasPorFecha: function(idVehiculo, fecha) { | |
73 | + return $http.post(API_ENDPOINT.URL + '/cisterna/listar/fecha', | |
74 | + {idVehiculo: idVehiculo, fechaReparto: fecha}); | |
71 | 75 | } |
72 | 76 | }; |
73 | 77 | }]); |
src/views/foca-detalle-vehiculo.html
... | ... | @@ -57,7 +57,7 @@ |
57 | 57 | </tr> |
58 | 58 | </thead> |
59 | 59 | <tbody> |
60 | - <tr ng-repeat="(key, cisterna) in vehiculo.cisternas"> | |
60 | + <tr ng-repeat="(key, cisterna) in cisternas"> | |
61 | 61 | <td class="py-3" ng-bind="cisterna.codigo"></td> |
62 | 62 | <td class="py-3" ng-bind="cisterna.capacidad"></td> |
63 | 63 | <td class="py-3" ng-bind="cisterna.cisternaCarga.articulo.DetArt || 'Sin asignar'"></td> |
... | ... | @@ -68,7 +68,7 @@ |
68 | 68 | foca-teclado |
69 | 69 | placeholder="A cargar..." |
70 | 70 | ng-model="aCargar[key]" |
71 | - ng-disabled="cisterna.disabled" | |
71 | + ng-disabled="cisterna.disabled || !tieneArticulosPendientes()" | |
72 | 72 | ng-focus="aCargar[key] = rellenarInput(aCargar[key]); actualizarArticulo()" |
73 | 73 | ng-change="actualizarArticulo()" |
74 | 74 | > |
src/views/foca-modal-crear-hoja-ruta.html
1 | 1 | <div class="modal-header"> |
2 | - <h4>Confeccionar hoja de ruta</h4> | |
2 | + <h5>En desarrollo</h5> | |
3 | + <h4>Confirmar hoja de ruta</h4> | |
3 | 4 | <div class="row"> |
4 | - <div class="col-6"> | |
5 | + <!-- <div class="col-6"> | |
5 | 6 | <span>Hoja de ruta Nº </span> |
6 | 7 | <strong ng-bind="[sucursal, numero] | comprobante"></strong> |
7 | - </div> | |
8 | + </div> --> | |
8 | 9 | <div class="col-6 row"> |
9 | 10 | <label class="col-3 mt-2">Fecha:</label> |
10 | 11 | <input |
... | ... | @@ -31,7 +32,7 @@ |
31 | 32 | <input |
32 | 33 | class="form-control" |
33 | 34 | readonly |
34 | - ng-model="vehiculo.transportista.NOM" | |
35 | + ng-value="vehiculo.transportista.COD + ' ' + vehiculo.transportista.NOM" | |
35 | 36 | > |
36 | 37 | </div> |
37 | 38 | <div class="col-2 form-group"> |
... | ... | @@ -44,36 +45,6 @@ |
44 | 45 | ng-model="vehiculo.tractor" |
45 | 46 | > |
46 | 47 | </div> |
47 | - <div class="col-2 form-group"> | |
48 | - <label>Chofer</label> | |
49 | - </div> | |
50 | - <div class="col-4 input-group"> | |
51 | - <input | |
52 | - class="form-control" | |
53 | - ng-model="chofer.nombre" | |
54 | - ng-click="seleccionarChofer()" | |
55 | - ng-required="true" | |
56 | - > | |
57 | - <div class="input-group-append"> | |
58 | - <button | |
59 | - class="brn btn-outline-secondary form-control" | |
60 | - ng-click="seleccionarChofer()" | |
61 | - ><i class="fa fa-search"></i> | |
62 | - </button> | |
63 | - </div> | |
64 | - </div> | |
65 | - <div class="col-2"> | |
66 | - <label>Tarifa</label> | |
67 | - </div> | |
68 | - <div class="col-4"> | |
69 | - <input | |
70 | - class="form-control" | |
71 | - ng-model="tarifaFlete" | |
72 | - ng-required="true" | |
73 | - foca-teclado | |
74 | - foca-tipo-input | |
75 | - > | |
76 | - </div> | |
77 | 48 | </form> |
78 | 49 | <strong>Remitos:</strong> |
79 | 50 | <table class="table"> |
... | ... | @@ -123,6 +94,6 @@ |
123 | 94 | class="btn btn-sm btn-primary" |
124 | 95 | ladda="cargando" |
125 | 96 | type="button" |
126 | - ng-disabled="!formHojaRuta.$valid || !remitos.length" | |
97 | + ng-disabled="!formHojaRuta.$valid || !remitos.length || true" | |
127 | 98 | ng-click="aceptar()">Crear hoja ruta</button> |
128 | 99 | </div> |