Commit 4deaf827fbd31f418b6d95a278fdb2e5be99a970
1 parent
8f74dfc4bb
Exists in
master
fix funciones
Showing
2 changed files
with
32 additions
and
34 deletions
Show diff stats
src/js/controllerDetalleVehiculo.js
... | ... | @@ -33,7 +33,7 @@ angular.module('focaLogisticaPedidoRuta') |
33 | 33 | $uibModalInstance.close(); |
34 | 34 | } |
35 | 35 | $scope.articulos = $scope.remito.articulosRemito; |
36 | - $scope.cambioArticulo($scope.articulos[0]); | |
36 | + $scope.seleccionarArticulo($scope.articulos[0]); | |
37 | 37 | }); |
38 | 38 | $scope.aceptar = function() { |
39 | 39 | $scope.cargando = true; |
... | ... | @@ -66,11 +66,9 @@ angular.module('focaLogisticaPedidoRuta') |
66 | 66 | focaModalService.alert('Hubo un error al cargar las cisternas'); |
67 | 67 | }); |
68 | 68 | }; |
69 | - | |
70 | 69 | $scope.cancelar = function() { |
71 | 70 | $uibModalInstance.close(); |
72 | 71 | }; |
73 | - | |
74 | 72 | $scope.cargarACisternas = function(vehiculo) { |
75 | 73 | for(var i = 0; i < vehiculo.cisternas.length; i++) { |
76 | 74 | var cisterna = vehiculo.cisternas[i]; |
... | ... | @@ -117,9 +115,8 @@ angular.module('focaLogisticaPedidoRuta') |
117 | 115 | } |
118 | 116 | ); |
119 | 117 | if(articuloSiguiente.length > 0) { |
120 | - $scope.cambioArticulo(articuloSiguiente[0]); | |
118 | + $scope.seleccionarArticulo(articuloSiguiente[0]); | |
121 | 119 | } |
122 | - $scope.aCargar = []; | |
123 | 120 | }; |
124 | 121 | $scope.calcularPorcentaje = function(cisterna) { |
125 | 122 | if(!cisterna.cisternaCarga.cantidad) { |
... | ... | @@ -132,17 +129,10 @@ angular.module('focaLogisticaPedidoRuta') |
132 | 129 | elementHtml.style.width = porcentaje; |
133 | 130 | } |
134 | 131 | }; |
135 | - $scope.cambioArticulo = function(articulo) { | |
136 | - $scope.aCargar = []; | |
137 | - $filter('filter')($scope.articulos, {id: articulo.id})[0].checked = true; | |
132 | + $scope.seleccionarArticulo = function(articulo) { | |
138 | 133 | $scope.articuloSeleccionado = articulo; |
139 | - for(var i = 0; i < $scope.vehiculo.cisternas.length; i++) { | |
140 | - $scope.vehiculo.cisternas[i] = | |
141 | - $scope.cisternaDisabled($scope.vehiculo.cisternas[i]); | |
142 | - } | |
143 | - var disponible = $filter('filter')($scope.vehiculo.cisternas, {disabled: false}); | |
144 | - var index = $scope.vehiculo.cisternas.indexOf(disponible[0]); | |
145 | - $scope.aCargar[index] = $scope.articuloSeleccionado.cantidad; | |
134 | + $scope.cisternaDisabled(); | |
135 | + $scope.autoCompletar(); | |
146 | 136 | $scope.actualizarArticulo(); |
147 | 137 | }; |
148 | 138 | $scope.actualizarArticulo = function () { |
... | ... | @@ -152,26 +142,33 @@ angular.module('focaLogisticaPedidoRuta') |
152 | 142 | parseFloat($scope.aCargar[i]) || 0; |
153 | 143 | } |
154 | 144 | }; |
155 | - $scope.cisternaDisabled = function(cisterna) { | |
156 | - if(!$scope.articuloSeleccionado || ($scope.articuloSeleccionado.idArticulo !== | |
157 | - cisterna.cisternaCarga.idProducto && cisterna.cisternaCarga.idProducto) || | |
158 | - !$scope.tieneArticulosPendientes()|| $scope.articuloSeleccionado.cantidad > | |
159 | - cisterna.disponible) { | |
160 | - cisterna.disabled = true; | |
161 | - }else { | |
162 | - cisterna.disabled = false; | |
163 | - } | |
164 | - return cisterna; | |
145 | + $scope.autoCompletar = function() { | |
146 | + $scope.aCargar = []; | |
147 | + var disponible = $filter('filter')($scope.vehiculo.cisternas, {disabled: false}); | |
148 | + var index = $scope.vehiculo.cisternas.indexOf(disponible[0]); | |
149 | + $scope.aCargar[index] = $scope.articuloSeleccionado.cantidad; | |
150 | + }; | |
151 | + $scope.cisternaDisabled = function() { | |
152 | + for (var i = 0; i < $scope.vehiculo.cisternas.length; i++) { | |
153 | + var cisterna = $scope.vehiculo.cisternas[i]; | |
154 | + if(!$scope.articuloSeleccionado || ($scope.articuloSeleccionado.idArticulo !== | |
155 | + cisterna.cisternaCarga.idProducto && cisterna.cisternaCarga.idProducto) || | |
156 | + !$scope.tieneArticulosPendientes()|| $scope.articuloSeleccionado.cantidad > | |
157 | + cisterna.disponible) { | |
158 | + cisterna.disabled = true; | |
159 | + }else { | |
160 | + cisterna.disabled = false; | |
161 | + } | |
162 | + } | |
165 | 163 | }; |
166 | 164 | $scope.rellenarInput = function(input) { |
167 | 165 | if(!$scope.articuloSeleccionado) return; |
166 | + if($scope.articuloSeleccionado.cantidad - | |
167 | + $scope.articuloSeleccionado.cantidadCargada === 0) { | |
168 | + return input; | |
169 | + } | |
168 | 170 | if(!input) input = 0; |
169 | 171 | input = parseFloat(input); |
170 | - if(input === $scope.articuloSeleccionado.cantidad || | |
171 | - $scope.articuloSeleccionado.cantidad - | |
172 | - $scope.articuloSeleccionado.cantidadCargada === 0) { | |
173 | - return input; | |
174 | - } | |
175 | 172 | input += parseFloat($scope.articuloSeleccionado.cantidad - |
176 | 173 | $scope.articuloSeleccionado.cantidadCargada); |
177 | 174 | return input; |
src/views/foca-detalle-vehiculo.html
... | ... | @@ -35,9 +35,9 @@ |
35 | 35 | type="radio" |
36 | 36 | name="articuloRadio" |
37 | 37 | id="{{'articulo' + articulo.id}}" |
38 | - ng-checked="articulo.checked" | |
38 | + ng-checked="articuloSeleccionado.id === articulo.id" | |
39 | 39 | ng-disabled="articulo.cargado" |
40 | - ng-click="cambioArticulo(articulo)" | |
40 | + ng-click="seleccionarArticulo(articulo)" | |
41 | 41 | ></td> |
42 | 42 | <td ng-bind="articulo.descripcion"></td> |
43 | 43 | <td ng-bind="articulo.cantidad"></td> |
... | ... | @@ -98,7 +98,7 @@ |
98 | 98 | </tr> |
99 | 99 | </tbody> |
100 | 100 | </table> |
101 | - <div class="col-12 aling-end"> | |
101 | + <div class="col-12"> | |
102 | 102 | <button |
103 | 103 | class="form-control btn btn-success" |
104 | 104 | ladda="cargando" |
... | ... | @@ -124,5 +124,6 @@ |
124 | 124 | ladda="cargando" |
125 | 125 | type="button" |
126 | 126 | ng-click="aceptar()" |
127 | - ng-disabled="tieneArticulosPendientes() || idRemito === -1">Cargar</button> | |
127 | + ng-disabled="tieneArticulosPendientes() || idRemito === -1" | |
128 | + foca-focus="!tieneArticulosPendientes() && idRemito !== -1">Cargar</button> | |
128 | 129 | </div> |