Commit cd2f24f5f8a090bdcf19e1c6a7eb09fe7d06e9ba

Authored by Eric Fernandez
1 parent 2813aeb8f7
Exists in master

precio editable cuando precios-condiciones ingresa plazo manual

Showing 2 changed files with 54 additions and 22 deletions   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(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
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(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
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(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
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(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
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 + ' ';
... ... @@ -422,12 +424,17 @@ angular.module(&#39;focaCrearNotaPedido&#39;) .controller(&#39;notaPedidoCtrl&#39;,
422 424 focaModalService.alert('El valor debe ser al menos 1');
423 425 return;
424 426 }
425   - articulo.edit = false;
  427 + articulo.editCantidad = false;
  428 + articulo.editPrecio = false;
426 429 }
427 430 };
428 431  
429   - $scope.cambioEdit = function(articulo) {
430   - articulo.edit = true;
  432 + $scope.cambioEdit = function(articulo, propiedad) {
  433 + if(propiedad === 'cantidad') {
  434 + articulo.editCantidad = true;
  435 + } else if(propiedad === 'precio') {
  436 + articulo.editPrecio = true;
  437 + }
431 438 };
432 439  
433 440 $scope.limpiarFlete = function() {
src/views/nota-pedido.html
... ... @@ -125,28 +125,43 @@
125 125 class="col-4"
126 126 ng-bind="articulo.descripcion"
127 127 ></td>
128   - <td class="col text-right">
  128 + <td class="col text-right">
129 129 <input
130   - ng-show="articulo.edit"
  130 + ng-show="articulo.editCantidad"
131 131 ng-model="articulo.cantidad"
132 132 class="form-control"
133 133 type="number"
134 134 min="1"
135   - foca-focus="articulo.edit"
  135 + foca-focus="articulo.editCantidad"
136 136 ng-keypress="editarArticulo($event.keyCode, articulo)"
137 137 ng-focus="selectFocus($event)"
138 138 >
139 139 <i
140 140 class="selectable"
141   - ng-click="cambioEdit(articulo)"
142   - ng-hide="articulo.edit"
  141 + ng-click="cambioEdit(articulo, 'cantidad')"
  142 + ng-hide="articulo.editCantidad"
143 143 ng-bind="articulo.cantidad">
144 144 </i>
145 145 </td>
146   - <td
147   - class="col text-right"
148   - ng-bind="articulo.precio | currency: '$'"
149   - ></td>
  146 + <td class="col text-right">
  147 + <input
  148 + ng-show="articulo.editPrecio"
  149 + ng-model="articulo.precio"
  150 + class="form-control"
  151 + type="number"
  152 + min="1"
  153 + step="0.01"
  154 + foca-focus="articulo.editPrecio"
  155 + ng-keypress="editarArticulo($event.keyCode, articulo)"
  156 + ng-focus="selectFocus($event)"
  157 + >
  158 + <i
  159 + class="selectable"
  160 + ng-click="cambioEdit(articulo, 'precio')"
  161 + ng-hide="articulo.editPrecio"
  162 + ng-bind="articulo.precio">
  163 + </i>
  164 + </td>
150 165 <td
151 166 class="col text-right"
152 167 ng-bind="(articulo.precio * articulo.cantidad) | currency: '$'">
... ... @@ -196,8 +211,18 @@
196 211 <input
197 212 class="form-control"
198 213 ng-value="articuloACargar.precio | currency: '$'"
  214 + ng-show="idLista != -1"
199 215 readonly
200 216 >
  217 + <input
  218 + class="form-control"
  219 + type="number"
  220 + step="0.01"
  221 + ng-model="articuloACargar.precio"
  222 + esc-key="resetFilter()"
  223 + ng-keypress="agregarATabla($event.keyCode)"
  224 + ng-show="idLista == -1"
  225 + >
201 226 </td>
202 227 <td class="col text-right">
203 228 <input