Commit e40d9b090658517428d41e5fd48168da32ebca59
Exists in
master
Merge branch 'master' into 'develop'
Master See merge request !73
Showing
2 changed files
Show diff stats
src/js/controller.js
... | ... | @@ -23,6 +23,8 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
23 | 23 | |
24 | 24 | function config() { |
25 | 25 | // PARAMETROS INICIALES PARA FUNCIONAMIENTO DEL PROGRAMA |
26 | + $scope.tmpCantidad = Number; | |
27 | + $scope.tmpPrecio = Number; | |
26 | 28 | $scope.notaPedido = {}; |
27 | 29 | $scope.isNumber = angular.isNumber; |
28 | 30 | $scope.datepickerAbierto = false; |
... | ... | @@ -76,7 +78,10 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
76 | 78 | fechaCarga: new Date(), |
77 | 79 | cotizacion: {}, |
78 | 80 | articulosNotaPedido: [], |
79 | - notaPedidoPlazo: [] | |
81 | + notaPedidoPlazo: [], | |
82 | + notaPedidoPuntoDescarga: { | |
83 | + puntoDescarga: {} | |
84 | + } | |
80 | 85 | }; |
81 | 86 | $scope.idLista = undefined; |
82 | 87 | |
... | ... | @@ -313,19 +318,19 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
313 | 318 | idDomicilio: $scope.notaPedido.domicilio.id, |
314 | 319 | idCliente: $scope.notaPedido.cliente.COD, |
315 | 320 | articulos: $scope.notaPedido.articulosNotaPedido, |
316 | - puntosDescarga: $scope.notaPedido.notaPedidoPuntoDescarga, | |
321 | + puntoDescarga: $scope.notaPedido.notaPedidoPuntoDescarga, | |
317 | 322 | domicilio: $scope.notaPedido.domicilio |
318 | 323 | } |
319 | 324 | } |
320 | 325 | } |
321 | 326 | ); |
322 | 327 | modalInstance.result.then( |
323 | - function(puntosDescarga) { | |
324 | - $scope.notaPedido.notaPedidoPuntoDescarga = puntosDescarga; | |
328 | + function(puntoDescarga) { | |
329 | + $scope.notaPedido.notaPedidoPuntoDescarga = puntoDescarga; | |
325 | 330 | |
326 | 331 | $scope.$broadcast('addCabecera', { |
327 | 332 | label: 'Puntos de descarga:', |
328 | - valor: getCabeceraPuntoDescarga(puntosDescarga) | |
333 | + valor: getCabeceraPuntoDescarga(puntoDescarga) | |
329 | 334 | }); |
330 | 335 | }, function() { |
331 | 336 | $scope.abrirModalDomicilios($scope.cliente); |
... | ... | @@ -530,7 +535,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
530 | 535 | domicilio.Localidad + ', ' + domicilio.Provincia; |
531 | 536 | $scope.notaPedido.domicilioStamp = domicilioStamp; |
532 | 537 | |
533 | - $scope.notaPedido.notaPedidoPuntoDescarga = domicilio.puntosDescarga; | |
538 | + $scope.notaPedido.notaPedidoPuntoDescarga = domicilio.puntoDescarga; | |
534 | 539 | |
535 | 540 | $scope.$broadcast('addCabecera', { |
536 | 541 | label: 'Cliente:', |
... | ... | @@ -612,23 +617,23 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
612 | 617 | $scope.notaPedido.precioCondicion = precioCondicion; |
613 | 618 | $scope.notaPedido.idPrecioCondicion = precioCondicion.id; |
614 | 619 | $scope.idLista = precioCondicion.idListaPrecio; |
615 | - for (var i = 0; i < precioCondicion.plazoPago.length; i++) { | |
616 | - plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | |
617 | - } | |
618 | - cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + | |
619 | - ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim(); | |
620 | + for (var i = 0; i < precioCondicion.plazoPago.length; i++) { | |
621 | + plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | |
622 | + } | |
623 | + cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + | |
624 | + ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim(); | |
620 | 625 | } else { //Cuando se ingresan los plazos manualmente |
621 | 626 | $scope.notaPedido.idPrecioCondicion = 0; |
622 | - //-1, el modal productos busca todos los productos | |
623 | - $scope.idLista = -1; | |
627 | + //-1, el modal productos busca todos los productos | |
628 | + $scope.idLista = -1; | |
624 | 629 | $scope.notaPedido.notaPedidoPlazo = precioCondicion; |
625 | - for (var j = 0; j < precioCondicion.length; j++) { | |
626 | - plazosConcat += precioCondicion[j].dias + ' '; | |
627 | - } | |
630 | + for (var j = 0; j < precioCondicion.length; j++) { | |
631 | + plazosConcat += precioCondicion[j].dias + ' '; | |
632 | + } | |
628 | 633 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
629 | 634 | } |
630 | 635 | $scope.notaPedido.articulosNotaPedido = []; |
631 | - $scope.$broadcast('addCabecera', { | |
636 | + $scope.$broadcast('addCabecera', { | |
632 | 637 | label: 'Precios y condiciones:', |
633 | 638 | valor: cabecera |
634 | 639 | }); |
... | ... | @@ -749,17 +754,27 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
749 | 754 | $scope.notaPedido.articulosNotaPedido.splice(key, 1); |
750 | 755 | }; |
751 | 756 | |
752 | - $scope.editarArticulo = function(key, articulo) { | |
757 | + $scope.editarArticulo = function(key, articulo, tmpCantidad, tmpPrecio) { | |
753 | 758 | if (key === 13) { |
754 | - if (articulo.cantidad === null || articulo.cantidad === 0 || | |
755 | - articulo.cantidad === undefined) { | |
756 | - focaModalService.alert('El valor debe ser al menos 1'); | |
759 | + if (!articulo.cantidad || !articulo.precio) { | |
760 | + focaModalService.alert('Los valores deben ser al menos 1'); | |
761 | + return; | |
762 | + } else if (articulo.cantidad < 0 || articulo.precio < 0) { | |
763 | + focaModalService.alert('Los valores no pueden ser negativos'); | |
757 | 764 | return; |
758 | 765 | } |
759 | - articulo.editCantidad = false; | |
760 | - articulo.editPrecio = false; | |
766 | + articulo.cantidad = tmpCantidad; | |
767 | + articulo.precio = tmpPrecio; | |
768 | + $scope.getTotal(); | |
769 | + articulo.editCantidad = articulo.editPrecio = false; | |
761 | 770 | } |
762 | 771 | }; |
772 | + | |
773 | + $scope.cancelarEditar = function(articulo) { | |
774 | + $scope.tmpCantidad = articulo.cantidad; | |
775 | + $scope.tmpPrecio = articulo.precio; | |
776 | + articulo.editCantidad = articulo.editPrecio = false; | |
777 | + }; | |
763 | 778 | |
764 | 779 | $scope.cambioEdit = function(articulo, propiedad) { |
765 | 780 | if (propiedad === 'cantidad') { |
... | ... | @@ -911,20 +926,23 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
911 | 926 | notaPedido.numeroNotaPedido, 8 |
912 | 927 | ); |
913 | 928 | |
914 | - if (notaPedido.notaPedidoPuntoDescarga) { | |
915 | - var puntosDescarga = notaPedido.notaPedidoPuntoDescarga; | |
929 | + if (notaPedido.notaPedidoPuntoDescarga) { | |
930 | + var puntos = []; | |
931 | + notaPedido.notaPedidoPuntoDescarga.forEach(function(notaPedidoPuntoDescarga, idx, arr) { | |
932 | + puntos.push(notaPedidoPuntoDescarga.puntoDescarga); | |
933 | + }); | |
916 | 934 | cabeceras.push({ |
917 | 935 | label: 'Puntos de descarga: ', |
918 | - valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntosDescarga)) | |
936 | + valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntos)) | |
919 | 937 | }); |
920 | 938 | } |
921 | 939 | |
922 | 940 | addArrayCabecera(cabeceras); |
923 | 941 | } |
924 | 942 | |
925 | - function getCabeceraPuntoDescarga(puntosDescarga){ | |
943 | + function getCabeceraPuntoDescarga(puntoDescarga){ | |
926 | 944 | var puntosStamp = ''; |
927 | - puntosDescarga.forEach(function(punto, idx, arr) { | |
945 | + puntoDescarga.forEach(function(punto, idx, arr) { | |
928 | 946 | puntosStamp += punto.descripcion; |
929 | 947 | if ((idx + 1) !== arr.length) puntosStamp += ', '; |
930 | 948 | }); |
src/views/nota-pedido.html
... | ... | @@ -69,14 +69,16 @@ |
69 | 69 | <td class="col text-right"> |
70 | 70 | <input |
71 | 71 | ng-show="articulo.editCantidad" |
72 | - ng-model="articulo.cantidad" | |
72 | + ng-model="tmpCantidad" | |
73 | 73 | class="form-control" |
74 | 74 | foca-tipo-input |
75 | 75 | min="1" |
76 | - step="0.001" | |
77 | 76 | foca-focus="articulo.editCantidad" |
78 | - ng-keypress="editarArticulo($event.keyCode, articulo)" | |
79 | - ng-focus="selectFocus($event)" | |
77 | + ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);" | |
78 | + esc-key="cancelarEditar(articulo)" | |
79 | + ng-focus="selectFocus($event); | |
80 | + tmpCantidad = articulo.cantidad; | |
81 | + tmpPrecio = articulo.precio" | |
80 | 82 | teclado-virtual |
81 | 83 | > |
82 | 84 | <i |
... | ... | @@ -89,22 +91,24 @@ |
89 | 91 | <td class="col text-right"> |
90 | 92 | <input |
91 | 93 | ng-show="articulo.editPrecio" |
92 | - ng-model="articulo.precio" | |
94 | + ng-model="tmpPrecio" | |
93 | 95 | class="form-control" |
94 | 96 | foca-tipo-input |
95 | - min="0" | |
97 | + min="1" | |
96 | 98 | step="0.0001" |
97 | 99 | foca-focus="articulo.editPrecio" |
98 | - ng-keypress="editarArticulo($event.keyCode, articulo)" | |
99 | - ng-focus="selectFocus($event)" | |
100 | + ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);" | |
101 | + esc-key="cancelarEditar(articulo)" | |
102 | + ng-focus="selectFocus($event); | |
103 | + tmpCantidad = articulo.cantidad; | |
104 | + tmpPrecio = articulo.precio" | |
100 | 105 | teclado-virtual |
101 | 106 | > |
102 | 107 | <i |
103 | 108 | class="selectable" |
104 | - ng-click="idLista == -1 && cambioEdit(articulo, 'precio')" | |
109 | + ng-click="cambioEdit(articulo, 'precio')" | |
105 | 110 | ng-hide="articulo.editPrecio" |
106 | - ng-bind="articulo.precio | | |
107 | - number: 4"> | |
111 | + ng-bind="articulo.precio | number: 4"> | |
108 | 112 | </i> |
109 | 113 | </td> |
110 | 114 | <td |