From 47bc57f50a176ecc6848dfff9b8c523da933f229 Mon Sep 17 00:00:00 2001 From: Eric Fernandez Date: Mon, 8 Oct 2018 19:09:19 -0300 Subject: [PATCH] agrego llamadas a los modal varios --- src/js/controller.js | 140 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 101 insertions(+), 39 deletions(-) diff --git a/src/js/controller.js b/src/js/controller.js index f35452c..418d37c 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -6,44 +6,28 @@ angular.module('focaCrearNotaPedido') 'crearNotaPedidoService', function ($scope, $uibModal, crearNotaPedidoService) { $scope.notaPedido = {}; + $scope.articulosTabla = []; + var idLista; var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); - var domiciliosCliente = [ - { - dom: 'sanjuan', - id: 3 - }, - { - dom: 'mendoza', - id: 2 + $scope.domiciliosCliente = crearNotaPedidoService.getDomicilios(1); + crearNotaPedidoService.getPrecioCondicion().then( + function (res) { + $scope.precioCondiciones = res.data; } - ] + ); if (notaPedidoTemp != undefined) { notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); $scope.notaPedido = notaPedidoTemp; - $scope.notaPedido.domicilio = domiciliosCliente; + $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); + $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); + $scope.notaPedido.precioCondicion = 2; + } else { $scope.notaPedido.fechaCarga = new Date(); - - $scope.notaPedido.domicilio = domiciliosCliente; + $scope.notaPedido.domicilio = [{ id: 0 }] + $scope.notaPedido.bomba = '1'; + $scope.notaPedido.flete = '1'; } - $scope.precioCondiciones = [ - { nombre: 'Precio y condicion 1' }, - { nombre: 'Precio y condicion 2' }, - { nombre: 'Precio y condicion 3' } - ] - $scope.articulosTabla = [ - { - codigo: '1', - item: 1, - nombre: 'naftaaskdahsñodaskdjhañslkdjahslñkjdhalskjdhaksjdhkasjhasddddddddddddddddddddddddddddddddddddddddddddddddd', - precio: '14,50', - costoUnitario: '14', - cantidad: 1, - subtotal: '19,22' - } - ] - $scope.notaPedido.bomba = '1'; - $scope.notaPedido.flete = '1'; $scope.addNewDom = function () { $scope.notaPedido.domicilio.push({ 'id': 0 }); } @@ -56,7 +40,7 @@ angular.module('focaCrearNotaPedido') var notaPedido = { idNotaPedido: 0, precioCondicion: $scope.notaPedido.precioCondicion, - fechaCarga: $scope.notaPedido.clientefechaCarga, + fechaCarga: $scope.notaPedido.fechaCarga, vendedor: $scope.notaPedido.vendedor, cliente: $scope.notaPedido.cliente, producto: $scope.notaPedido.producto, @@ -64,10 +48,11 @@ angular.module('focaCrearNotaPedido') petrolera: $scope.notaPedido.petrolera, domicilio: $scope.notaPedido.domicilio, kilometros: $scope.notaPedido.kilometros, - jurisdiccionIIBB: $scope.notaPedido.jurisdiccion, + jurisdiccionIIBB: $scope.notaPedido.jurisdiccionIIBB, costoFinanciacion: $scope.notaPedido.costoFinanciacion, flete: $scope.notaPedido.flete, - costoUnitarioKmFlete: $scope.costoUnitarioKmFlete + costoUnitarioKmFlete: $scope.notaPedido.costoUnitarioKmFlete, + articulosTabla: $scope.articulosTabla } crearNotaPedidoService.crearNotaPedido(notaPedido).then( function (res) { @@ -79,23 +64,87 @@ angular.module('focaCrearNotaPedido') $scope.active = 1; } $scope.seleccionarArticulo = function () { - var modalIntance = $uibModal.open( + if(idLista==undefined){ + alert('primero seleccione una lista de precio y condicion'); + return; + } + var modalInstance = $uibModal.open( { ariaLabelledBy: 'Busqueda de Productos', templateUrl: 'modal-busqueda-productos.html', controller: 'modalBusquedaProductosCtrl', - size: 'md' + resolve: {idLista: function() {return idLista}}, + size: 'lg' } ) modalInstance.result.then( function (producto) { - console.info(producto); - // variable producto tiene el producto seleccionado en el modal + var newArt = + { + codigo: producto.FiltroSectorCodigo, + item: $scope.articulosTabla.length + 1, + nombre: producto.descripcion, + precio: producto.precio, + costoUnitario: producto.costo, + cantidad: 1 + } + $scope.articulosTabla.unshift(newArt); }, function () { // funcion ejecutada cuando se cancela el modal } ); } + $scope.seleccionarVendedor = function () { + var modalInstance = $uibModal.open( + { + ariaLabelledBy: 'Busqueda de Vendedores', + templateUrl: 'modal-vendedores.html', + controller: 'modalVendedoresCtrl', + size: 'lg' + } + ) + modalInstance.result.then( + function (vendedor) { + $scope.notaPedido.vendedor = vendedor.NomVen; + }, function () { + + } + ); + } + $scope.seleccionarPetrolera = function() { + var modalInstance = $uibModal.open( + { + ariaLabelledBy: 'Busqueda de Petrolera', + templateUrl: 'modal-petroleras.html', + controller: 'modalPetrolerasCtrl', + size: 'lg' + } + ) + modalInstance.result.then( + function (petrolera) { + $scope.notaPedido.petrolera = petrolera.NOM; + }, function () { + + } + ); + } + $scope.seleccionarCliente = function() { + var modalInstance = $uibModal.open( + { + ariaLabelledBy: 'Busqueda de Cliente', + templateUrl: 'foca-busqueda-cliente-modal.html', + controller: 'focaBusquedaClienteModalController', + size: 'lg' + } + ) + modalInstance.result.then( + function (cliente) { + $scope.notaPedido.cliente = cliente.nom; + }, function () { + + } + ); + } $scope.obtenerDomicilios = function (id) { crearNotaPedidoService.getDomicilios(id).then( function (res) { @@ -103,6 +152,17 @@ angular.module('focaCrearNotaPedido') } ) } + $scope.getSubTotal = function(item) { + var subTotal=0; + var array = $scope.articulosTabla.filter(a=>a.item<=item); + for(var i = 0; i< array.length; i++) { + subTotal+=array[i].precio*array[i].cantidad + } + return subTotal.toFixed(2); + } + $scope.cargarArticulos = function() { + idLista=$scope.notaPedido.precioCondicion; + } } ] ) @@ -117,7 +177,9 @@ angular.module('focaCrearNotaPedido') $scope.editar = function (notaPedido) { crearNotaPedidoService.setNotaPedido(notaPedido); $location.path('/venta-nota-pedido/abm/'); - }; + } + $scope.crearPedido = function () { + $location.path('/venta-nota-pedido/abm/'); + } } ]) - -- 1.9.1