Commit 2cae8ae31a241c00e3499c5826a2aa57b1ce3f80
Exists in
master
Merge branch 'master' of git.focasoftware.com:mpuebla/foca-crear-nota-pedido
# Conflicts: # src/js/controller.js
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 | |
| ... | ... | @@ -188,7 +193,7 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 188 | 193 | data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); |
| 189 | 194 | |
| 190 | 195 | if ($scope.notaPedido.notaPedidoPuntoDescarga) { |
| 191 | - notaPedidoBusinessService.addPuntosDescarga(data.data.id, | |
| 196 | + notaPedidoBusinessService.addpuntoDescarga(data.data.id, | |
| 192 | 197 | $scope.notaPedido.notaPedidoPuntoDescarga); |
| 193 | 198 | } |
| 194 | 199 | |
| ... | ... | @@ -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:', |
| ... | ... | @@ -739,17 +744,27 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 739 | 744 | $scope.notaPedido.articulosNotaPedido.splice(key, 1); |
| 740 | 745 | }; |
| 741 | 746 | |
| 742 | - $scope.editarArticulo = function(key, articulo) { | |
| 747 | + $scope.editarArticulo = function(key, articulo, tmpCantidad, tmpPrecio) { | |
| 743 | 748 | if (key === 13) { |
| 744 | - if (articulo.cantidad === null || articulo.cantidad === 0 || | |
| 745 | - articulo.cantidad === undefined) { | |
| 746 | - focaModalService.alert('El valor debe ser al menos 1'); | |
| 749 | + if (!articulo.cantidad || !articulo.precio) { | |
| 750 | + focaModalService.alert('Los valores deben ser al menos 1'); | |
| 751 | + return; | |
| 752 | + } else if (articulo.cantidad < 0 || articulo.precio < 0) { | |
| 753 | + focaModalService.alert('Los valores no pueden ser negativos'); | |
| 747 | 754 | return; |
| 748 | 755 | } |
| 749 | - articulo.editCantidad = false; | |
| 750 | - articulo.editPrecio = false; | |
| 756 | + articulo.cantidad = tmpCantidad; | |
| 757 | + articulo.precio = tmpPrecio; | |
| 758 | + $scope.getTotal(); | |
| 759 | + articulo.editCantidad = articulo.editPrecio = false; | |
| 751 | 760 | } |
| 752 | 761 | }; |
| 762 | + | |
| 763 | + $scope.cancelarEditar = function(articulo) { | |
| 764 | + $scope.tmpCantidad = articulo.cantidad; | |
| 765 | + $scope.tmpPrecio = articulo.precio; | |
| 766 | + articulo.editCantidad = articulo.editPrecio = false; | |
| 767 | + }; | |
| 753 | 768 | |
| 754 | 769 | $scope.cambioEdit = function(articulo, propiedad) { |
| 755 | 770 | if (propiedad === 'cantidad') { |
| ... | ... | @@ -902,19 +917,22 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 902 | 917 | ); |
| 903 | 918 | |
| 904 | 919 | if (notaPedido.notaPedidoPuntoDescarga) { |
| 905 | - var puntosDescarga = notaPedido.notaPedidoPuntoDescarga | |
| 920 | + var puntos = []; | |
| 921 | + notaPedido.notaPedidoPuntoDescarga.forEach(function(notaPedidoPuntoDescarga, idx, arr) { | |
| 922 | + puntos.push(notaPedidoPuntoDescarga.puntoDescarga); | |
| 923 | + }); | |
| 906 | 924 | cabeceras.push({ |
| 907 | 925 | label: 'Puntos de descarga: ', |
| 908 | - valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntosDescarga)) | |
| 926 | + valor: $filter('rellenarDigitos')(getCabeceraPuntoDescarga(puntos)) | |
| 909 | 927 | }); |
| 910 | 928 | } |
| 911 | 929 | |
| 912 | 930 | addArrayCabecera(cabeceras); |
| 913 | 931 | } |
| 914 | 932 | |
| 915 | - function getCabeceraPuntoDescarga(puntosDescarga){ | |
| 933 | + function getCabeceraPuntoDescarga(puntoDescarga){ | |
| 916 | 934 | var puntosStamp = ''; |
| 917 | - puntosDescarga.forEach(function(punto, idx, arr) { | |
| 935 | + puntoDescarga.forEach(function(punto, idx, arr) { | |
| 918 | 936 | puntosStamp += punto.descripcion; |
| 919 | 937 | if ((idx + 1) !== arr.length) puntosStamp += ', '; |
| 920 | 938 | }); |
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 |