Commit c28654bef64d39099709ad3c513ccf6f1812321c
1 parent
65bab73095
Exists in
master
recibo fecha reparto, distribuyo funciones, refactor guardado de cisternas
Showing
3 changed files
with
44 additions
and
34 deletions
Show diff stats
src/js/controllerDetalleVehiculo.js
1 | angular.module('focaLogisticaPedidoRuta') | 1 | angular.module('focaLogisticaPedidoRuta') |
2 | .controller('focaDetalleVehiculo', | 2 | .controller('focaDetalleVehiculo', |
3 | ['$scope', | 3 | ['$scope', |
4 | '$uibModalInstance', | 4 | '$uibModalInstance', |
5 | 'idVehiculo', | 5 | 'idVehiculo', |
6 | 'idRemito', | 6 | 'idRemito', |
7 | 'focaModalService', | 7 | 'focaModalService', |
8 | '$filter', | 8 | '$filter', |
9 | 'focaLogisticaPedidoRutaService', | 9 | 'focaLogisticaPedidoRutaService', |
10 | 'fechaReparto', | ||
10 | function($scope, $uibModalInstance, idVehiculo, idRemito, focaModalService, $filter, | 11 | function($scope, $uibModalInstance, idVehiculo, idRemito, focaModalService, $filter, |
11 | focaLogisticaPedidoRutaService | 12 | focaLogisticaPedidoRutaService, fechaReparto |
12 | ) { | 13 | ) { |
13 | //seteo variables | 14 | //seteo variables |
14 | $scope.cargandoDatos = true; | 15 | $scope.cargandoDatos = true; |
15 | $scope.idRemito = idRemito; | 16 | $scope.idRemito = idRemito; |
16 | $scope.articulos = []; | 17 | $scope.articulos = []; |
17 | $scope.vehiculo = {}; | 18 | $scope.vehiculo = {}; |
19 | $scope.cisternas = []; | ||
20 | $scope.cisternasCarga = []; | ||
18 | $scope.remito = {}; | 21 | $scope.remito = {}; |
19 | $scope.aCargar = []; | 22 | $scope.aCargar = []; |
20 | var cisternaMovimientos = []; | 23 | var cisternaMovimientos = []; |
21 | var promesaVehiculo = focaLogisticaPedidoRutaService.obtenerVehiculoById(idVehiculo); | ||
22 | var promesaRemito; | 24 | var promesaRemito; |
25 | var promesaVehiculo = focaLogisticaPedidoRutaService.obtenerVehiculoById(idVehiculo); | ||
26 | var promesaCisternas = focaLogisticaPedidoRutaService | ||
27 | .obtenerCisternasPorFecha(idVehiculo, fechaReparto); | ||
23 | if(idRemito !== -1) { | 28 | if(idRemito !== -1) { |
24 | promesaRemito = focaLogisticaPedidoRutaService.obtenerRemitoById(idRemito); | 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 | $scope.cargandoDatos = false; | 32 | $scope.cargandoDatos = false; |
28 | $scope.vehiculo = res[0].data; | 33 | $scope.vehiculo = res[0].data; |
29 | if(!res[1]) return; | 34 | $scope.cisternas = res[1].data; |
30 | $scope.remito = res[1].data; | 35 | if(!res[2]) return; |
36 | $scope.remito = res[2].data; | ||
31 | if($scope.remito.idUsuarioProceso) { | 37 | if($scope.remito.idUsuarioProceso) { |
32 | focaModalService.alert('Remito ya asignado'); | 38 | focaModalService.alert('Remito ya asignado'); |
33 | $uibModalInstance.close(); | 39 | $uibModalInstance.close(); |
34 | } | 40 | } |
35 | $scope.articulos = $scope.remito.articulosRemito; | 41 | $scope.articulos = $scope.remito.articulosRemito; |
36 | $scope.seleccionarArticulo($scope.articulos[0]); | 42 | $scope.seleccionarArticulo($scope.articulos[0]); |
37 | }); | 43 | }); |
38 | $scope.aceptar = function() { | 44 | $scope.aceptar = function() { |
39 | $scope.cargando = true; | 45 | $scope.cargando = true; |
40 | var cisternaCargas = []; | 46 | for (var i = 0; i < $scope.cisternasCarga.length; i++) { |
1 |
|
||
41 | for (var i = 0; i < $scope.vehiculo.cisternas.length; i++) { | 47 | delete $scope.cisternasCarga[i].articulo; |
42 | delete $scope.vehiculo.cisternas[i].cisternaCarga.articulo; | ||
43 | cisternaCargas.push($scope.vehiculo.cisternas[i].cisternaCarga); | ||
44 | } | 48 | } |
45 | var cisterna = { | 49 | var cisterna = { |
46 | cisternaMovimientos: cisternaMovimientos, | 50 | cisternaMovimientos: cisternaMovimientos, |
47 | cisternaCargas: cisternaCargas, | 51 | cisternaCargas: $scope.cisternasCarga, |
48 | idVehiculo: $scope.vehiculo.id | 52 | idVehiculo: $scope.vehiculo.id |
49 | }; | 53 | }; |
50 | focaLogisticaPedidoRutaService.guardarCisternas(cisterna, $scope.remito.id) | 54 | focaLogisticaPedidoRutaService.guardarCisternas(cisterna, $scope.remito.id) |
51 | .then(function() { | 55 | .then(function() { |
52 | focaModalService.alert('Cisternas cargadas con éxito').then(function() { | 56 | focaModalService.alert('Cisternas cargadas con éxito').then(function() { |
53 | $scope.cargando = false; | 57 | $scope.cargando = false; |
54 | $uibModalInstance.close(); | 58 | $uibModalInstance.close(); |
55 | }); | 59 | }); |
56 | }).catch(function(error) { | 60 | }).catch(function(error) { |
57 | $scope.cargando = false; | 61 | $scope.cargando = false; |
58 | $uibModalInstance.close(); | 62 | $uibModalInstance.close(); |
59 | if (error.status === 403.1) { | 63 | if (error.status === 403.1) { |
60 | focaModalService.alert('ERROR: El vehículo esta en uso'); | 64 | focaModalService.alert('ERROR: El vehículo esta en uso'); |
61 | } | 65 | } |
62 | if(error.status === 403.2) { | 66 | if(error.status === 403.2) { |
63 | focaModalService.alert('ERROR: Otro usario ya cargó este remito'); | 67 | focaModalService.alert('ERROR: Otro usario ya cargó este remito'); |
64 | return; | 68 | return; |
65 | } | 69 | } |
66 | focaModalService.alert('Hubo un error al cargar las cisternas'); | 70 | focaModalService.alert('Hubo un error al cargar las cisternas'); |
67 | }); | 71 | }); |
68 | }; | 72 | }; |
69 | $scope.cancelar = function() { | 73 | $scope.cancelar = function() { |
70 | $uibModalInstance.close(); | 74 | $uibModalInstance.close(); |
71 | }; | 75 | }; |
72 | $scope.cargarACisternas = function(vehiculo) { | 76 | $scope.cargarACisternas = function() { |
73 | for(var i = 0; i < vehiculo.cisternas.length; i++) { | 77 | for(var i = 0; i < $scope.cisternas.length; i++) { |
74 | var cisterna = vehiculo.cisternas[i]; | 78 | var cisterna = $scope.cisternas[i]; |
75 | var aCargar = parseFloat($scope.aCargar[i]); | 79 | var aCargar = parseFloat($scope.aCargar[i]); |
76 | //validaciones | 80 | //validaciones |
77 | if(!aCargar) { | 81 | if(!aCargar) { |
78 | continue; | 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 | //cargar | 84 | //cargar |
86 | if(cisterna.cisternaCarga.cantidad) { | 85 | if(cisterna.cisternaCarga.cantidad) { |
87 | cisterna.cisternaCarga.cantidad += aCargar; | 86 | cisterna.cisternaCarga.cantidad += aCargar; |
88 | }else { | 87 | }else { |
89 | cisterna.cisternaCarga.cantidad = aCargar; | 88 | cisterna.cisternaCarga.cantidad = aCargar; |
90 | cisterna.cisternaCarga.idProducto = $scope.articuloSeleccionado.idArticulo; | 89 | cisterna.cisternaCarga.idProducto = $scope.articuloSeleccionado.idArticulo; |
91 | } | 90 | } |
92 | cisterna.disponible = cisterna.capacidad - cisterna.cisternaCarga.cantidad; | 91 | cisterna.disponible = cisterna.capacidad - cisterna.cisternaCarga.cantidad; |
93 | 92 | ||
94 | cisterna.cisternaCarga.articulo = { | 93 | cisterna.cisternaCarga.articulo = { |
95 | DetArt: $scope.articuloSeleccionado.descripcion | 94 | DetArt: $scope.articuloSeleccionado.descripcion |
96 | }; | 95 | }; |
97 | $filter('filter')($scope.articulos, {id: $scope.articuloSeleccionado.id})[0] | 96 | $filter('filter')($scope.articulos, {id: $scope.articuloSeleccionado.id})[0] |
98 | .cargado = true; | 97 | .cargado = true; |
99 | 98 | ||
100 | $scope.calcularPorcentaje(cisterna); | 99 | $scope.calcularPorcentaje(cisterna); |
101 | //Guardar | 100 | //Guardar |
102 | var now = new Date(); | 101 | var now = new Date(); |
103 | var cisternaMovimiento = { | 102 | var cisternaMovimiento = { |
104 | fecha: now.toISOString().slice(0, 19).replace('T', ' '), | 103 | fecha: now.toISOString().slice(0, 19).replace('T', ' '), |
105 | cantidad: aCargar, | 104 | cantidad: aCargar, |
106 | metodo: 'carga', | 105 | metodo: 'carga', |
107 | idCisternaCarga: cisterna.cisternaCarga.id, | 106 | idCisternaCarga: cisterna.cisternaCarga.id, |
108 | idRemito: $scope.remito.id | 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 | cisternaMovimientos.push(cisternaMovimiento); | 112 | cisternaMovimientos.push(cisternaMovimiento); |
111 | } | 113 | } |
112 | var articuloSiguiente = $scope.articulos.filter( | 114 | var articuloSiguiente = $scope.articulos.filter( |
113 | function(filter) { | 115 | function(filter) { |
114 | return filter.cargado !== true; | 116 | return filter.cargado !== true; |
115 | } | 117 | } |
116 | ); | 118 | ); |
117 | if(articuloSiguiente.length > 0) { | 119 | if(articuloSiguiente.length > 0) { |
118 | $scope.seleccionarArticulo(articuloSiguiente[0]); | 120 | $scope.seleccionarArticulo(articuloSiguiente[0]); |
119 | } | 121 | } |
120 | }; | 122 | }; |
121 | $scope.calcularPorcentaje = function(cisterna) { | 123 | $scope.calcularPorcentaje = function(cisterna) { |
122 | if(!cisterna.cisternaCarga.cantidad) { | 124 | if(!cisterna.cisternaCarga.cantidad) { |
123 | cisterna.cisternaCarga.cantidad = 0; | 125 | cisterna.cisternaCarga.cantidad = 0; |
124 | } | 126 | } |
125 | var porcentaje = (cisterna.cisternaCarga.cantidad * 100 / | 127 | var porcentaje = (cisterna.cisternaCarga.cantidad * 100 / |
126 | cisterna.capacidad) + '%'; | 128 | cisterna.capacidad) + '%'; |
127 | var elementHtml = document.getElementById(cisterna.id); | 129 | var elementHtml = document.getElementById(cisterna.id); |
128 | if(elementHtml) { | 130 | if(elementHtml) { |
129 | elementHtml.style.width = porcentaje; | 131 | elementHtml.style.width = porcentaje; |
130 | } | 132 | } |
131 | }; | 133 | }; |
132 | $scope.seleccionarArticulo = function(articulo) { | 134 | $scope.seleccionarArticulo = function(articulo) { |
133 | $scope.articuloSeleccionado = articulo; | 135 | $scope.articuloSeleccionado = articulo; |
134 | $scope.cisternaDisabled(); | 136 | $scope.cisternaDisponible(); |
135 | $scope.autoCompletar(); | 137 | $scope.autoCompletar(); |
136 | $scope.actualizarArticulo(); | 138 | $scope.actualizarArticulo(); |
137 | }; | 139 | }; |
138 | $scope.actualizarArticulo = function () { | 140 | $scope.actualizarArticulo = function () { |
139 | $scope.articuloSeleccionado.cantidadCargada = 0; | 141 | $scope.articuloSeleccionado.cantidadCargada = 0; |
140 | for (var i = 0; i < $scope.aCargar.length; i++) { | 142 | for (var i = 0; i < $scope.aCargar.length; i++) { |
141 | $scope.articuloSeleccionado.cantidadCargada += | 143 | $scope.articuloSeleccionado.cantidadCargada += |
142 | parseFloat($scope.aCargar[i]) || 0; | 144 | parseFloat($scope.aCargar[i]) || 0; |
143 | } | 145 | } |
144 | }; | 146 | }; |
145 | $scope.autoCompletar = function() { | 147 | $scope.autoCompletar = function() { |
146 | $scope.aCargar = []; | 148 | $scope.aCargar = []; |
147 | var disponible = $filter('filter')($scope.vehiculo.cisternas, {disabled: false}); | 149 | var disponible = $filter('filter')($scope.cisternas, {disabled: false}); |
148 | var index = $scope.vehiculo.cisternas.indexOf(disponible[0]); | 150 | var index = $scope.cisternas.indexOf(disponible[0]); |
149 | $scope.aCargar[index] = $scope.articuloSeleccionado.cantidad; | 151 | $scope.aCargar[index] = $scope.articuloSeleccionado.cantidad; |
150 | }; | 152 | }; |
151 | $scope.cisternaDisabled = function() { | 153 | $scope.cisternaDisponible = function() { |
152 | for(var i = 0; i < $scope.vehiculo.cisternas.length; i++) { | 154 | for(var i = 0; i < $scope.cisternas.length; i++) { |
153 | var cisterna = $scope.vehiculo.cisternas[i]; | 155 | if($scope.articuloSeleccionado.cantidad > $scope.cisternas[i].disponible) { |
154 | if(!$scope.articuloSeleccionado || ($scope.articuloSeleccionado.idArticulo !== | 156 | $scope.cisternas[i].disabled = true; |
155 | cisterna.cisternaCarga.idProducto && cisterna.cisternaCarga.idProducto) || | 157 | continue; |
156 | !$scope.tieneArticulosPendientes()|| $scope.articuloSeleccionado.cantidad > | 158 | } |
157 | cisterna.disponible) { | 159 | if($scope.cisternas[i].cisternaCarga.idProducto && |
158 | cisterna.disabled = true; | 160 | $scope.articuloSeleccionado.idArticulo !== |
159 | }else { | 161 | $scope.cisternas[i].cisternaCarga.idProducto) |
160 | cisterna.disabled = false; | 162 | { |
161 | } | 163 | $scope.cisternas[i].disabled = true; |
164 | continue; | ||
165 | } | ||
166 | $scope.cisternas[i].disabled = false; | ||
162 | } | 167 | } |
163 | }; | 168 | }; |
164 | $scope.rellenarInput = function(input) { | 169 | $scope.rellenarInput = function(input) { |
165 | if(!$scope.articuloSeleccionado) return; | 170 | if(!$scope.articuloSeleccionado) return; |
166 | if($scope.articuloSeleccionado.cantidad - | 171 | if($scope.articuloSeleccionado.cantidad - |
167 | $scope.articuloSeleccionado.cantidadCargada === 0) { | 172 | $scope.articuloSeleccionado.cantidadCargada === 0) { |
168 | return input; | 173 | return input; |
169 | } | 174 | } |
170 | if(!input) input = 0; | 175 | if(!input) input = 0; |
171 | input = parseFloat(input); | 176 | input = parseFloat(input); |
172 | input += parseFloat($scope.articuloSeleccionado.cantidad - | 177 | input += parseFloat($scope.articuloSeleccionado.cantidad - |
173 | $scope.articuloSeleccionado.cantidadCargada); | 178 | $scope.articuloSeleccionado.cantidadCargada); |
174 | return input; | 179 | return input; |
175 | }; | 180 | }; |
176 | $scope.distribucionDisponible = function() { | 181 | $scope.distribucionDisponible = function() { |
177 | if(!$scope.articuloSeleccionado || $scope.articuloSeleccionado.cantidad - | 182 | if(!$scope.articuloSeleccionado || $scope.articuloSeleccionado.cantidad - |
178 | $scope.articuloSeleccionado.cantidadCargada !== 0 || | 183 | $scope.articuloSeleccionado.cantidadCargada !== 0 || |
179 | !$scope.tieneArticulosPendientes()) { | 184 | !$scope.tieneArticulosPendientes()) { |
180 | return false; | 185 | return false; |
181 | } | 186 | } |
182 | return true; | 187 | return true; |
183 | }; | 188 | }; |
184 | $scope.tieneArticulosPendientes = function() { | 189 | $scope.tieneArticulosPendientes = function() { |
185 | var algunValorNegativo = $scope.aCargar.filter(function(p) { | 190 | var algunValorNegativo = $scope.aCargar.filter(function(p) { |
186 | return p < 0; | 191 | return p < 0; |
187 | }); | 192 | }); |
188 | if(algunValorNegativo.length) { | 193 | if(algunValorNegativo.length) { |
189 | return false; | 194 | return false; |
190 | } | 195 | } |
191 | var articulosDescargados = $scope.articulos.filter(function(filter) { | 196 | var articulosDescargados = $scope.articulos.filter(function(filter) { |
192 | return filter.cargado === true; | 197 | return filter.cargado === true; |
193 | }); | 198 | }); |
src/js/service.js
1 | angular.module('focaLogisticaPedidoRuta') | 1 | angular.module('focaLogisticaPedidoRuta') |
2 | .service( | 2 | .service( |
3 | 'focaLogisticaPedidoRutaService', [ | 3 | 'focaLogisticaPedidoRutaService', [ |
4 | '$http', | 4 | '$http', |
5 | '$cookies', | 5 | '$cookies', |
6 | 'API_ENDPOINT', | 6 | 'API_ENDPOINT', |
7 | '$filter', | 7 | '$filter', |
8 | function($http, $cookies, API_ENDPOINT, $filter) { | 8 | function($http, $cookies, API_ENDPOINT, $filter) { |
9 | return { | 9 | return { |
10 | idUsuario: $cookies.get('idUsuario'), | 10 | idUsuario: $cookies.get('idUsuario'), |
11 | obtenerActividad: function(parametros) { | 11 | obtenerActividad: function(parametros) { |
12 | return $http.post(API_ENDPOINT.URL + '/seguimiento/filtros', parametros); | 12 | return $http.post(API_ENDPOINT.URL + '/seguimiento/filtros', parametros); |
13 | }, | 13 | }, |
14 | obtenerVehiculoById: function(idVehiculo) { | 14 | obtenerVehiculoById: function(idVehiculo) { |
15 | return $http.get(API_ENDPOINT.URL + '/vehiculo/' + idVehiculo); | 15 | return $http.get(API_ENDPOINT.URL + '/vehiculo/' + idVehiculo); |
16 | }, | 16 | }, |
17 | obtenerRemitoById: function(idRemito) { | 17 | obtenerRemitoById: function(idRemito) { |
18 | return $http.get(API_ENDPOINT.URL + '/remito/obtener/' + idRemito); | 18 | return $http.get(API_ENDPOINT.URL + '/remito/obtener/' + idRemito); |
19 | }, | 19 | }, |
20 | guardarCisternas: function(cisterna, idRemito) { | 20 | guardarCisternas: function(cisterna, idRemito) { |
21 | return $http.post(API_ENDPOINT.URL + '/cisterna/guardar/cargar/' + | 21 | return $http.post(API_ENDPOINT.URL + '/cisterna/guardar/cargar/' + |
22 | this.idUsuario + '/' + idRemito,cisterna); | 22 | this.idUsuario + '/' + idRemito,cisterna); |
23 | }, | 23 | }, |
24 | numeroHojaRuta: function() { | 24 | numeroHojaRuta: function() { |
25 | return $http.get(API_ENDPOINT.URL + '/hoja-ruta/numero-siguiente'); | 25 | return $http.get(API_ENDPOINT.URL + '/hoja-ruta/numero-siguiente'); |
26 | }, | 26 | }, |
27 | getRemitos: function(idVehiculo) { | 27 | getRemitos: function(idVehiculo) { |
28 | return $http.get(API_ENDPOINT.URL + '/remito/sin-hoja-ruta/' +idVehiculo); | 28 | return $http.get(API_ENDPOINT.URL + '/remito/sin-hoja-ruta/' +idVehiculo); |
29 | }, | 29 | }, |
30 | crearHojaRuta: function(hojaRuta) { | 30 | crearHojaRuta: function(hojaRuta) { |
31 | return $http.post(API_ENDPOINT.URL + '/hoja-ruta', hojaRuta); | 31 | return $http.post(API_ENDPOINT.URL + '/hoja-ruta', hojaRuta); |
32 | }, | 32 | }, |
33 | desasociarRemitos: function(remitos, idVehiculo, sinRemitos) { | 33 | desasociarRemitos: function(remitos, idVehiculo, sinRemitos) { |
34 | var idsRemitos = []; | 34 | var idsRemitos = []; |
35 | for (var i = 0; i < remitos.length; i++) { | 35 | for (var i = 0; i < remitos.length; i++) { |
36 | idsRemitos.push(remitos[i].id); | 36 | idsRemitos.push(remitos[i].id); |
37 | } | 37 | } |
38 | return $http.post(API_ENDPOINT.URL + '/vehiculo/desasociar-remitos', | 38 | return $http.post(API_ENDPOINT.URL + '/vehiculo/desasociar-remitos', |
39 | { | 39 | { |
40 | idsRemitos: idsRemitos, | 40 | idsRemitos: idsRemitos, |
41 | idVehiculo: idVehiculo, | 41 | idVehiculo: idVehiculo, |
42 | vehiculoSinRemitos: sinRemitos | 42 | vehiculoSinRemitos: sinRemitos |
43 | }); | 43 | }); |
44 | }, | 44 | }, |
45 | obtenerRemitosDeCarga: function(remitos) { | 45 | obtenerRemitosDeCarga: function(remitos) { |
46 | var remitosRes = []; | 46 | var remitosRes = []; |
47 | for(var i = 0; i < remitos.cisternas.length; i++) { | 47 | for(var i = 0; i < remitos.cisternas.length; i++) { |
48 | procesoCistena(remitos.cisternas[i]); | 48 | procesoCistena(remitos.cisternas[i]); |
49 | } | 49 | } |
50 | function procesoCistena(cisterna) { | 50 | function procesoCistena(cisterna) { |
51 | for(var j = 0; j < cisterna.cisternaCarga.cisternaMovimientos.length; | 51 | for(var j = 0; j < cisterna.cisternaCarga.cisternaMovimientos.length; |
52 | j++) { | 52 | j++) { |
53 | procesoMovimiento( | 53 | procesoMovimiento( |
54 | cisterna.cisternaCarga.cisternaMovimientos[j]); | 54 | cisterna.cisternaCarga.cisternaMovimientos[j]); |
55 | } | 55 | } |
56 | } | 56 | } |
57 | function procesoMovimiento(movimiento) { | 57 | function procesoMovimiento(movimiento) { |
58 | if(!movimiento.anulado && movimiento.remito && | 58 | if(!movimiento.anulado && movimiento.remito && |
59 | !movimiento.remito.idHojaRuta) { | 59 | !movimiento.remito.idHojaRuta) { |
60 | var remito = movimiento.remito; | 60 | var remito = movimiento.remito; |
61 | var yaEstaCargado = $filter('filter')(remitosRes, {id: remito.id}); | 61 | var yaEstaCargado = $filter('filter')(remitosRes, {id: remito.id}); |
62 | if(!yaEstaCargado.length && movimiento.metodo === 'carga') { | 62 | if(!yaEstaCargado.length && movimiento.metodo === 'carga') { |
63 | remitosRes.push(remito); | 63 | remitosRes.push(remito); |
64 | } | 64 | } |
65 | } | 65 | } |
66 | } | 66 | } |
67 | return remitosRes; | 67 | return remitosRes; |
68 | }, | 68 | }, |
69 | getVehiculosByIdUsuario: function() { | 69 | getVehiculosByIdUsuario: function() { |
70 | return $http.get(API_ENDPOINT.URL + '/vehiculo/usuario/' + this.idUsuario); | 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 | }]); |
74 | 78 |
src/views/foca-detalle-vehiculo.html
1 | <div class="modal-header"> | 1 | <div class="modal-header"> |
2 | <h4>Detalle de carga</h4> | 2 | <h4>Detalle de carga</h4> |
3 | Transportista | 3 | Transportista |
4 | <strong ng-bind="vehiculo.transportista.COD"></strong> | 4 | <strong ng-bind="vehiculo.transportista.COD"></strong> |
5 | <strong ng-bind="vehiculo.transportista.NOM"></strong> | 5 | <strong ng-bind="vehiculo.transportista.NOM"></strong> |
6 | Unidad <strong ng-bind="vehiculo.codigo"></strong> | 6 | Unidad <strong ng-bind="vehiculo.codigo"></strong> |
7 | Tractor <strong ng-bind="vehiculo.tractor"></strong> | 7 | Tractor <strong ng-bind="vehiculo.tractor"></strong> |
8 | <br> | 8 | <br> |
9 | <div ng-show="idRemito !== -1"> | 9 | <div ng-show="idRemito !== -1"> |
10 | <span>Remito Nº</span> | 10 | <span>Remito Nº</span> |
11 | <strong ng-bind="[remito.sucursal, remito.numeroRemito] | comprobante"></strong> | 11 | <strong ng-bind="[remito.sucursal, remito.numeroRemito] | comprobante"></strong> |
12 | <span>, Fecha</span> | 12 | <span>, Fecha</span> |
13 | <strong ng-bind="remito.fechaRemito | date: 'dd/MM/yyyy HH:mm'"></strong> | 13 | <strong ng-bind="remito.fechaRemito | date: 'dd/MM/yyyy HH:mm'"></strong> |
14 | <span>, Cliente</span> | 14 | <span>, Cliente</span> |
15 | <strong ng-bind="remito.nombreCliente"></strong> | 15 | <strong ng-bind="remito.nombreCliente"></strong> |
16 | <span>, Domicilio entrega</span> | 16 | <span>, Domicilio entrega</span> |
17 | <strong ng-bind="remito.domicilioStamp"></strong> | 17 | <strong ng-bind="remito.domicilioStamp"></strong> |
18 | </div> | 18 | </div> |
19 | </div> | 19 | </div> |
20 | <div class="modal-body"> | 20 | <div class="modal-body"> |
21 | <div> | 21 | <div> |
22 | <table class="table table-sm" ng-show="idRemito !== -1"> | 22 | <table class="table table-sm" ng-show="idRemito !== -1"> |
23 | <thead> | 23 | <thead> |
24 | <tr> | 24 | <tr> |
25 | <th></th> | 25 | <th></th> |
26 | <th>Articulo</th> | 26 | <th>Articulo</th> |
27 | <th>Cantidad</th> | 27 | <th>Cantidad</th> |
28 | <th>Cargado</th> | 28 | <th>Cargado</th> |
29 | <th>Resta asignar</th> | 29 | <th>Resta asignar</th> |
30 | </tr> | 30 | </tr> |
31 | </thead> | 31 | </thead> |
32 | <tbody> | 32 | <tbody> |
33 | <tr ng-repeat="(key, articulo) in articulos"> | 33 | <tr ng-repeat="(key, articulo) in articulos"> |
34 | <td><input | 34 | <td><input |
35 | type="radio" | 35 | type="radio" |
36 | name="articuloRadio" | 36 | name="articuloRadio" |
37 | id="{{'articulo' + articulo.id}}" | 37 | id="{{'articulo' + articulo.id}}" |
38 | ng-checked="articuloSeleccionado.id === articulo.id" | 38 | ng-checked="articuloSeleccionado.id === articulo.id" |
39 | ng-disabled="articulo.cargado" | 39 | ng-disabled="articulo.cargado" |
40 | ng-click="seleccionarArticulo(articulo)" | 40 | ng-click="seleccionarArticulo(articulo)" |
41 | ></td> | 41 | ></td> |
42 | <td ng-bind="articulo.descripcion"></td> | 42 | <td ng-bind="articulo.descripcion"></td> |
43 | <td ng-bind="articulo.cantidad"></td> | 43 | <td ng-bind="articulo.cantidad"></td> |
44 | <td ng-bind="articulo.cantidadCargada || 0"></td> | 44 | <td ng-bind="articulo.cantidadCargada || 0"></td> |
45 | <td ng-bind="articulo.cantidad - articulo.cantidadCargada"></td> | 45 | <td ng-bind="articulo.cantidad - articulo.cantidadCargada"></td> |
46 | </tr> | 46 | </tr> |
47 | </tbody> | 47 | </tbody> |
48 | </table> | 48 | </table> |
49 | <table class="table table-sm" ladda="cargandoDatos" data-spinner-color="#FF0000"> | 49 | <table class="table table-sm" ladda="cargandoDatos" data-spinner-color="#FF0000"> |
50 | <thead> | 50 | <thead> |
51 | <tr> | 51 | <tr> |
52 | <th width="10%">Cisterna</th> | 52 | <th width="10%">Cisterna</th> |
53 | <th>Capacidad</th> | 53 | <th>Capacidad</th> |
54 | <th>Articulo cargado</th> | 54 | <th>Articulo cargado</th> |
55 | <th width="20%">Asignado</th> | 55 | <th width="20%">Asignado</th> |
56 | <th>Cargado / Capacidad Disponible</th> | 56 | <th>Cargado / Capacidad Disponible</th> |
57 | </tr> | 57 | </tr> |
58 | </thead> | 58 | </thead> |
59 | <tbody> | 59 | <tbody> |
60 | <tr ng-repeat="(key, cisterna) in vehiculo.cisternas"> | 60 | <tr ng-repeat="(key, cisterna) in cisternas"> |
61 | <td class="py-3" ng-bind="cisterna.codigo"></td> | 61 | <td class="py-3" ng-bind="cisterna.codigo"></td> |
62 | <td class="py-3" ng-bind="cisterna.capacidad"></td> | 62 | <td class="py-3" ng-bind="cisterna.capacidad"></td> |
63 | <td class="py-3" ng-bind="cisterna.cisternaCarga.articulo.DetArt || 'Sin asignar'"></td> | 63 | <td class="py-3" ng-bind="cisterna.cisternaCarga.articulo.DetArt || 'Sin asignar'"></td> |
64 | <td ng-if="idRemito != -1"> | 64 | <td ng-if="idRemito != -1"> |
65 | <input | 65 | <input |
66 | class="form-control" | 66 | class="form-control" |
67 | foca-tipo-input | 67 | foca-tipo-input |
68 | foca-teclado | 68 | foca-teclado |
69 | placeholder="A cargar..." | 69 | placeholder="A cargar..." |
70 | ng-model="aCargar[key]" | 70 | ng-model="aCargar[key]" |
71 | ng-disabled="cisterna.disabled" | 71 | ng-disabled="cisterna.disabled || !tieneArticulosPendientes()" |
72 | ng-focus="aCargar[key] = rellenarInput(aCargar[key]); actualizarArticulo()" | 72 | ng-focus="aCargar[key] = rellenarInput(aCargar[key]); actualizarArticulo()" |
73 | ng-change="actualizarArticulo()" | 73 | ng-change="actualizarArticulo()" |
74 | > | 74 | > |
75 | </td> | 75 | </td> |
76 | <td ng-if="idRemito == -1"> | 76 | <td ng-if="idRemito == -1"> |
77 | <input | 77 | <input |
78 | class="form-control" | 78 | class="form-control" |
79 | placeholder="A cargar..." | 79 | placeholder="A cargar..." |
80 | readonly> | 80 | readonly> |
81 | </td> | 81 | </td> |
82 | <td><div class="progress foca-alto-progress pl-0 pr-0 mt-1"> | 82 | <td><div class="progress foca-alto-progress pl-0 pr-0 mt-1"> |
83 | <strong | 83 | <strong |
84 | class="mt-2 col-4 text-center position-absolute" | 84 | class="mt-2 col-4 text-center position-absolute" |
85 | ng-bind="(cisterna.cisternaCarga.cantidad || 0) + '/' + | 85 | ng-bind="(cisterna.cisternaCarga.cantidad || 0) + '/' + |
86 | (cisterna.capacidad - cisterna.cisternaCarga.cantidad)"> | 86 | (cisterna.capacidad - cisterna.cisternaCarga.cantidad)"> |
87 | </strong> | 87 | </strong> |
88 | <div | 88 | <div |
89 | id="{{cisterna.id}}" | 89 | id="{{cisterna.id}}" |
90 | class="progress-bar" | 90 | class="progress-bar" |
91 | role="progressbar" | 91 | role="progressbar" |
92 | aria-valuemin="0" | 92 | aria-valuemin="0" |
93 | aria-valuemax="{{cisterna.capacidad}}" | 93 | aria-valuemax="{{cisterna.capacidad}}" |
94 | ng-style="{'width':'{{calcularPorcentaje(cisterna)}}'}"> | 94 | ng-style="{'width':'{{calcularPorcentaje(cisterna)}}'}"> |
95 | </div> | 95 | </div> |
96 | </div> | 96 | </div> |
97 | </td> | 97 | </td> |
98 | </tr> | 98 | </tr> |
99 | </tbody> | 99 | </tbody> |
100 | </table> | 100 | </table> |
101 | <div class="col-12"> | 101 | <div class="col-12"> |
102 | <button | 102 | <button |
103 | class="form-control btn btn-success" | 103 | class="form-control btn btn-success" |
104 | ladda="cargando" | 104 | ladda="cargando" |
105 | data-spinner-color="#FF0000" | 105 | data-spinner-color="#FF0000" |
106 | type="button" | 106 | type="button" |
107 | ng-disabled="!distribucionDisponible()" | 107 | ng-disabled="!distribucionDisponible()" |
108 | ng-class="{'btn-light': !distribucionDisponible()}" | 108 | ng-class="{'btn-light': !distribucionDisponible()}" |
109 | ng-click="cargarACisternas(vehiculo)" | 109 | ng-click="cargarACisternas(vehiculo)" |
110 | foca-focus="distribucionDisponible()"> | 110 | foca-focus="distribucionDisponible()"> |
111 | Aplicar distribución de cargas | 111 | Aplicar distribución de cargas |
112 | </button> | 112 | </button> |
113 | </div> | 113 | </div> |
114 | </div> | 114 | </div> |
115 | </div> | 115 | </div> |
116 | <div class="modal-footer py-1"> | 116 | <div class="modal-footer py-1"> |
117 | <button | 117 | <button |
118 | class="btn btn-sm btn-secondary" | 118 | class="btn btn-sm btn-secondary" |
119 | ladda="cargando" | 119 | ladda="cargando" |
120 | type="button" | 120 | type="button" |
121 | ng-click="cancelar()">Cancelar</button> | 121 | ng-click="cancelar()">Cancelar</button> |
122 | <button | 122 | <button |
123 | class="btn btn-sm btn-primary" | 123 | class="btn btn-sm btn-primary" |
124 | ladda="cargando" | 124 | ladda="cargando" |
125 | type="button" | 125 | type="button" |
126 | ng-click="aceptar()" | 126 | ng-click="aceptar()" |
127 | ng-disabled="tieneArticulosPendientes() || idRemito === -1" | 127 | ng-disabled="tieneArticulosPendientes() || idRemito === -1" |
128 | foca-focus="!tieneArticulosPendientes() && idRemito !== -1">Cargar</button> | 128 | foca-focus="!tieneArticulosPendientes() && idRemito !== -1">Cargar</button> |
129 | </div> | 129 | </div> |
130 | 130 |