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