Commit c09ac249b620b8ed260f4bef986b5765bc325f28
Exists in
master
Merge branch 'master' into 'master'
Master See merge request modulos-npm/foca-crear-nota-pedido!41
Showing
2 changed files
Show diff stats
src/js/controller.js
... | ... | @@ -41,7 +41,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
41 | 41 | $scope.comprobante = Math.round(Math.random() * 1000000); |
42 | 42 | |
43 | 43 | $scope.articulosTabla = []; |
44 | - var idLista; | |
44 | + $scope.idLista = undefined; | |
45 | 45 | var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); |
46 | 46 | crearNotaPedidoService.getPrecioCondicion().then( |
47 | 47 | function(res) { |
... | ... | @@ -53,7 +53,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
53 | 53 | $scope.notaPedido = notaPedidoTemp; |
54 | 54 | $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); |
55 | 55 | $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); |
56 | - idLista = $scope.notaPedido.precioCondicion; | |
56 | + $scope.idLista = $scope.notaPedido.precioCondicion; | |
57 | 57 | crearNotaPedidoService |
58 | 58 | .getArticulosByIdNotaPedido($scope.notaPedido.id).then( |
59 | 59 | function(res) { |
... | ... | @@ -71,7 +71,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
71 | 71 | $scope.notaPedido.fechaCarga = new Date(); |
72 | 72 | $scope.notaPedido.bomba = '0'; |
73 | 73 | $scope.notaPedido.flete = '0'; |
74 | - idLista = undefined; | |
74 | + $scope.idLista = undefined; | |
75 | 75 | } |
76 | 76 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO |
77 | 77 | // $scope.addNewDom = function() { |
... | ... | @@ -121,7 +121,8 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
121 | 121 | } |
122 | 122 | var articulosNotaPedido = $scope.articulosTabla; |
123 | 123 | for(var i = 0; i < articulosNotaPedido.length; i++) { |
124 | - delete articulosNotaPedido[i].edit; | |
124 | + delete articulosNotaPedido[i].editCantidad; | |
125 | + delete articulosNotaPedido[i].editPrecio; | |
125 | 126 | articulosNotaPedido[i].idNotaPedido = data.data.id; |
126 | 127 | crearNotaPedidoService |
127 | 128 | .crearArticulosParaNotaPedido(articulosNotaPedido[i]); |
... | ... | @@ -141,7 +142,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
141 | 142 | }; |
142 | 143 | |
143 | 144 | $scope.seleccionarArticulo = function() { |
144 | - if (idLista === undefined) { | |
145 | + if ($scope.idLista === undefined) { | |
145 | 146 | focaModalService.alert( |
146 | 147 | 'Primero seleccione una lista de precio y condicion'); |
147 | 148 | return; |
... | ... | @@ -151,7 +152,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
151 | 152 | ariaLabelledBy: 'Busqueda de Productos', |
152 | 153 | templateUrl: 'modal-busqueda-productos.html', |
153 | 154 | controller: 'modalBusquedaProductosCtrl', |
154 | - resolve: { idLista: function() { return idLista; } }, | |
155 | + resolve: { idLista: function() { return $scope.idLista; } }, | |
155 | 156 | size: 'lg' |
156 | 157 | } |
157 | 158 | ); |
... | ... | @@ -166,9 +167,10 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
166 | 167 | descripcion: producto.descripcion, |
167 | 168 | item: $scope.articulosTabla.length + 1, |
168 | 169 | nombre: producto.descripcion, |
169 | - precio: producto.precio.toFixed(2), | |
170 | + precio: parseFloat(producto.precio.toFixed(2)), | |
170 | 171 | costoUnitario: producto.costo, |
171 | - edit: false | |
172 | + editCantidad: false, | |
173 | + editPrecio: false | |
172 | 174 | }; |
173 | 175 | $scope.articuloACargar = newArt; |
174 | 176 | $scope.cargando = false; |
... | ... | @@ -313,13 +315,13 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
313 | 315 | var plazosConcat = ''; |
314 | 316 | if(!Array.isArray(precioCondicion)) { |
315 | 317 | $scope.plazosPagos = precioCondicion.plazoPago; |
316 | - idLista = precioCondicion.idListaPrecio; | |
318 | + $scope.idLista = precioCondicion.idListaPrecio; | |
317 | 319 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { |
318 | 320 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
319 | 321 | } |
320 | 322 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); |
321 | 323 | } else { //Cuando se ingresan los plazos manualmente |
322 | - idLista = -1; //-1, el modal productos busca todos los productos | |
324 | + $scope.idLista = -1; //-1, el modal productos busca todos los productos | |
323 | 325 | $scope.plazosPagos = precioCondicion; |
324 | 326 | for(var j = 0; j < precioCondicion.length; j++) { |
325 | 327 | plazosConcat += precioCondicion[j].dias + ' '; |
... | ... | @@ -451,12 +453,17 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
451 | 453 | focaModalService.alert('El valor debe ser al menos 1'); |
452 | 454 | return; |
453 | 455 | } |
454 | - articulo.edit = false; | |
456 | + articulo.editCantidad = false; | |
457 | + articulo.editPrecio = false; | |
455 | 458 | } |
456 | 459 | }; |
457 | 460 | |
458 | - $scope.cambioEdit = function(articulo) { | |
459 | - articulo.edit = true; | |
461 | + $scope.cambioEdit = function(articulo, propiedad) { | |
462 | + if(propiedad === 'cantidad') { | |
463 | + articulo.editCantidad = true; | |
464 | + } else if(propiedad === 'precio') { | |
465 | + articulo.editPrecio = true; | |
466 | + } | |
460 | 467 | }; |
461 | 468 | |
462 | 469 | $scope.limpiarFlete = function() { |
src/views/nota-pedido.html
... | ... | @@ -126,28 +126,43 @@ |
126 | 126 | class="col-4" |
127 | 127 | ng-bind="articulo.descripcion" |
128 | 128 | ></td> |
129 | - <td class="col text-right"> | |
129 | + <td class="col text-right"> | |
130 | 130 | <input |
131 | - ng-show="articulo.edit" | |
131 | + ng-show="articulo.editCantidad" | |
132 | 132 | ng-model="articulo.cantidad" |
133 | 133 | class="form-control" |
134 | 134 | type="number" |
135 | 135 | min="1" |
136 | - foca-focus="articulo.edit" | |
136 | + foca-focus="articulo.editCantidad" | |
137 | 137 | ng-keypress="editarArticulo($event.keyCode, articulo)" |
138 | 138 | ng-focus="selectFocus($event)" |
139 | 139 | > |
140 | 140 | <i |
141 | 141 | class="selectable" |
142 | - ng-click="cambioEdit(articulo)" | |
143 | - ng-hide="articulo.edit" | |
142 | + ng-click="cambioEdit(articulo, 'cantidad')" | |
143 | + ng-hide="articulo.editCantidad" | |
144 | 144 | ng-bind="articulo.cantidad"> |
145 | 145 | </i> |
146 | 146 | </td> |
147 | - <td | |
148 | - class="col text-right" | |
149 | - ng-bind="articulo.precio | currency: '$'" | |
150 | - ></td> | |
147 | + <td class="col text-right"> | |
148 | + <input | |
149 | + ng-show="articulo.editPrecio" | |
150 | + ng-model="articulo.precio" | |
151 | + class="form-control" | |
152 | + type="number" | |
153 | + min="1" | |
154 | + step="0.01" | |
155 | + foca-focus="articulo.editPrecio" | |
156 | + ng-keypress="editarArticulo($event.keyCode, articulo)" | |
157 | + ng-focus="selectFocus($event)" | |
158 | + > | |
159 | + <i | |
160 | + class="selectable" | |
161 | + ng-click="cambioEdit(articulo, 'precio')" | |
162 | + ng-hide="articulo.editPrecio" | |
163 | + ng-bind="articulo.precio"> | |
164 | + </i> | |
165 | + </td> | |
151 | 166 | <td |
152 | 167 | class="col text-right" |
153 | 168 | ng-bind="(articulo.precio * articulo.cantidad) | currency: '$'"> |
... | ... | @@ -197,8 +212,18 @@ |
197 | 212 | <input |
198 | 213 | class="form-control" |
199 | 214 | ng-value="articuloACargar.precio | currency: '$'" |
215 | + ng-show="idLista != -1" | |
200 | 216 | readonly |
201 | 217 | > |
218 | + <input | |
219 | + class="form-control" | |
220 | + type="number" | |
221 | + step="0.01" | |
222 | + ng-model="articuloACargar.precio" | |
223 | + esc-key="resetFilter()" | |
224 | + ng-keypress="agregarATabla($event.keyCode)" | |
225 | + ng-show="idLista == -1" | |
226 | + > | |
202 | 227 | </td> |
203 | 228 | <td class="col text-right"> |
204 | 229 | <input |