From d661a13633bd703280018b9a8c383e8a23e60731 Mon Sep 17 00:00:00 2001 From: Eric Fernandez Date: Fri, 19 Oct 2018 11:45:44 -0300 Subject: [PATCH] funcionamiento grilla articulos --- src/js/controller.js | 33 +++++++++++++++++++++++---------- src/views/nota-pedido.html | 33 ++++++++++++++++++++++++--------- 2 files changed, 47 insertions(+), 19 deletions(-) diff --git a/src/js/controller.js b/src/js/controller.js index 2d96f18..89257b7 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -3,7 +3,7 @@ angular.module('focaCrearNotaPedido') ['$scope', '$uibModal', '$location', 'crearNotaPedidoService', function($scope, $uibModal, $location, crearNotaPedidoService) { $scope.show = false; - + $scope.edit = false; $scope.dateOptions = { maxDate: new Date(), minDate: new Date(2010, 0, 1) @@ -197,17 +197,18 @@ angular.module('focaCrearNotaPedido') } ); }; - $scope.getSubTotal = function(item) { - var subTotal = 0; - var array = $scope.articulosTabla.filter( - function(a) { - return a.item <= item; - } - ); + $scope.getTotal = function() { + var total = 0; + var array = $scope.articulosTabla; for (var i = 0; i < array.length; i++) { - subTotal += array[i].precio * array[i].cantidad; + total += array[i].precio * array[i].cantidad; } - return subTotal.toFixed(2); + return total.toFixed(2); + }; + $scope.getSubTotal = function() { + if($scope.articuloACargar) { + return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; + } }; $scope.cargarArticulos = function() { idLista = $scope.notaPedido.precioCondicion; @@ -226,6 +227,7 @@ angular.module('focaCrearNotaPedido') function(precioCondicion) { $scope.notaPedido.precioCondicion = precioCondicion.nombre; idLista = precioCondicion.idListaPrecio; + $scope.articulosTabla = []; }, function() { } @@ -257,6 +259,17 @@ angular.module('focaCrearNotaPedido') $scope.articuloACargar = undefined; } }; + $scope.quitarArticulo = function(key) { + $scope.articulosTabla.splice(key, 1); + }; + $scope.editarArticulo = function(key) { + if(key === 13) { + $scope.edit = false; + } + }; + $scope.cambioEdit = function() { + $scope.edit = !$scope.edit ? true : false; + }; } ] ) diff --git a/src/views/nota-pedido.html b/src/views/nota-pedido.html index 8ad5b59..e535a49 100644 --- a/src/views/nota-pedido.html +++ b/src/views/nota-pedido.html @@ -71,7 +71,7 @@ type="text" readonly="true" ng-model="notaPedido.precioCondicion" - ng-click="abrirModalListaPrecio()" + ng-click="abrirModalListaPrecio()" placeholder="Seleccione Lista de precio" > @@ -153,7 +153,7 @@ - + @@ -175,7 +175,7 @@ readonly> - + - - + + + + - @@ -207,7 +222,7 @@ Cantidad Items: - {{getSubTotal(articulosTabla[0].item) | currency:'$'}} + {{getTotal() | currency:'$'}} -- 1.9.1