Commit ec438219531cc6f3318728d0ca3c0b4a93a01075
1 parent
8198ae90c8
Exists in
master
controlo eliminación cuando el vehículo tiene remitos
Showing
1 changed file
with
14 additions
and
1 deletions
Show diff stats
src/js/controller.js
| ... | ... | @@ -59,7 +59,7 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo |
| 59 | 59 | $scope.quitarVehiculo = function(vehiculo) { |
| 60 | 60 | focaModalService.confirm('Esta seguro que desea eliminar el vehículo ' + |
| 61 | 61 | vehiculo.codigo + '?').then(function() { |
| 62 | - $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); | |
| 62 | + eliminarVehiculo(vehiculo); | |
| 63 | 63 | }); |
| 64 | 64 | }; |
| 65 | 65 | |
| ... | ... | @@ -197,6 +197,19 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo |
| 197 | 197 | } |
| 198 | 198 | }); |
| 199 | 199 | } |
| 200 | + | |
| 201 | + function eliminarVehiculo(vehiculo) { | |
| 202 | + focaLogisticaPedidoRutaService.getRemitos(vehiculo.id).then(function(res) { | |
| 203 | + if(!focaLogisticaPedidoRutaService.obtenerRemitosDeCarga(res.data).length) { | |
| 204 | + $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); | |
| 205 | + }else { | |
| 206 | + focaModalService.alert('No ha sido posible eliminar el vehiculo porque ' + | |
| 207 | + 'tiene remitos asociados').then(function() { | |
| 208 | + $scope.hacerHojaRuta(vehiculo); | |
| 209 | + }); | |
| 210 | + } | |
| 211 | + }); | |
| 212 | + } | |
| 200 | 213 | $interval(function() { |
| 201 | 214 | getSeguimiento(); |
| 202 | 215 | }, 5000); |