Commit 359d51a957a54a1ff666773500c952711b2fa366
1 parent
d1411789ec
Exists in
master
capacidad total vehiculo, formato tabla y crear cisternas
Showing
4 changed files
with
49 additions
and
81 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', | 3 | '$scope', 'focaAbmVehiculoService', '$location', 'focaModalService', |
4 | '$uibModal', 'focaBotoneraLateralService', '$timeout', | 4 | '$uibModal', 'focaBotoneraLateralService', '$timeout', |
5 | function($scope, focaAbmVehiculoService, $location, focaModalService, | 5 | function($scope, focaAbmVehiculoService, $location, focaModalService, |
6 | $uibModal, focaBotoneraLateralService, $timeout) { | 6 | $uibModal, focaBotoneraLateralService, $timeout) { |
7 | 7 | ||
8 | $scope.now = new Date(); | 8 | $scope.now = new Date(); |
9 | $scope.botonera = [{ | 9 | $scope.botonera = [{ |
10 | label: 'Transportista', | 10 | label: 'Transportista', |
11 | image: 'cliente.png' | 11 | image: 'cliente.png' |
12 | }]; | 12 | }]; |
13 | 13 | ||
14 | //SETEO BOTONERA LATERAL | 14 | //SETEO BOTONERA LATERAL |
15 | focaBotoneraLateralService.showSalir(true); | 15 | focaBotoneraLateralService.showSalir(true); |
16 | focaBotoneraLateralService.showPausar(false); | 16 | focaBotoneraLateralService.showPausar(false); |
17 | focaBotoneraLateralService.showCancelar(false); | 17 | focaBotoneraLateralService.showCancelar(false); |
18 | focaBotoneraLateralService.showGuardar(false); | 18 | focaBotoneraLateralService.showGuardar(false); |
19 | 19 | ||
20 | if(focaAbmVehiculoService.transportistaSeleccionado.COD) { | 20 | if(focaAbmVehiculoService.transportistaSeleccionado.COD) { |
21 | elegirTransportista(focaAbmVehiculoService.transportistaSeleccionado); | 21 | elegirTransportista(focaAbmVehiculoService.transportistaSeleccionado); |
22 | } | 22 | } |
23 | 23 | ||
24 | $scope.editar = function(id) { | 24 | $scope.editar = function(id) { |
25 | $location.path('/vehiculo/' + id + '/' + $scope.idTransportista); | 25 | $location.path('/vehiculo/' + id + '/' + $scope.idTransportista); |
26 | }; | 26 | }; |
27 | $scope.solicitarConfirmacion = function(vehiculo) { | 27 | $scope.solicitarConfirmacion = function(vehiculo) { |
28 | focaModalService.confirm('¿Está seguro que desea borrar el vehiculo ' + | 28 | focaModalService.confirm('¿Está seguro que desea borrar el vehiculo ' + |
29 | vehiculo.id + ' ' + vehiculo.tractor + ' ?').then( | 29 | vehiculo.id + ' ' + vehiculo.tractor + ' ?').then( |
30 | function(data) { | 30 | function(data) { |
31 | if(data) { | 31 | if(data) { |
32 | focaAbmVehiculoService.deleteVehiculo(vehiculo.id); | 32 | focaAbmVehiculoService.deleteVehiculo(vehiculo.id); |
33 | $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); | 33 | $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); |
34 | } | 34 | } |
35 | } | 35 | } |
36 | ); | 36 | ); |
37 | }; | 37 | }; |
38 | $scope.seleccionarTransportista = function() { | 38 | $scope.seleccionarTransportista = function() { |
39 | var modalInstance = $uibModal.open( | 39 | var modalInstance = $uibModal.open( |
40 | { | 40 | { |
41 | ariaLabelledBy: 'Busqueda de Transportista', | 41 | ariaLabelledBy: 'Busqueda de Transportista', |
42 | templateUrl: 'modal-proveedor.html', | 42 | templateUrl: 'modal-proveedor.html', |
43 | controller: 'focaModalProveedorCtrl', | 43 | controller: 'focaModalProveedorCtrl', |
44 | size: 'lg', | 44 | size: 'lg', |
45 | resolve: { | 45 | resolve: { |
46 | transportista: function() { | 46 | transportista: function() { |
47 | return true; | 47 | return true; |
48 | } | 48 | } |
49 | } | 49 | } |
50 | } | 50 | } |
51 | ); | 51 | ); |
52 | modalInstance.result.then( | 52 | modalInstance.result.then( |
53 | function(transportista) { | 53 | function(transportista) { |
54 | elegirTransportista(transportista); | 54 | elegirTransportista(transportista); |
55 | focaAbmVehiculoService.transportistaSeleccionado = transportista; | 55 | focaAbmVehiculoService.transportistaSeleccionado = transportista; |
56 | }, function() { | 56 | }, function() { |
57 | 57 | ||
58 | } | 58 | } |
59 | ); | 59 | ); |
60 | }; | 60 | }; |
61 | 61 | ||
62 | function elegirTransportista(transportista) { | 62 | function elegirTransportista(transportista) { |
63 | var codigo = ('00000' + transportista.COD).slice(-5); | 63 | var codigo = ('00000' + transportista.COD).slice(-5); |
64 | $scope.idTransportista = transportista.COD; | 64 | $scope.idTransportista = transportista.COD; |
65 | $scope.filtros = transportista.NOM.trim(); | 65 | $scope.filtros = transportista.NOM.trim(); |
66 | $timeout(function() { | 66 | $timeout(function() { |
67 | $scope.$broadcast('addCabecera', { | 67 | $scope.$broadcast('addCabecera', { |
68 | label: 'Transportista:', | 68 | label: 'Transportista:', |
69 | valor: codigo + ' - ' + transportista.NOM | 69 | valor: codigo + ' - ' + transportista.NOM |
70 | }); | 70 | }); |
71 | }); | 71 | }); |
72 | buscar(transportista.COD); | 72 | buscar(transportista.COD); |
73 | } | 73 | } |
74 | 74 | ||
75 | function buscar(idTransportista) { | 75 | function buscar(idTransportista) { |
76 | focaAbmVehiculoService | 76 | focaAbmVehiculoService |
77 | .getVehiculosPorTransportista(idTransportista) | 77 | .getVehiculosPorTransportista(idTransportista) |
78 | .then(function(datos) { | 78 | .then(function(datos) { |
79 | $scope.vehiculos = datos.data; | 79 | $scope.vehiculos = datos.data; |
80 | }); | 80 | }); |
81 | } | 81 | } |
82 | } | 82 | } |
83 | ]) | 83 | ]) |
84 | .controller('focaAbmVehiculoController', [ | 84 | .controller('focaAbmVehiculoController', [ |
85 | '$scope', 'focaAbmVehiculoService', '$routeParams', '$location', '$uibModal', | 85 | '$scope', 'focaAbmVehiculoService', '$routeParams', '$location', '$uibModal', |
86 | 'focaModalService', '$timeout', 'focaBotoneraLateralService', | 86 | 'focaModalService', '$timeout', 'focaBotoneraLateralService', |
87 | function($scope, focaAbmVehiculoService, $routeParams, $location, $uibModal, | 87 | function($scope, focaAbmVehiculoService, $routeParams, $location, $uibModal, |
88 | focaModalService, $timeout, focaBotoneraLateralService) { | 88 | focaModalService, $timeout, focaBotoneraLateralService) { |
89 | $scope.nuevo = $routeParams.idVehiculo === '0' ? true : false; | 89 | $scope.nuevo = $routeParams.idVehiculo === '0' ? true : false; |
90 | $scope.now = new Date(); | 90 | $scope.now = new Date(); |
91 | $scope.focused = 1; | 91 | $scope.focused = 1; |
92 | $scope.transportistaStamp = ''; | ||
92 | 93 | ||
93 | $timeout(function() { | 94 | $timeout(function() { |
94 | focaBotoneraLateralService.showSalir(false); | 95 | focaBotoneraLateralService.showSalir(false); |
95 | focaBotoneraLateralService.showPausar(false); | 96 | focaBotoneraLateralService.showPausar(false); |
96 | focaBotoneraLateralService.showCancelar(true, '/vehiculo'); | 97 | focaBotoneraLateralService.showCancelar(true, '/vehiculo'); |
97 | focaBotoneraLateralService.showGuardar(true, $scope.guardar); | 98 | focaBotoneraLateralService.showGuardar(true, $scope.guardar); |
98 | }); | 99 | }); |
99 | 100 | ||
100 | if($scope.nuevo) { | 101 | if($scope.nuevo) { |
101 | focaAbmVehiculoService | 102 | focaAbmVehiculoService |
102 | .getTransportistaPorId($routeParams.idTransportista) | 103 | .getTransportistaPorId($routeParams.idTransportista) |
103 | .then(function(res) { | 104 | .then(function(res) { |
104 | var codigo = ('00000' + res.data.COD).slice(-5); | 105 | var codigo = ('00000' + res.data.COD).slice(-5); |
105 | $scope.vehiculo.idTransportista = res.data.COD; | 106 | $scope.vehiculo.idTransportista = res.data.COD; |
106 | $scope.vehiculo.transportista = res.data; | 107 | $scope.vehiculo.transportista = res.data; |
107 | $scope.$broadcast('addCabecera', { | 108 | $scope.$broadcast('addCabecera', { |
108 | label: 'Transportista:', | 109 | label: 'Transportista:', |
109 | valor: codigo + ' - ' + res.data.NOM | 110 | valor: codigo + ' - ' + res.data.NOM |
110 | }); | 111 | }); |
111 | }); | 112 | }); |
112 | } | 113 | } |
113 | $scope.vehiculo = {}; | 114 | $scope.vehiculo = {}; |
114 | focaAbmVehiculoService.getVehiculo($routeParams.idVehiculo).then(function(res) { | 115 | focaAbmVehiculoService.getVehiculo($routeParams.idVehiculo).then(function(res) { |
115 | if(res.data) { | 116 | if(res.data) { |
116 | var codigo = ('00000' + res.data.transportista.COD).slice(-5); | 117 | $scope.transportistaStamp = ('00000' + res.data.transportista.COD).slice(-5); |
118 | $scope.transportistaStamp += ' - ' + res.data.transportista.NOM | ||
119 | |||
117 | $scope.vehiculo = res.data; | 120 | $scope.vehiculo = res.data; |
118 | $scope.$broadcast('addCabecera', { | 121 | $scope.$broadcast('addCabecera', { |
119 | label: 'Transportista:', | 122 | label: 'Transportista:', |
120 | valor: codigo + ' - ' + res.data.transportista.NOM | 123 | valor: $scope.transportistaStamp |
121 | }); | 124 | }); |
122 | $scope.$broadcast('addCabecera', { | 125 | $scope.$broadcast('addCabecera', { |
123 | label: 'Unidad:', | 126 | label: 'Unidad:', |
124 | valor: res.data.codigo | 127 | valor: res.data.codigo |
125 | }); | 128 | }); |
126 | } | 129 | } |
127 | }); | 130 | }); |
128 | focaAbmVehiculoService.getCisternadoPorVehiculo($routeParams.idVehiculo) | 131 | focaAbmVehiculoService.getCisternadoPorVehiculo($routeParams.idVehiculo) |
129 | .then(function(res) { | 132 | .then(function(res) { |
130 | $scope.cisternas = res.data; | 133 | $scope.cisternas = res.data; |
131 | }); | 134 | }); |
132 | $scope.next = function(key) { | 135 | $scope.next = function(key) { |
133 | if (key === 13) $scope.focused++; | 136 | if (key === 13) $scope.focused++; |
134 | }; | 137 | }; |
135 | $scope.cancelar = function() { | 138 | $scope.cancelar = function() { |
136 | $location.path('/vehiculo'); | 139 | $location.path('/vehiculo'); |
137 | }; | 140 | }; |
138 | $scope.editar = function(id) { | 141 | $scope.editar = function(id) { |
139 | $location.path('/vehiculo/' + $routeParams.idVehiculo + '/cisterna/' + id); | 142 | $location.path('/vehiculo/' + $routeParams.idVehiculo + '/cisterna/' + id); |
140 | }; | 143 | }; |
141 | $scope.guardar = function() { | 144 | $scope.guardar = function() { |
142 | //Valida si existe numero de unidad | 145 | //Valida si existe numero de unidad |
143 | existeCodigoUnidad().then(function() { | 146 | existeCodigoUnidad().then(function() { |
144 | delete $scope.vehiculo.transportista; | 147 | delete $scope.vehiculo.transportista; |
145 | delete $scope.vehiculo.cisternas; | 148 | delete $scope.vehiculo.cisternas; |
146 | focaAbmVehiculoService.guardarVehiculo($scope.vehiculo) | 149 | focaAbmVehiculoService.guardarVehiculo($scope.vehiculo) |
147 | .then(function(res){ | 150 | .then(function(res){ |
148 | if($scope.nuevo) { | 151 | if($scope.nuevo) { |
149 | $location.path('/vehiculo/' + res.data.id + | 152 | $location.path('/vehiculo/' + res.data.id + |
150 | '/' + res.data.idTransportista); | 153 | '/' + res.data.idTransportista); |
151 | } else { | 154 | } else { |
152 | $location.path('/vehiculo'); | 155 | $location.path('/vehiculo'); |
153 | } | 156 | } |
154 | }); | 157 | }); |
155 | }, function(){ | 158 | }, function(){ |
156 | focaModalService.alert('Código de unidad existente'); | 159 | focaModalService.alert('Código de unidad existente'); |
157 | }); | 160 | }); |
158 | 161 | ||
159 | }; | 162 | }; |
160 | $scope.solicitarConfirmacionCisterna = function(cisterna) { | 163 | $scope.solicitarConfirmacionCisterna = function(cisterna) { |
161 | focaModalService.confirm('¿Está seguro que desea borrar la cisterna ' + | 164 | focaModalService.confirm('¿Está seguro que desea borrar la cisterna ' + |
162 | cisterna.id + ' ' + cisterna.codigo + ' ?').then( | 165 | cisterna.id + ' ' + cisterna.codigo + ' ?').then( |
163 | function(data) { | 166 | function(data) { |
164 | if(data) { | 167 | if(data) { |
165 | focaAbmVehiculoService.deleteCisterna(cisterna.id); | 168 | focaAbmVehiculoService.deleteCisterna(cisterna.id); |
166 | $scope.cisternas.splice($scope.cisternas.indexOf(cisterna), 1); | 169 | $scope.cisternas.splice($scope.cisternas.indexOf(cisterna), 1); |
167 | } | 170 | } |
168 | } | 171 | } |
169 | ); | 172 | ); |
170 | }; | 173 | }; |
171 | $scope.seleccionarTransportista = function() { | 174 | $scope.seleccionarTransportista = function() { |
172 | var modalInstance = $uibModal.open( | 175 | var modalInstance = $uibModal.open( |
173 | { | 176 | { |
174 | ariaLabelledBy: 'Busqueda de Transportista', | 177 | ariaLabelledBy: 'Busqueda de Transportista', |
175 | templateUrl: 'modal-proveedor.html', | 178 | templateUrl: 'modal-proveedor.html', |
176 | controller: 'focaModalProveedorCtrl', | 179 | controller: 'focaModalProveedorCtrl', |
177 | size: 'lg', | 180 | size: 'lg', |
178 | resolve: { | 181 | resolve: { |
179 | transportista: function() { | 182 | transportista: function() { |
180 | return true; | 183 | return true; |
181 | } | 184 | } |
182 | } | 185 | } |
183 | } | 186 | } |
184 | ); | 187 | ); |
185 | modalInstance.result.then( | 188 | modalInstance.result.then( |
186 | function(transportista) { | 189 | function(transportista) { |
187 | $scope.vehiculo.idTransportista = transportista.COD; | 190 | $scope.vehiculo.idTransportista = transportista.COD; |
188 | $scope.vehiculo.transportista = transportista; | 191 | $scope.vehiculo.transportista = transportista; |
189 | }, function() { | 192 | }, function() { |
190 | 193 | ||
191 | } | 194 | } |
192 | ); | 195 | ); |
193 | }; | 196 | }; |
194 | 197 | ||
195 | function existeCodigoUnidad(){ | 198 | function existeCodigoUnidad(){ |
196 | return new Promise(function(resolve, reject) { | 199 | return new Promise(function(resolve, reject) { |
197 | focaAbmVehiculoService | 200 | focaAbmVehiculoService |
198 | .getVehiculosPorTransportista($routeParams.idTransportista) | 201 | .getVehiculosPorTransportista($routeParams.idTransportista) |
199 | .then(function(res){ | 202 | .then(function(res){ |
200 | //Valida si existe numero de unidad | 203 | //Valida si existe numero de unidad |
201 | var existe = res.data.filter(function(vehiculo) { | 204 | var existe = res.data.filter(function(vehiculo) { |
202 | return vehiculo.codigo === $scope.vehiculo.codigo && | 205 | return vehiculo.codigo === $scope.vehiculo.codigo && |
203 | vehiculo.id !== $scope.vehiculo.id; | 206 | vehiculo.id !== $scope.vehiculo.id; |
204 | }); | 207 | }); |
205 | 208 | ||
206 | if(existe.length){ | 209 | if(existe.length){ |
207 | reject(existe); | 210 | reject(existe); |
208 | } else { | 211 | } else { |
209 | resolve(); | 212 | resolve(); |
210 | } | 213 | } |
211 | }); | 214 | }); |
212 | }); | 215 | }); |
213 | } | 216 | } |
214 | } | 217 | } |
215 | ]); | 218 | ]); |
216 | 219 |
src/js/controllerCisterna.js
1 | angular.module('focaAbmVehiculo') | 1 | angular.module('focaAbmVehiculo') |
2 | .controller('focaAbmVehiculoCisternaController', [ | 2 | .controller('focaAbmVehiculoCisternaController', [ |
3 | '$scope', 'focaAbmVehiculoService', '$routeParams', '$location', '$uibModal', | 3 | '$scope', 'focaAbmVehiculoService', '$routeParams', '$location', '$uibModal', |
4 | 'focaModalService', 'focaBotoneraLateralService', '$timeout', | 4 | 'focaModalService', 'focaBotoneraLateralService', '$timeout', |
5 | function($scope, focaAbmVehiculoService, $routeParams, $location, $uibModal, | 5 | function($scope, focaAbmVehiculoService, $routeParams, $location, $uibModal, |
6 | focaModalService, focaBotoneraLateralService, $timeout) { | 6 | focaModalService, focaBotoneraLateralService, $timeout) { |
7 | $scope.editar = false; | 7 | $scope.editar = false; |
8 | $scope.now = new Date(); | 8 | $scope.now = new Date(); |
9 | $scope.cisterna = { | 9 | $scope.cisterna = { |
10 | cisternaCarga: { | 10 | cisternaCarga: { |
11 | articulo: {} | 11 | articulo: {} |
12 | } | 12 | } |
13 | }; | 13 | }; |
14 | 14 | ||
15 | $scope.focused = 1; | 15 | $scope.focused = 1; |
16 | $scope.next = function(key) { | 16 | $scope.next = function(key) { |
17 | if (key === 13) $scope.focused++; | 17 | if (key === 13) $scope.focused++; |
18 | }; | 18 | }; |
19 | $scope.capacidadVechiulo = 0; | ||
19 | 20 | ||
20 | //SETEO BOTONERA LATERAL | 21 | //SETEO BOTONERA LATERAL |
21 | $timeout(function() { | 22 | $timeout(function() { |
22 | focaBotoneraLateralService.showSalir(false); | 23 | focaBotoneraLateralService.showSalir(false); |
23 | focaBotoneraLateralService.showPausar(false); | 24 | focaBotoneraLateralService.showPausar(false); |
24 | focaBotoneraLateralService.showCancelar(true); | 25 | focaBotoneraLateralService.showCancelar(true); |
25 | focaBotoneraLateralService.showGuardar(true, $scope.guardar); | 26 | focaBotoneraLateralService.showGuardar(true, $scope.guardar); |
26 | }); | 27 | }); |
27 | 28 | ||
28 | focaAbmVehiculoService.getCisterna($routeParams.id).then(function(res) { | 29 | focaAbmVehiculoService.getCisterna($routeParams.id).then(function(res) { |
29 | if(res.data) { | 30 | if(res.data) { |
30 | $scope.cisterna = res.data; | 31 | $scope.cisterna = res.data; |
31 | $scope.editar = true; | 32 | $scope.editar = true; |
32 | }else { | 33 | }else { |
33 | $scope.editar = false; | 34 | $scope.editar = false; |
34 | } | 35 | } |
35 | }); | 36 | }); |
36 | focaAbmVehiculoService.getVehiculo($routeParams.idVehiculo).then(function(res) { | 37 | focaAbmVehiculoService.getVehiculo($routeParams.idVehiculo).then(function(res) { |
37 | var codigo = ('00000' + res.data.transportista.COD).slice(-5); | 38 | var codigo = ('00000' + res.data.transportista.COD).slice(-5); |
39 | $scope.capacidadVechiulo = res.data.capacidad; | ||
38 | $scope.$broadcast('addCabecera', { | 40 | $scope.$broadcast('addCabecera', { |
39 | label: 'Transportista:', | 41 | label: 'Transportista:', |
40 | valor: codigo + ' - ' + res.data.transportista.NOM | 42 | valor: codigo + ' - ' + res.data.transportista.NOM |
41 | }); | 43 | }); |
42 | $scope.$broadcast('addCabecera', { | 44 | $scope.$broadcast('addCabecera', { |
43 | label: 'Unidad:', | 45 | label: 'Unidad:', |
44 | valor: res.data.codigo | 46 | valor: res.data.codigo |
45 | }); | 47 | }); |
46 | }); | 48 | }); |
47 | $scope.cancelar = function() { | 49 | $scope.cancelar = function() { |
48 | $location.path('/vehiculo/' + $routeParams.idVehiculo); | 50 | $location.path('/vehiculo/' + $routeParams.idVehiculo); |
49 | }; | 51 | }; |
50 | $scope.guardar = function() { | 52 | $scope.guardar = function() { |
51 | if(!$scope.cisterna.unidadMedida) { | 53 | if(!$scope.cisterna.unidadMedida) { |
52 | focaModalService.alert('Ingrese unidad de medida'); | 54 | focaModalService.alert('Ingrese unidad de medida'); |
53 | return; | 55 | return; |
54 | } | 56 | } |
55 | existeCodigoCisterna().then(function() { | 57 | validaCodigoCapacidad().then(function() { |
56 | $scope.cisterna.idVehiculo = $routeParams.idVehiculo; | 58 | $scope.cisterna.idVehiculo = $routeParams.idVehiculo; |
57 | delete $scope.cisterna.vehiculo; | 59 | delete $scope.cisterna.vehiculo; |
58 | delete $scope.cisterna.unidadMedida; | 60 | delete $scope.cisterna.unidadMedida; |
59 | delete $scope.cisterna.cisternaCarga.articulo; | 61 | delete $scope.cisterna.cisternaCarga.articulo; |
60 | focaAbmVehiculoService.guardarCisterna($scope.cisterna).then(function(){ | 62 | focaAbmVehiculoService.guardarCisterna($scope.cisterna).then(function(){ |
61 | $location.path('/vehiculo/' + $routeParams.idVehiculo); | 63 | $location.path('/vehiculo/' + $routeParams.idVehiculo); |
62 | }); | 64 | }); |
63 | }, function() { | 65 | }, function(err) { |
64 | focaModalService.alert('Código de cisterna existente'); | 66 | focaModalService.alert(err); |
65 | }); | 67 | }); |
66 | 68 | ||
67 | }; | 69 | }; |
68 | 70 | ||
69 | // $scope.seleccionarArticulo = function() { | ||
70 | // var modalInstance = $uibModal.open( | ||
71 | // { | ||
72 | // ariaLabelledBy: 'Busqueda de Productos', | ||
73 | // templateUrl: 'modal-busqueda-productos.html', | ||
74 | // controller: 'modalBusquedaProductosCtrl', | ||
75 | // resolve: { | ||
76 | // parametroProducto: { | ||
77 | // idLista: -1, | ||
78 | // cotizacion: 1, | ||
79 | // simbolo: '$' | ||
80 | // } | ||
81 | // }, | ||
82 | // size: 'lg' | ||
83 | // } | ||
84 | // ); | ||
85 | // modalInstance.result.then( | ||
86 | // function(producto) { | ||
87 | // $scope.cisterna.cisternaCarga.idProducto = producto.id, | ||
88 | // $scope.cisterna.cisternaCarga.articulo.DetArt = producto.descripcion; | ||
89 | // }, function() { | ||
90 | // // funcion ejecutada cuando se cancela el modal | ||
91 | // } | ||
92 | // ); | ||
93 | // }; | ||
94 | |||
95 | $scope.seleccionarUnidadMedida = function() { | 71 | $scope.seleccionarUnidadMedida = function() { |
96 | var modalInstance = $uibModal.open( | 72 | var modalInstance = $uibModal.open( |
97 | { | 73 | { |
98 | ariaLabelledBy: 'Busqueda de Unidades de medida', | 74 | ariaLabelledBy: 'Busqueda de Unidades de medida', |
99 | templateUrl: 'modal-unidad-medida.html', | 75 | templateUrl: 'modal-unidad-medida.html', |
100 | controller: 'focaModalUnidadMedidaCtrl', | 76 | controller: 'focaModalUnidadMedidaCtrl', |
101 | size: 'lg' | 77 | size: 'lg' |
102 | } | 78 | } |
103 | ); | 79 | ); |
104 | modalInstance.result.then(function(unidaMedida) { | 80 | modalInstance.result.then(function(unidaMedida) { |
105 | $scope.cisterna.idUnidadMedida = unidaMedida.ID; | 81 | $scope.cisterna.idUnidadMedida = unidaMedida.ID; |
106 | $scope.cisterna.unidadMedida = unidaMedida; | 82 | $scope.cisterna.unidadMedida = unidaMedida; |
107 | }); | 83 | }); |
108 | }; | 84 | }; |
109 | 85 | ||
110 | function existeCodigoCisterna(){ | 86 | function validaCodigoCapacidad(){ |
111 | return new Promise(function(resolve, reject) { | 87 | return new Promise(function(resolve, reject) { |
112 | focaAbmVehiculoService | 88 | focaAbmVehiculoService |
113 | .getCisternadoPorVehiculo($routeParams.idVehiculo) | 89 | .getCisternadoPorVehiculo($routeParams.idVehiculo) |
114 | .then(function(res){ | 90 | .then(function(res){ |
115 | //Valida si existe numero de unidad | 91 | |
116 | var existe = res.data.filter(function(cisterna) { | 92 | var totalCargado = 0; |
117 | return cisterna.codigo === $scope.cisterna.codigo && | 93 | |
118 | cisterna.id !== $scope.cisterna.id; | 94 | res.data.forEach(function(cisterna) { |
95 | //SI EL CODIGO YA EXISTE | ||
96 | if(cisterna.codigo === $scope.cisterna.codigo && | ||
97 | cisterna.id !== $scope.cisterna.id){ | ||
98 | reject('Código de cisterna existente'); | ||
99 | } | ||
100 | if(cisterna.id !== $scope.cisterna.id){ | ||
101 | totalCargado += cisterna.capacidad; | ||
102 | } | ||
119 | }); | 103 | }); |
120 | 104 | ||
121 | if(existe.length){ | 105 | //SI EL TOTAL DE CAPACIDAD DE CISTERNAS ES MAYOR QUE LA DEL VEHICULO |
src/views/foca-abm-cisterna-item.html
1 | <div class="row"> | 1 | <div class="row"> |
2 | <foca-cabecera-facturador | 2 | <foca-cabecera-facturador |
3 | titulo="'Vehículo cisterna'" | 3 | titulo="'Vehículo cisterna'" |
4 | fecha="now" | 4 | fecha="now" |
5 | class="mb-0 col-lg-12" | 5 | class="mb-0 col-lg-12" |
6 | ></foca-cabecera-facturador> | 6 | ></foca-cabecera-facturador> |
7 | </div> | 7 | </div> |
8 | <div class="row"></div> | 8 | <div class="row"></div> |
9 | <form name="formCisterna"> | 9 | <form name="formCisterna"> |
10 | <div class="form-group row"> | 10 | <div class="form-group row"> |
11 | <label class="offset-sm-1 col-sm-2 col-form-label">Código de cisterna</label> | 11 | <label class="offset-sm-1 col-sm-2 col-form-label">Código de cisterna</label> |
12 | <div class="col-sm-4"> | 12 | <div class="col-sm-4"> |
13 | <input | 13 | <input |
14 | class="form-control" | 14 | class="form-control" |
15 | type="text" | 15 | type="text" |
16 | ng-required="true" | 16 | ng-required="true" |
17 | ng-model="cisterna.codigo" | 17 | ng-model="cisterna.codigo" |
18 | ng-keypress="next($event.keyCode)" | 18 | ng-keypress="next($event.keyCode)" |
19 | foca-focus="focused == 1" | 19 | foca-focus="focused == 1" |
20 | ng-focus="focused = 1" | 20 | ng-focus="focused = 1" |
21 | teclado-virtual | 21 | teclado-virtual |
22 | /> | 22 | /> |
23 | </div> | 23 | </div> |
24 | </div> | 24 | </div> |
25 | <div class="form-group row"> | 25 | <div class="form-group row"> |
26 | <label class="offset-sm-1 col-sm-2 col-form-label">Capacidad</label> | 26 | <label class="offset-sm-1 col-sm-2 col-form-label">Capacidad</label> |
27 | <div class="col-sm-4"> | 27 | <div class="col-sm-4"> |
28 | <input | 28 | <input |
29 | class="form-control" | 29 | class="form-control" |
30 | type="text" | 30 | type="text" |
31 | teclado-virtual | 31 | teclado-virtual |
32 | foca-tipo-input | 32 | foca-tipo-input |
33 | ng-model="cisterna.capacidad" | 33 | ng-model="cisterna.capacidad" |
34 | ng-required="true" | 34 | ng-required="true" |
35 | ng-keypress="next($event.keyCode)" | 35 | ng-keypress="next($event.keyCode)" |
36 | foca-focus="focused == 2" | 36 | foca-focus="focused == 2" |
37 | ng-focus="focused = 2" | 37 | ng-focus="focused = 2" |
38 | /> | 38 | /> |
39 | </div> | 39 | </div> |
40 | </div> | 40 | </div> |
41 | <div class="form-group row"> | 41 | <div class="form-group row"> |
42 | <label class="offset-sm-1 col-sm-2 col-form-label">Unidad de medida</label> | 42 | <label class="offset-sm-1 col-sm-2 col-form-label">Unidad de medida</label> |
43 | <div class="col-sm-4 input-group"> | 43 | <div class="col-sm-4 input-group"> |
44 | <input | 44 | <input |
45 | ng-model="cisterna.unidadMedida.NOM" | 45 | ng-model="cisterna.unidadMedida.NOM" |
46 | class="form-control" | 46 | class="form-control" |
47 | readonly | 47 | readonly |
48 | /> | 48 | /> |
49 | <div class="input-group-append"> | 49 | <div class="input-group-append"> |
50 | <button | 50 | <button |
51 | ladda="searchLoading" | 51 | ladda="searchLoading" |
52 | class="btn btn-outline-secondary form-control" | 52 | class="btn btn-outline-secondary form-control" |
53 | type="button" | 53 | type="button" |
54 | ng-click="seleccionarUnidadMedida()" | 54 | ng-click="seleccionarUnidadMedida()" |
55 | foca-focus="focused == 3" | 55 | foca-focus="focused == 3" |
56 | > | 56 | > |
57 | <i class="fa fa-search" aria-hidden="true"></i> | 57 | <i class="fa fa-search" aria-hidden="true"></i> |
58 | </button> | 58 | </button> |
59 | </div> | 59 | </div> |
60 | </div> | 60 | </div> |
61 | </div> | 61 | </div> |
62 | <div class="form-group row"> | ||
63 | <label class="offset-sm-1 col-sm-2 col-form-label">Carga</label> | ||
64 | <div class="col-sm-4"> | ||
65 | <input | ||
66 | class="form-control" | ||
67 | foca-tipo-input | ||
68 | teclado-virtual | ||
69 | ng-model="cisterna.cisternaCarga.cantidad" | ||
70 | readonly | ||
71 | /> | ||
72 | </div> | ||
73 | </div> | ||
74 | <div class="form-group row"> | ||
75 | <label class="offset-sm-1 col-sm-2 col-form-label">Producto</label> | ||
76 | <div class="col-sm-4 input-group"> | ||
77 | <input | ||
78 | ng-model="cisterna.cisternaCarga.articulo.DetArt" | ||
79 | class="form-control" | ||
80 | readonly | ||
81 | /> | ||
82 | <!-- <div class="input-group-append"> | ||
83 | <button | ||
84 | ladda="searchLoading" | ||
85 | class="btn btn-outline-secondary form-control" | ||
86 | type="button" | ||
87 | ng-click="seleccionarArticulo(13)" | ||
88 | ng-disabled="editar" | ||
89 | > | ||
90 | <i class="fa fa-search" aria-hidden="true"></i> | ||
91 | </button> | ||
92 | </div> --> | ||
93 | </div> | ||
94 | </div> | ||
95 | </form> | 62 | </form> |
96 | 63 |
src/views/foca-abm-vehiculos-item.html
1 | <div class="row"> | 1 | <div class="row"> |
2 | <foca-cabecera-facturador | 2 | <foca-cabecera-facturador |
3 | titulo="'Vehículo'" | 3 | titulo="'Vehículo'" |
4 | fecha="now" | 4 | fecha="now" |
5 | class="mb-0 col-lg-12" | 5 | class="mb-0 col-lg-12" |
6 | ></foca-cabecera-facturador> | 6 | ></foca-cabecera-facturador> |
7 | </div> | 7 | </div> |
8 | <div class="row"> | 8 | <div class="row"> |
9 | <div class="col-12 col-md-10 p-0 mt-4 border border-white rounded"> | 9 | <div class="col-12 col-md-10 p-0 mt-4 border border-white rounded"> |
10 | <form name="formVehiculo" class="px-3"> | 10 | <form name="formVehiculo" class="px-3"> |
11 | <input type="hidden" name="id" ng-model="sector.id" /> | 11 | <input type="hidden" name="id" ng-model="sector.id" /> |
12 | <div class="row mt-3"> | 12 | <div class="row mt-3"> |
13 | <div class="form-group d-flex mb-2 col-md-6"> | 13 | <div class="form-group d-flex mb-2 col-md-6"> |
14 | <label class="col-form-label col-md-3">Transportista</label> | 14 | <label class="col-form-label col-md-3">Transportista</label> |
15 | <div class="input-group col-md-9 pl-0"> | 15 | <div class="input-group col-md-9 pl-0"> |
16 | <input | 16 | <input |
17 | class="form-control" | 17 | class="form-control" |
18 | type="text" | 18 | type="text" |
19 | ng-model="vehiculo.transportista.NOM" | 19 | ng-value="transportistaStamp" |
20 | readonly | 20 | readonly |
21 | /> | 21 | /> |
22 | </div> | 22 | </div> |
23 | </div> | 23 | </div> |
24 | <div class="form-group d-flex mb-2 col-md-6"> | 24 | <div class="form-group d-flex mb-2 col-md-6"> |
25 | <label class="col-form-label col-md-3">Unidad</label> | 25 | <label class="col-form-label col-md-3">Unidad</label> |
26 | <div class="input-group col-md-9 pl-0"> | 26 | <div class="input-group col-md-9 pl-0"> |
27 | <input | 27 | <input |
28 | class="form-control" | 28 | class="form-control" |
29 | type="text" | 29 | type="text" |
30 | teclado-virtual | 30 | teclado-virtual |
31 | ng-model="vehiculo.codigo" | 31 | ng-model="vehiculo.codigo" |
32 | foca-focus="focused == 2" | 32 | foca-focus="focused == 3" |
33 | ng-focus="focused = 2" | 33 | ng-focus="focused = 3" |
34 | ng-keypress="next($event.keyCode)" | 34 | ng-keypress="next($event.keyCode)" |
35 | /> | 35 | /> |
36 | </div> | 36 | </div> |
37 | </div> | 37 | </div> |
38 | <div class="form-group d-flex mb-2 col-md-6"> | 38 | <div class="form-group d-flex mb-2 col-md-6"> |
39 | <label class="col-form-label col-md-4">Dominio tractor</label> | 39 | <label class="col-form-label col-md-4">Dominio tractor</label> |
40 | <div class="input-group col-md-8 pl-0"> | 40 | <div class="input-group col-md-8 pl-0"> |
41 | <input | 41 | <input |
42 | class="form-control" | 42 | class="form-control" |
43 | type="text" | 43 | type="text" |
44 | teclado-virtual | 44 | teclado-virtual |
45 | ng-model="vehiculo.tractor" | 45 | ng-model="vehiculo.tractor" |
46 | ng-required="true" | 46 | ng-required="true" |
47 | foca-focus="focused == 1" | 47 | foca-focus="focused == 1" |
48 | ng-focus="focused = 1" | 48 | ng-focus="focused = 1" |
49 | ng-keypress="next($event.keyCode)" | 49 | ng-keypress="next($event.keyCode)" |
50 | /> | 50 | /> |
51 | </div> | 51 | </div> |
52 | </div> | 52 | </div> |
53 | <div class="form-group d-flex mb-2 col-md-6"> | 53 | <div class="form-group d-flex mb-2 col-md-6"> |
54 | <label class="col-form-label col-md-4">Dominio semi</label> | 54 | <label class="col-form-label col-md-4">Dominio semi</label> |
55 | <div class="input-group col-md-8 pl-0"> | 55 | <div class="input-group col-md-8 pl-0"> |
56 | <input | 56 | <input |
57 | class="form-control" | 57 | class="form-control" |
58 | type="text" | 58 | type="text" |
59 | teclado-virtual | 59 | teclado-virtual |
60 | ng-model="vehiculo.semi" | 60 | ng-model="vehiculo.semi" |
61 | ng-required="true" | 61 | ng-required="true" |
62 | foca-focus="focused == 3" | 62 | foca-focus="focused == 4" |
63 | ng-focus="focused = 3" | 63 | ng-focus="focused = 4" |
64 | ng-keypress="next($event.keyCode)" | ||
65 | /> | ||
66 | </div> | ||
67 | </div> | ||
68 | <div class="form-group d-flex mb-2 col-md-6"> | ||
69 | <label class="col-form-label col-md-4">Capacidad total</label> | ||
70 | <div class="input-group col-md-8 pl-0"> | ||
71 | <input | ||
72 | class="form-control" | ||
73 | type="text" | ||
74 | teclado-virtual | ||
75 | ng-model="vehiculo.capacidad" | ||
76 | ng-required="true" | ||
77 | foca-focus="focused == 2" | ||
78 | ng-focus="focused = 2" | ||
64 | ng-keypress="next($event.keyCode)" | 79 | ng-keypress="next($event.keyCode)" |
65 | /> | 80 | /> |
66 | </div> | 81 | </div> |
67 | </div> | 82 | </div> |
68 | </div> | 83 | </div> |
69 | </form> | 84 | </form> |
70 | <div ng-show="!nuevo"> | 85 | <div ng-show="!nuevo"> |
71 | <h5 class="pl-4 table-title">Cisternas</h5> | 86 | <h5 class="pl-4 table-title">Cisternas</h5> |
72 | <table class="table table-default table-hover table-sm table-abm table-striped mb-0"> | 87 | <table class="table table-default table-hover table-sm table-abm table-striped mb-0"> |
73 | <thead> | 88 | <thead> |
74 | <tr> | 89 | <tr> |
75 | <th class="px-5">Código</th> | 90 | <th class="px-5">Código</th> |
76 | <th class="text-right px-5">Capacidad</th> | 91 | <th class="text-right px-5">Capacidad</th> |
77 | <th class="px-5">Unidad de Medida</th> | ||
78 | <th class="text-right px-5">Carga</th> | ||
79 | <th class="text-center px-4"> | 92 | <th class="text-center px-4"> |
80 | <button | 93 | <button |
81 | class="btn btn-outline-debo boton-accion" | 94 | class="btn btn-outline-debo boton-accion" |
82 | title="Agregar" | 95 | title="Agregar" |
83 | ng-click="editar(0)"> | 96 | ng-click="editar(0)"> |
84 | <i class="fa fa-plus"></i> | 97 | <i class="fa fa-plus"></i> |
85 | </button> | 98 | </button> |
86 | </th> | 99 | </th> |
87 | </tr> | 100 | </tr> |
88 | </thead> | 101 | </thead> |
89 | <tbody> | 102 | <tbody> |
90 | <tr ng-repeat="cisterna in cisternas | filter:filtros"> | 103 | <tr ng-repeat="cisterna in cisternas | filter:filtros"> |
91 | <td ng-bind="cisterna.codigo" class="px-5"></td> | 104 | <td ng-bind="cisterna.codigo" class="px-5"></td> |
92 | <td ng-bind="cisterna.capacidad" class="text-right px-5"></td> | 105 | <td ng-bind="cisterna.capacidad + ' ' + cisterna.unidadMedida.NOM" class="text-right px-5"></td> |
93 | <td ng-bind="cisterna.unidadMedida.NOM" class="px-5"></td> | ||
94 | <td ng-bind="cisterna.cisternaCarga.cantidad || 0" class="text-right px-5"></td> | ||
95 | <td class="text-center px-4"> | 106 | <td class="text-center px-4"> |
96 | <button | 107 | <button |
97 | class="btn btn-outline-dark boton-accion" | 108 | class="btn btn-outline-dark boton-accion" |
98 | title="Editar" | 109 | title="Editar" |
99 | ng-click="editar(cisterna.id)" | 110 | ng-click="editar(cisterna.id)" |
100 | > | 111 | > |
101 | <i class="fa fa-pencil"></i> | 112 | <i class="fa fa-pencil"></i> |
102 | </button> | 113 | </button> |
103 | <button | 114 | <button |
104 | class="btn btn-outline-dark boton-accion" | 115 | class="btn btn-outline-dark boton-accion" |
105 | title="Eliminar" | 116 | title="Eliminar" |
106 | ng-click="solicitarConfirmacionCisterna(cisterna)" | 117 | ng-click="solicitarConfirmacionCisterna(cisterna)" |
107 | > | 118 | > |
108 | <i class="fa fa-trash"></i> | 119 | <i class="fa fa-trash"></i> |
109 | </button> | 120 | </button> |
110 | </td> | 121 | </td> |
111 | </tr> | 122 | </tr> |
112 | </body> | 123 | </body> |
113 | </table> | 124 | </table> |