Commit 580887952eedfc96d18a43670a1c461aaa067758
1 parent
dafcad032b
Exists in
master
espacio
Showing
1 changed file
with
1 additions
and
1 deletions
Show diff stats
src/js/controller.js
1 | angular.module('focaAbmVehiculo') | 1 | angular.module('focaAbmVehiculo') |
2 | .controller('focaAbmVehiculosController', [ | 2 | .controller('focaAbmVehiculosController', [ |
3 | '$scope', 'focaAbmVehiculoService', '$location', 'focaModalService', '$uibModal', | 3 | '$scope', 'focaAbmVehiculoService', '$location', 'focaModalService', '$uibModal', |
4 | function($scope, focaAbmVehiculoService, $location, focaModalService, $uibModal) { | 4 | function($scope, focaAbmVehiculoService, $location, focaModalService, $uibModal) { |
5 | $scope.buscar = function(idTransportista) { | 5 | $scope.buscar = function(idTransportista) { |
6 | focaAbmVehiculoService | 6 | focaAbmVehiculoService |
7 | .getVehiculosPorTransportista(idTransportista) | 7 | .getVehiculosPorTransportista(idTransportista) |
8 | .then(function(datos) { | 8 | .then(function(datos) { |
9 | $scope.vehiculos = datos.data; | 9 | $scope.vehiculos = datos.data; |
10 | }); | 10 | }); |
11 | }; | 11 | }; |
12 | $scope.editar = function(id) { | 12 | $scope.editar = function(id) { |
13 | $location.path('/vehiculo/' + id + '/' + $scope.idTransportista); | 13 | $location.path('/vehiculo/' + id + '/' + $scope.idTransportista); |
14 | }; | 14 | }; |
15 | $scope.solicitarConfirmacion = function(vehiculo) { | 15 | $scope.solicitarConfirmacion = function(vehiculo) { |
16 | focaModalService.confirm('¿Está seguro que desea borrar el vehiculo ' + | 16 | focaModalService.confirm('¿Está seguro que desea borrar el vehiculo ' + |
17 | vehiculo.id + ' ' + vehiculo.tractor + ' ?').then( | 17 | vehiculo.id + ' ' + vehiculo.tractor + ' ?').then( |
18 | function(data) { | 18 | function(data) { |
19 | if(data) { | 19 | if(data) { |
20 | focaAbmVehiculoService.deleteVehiculo(vehiculo.id); | 20 | focaAbmVehiculoService.deleteVehiculo(vehiculo.id); |
21 | $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); | 21 | $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); |
22 | } | 22 | } |
23 | } | 23 | } |
24 | ); | 24 | ); |
25 | }; | 25 | }; |
26 | $scope.seleccionarTransportista = function() { | 26 | $scope.seleccionarTransportista = function() { |
27 | var modalInstance = $uibModal.open( | 27 | var modalInstance = $uibModal.open( |
28 | { | 28 | { |
29 | ariaLabelledBy: 'Busqueda de Transportista', | 29 | ariaLabelledBy: 'Busqueda de Transportista', |
30 | templateUrl: 'modal-proveedor.html', | 30 | templateUrl: 'modal-proveedor.html', |
31 | controller: 'focaModalProveedorCtrl', | 31 | controller: 'focaModalProveedorCtrl', |
32 | size: 'lg', | 32 | size: 'lg', |
33 | resolve: { | 33 | resolve: { |
34 | transportista: function() { | 34 | transportista: function() { |
35 | return true; | 35 | return true; |
36 | } | 36 | } |
37 | } | 37 | } |
38 | } | 38 | } |
39 | ); | 39 | ); |
40 | modalInstance.result.then( | 40 | modalInstance.result.then( |
41 | function(transprotista) { | 41 | function(transprotista) { |
42 | $scope.idTransportista = transprotista.COD; | 42 | $scope.idTransportista = transprotista.COD; |
43 | $scope.filtros = transprotista.NOM.trim(); | 43 | $scope.filtros = transprotista.NOM.trim(); |
44 | $scope.buscar(transprotista.COD); | 44 | $scope.buscar(transprotista.COD); |
45 | }, function() { | 45 | }, function() { |
46 | 46 | ||
47 | } | 47 | } |
48 | ); | 48 | ); |
49 | }; | 49 | }; |
50 | } | 50 | } |
51 | ]) | 51 | ]) |
52 | .controller('focaAbmVehiculoController', [ | 52 | .controller('focaAbmVehiculoController', [ |
53 | '$scope', 'focaAbmVehiculoService', '$routeParams', '$location', '$uibModal', | 53 | '$scope', 'focaAbmVehiculoService', '$routeParams', '$location', '$uibModal', |
54 | 'focaModalService', | 54 | 'focaModalService', |
55 | function($scope, focaAbmVehiculoService, $routeParams, $location, $uibModal, | 55 | function($scope, focaAbmVehiculoService, $routeParams, $location, $uibModal, |
56 | focaModalService) { | 56 | focaModalService) { |
57 | $scope.nuevo = $routeParams.idVehiculo == 0 ? true : false; | 57 | $scope.nuevo = $routeParams.idVehiculo == 0 ? true : false; |
58 | if($scope.nuevo) { | 58 | if($scope.nuevo) { |
59 | focaAbmVehiculoService | 59 | focaAbmVehiculoService |
60 | .getTransportistaPorId($routeParams.idTransportista) | 60 | .getTransportistaPorId($routeParams.idTransportista) |
61 | .then(function(res) { | 61 | .then(function(res) { |
62 | $scope.vehiculo.transportista = res.data; | 62 | $scope.vehiculo.transportista = res.data; |
63 | }) | 63 | }) |
64 | } | 64 | } |
65 | $scope.vehiculo = {}; | 65 | $scope.vehiculo = {}; |
66 | focaAbmVehiculoService.getVehiculo($routeParams.idVehiculo).then(function(res) { | 66 | focaAbmVehiculoService.getVehiculo($routeParams.idVehiculo).then(function(res) { |
67 | if(res.data) $scope.vehiculo = res.data; | 67 | if(res.data) $scope.vehiculo = res.data; |
68 | }); | 68 | }); |
69 | focaAbmVehiculoService.getCisternadoPorVehiculo($routeParams.idVehiculo) | 69 | focaAbmVehiculoService.getCisternadoPorVehiculo($routeParams.idVehiculo) |
70 | .then(function(res) { | 70 | .then(function(res) { |
71 | $scope.cisternas = res.data; | 71 | $scope.cisternas = res.data; |
72 | }); | 72 | }); |
73 | $scope.cancelar = function() { | 73 | $scope.cancelar = function() { |
74 | $location.path('/vehiculo'); | 74 | $location.path('/vehiculo'); |
75 | }; | 75 | }; |
76 | $scope.editar = function(id) { | 76 | $scope.editar = function(id) { |
77 | $location.path('/vehiculo/' + $routeParams.idVehiculo + '/cisterna/' + id); | 77 | $location.path('/vehiculo/' + $routeParams.idVehiculo + '/cisterna/' + id); |
78 | }; | 78 | }; |
79 | $scope.guardar = function() { | 79 | $scope.guardar = function() { |
80 | if(!$scope.vehiculo.transportista){ | 80 | if(!$scope.vehiculo.transportista) { |
81 | focaModalService.alert('Elija Transportista'); | 81 | focaModalService.alert('Elija Transportista'); |
82 | return; | 82 | return; |
83 | } | 83 | } |
84 | delete $scope.vehiculo.transportista; | 84 | delete $scope.vehiculo.transportista; |
85 | focaAbmVehiculoService.guerdarVehiculo($scope.vehiculo).then(function(res) { | 85 | focaAbmVehiculoService.guerdarVehiculo($scope.vehiculo).then(function(res) { |
86 | $location.path('/vehiculo/' + res.data.id); | 86 | $location.path('/vehiculo/' + res.data.id); |
87 | }); | 87 | }); |
88 | }; | 88 | }; |
89 | $scope.solicitarConfirmacionCisterna = function(cisterna) { | 89 | $scope.solicitarConfirmacionCisterna = function(cisterna) { |
90 | focaModalService.confirm('¿Está seguro que desea borrar la cisterna ' + | 90 | focaModalService.confirm('¿Está seguro que desea borrar la cisterna ' + |
91 | cisterna.id + ' ' + cisterna.codigo + ' ?').then( | 91 | cisterna.id + ' ' + cisterna.codigo + ' ?').then( |
92 | function(data) { | 92 | function(data) { |
93 | if(data) { | 93 | if(data) { |
94 | focaAbmVehiculoService.deleteCisterna(cisterna.id); | 94 | focaAbmVehiculoService.deleteCisterna(cisterna.id); |
95 | $scope.cisternas.splice($scope.cisternas.indexOf(cisterna), 1); | 95 | $scope.cisternas.splice($scope.cisternas.indexOf(cisterna), 1); |
96 | } | 96 | } |
97 | } | 97 | } |
98 | ); | 98 | ); |
99 | }; | 99 | }; |
100 | $scope.seleccionarTransportista = function() { | 100 | $scope.seleccionarTransportista = function() { |
101 | var modalInstance = $uibModal.open( | 101 | var modalInstance = $uibModal.open( |
102 | { | 102 | { |
103 | ariaLabelledBy: 'Busqueda de Transportista', | 103 | ariaLabelledBy: 'Busqueda de Transportista', |
104 | templateUrl: 'modal-proveedor.html', | 104 | templateUrl: 'modal-proveedor.html', |
105 | controller: 'focaModalProveedorCtrl', | 105 | controller: 'focaModalProveedorCtrl', |
106 | size: 'lg', | 106 | size: 'lg', |
107 | resolve: { | 107 | resolve: { |
108 | transportista: function() { | 108 | transportista: function() { |
109 | return true; | 109 | return true; |
110 | } | 110 | } |
111 | } | 111 | } |
112 | } | 112 | } |
113 | ); | 113 | ); |
114 | modalInstance.result.then( | 114 | modalInstance.result.then( |
115 | function(transprotista) { | 115 | function(transprotista) { |
116 | $scope.vehiculo.idTransportista = transprotista.COD; | 116 | $scope.vehiculo.idTransportista = transprotista.COD; |
117 | $scope.vehiculo.transportista = transprotista; | 117 | $scope.vehiculo.transportista = transprotista; |
118 | }, function() { | 118 | }, function() { |
119 | 119 | ||
120 | } | 120 | } |
121 | ); | 121 | ); |
122 | }; | 122 | }; |
123 | } | 123 | } |
124 | ]); | 124 | ]); |
125 | 125 |