Commit 4bcdeb329ca2d5797426f7c3465c6a62f511af1d
1 parent
772ec922f8
Exists in
master
codigo de vehiculo y cisterna unicos
Showing
2 changed files
with
42 additions
and
15 deletions
Show diff stats
src/js/controller.js
... | ... | @@ -90,7 +90,7 @@ angular.module('focaAbmVehiculo') |
90 | 90 | $timeout(function() { |
91 | 91 | focaBotoneraLateralService.showSalir(false); |
92 | 92 | focaBotoneraLateralService.showPausar(false); |
93 | - focaBotoneraLateralService.showCancelar(true); | |
93 | + focaBotoneraLateralService.showCancelar(true, '/vehiculo'); | |
94 | 94 | focaBotoneraLateralService.showGuardar(true, $scope.guardar); |
95 | 95 | }); |
96 | 96 | |
... | ... | @@ -140,14 +140,29 @@ angular.module('focaAbmVehiculo') |
140 | 140 | focaModalService.alert('Elija Transportista'); |
141 | 141 | return; |
142 | 142 | } |
143 | - delete $scope.vehiculo.transportista; | |
144 | - focaAbmVehiculoService.guerdarVehiculo($scope.vehiculo).then(function(res) { | |
145 | - if($scope.nuevo) { | |
146 | - $location.path('/vehiculo/' + res.data.id + '/' + res.data.idTransportista); | |
147 | - } else { | |
148 | - $location.path('/vehiculo'); | |
149 | - } | |
150 | - }); | |
143 | + focaAbmVehiculoService.getVehiculosPorTransportista($routeParams.idTransportista) | |
144 | + .then(function(res) { | |
145 | + var existe = res.data.filter(function(vehiculo) { | |
146 | + return vehiculo.codigo === $scope.vehiculo.codigo && | |
147 | + vehiculo.id !== $scope.vehiculo.id; | |
148 | + }); | |
149 | + | |
150 | + if(existe.length > 0) { | |
151 | + return Promise.reject('Existe codigo de unidad'); | |
152 | + }else { | |
153 | + delete $scope.vehiculo.transportista; | |
154 | + return focaAbmVehiculoService.guerdarVehiculo($scope.vehiculo); | |
155 | + } | |
156 | + }).then(function(res) { | |
157 | + if($scope.nuevo) { | |
158 | + $location.path('/vehiculo/' + res.data.id + | |
159 | + '/' + res.data.idTransportista); | |
160 | + }else { | |
161 | + $location.path('/vehiculo'); | |
162 | + } | |
163 | + }, function(rej) { | |
164 | + focaModalService.alert(rej); | |
165 | + }); | |
151 | 166 | }; |
152 | 167 | $scope.solicitarConfirmacionCisterna = function(cisterna) { |
153 | 168 | focaModalService.confirm('¿Está seguro que desea borrar la cisterna ' + |
src/js/controllerCisterna.js
... | ... | @@ -56,12 +56,24 @@ angular.module('focaAbmVehiculo') |
56 | 56 | focaModalService.alert('Ingrese producto'); |
57 | 57 | return; |
58 | 58 | } |
59 | - $scope.cisterna.idVehiculo = $routeParams.idVehiculo; | |
60 | - delete $scope.cisterna.unidadMedida; | |
61 | - delete $scope.cisterna.cisternaCarga.articulo; | |
62 | - focaAbmVehiculoService.guardarCisterna($scope.cisterna).then(function() { | |
63 | - $location.path('/vehiculo/' + $routeParams.idVehiculo); | |
64 | - }); | |
59 | + focaAbmVehiculoService.getCisternadoPorVehiculo($routeParams.idVehiculo) | |
60 | + .then(function(res) { | |
61 | + var existe = res.data.filter(function(cisterna) { | |
62 | + return cisterna.codigo === $scope.cisterna.codigo; | |
63 | + }); | |
64 | + if(existe.length > 0) { | |
65 | + return Promise.reject('Existe codigo de cisterna'); | |
66 | + }else { | |
67 | + $scope.cisterna.idVehiculo = $routeParams.idVehiculo; | |
68 | + delete $scope.cisterna.unidadMedida; | |
69 | + delete $scope.cisterna.cisternaCarga.articulo; | |
70 | + return focaAbmVehiculoService.guardarCisterna($scope.cisterna); | |
71 | + } | |
72 | + }).then(function() { | |
73 | + $location.path('/vehiculo/' + $routeParams.idVehiculo); | |
74 | + }, function(rej) { | |
75 | + focaModalService.alert(rej); | |
76 | + }); | |
65 | 77 | }; |
66 | 78 | |
67 | 79 | // $scope.seleccionarArticulo = function() { |