Commit c93c5a0d3cf40a8e03614075b78b72e7c53be6ab
Exists in
master
and in
2 other branches
Merge branch 'master' into 'master'
Master See merge request !12
Showing
2 changed files
Show diff stats
src/js/controller.js
1 | angular.module('focaModalDetalleCisternas') | 1 | angular.module('focaModalDetalleCisternas') |
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 | 'focaModalDetalleCisternasService', | 9 | 'focaModalDetalleCisternasService', |
10 | 'fechaReparto', | 10 | 'fechaReparto', |
11 | function($scope, $uibModalInstance, idVehiculo, idRemito, focaModalService, $filter, | 11 | function($scope, $uibModalInstance, idVehiculo, idRemito, focaModalService, $filter, |
12 | focaModalDetalleCisternasService, fechaReparto | 12 | focaModalDetalleCisternasService, fechaReparto |
13 | ) { | 13 | ) { |
14 | //seteo variables | 14 | //seteo variables |
15 | $scope.cargandoDatos = true; | 15 | $scope.cargandoDatos = true; |
16 | $scope.idRemito = idRemito; | 16 | $scope.idRemito = idRemito; |
17 | $scope.articulos = []; | 17 | $scope.articulos = []; |
18 | $scope.vehiculo = {}; | 18 | $scope.vehiculo = {}; |
19 | $scope.cisternas = []; | 19 | $scope.cisternas = []; |
20 | $scope.cisternasCarga = []; | 20 | $scope.cisternasCarga = []; |
21 | $scope.remito = {}; | 21 | $scope.remito = {}; |
22 | $scope.aCargar = []; | 22 | $scope.aCargar = []; |
23 | var cisternaMovimientos = []; | 23 | var cisternaMovimientos = []; |
24 | var promesaRemito; | 24 | var promesaRemito; |
25 | 25 | ||
26 | if(fechaReparto) { | 26 | if(fechaReparto) { |
27 | focaModalDetalleCisternasService.fecha = fechaReparto; | 27 | focaModalDetalleCisternasService.fecha = fechaReparto; |
28 | } | 28 | } |
29 | var promesaVehiculo = focaModalDetalleCisternasService.obtenerVehiculoById(idVehiculo); | 29 | var promesaVehiculo = focaModalDetalleCisternasService.obtenerVehiculoById(idVehiculo); |
30 | var promesaCisternas = focaModalDetalleCisternasService | 30 | var promesaCisternas = focaModalDetalleCisternasService |
31 | .obtenerCisternasPorFecha(idVehiculo); | 31 | .obtenerCisternasPorFecha(idVehiculo); |
32 | if(idRemito !== -1) { | 32 | if(idRemito !== -1) { |
33 | promesaRemito = focaModalDetalleCisternasService.obtenerRemitoById(idRemito); | 33 | promesaRemito = focaModalDetalleCisternasService.obtenerRemitoById(idRemito); |
34 | } | 34 | } |
35 | Promise.all([promesaVehiculo, promesaCisternas, promesaRemito]).then(function(res) { | 35 | Promise.all([promesaVehiculo, promesaCisternas, promesaRemito]).then(function(res) { |
36 | $scope.cargandoDatos = false; | 36 | $scope.cargandoDatos = false; |
37 | $scope.vehiculo = res[0].data; | 37 | $scope.vehiculo = res[0].data; |
38 | $scope.cisternas = res[1].data; | 38 | $scope.cisternas = res[1].data; |
39 | if(!$scope.cisternas.length) { | 39 | if(!$scope.cisternas.length) { |
40 | focaModalService.alert('El vehículo no tiene cisternas'); | 40 | focaModalService.alert('El vehículo no tiene cisternas'); |
41 | $uibModalInstance.dismiss(); | 41 | $uibModalInstance.dismiss(); |
42 | return; | 42 | return; |
43 | } | 43 | } |
44 | if(!res[2]) { | 44 | if(!res[2]) { |
45 | $scope.$digest(); | 45 | $scope.$digest(); |
46 | return; | 46 | return; |
47 | } | 47 | } |
48 | $scope.remito = res[2].data; | 48 | $scope.remito = res[2].data; |
49 | if($scope.remito.idUsuarioProceso) { | 49 | if($scope.remito.idUsuarioProceso) { |
50 | focaModalService.alert('Remito ya asignado'); | 50 | focaModalService.alert('Remito ya asignado'); |
51 | $uibModalInstance.close(); | 51 | $uibModalInstance.close(); |
52 | } | 52 | } |
53 | $scope.articulos = $scope.remito.articulosRemito; | 53 | $scope.articulos = $scope.remito.articulosRemito; |
54 | if(!$scope.articulos.length) { | 54 | if(!$scope.articulos.length) { |
55 | focaModalService.alert('El remito no tiene articulos'); | 55 | focaModalService.alert('El remito no tiene articulos'); |
56 | $uibModalInstance.dismiss(); | 56 | $uibModalInstance.dismiss(); |
57 | return; | 57 | return; |
58 | } | 58 | } |
59 | 59 | ||
60 | $scope.seleccionarArticulo($scope.articulos[0]); | 60 | $scope.seleccionarArticulo($scope.articulos[0]); |
61 | var tieneUsuario = $scope.cisternas.filter(function(cisterna) { | 61 | var tieneUsuario = $scope.cisternas.filter(function(cisterna) { |
62 | if(cisterna.cisternaCarga && cisterna.cisternaCarga.idUsuarioProceso) { | 62 | if(cisterna.cisternaCarga && cisterna.cisternaCarga.idUsuarioProceso) { |
63 | return cisterna.cisternaCarga.idUsuarioProceso !== | 63 | return cisterna.cisternaCarga.idUsuarioProceso !== |
64 | focaModalDetalleCisternasService.idUsuario; | 64 | focaModalDetalleCisternasService.idUsuario; |
65 | } | 65 | } |
66 | }); | 66 | }); |
67 | if(tieneUsuario.length) { | 67 | if(tieneUsuario.length) { |
68 | focaModalService.alert('Otro usario esta usando este vehículo'); | 68 | focaModalService.alert('Otro usario esta usando este vehículo'); |
69 | $uibModalInstance.close(); | 69 | $uibModalInstance.close(); |
70 | } | 70 | } |
71 | $scope.$digest(); | 71 | $scope.$digest(); |
72 | }); | 72 | }); |
73 | $scope.aceptar = function() { | 73 | $scope.aceptar = function() { |
74 | $scope.cargando = true; | 74 | $scope.cargando = true; |
75 | for(var i = 0; i < $scope.cisternasCarga.length; i++) { | 75 | for(var i = 0; i < $scope.cisternasCarga.length; i++) { |
76 | $scope.cisternasCarga[i].idUsuarioProceso = | 76 | $scope.cisternasCarga[i].idUsuarioProceso = |
77 | focaModalDetalleCisternasService.idUsuario; | 77 | focaModalDetalleCisternasService.idUsuario; |
78 | delete $scope.cisternasCarga[i].articulo; | 78 | delete $scope.cisternasCarga[i].articulo; |
79 | } | 79 | } |
80 | var cisterna = { | 80 | var cisterna = { |
81 | cisternaMovimientos: cisternaMovimientos, | 81 | cisternaMovimientos: cisternaMovimientos, |
82 | cisternaCargas: $scope.cisternasCarga, | 82 | cisternaCargas: $scope.cisternasCarga, |
83 | idVehiculo: $scope.vehiculo.id, | 83 | idVehiculo: $scope.vehiculo.id, |
84 | fechaReparto: focaModalDetalleCisternasService.fecha | 84 | fechaReparto: focaModalDetalleCisternasService.fecha |
85 | }; | 85 | }; |
86 | if(!focaModalDetalleCisternasService.idUsuario) { | 86 | if(!focaModalDetalleCisternasService.idUsuario) { |
87 | focaModalService.alert('No logeado como vendedor'); | 87 | focaModalService.alert('No logeado como vendedor'); |
88 | $scope.cargando = false; | 88 | $scope.cargando = false; |
89 | return; | 89 | return; |
90 | } | 90 | } |
91 | focaModalDetalleCisternasService.guardarCisternas(cisterna, $scope.remito.id) | 91 | focaModalDetalleCisternasService.guardarCisternas(cisterna, $scope.remito.id) |
92 | .then(function() { | 92 | .then(function() { |
93 | $scope.cargando = false; | 93 | $scope.cargando = false; |
94 | $uibModalInstance.close(); | 94 | $uibModalInstance.close(); |
95 | }).catch(function(error) { | 95 | }).catch(function(error) { |
96 | $scope.cargando = false; | 96 | $scope.cargando = false; |
97 | $uibModalInstance.close(); | 97 | $uibModalInstance.close(); |
98 | if (error.status === 403) { | 98 | if (error.status === 403) { |
99 | focaModalService.alert('ERROR: ' + error.data); | 99 | focaModalService.alert('ERROR: ' + error.data); |
100 | return; | 100 | return; |
101 | } | 101 | } |
102 | focaModalService.alert('Hubo un error al cargar las cisternas'); | 102 | focaModalService.alert('Hubo un error al cargar las cisternas'); |
103 | }); | 103 | }); |
104 | }; | 104 | }; |
105 | $scope.cancelar = function() { | 105 | $scope.cancelar = function() { |
106 | $uibModalInstance.dismiss(); | 106 | $uibModalInstance.dismiss(); |
107 | }; | 107 | }; |
108 | $scope.cargarACisternas = function() { | 108 | $scope.cargarACisternas = function() { |
109 | for(var i = 0; i < $scope.cisternas.length; i++) { | 109 | for(var i = 0; i < $scope.cisternas.length; i++) { |
110 | var cisterna = $scope.cisternas[i]; | 110 | var cisterna = $scope.cisternas[i]; |
111 | var aCargar = parseFloat($scope.aCargar[i]); | 111 | var aCargar = parseFloat($scope.aCargar[i]); |
112 | var fechaReparto = focaModalDetalleCisternasService.fecha; | 112 | var fechaReparto = focaModalDetalleCisternasService.fecha; |
113 | //validaciones | 113 | //validaciones |
114 | if(!aCargar) { | 114 | if(!aCargar) { |
115 | continue; | 115 | continue; |
116 | } | 116 | } |
117 | //cargar | 117 | //cargar |
118 | if(cisterna.cisternaCarga.cantidad) { | 118 | if(cisterna.cisternaCarga.cantidad) { |
119 | cisterna.cisternaCarga.cantidad += aCargar; | 119 | cisterna.cisternaCarga.cantidad += aCargar; |
120 | }else { | 120 | }else { |
121 | cisterna.cisternaCarga.cantidad = aCargar; | 121 | cisterna.cisternaCarga.cantidad = aCargar; |
122 | cisterna.cisternaCarga.idProducto = $scope.articuloSeleccionado.idArticulo; | 122 | cisterna.cisternaCarga.idProducto = $scope.articuloSeleccionado.idArticulo; |
123 | } | 123 | } |
124 | cisterna.disponible = cisterna.capacidad - cisterna.cisternaCarga.cantidad; | 124 | cisterna.disponible = cisterna.capacidad - cisterna.cisternaCarga.cantidad; |
125 | 125 | ||
126 | cisterna.cisternaCarga.articulo = { | 126 | cisterna.cisternaCarga.articulo = { |
127 | DetArt: $scope.articuloSeleccionado.descripcion | 127 | DetArt: $scope.articuloSeleccionado.descripcion |
128 | }; | 128 | }; |
129 | $filter('filter')($scope.articulos, {id: $scope.articuloSeleccionado.id})[0] | 129 | $filter('filter')($scope.articulos, {id: $scope.articuloSeleccionado.id})[0] |
130 | .cargado = true; | 130 | .cargado = true; |
131 | 131 | ||
132 | $scope.calcularPorcentaje(cisterna); | 132 | $scope.calcularPorcentaje(cisterna); |
133 | //Guardar | 133 | //Guardar |
134 | var now = new Date(); | 134 | var now = new Date(); |
135 | var cisternaMovimiento = { | 135 | var cisternaMovimiento = { |
136 | fecha: now.toISOString().slice(0, 19).replace('T', ' '), | 136 | fecha: now.toISOString().slice(0, 19).replace('T', ' '), |
137 | cantidad: aCargar, | 137 | cantidad: aCargar, |
138 | metodo: 'carga', | 138 | metodo: 'carga', |
139 | idCisternaCarga: cisterna.cisternaCarga.id, | 139 | idCisternaCarga: cisterna.cisternaCarga.id, |
140 | idRemito: $scope.remito.id | 140 | idRemito: $scope.remito.id |
141 | }; | 141 | }; |
142 | cisterna.cisternaCarga.fechaReparto = fechaReparto; | 142 | cisterna.cisternaCarga.fechaReparto = fechaReparto; |
143 | cisterna.cisternaCarga.idCisterna = cisterna.id; | 143 | cisterna.cisternaCarga.idCisterna = cisterna.id; |
144 | $scope.cisternasCarga.push(cisterna.cisternaCarga); | 144 | $scope.cisternasCarga.push(cisterna.cisternaCarga); |
145 | cisternaMovimientos.push(cisternaMovimiento); | 145 | cisternaMovimientos.push(cisternaMovimiento); |
146 | } | 146 | } |
147 | var articuloSiguiente = $scope.articulos.filter( | 147 | var articuloSiguiente = $scope.articulos.filter( |
148 | function(filter) { | 148 | function(filter) { |
149 | return filter.cargado !== true; | 149 | return filter.cargado !== true; |
150 | } | 150 | } |
151 | ); | 151 | ); |
152 | if(articuloSiguiente.length > 0) { | 152 | if(articuloSiguiente.length > 0) { |
153 | $scope.seleccionarArticulo(articuloSiguiente[0]); | 153 | $scope.seleccionarArticulo(articuloSiguiente[0]); |
154 | } | 154 | } |
155 | }; | 155 | }; |
156 | $scope.calcularPorcentaje = function(cisterna) { | 156 | $scope.calcularPorcentaje = function(cisterna) { |
157 | if(!cisterna.cisternaCarga) { | 157 | if(!cisterna.cisternaCarga) { |
158 | cisterna.cisternaCarga = { | 158 | cisterna.cisternaCarga = { |
159 | cantidad: 0 | 159 | cantidad: 0 |
160 | }; | 160 | }; |
161 | } | 161 | } |
162 | var porcentaje = (cisterna.cisternaCarga.cantidad * 100 / | 162 | var porcentaje = (cisterna.cisternaCarga.cantidad * 100 / |
163 | cisterna.capacidad) + '%'; | 163 | cisterna.capacidad) + '%'; |
164 | var elementHtml = document.getElementById(cisterna.id); | 164 | var elementHtml = document.getElementById(cisterna.id); |
165 | if(elementHtml) { | 165 | if(elementHtml) { |
166 | elementHtml.style.width = porcentaje; | 166 | elementHtml.style.width = porcentaje; |
167 | } | 167 | } |
168 | }; | 168 | }; |
169 | 169 | ||
170 | $scope.seleccionarArticulo = function(articulo) { | 170 | $scope.seleccionarArticulo = function(articulo) { |
171 | $scope.articuloSeleccionado = articulo; | 171 | $scope.articuloSeleccionado = articulo; |
172 | $scope.cisternaDisponible(); | 172 | $scope.cisternaDisponible(); |
173 | $scope.autoCompletar(); | 173 | $scope.autoCompletar(); |
174 | $scope.actualizarArticulo(); | 174 | $scope.actualizarArticulo(); |
175 | }; | 175 | }; |
176 | 176 | ||
177 | $scope.actualizarArticulo = function() { | 177 | $scope.actualizarArticulo = function() { |
178 | $scope.articuloSeleccionado.cantidadCargada = 0; | 178 | $scope.articuloSeleccionado.cantidadCargada = 0; |
179 | for(var i = 0; i < $scope.aCargar.length; i++) { | 179 | for(var i = 0; i < $scope.aCargar.length; i++) { |
180 | $scope.articuloSeleccionado.cantidadCargada += | 180 | $scope.articuloSeleccionado.cantidadCargada += |
181 | parseFloat($scope.aCargar[i]) || 0; | 181 | parseFloat($scope.aCargar[i]) || 0; |
182 | } | 182 | } |
183 | }; | 183 | }; |
184 | 184 | ||
185 | $scope.autoCompletar = function() { | 185 | $scope.autoCompletar = function() { |
186 | var arrayMismoProducto = []; | 186 | var arrayMismoProducto = []; |
187 | var arrayVacioProducto = []; | 187 | var arrayVacioProducto = []; |
188 | for(var i = 0; i < $scope.cisternas.length; i++) { | 188 | for(var i = 0; i < $scope.cisternas.length; i++) { |
189 | var cisterna = $scope.cisternas[i]; | 189 | var cisterna = $scope.cisternas[i]; |
190 | cisterna.posicion = i; | 190 | cisterna.posicion = i; |
191 | console.info(i, cisterna.posicion); | 191 | console.info(i, cisterna.posicion); |
192 | if (!cisterna.disabled && cisterna.disponible > 0) { | 192 | if (!cisterna.disabled && cisterna.disponible > 0) { |
193 | if (cisterna.cisternaCarga) { | 193 | if (cisterna.cisternaCarga) { |
194 | arrayMismoProducto.push(cisterna); | 194 | arrayMismoProducto.push(cisterna); |
195 | } else { | 195 | } else { |
196 | arrayVacioProducto.push(cisterna); | 196 | arrayVacioProducto.push(cisterna); |
197 | } | 197 | } |
198 | } | 198 | } |
199 | } | 199 | } |
200 | 200 | ||
201 | arrayMismoProducto.sort(function(a,b) { | 201 | arrayMismoProducto.sort(function(a,b) { |
202 | return a.disponible - b.disponible; | 202 | return a.disponible - b.disponible; |
203 | }); | 203 | }); |
204 | 204 | ||
205 | var cisternas = arrayMismoProducto.concat(arrayVacioProducto); | 205 | var cisternas = arrayMismoProducto.concat(arrayVacioProducto); |
206 | 206 | ||
207 | for (var j = 0; j < cisternas.length; j++) { | 207 | for (var j = 0; j < cisternas.length; j++) { |
208 | var aCargar = $scope.articuloSeleccionado.cantidad - | 208 | var aCargar = $scope.articuloSeleccionado.cantidad - |
209 | ($scope.articuloSeleccionado.cantidadCargada || 0); | 209 | ($scope.articuloSeleccionado.cantidadCargada || 0); |
210 | 210 | ||
211 | if(aCargar > cisternas[j].disponible) { | 211 | if(aCargar > cisternas[j].disponible) { |
212 | aCargar = cisternas[j].disponible; | 212 | aCargar = cisternas[j].disponible; |
213 | } | 213 | } |
214 | 214 | ||
215 | if(aCargar > 0) { | 215 | if(aCargar > 0) { |
216 | $scope.aCargar[cisternas[j].posicion] = aCargar; | 216 | $scope.aCargar[cisternas[j].posicion] = aCargar; |
217 | $scope.actualizarArticulo(); | 217 | $scope.actualizarArticulo(); |
218 | } | 218 | } |
219 | } | 219 | } |
220 | }; | 220 | }; |
221 | $scope.cisternaDisponible = function() { | 221 | $scope.cisternaDisponible = function() { |
222 | for(var i = 0; i < $scope.cisternas.length; i++) { | 222 | for(var i = 0; i < $scope.cisternas.length; i++) { |
223 | //Puede meter un porcentaje del total | 223 | //Puede meter un porcentaje del total |
224 | // if($scope.articuloSeleccionado.cantidad > $scope.cisternas[i].disponible) { | 224 | // if($scope.articuloSeleccionado.cantidad > $scope.cisternas[i].disponible) { |
225 | // $scope.cisternas[i].disabled = true; | 225 | // $scope.cisternas[i].disabled = true; |
226 | // continue; | 226 | // continue; |
227 | // } | 227 | // } |
228 | if($scope.cisternas[i].cisternaCarga && | 228 | if($scope.cisternas[i].cisternaCarga && |
229 | $scope.cisternas[i].cisternaCarga.idProducto && | 229 | $scope.cisternas[i].cisternaCarga.idProducto && |
230 | $scope.articuloSeleccionado.idArticulo !== | 230 | $scope.articuloSeleccionado.idArticulo !== |
231 | $scope.cisternas[i].cisternaCarga.idProducto) | 231 | $scope.cisternas[i].cisternaCarga.idProducto) |
232 | { | 232 | { |
233 | $scope.cisternas[i].disabled = true; | 233 | $scope.cisternas[i].disabled = true; |
234 | continue; | 234 | continue; |
235 | } | 235 | } |
236 | $scope.cisternas[i].disabled = false; | 236 | $scope.cisternas[i].disabled = false; |
237 | } | 237 | } |
238 | }; | 238 | }; |
239 | $scope.rellenarInput = function(input, cisterna) { | 239 | $scope.rellenarInput = function(input, cisterna) { |
240 | if(!$scope.articuloSeleccionado) return; | 240 | if(!$scope.articuloSeleccionado) return; |
241 | if($scope.articuloSeleccionado.cantidad - | 241 | if($scope.articuloSeleccionado.cantidad - |
242 | $scope.articuloSeleccionado.cantidadCargada === 0) { | 242 | $scope.articuloSeleccionado.cantidadCargada === 0) { |
243 | return input; | 243 | return input; |
244 | } | 244 | } |
245 | if(!input) input = 0; | 245 | if(!input) input = 0; |
246 | input = parseFloat(input); | 246 | input = parseFloat(input); |
247 | input += parseFloat($scope.articuloSeleccionado.cantidad - | 247 | input += parseFloat($scope.articuloSeleccionado.cantidad - |
248 | $scope.articuloSeleccionado.cantidadCargada); | 248 | $scope.articuloSeleccionado.cantidadCargada); |
249 | if(input <= 0) return; | 249 | if(input <= 0) return; |
250 | if(input > cisterna.disponible) { | 250 | if(input > cisterna.disponible) { |
251 | input = cisterna.disponible; | 251 | input = cisterna.disponible; |
252 | } | 252 | } |
253 | return input; | 253 | return input; |
254 | }; | 254 | }; |
255 | $scope.distribucionDisponible = function() { | 255 | $scope.distribucionDisponible = function() { |
256 | if(!$scope.articuloSeleccionado || $scope.articuloSeleccionado.cantidad - | 256 | if(!$scope.articuloSeleccionado || $scope.articuloSeleccionado.cantidad - |
257 | $scope.articuloSeleccionado.cantidadCargada !== 0 || | 257 | $scope.articuloSeleccionado.cantidadCargada !== 0 || |
258 | !$scope.tieneArticulosPendientes()) { | 258 | !$scope.tieneArticulosPendientes()) { |
259 | return false; | 259 | return false; |
260 | } | 260 | } |
261 | for(var i = 0; i < $scope.cisternas.length; i++) { | 261 | for(var i = 0; i < $scope.cisternas.length; i++) { |
262 | if($scope.aCargar[i] > $scope.cisternas[i].disponible) { | 262 | if($scope.aCargar[i] > $scope.cisternas[i].disponible) { |
263 | return false; | 263 | return false; |
264 | } | 264 | } |
265 | } | 265 | } |
266 | return true; | 266 | return true; |
267 | }; | 267 | }; |
268 | $scope.tieneArticulosPendientes = function() { | 268 | $scope.tieneArticulosPendientes = function() { |
269 | var algunValorNegativo = $scope.aCargar.filter(function(p) { | 269 | var algunValorNegativo = $scope.aCargar.filter(function(p) { |
270 | return p < 0; | 270 | return p < 0; |
271 | }); | 271 | }); |
272 | if(algunValorNegativo.length) { | 272 | if(algunValorNegativo.length) { |
273 | return false; | 273 | return false; |
274 | } | 274 | } |
275 | var articulosDescargados = $scope.articulos.filter(function(filter) { | 275 | var articulosDescargados = $scope.articulos.filter(function(filter) { |
276 | return filter.cargado === true; | 276 | return filter.cargado === true; |
277 | }); | 277 | }); |
278 | if(articulosDescargados.length === $scope.articulos.length) { | 278 | if(articulosDescargados.length === $scope.articulos.length) { |
279 | $scope.aCargar = []; | 279 | $scope.aCargar = []; |
280 | return false; | 280 | return false; |
281 | } | 281 | } |
282 | return true; | 282 | return true; |
283 | }; | 283 | }; |
284 | |||
285 | $scope.verRemitos = function(data) { | ||
286 | var parametrosModal = { | ||
287 | titulo: 'Remitos cargados', | ||
288 | data: data, | ||
289 | soloMostrar: true, | ||
290 | columnas: [ | ||
291 | { | ||
292 | nombre: 'Fecha', | ||
293 | propiedad: 'fechaRemito', | ||
294 | filtro: { | ||
295 | nombre: 'date', | ||
296 | parametro:'dd/MM/yyyy' | ||
297 | } | ||
298 | }, | ||
299 | { | ||
300 | nombre: 'Cliente', | ||
301 | propiedad: 'nombreCliente' | ||
302 | }, | ||
303 | { | ||
304 | nombre: 'Comprobante', | ||
305 | propiedad: ['sucursal', 'numeroRemito'], | ||
306 | filtro: { | ||
307 | nombre: 'comprobante' | ||
308 | } | ||
309 | }, | ||
310 | { | ||
311 | nombre: 'Importe', | ||
312 | propiedad: 'total' | ||
313 | } | ||
314 | ] | ||
315 | }; | ||
316 | focaModalService.modal(parametrosModal).then(function(transportista) { | ||
317 | $scope.selectVehiculo(transportista.COD, transportista.NOM); | ||
318 | }); | ||
319 | }; | ||
284 | }]); | 320 | }]); |
285 | 321 |
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%">Por asignar</th> | 55 | <th width="20%">Por asignar</th> |
56 | <th>Cargado / Capacidad Disponible</th> | 56 | <th>Cargado / Capacidad Disponible</th> |
57 | <th></th> | ||
57 | </tr> | 58 | </tr> |
58 | </thead> | 59 | </thead> |
59 | <tbody> | 60 | <tbody> |
60 | <tr ng-repeat="(key, cisterna) in cisternas"> | 61 | <tr ng-repeat="(key, cisterna) in cisternas"> |
61 | <td class="py-3" ng-bind="cisterna.codigo"></td> | 62 | <td class="py-3" ng-bind="cisterna.codigo"></td> |
62 | <td class="py-3" ng-bind="cisterna.capacidad"></td> | 63 | <td class="py-3" ng-bind="cisterna.capacidad"></td> |
63 | <td class="py-3" ng-bind="cisterna.cisternaCarga.articulo.DetArt || 'Sin asignar'"></td> | 64 | <td class="py-3" ng-bind="cisterna.cisternaCarga.articulo.DetArt || 'Sin asignar'"></td> |
64 | <td ng-if="idRemito != -1"> | 65 | <td ng-if="idRemito != -1"> |
65 | <input | 66 | <input |
66 | class="form-control" | 67 | class="form-control" |
67 | foca-tipo-input | 68 | foca-tipo-input |
68 | foca-teclado | 69 | foca-teclado |
69 | placeholder="A cargar..." | 70 | placeholder="A cargar..." |
70 | ng-model="aCargar[key]" | 71 | ng-model="aCargar[key]" |
71 | ng-disabled="cisterna.disabled || !tieneArticulosPendientes()" | 72 | ng-disabled="cisterna.disabled || !tieneArticulosPendientes()" |
72 | ng-focus="aCargar[key] = rellenarInput(aCargar[key], cisterna); actualizarArticulo()" | 73 | ng-focus="aCargar[key] = rellenarInput(aCargar[key], cisterna); actualizarArticulo()" |
73 | ng-change="actualizarArticulo()" | 74 | ng-change="actualizarArticulo()" |
74 | > | 75 | > |
75 | </td> | 76 | </td> |
76 | <td ng-if="idRemito == -1"> | 77 | <td ng-if="idRemito == -1"> |
77 | <input | 78 | <input |
78 | class="form-control" | 79 | class="form-control" |
79 | placeholder="A cargar..." | 80 | placeholder="A cargar..." |
80 | readonly> | 81 | readonly> |
81 | </td> | 82 | </td> |
82 | <td><div class="progress foca-alto-progress pl-0 pr-0 mt-1"> | 83 | <td><div class="progress foca-alto-progress pl-0 pr-0 mt-1"> |
83 | <strong | 84 | <strong |
84 | class="mt-2 col-4 text-center position-absolute" | 85 | class="mt-2 col-4 text-center position-absolute" |
85 | ng-bind="(cisterna.cisternaCarga.cantidad || 0) + '/' + | 86 | ng-bind="(cisterna.cisternaCarga.cantidad || 0) + '/' + |
86 | (cisterna.capacidad - cisterna.cisternaCarga.cantidad)"> | 87 | (cisterna.capacidad - cisterna.cisternaCarga.cantidad)"> |
87 | </strong> | 88 | </strong> |
88 | <div | 89 | <div |
89 | id="{{cisterna.id}}" | 90 | id="{{cisterna.id}}" |
90 | class="progress-bar" | 91 | class="progress-bar" |
91 | role="progressbar" | 92 | role="progressbar" |
92 | aria-valuemin="0" | 93 | aria-valuemin="0" |
93 | aria-valuemax="{{cisterna.capacidad}}" | 94 | aria-valuemax="{{cisterna.capacidad}}" |
94 | ng-style="{'width':'{{calcularPorcentaje(cisterna)}}'}"> | 95 | ng-style="{'width':'{{calcularPorcentaje(cisterna)}}'}"> |
95 | </div> | 96 | </div> |
96 | </div> | 97 | </div> |
97 | </td> | 98 | </td> |
99 | <td> | ||
100 | <button | ||
101 | class="btn btn-outline-secondary" | ||
102 | ng-click="verRemitos(cisterna.cisternaCarga.remitos)"> | ||
103 | <i class="fa fa-info" aria-hidden="true"></i> | ||
104 | </button> | ||
105 | </td> | ||
98 | </tr> | 106 | </tr> |
99 | </tbody> | 107 | </tbody> |
100 | </table> | 108 | </table> |
101 | <div class="col-12"> | 109 | <div class="col-12"> |
102 | <button | 110 | <button |
103 | class="form-control btn btn-success" | 111 | class="form-control btn btn-success" |
104 | ladda="cargando" | 112 | ladda="cargando" |
105 | data-spinner-color="#FF0000" | 113 | data-spinner-color="#FF0000" |
106 | type="button" | 114 | type="button" |
107 | ng-disabled="!distribucionDisponible()" | 115 | ng-disabled="!distribucionDisponible()" |
108 | ng-class="{'btn-light': !distribucionDisponible()}" | 116 | ng-class="{'btn-light': !distribucionDisponible()}" |
109 | ng-click="cargarACisternas(vehiculo)" | 117 | ng-click="cargarACisternas(vehiculo)" |
110 | foca-focus="distribucionDisponible()"> | 118 | foca-focus="distribucionDisponible()"> |
111 | Aplicar distribución de cargas | 119 | Aplicar distribución de cargas |
112 | </button> | 120 | </button> |
113 | </div> | 121 | </div> |
114 | </div> | 122 | </div> |
115 | </div> | 123 | </div> |
116 | <div class="modal-footer py-1"> | 124 | <div class="modal-footer py-1"> |
117 | <button | 125 | <button |
118 | class="btn btn-sm btn-secondary" | 126 | class="btn btn-sm btn-secondary" |
119 | ladda="cargando" | 127 | ladda="cargando" |
120 | type="button" | 128 | type="button" |
121 | ng-click="cancelar()">Cancelar</button> | 129 | ng-click="cancelar()">Cancelar</button> |
122 | <button | 130 | <button |
123 | class="btn btn-sm btn-primary" | 131 | class="btn btn-sm btn-primary" |
124 | ladda="cargando" | 132 | ladda="cargando" |
125 | type="button" | 133 | type="button" |
126 | ng-click="aceptar()" | 134 | ng-click="aceptar()" |
127 | ng-disabled="tieneArticulosPendientes() || idRemito === -1" | 135 | ng-disabled="tieneArticulosPendientes() || idRemito === -1" |
128 | foca-focus="!tieneArticulosPendientes() && idRemito !== -1">Cargar</button> | 136 | foca-focus="!tieneArticulosPendientes() && idRemito !== -1">Cargar</button> |
129 | </div> | 137 | </div> |
130 | 138 |