From 5f0ec229956d0f5ad9bda097cf587322d244f291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s?= Date: Thu, 11 Oct 2018 12:41:48 -0300 Subject: [PATCH] demo 9/10 --- foca-busqueda-cliente-modal.html | 35 +++++ gulpfile.js | 2 +- index.html | 24 +++- package.json | 18 ++- src/js/app.js | 18 ++- vendor/foca-crear-nota-pedido.js | 291 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 382 insertions(+), 6 deletions(-) create mode 100644 foca-busqueda-cliente-modal.html create mode 100644 vendor/foca-crear-nota-pedido.js diff --git a/foca-busqueda-cliente-modal.html b/foca-busqueda-cliente-modal.html new file mode 100644 index 0000000..fd42ef9 --- /dev/null +++ b/foca-busqueda-cliente-modal.html @@ -0,0 +1,35 @@ + + + diff --git a/gulpfile.js b/gulpfile.js index ae9a8a0..00b3d29 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -66,7 +66,7 @@ gulp.task('webserver', function() { connect.server( { port: 3000, - livereload: true + host: '0.0.0.0' } ) ] diff --git a/index.html b/index.html index 269401e..c02f342 100644 --- a/index.html +++ b/index.html @@ -13,15 +13,35 @@ - + + + + + + + + + + + + + + -
diff --git a/package.json b/package.json index 4437e80..1acf5d9 100644 --- a/package.json +++ b/package.json @@ -23,13 +23,27 @@ "angular": "^1.7.4", "angular-route": "1.7.3", "bootstrap": "4.1.3", + "foca-abm-plazo-pago": "git+https://192.168.0.11/modulos-npm/foca-abm-plazo-pago.git", + "foca-abm-precios-condiciones": "git+https://192.168.0.11/modulos-npm/foca-abm-precios-condiciones.git", + "foca-abm-sectores": "git+https://192.168.0.11/modulos-npm/foca-abm-sectores", "foca-botonera-horizontal": "git+https://192.168.0.11/modulos-npm/foca-botonera-horizontal.git", + "foca-busqueda-cliente": "git+https://192.168.0.11/modulos-npm/foca-busqueda-cliente.git", + "foca-directivas": "git+https://192.168.0.11/modulos-npm/foca-directivas.git", + "foca-modal-busqueda-productos": "git+https://192.168.0.11/nguarnieri/foca-modal-busqueda-productos", + "foca-modal-petroleras": "git+https://192.168.0.11/modulos-npm/foca-modal-petroleras.git", + "foca-modal-vendedores": "git+https://192.168.0.11/modulos-npm/foca-modal-vendedores.git", "foca-turno-apertura": "git+https://192.168.0.11/modulos-npm/foca-turno-apertura.git", "font-awesome": "4.7.0", - "jquery": "3.3.1" + "gulp-angular-templatecache": "^2.2.1", + "gulp-htmlmin": "^5.0.1", + "gulp-uglify": "^3.0.1", + "jquery": "3.3.1", + "uglify": "^0.1.5", + "ui-bootstrap4": "^3.0.5" }, "devDependencies": { - "gulp": "3.9.1", + "electron": "^3.0.2", + "gulp": "^3.9.1", "gulp-concat": "2.6.1", "gulp-connect": "^5.6.1", "gulp-jshint": "^2.1.0", diff --git a/src/js/app.js b/src/js/app.js index 6ef8fc3..b642956 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -1 +1,17 @@ -angular.module('appWrapperDemo', ['ngRoute', 'focaBotoneraHorizontal', 'focaTurnoApertura']); +angular + .module('appWrapperDemo', [ + 'ngRoute', + 'ui.bootstrap', + + 'focaBotoneraHorizontal', + 'focaTurnoApertura', + 'focaAbmPreciosCondiciones', + 'focaAbmPlazoPago', + 'focaAbmSectores', + 'focaBusquedaCliente', + 'focaCrearNotaPedido' + ]) + .constant("API_ENDPOINT", { + 'URL': '//201.190.140.28:9900' + }); + diff --git a/vendor/foca-crear-nota-pedido.js b/vendor/foca-crear-nota-pedido.js new file mode 100644 index 0000000..e0eea1b --- /dev/null +++ b/vendor/foca-crear-nota-pedido.js @@ -0,0 +1,291 @@ +angular.module('focaCrearNotaPedido', ['ngRoute', 'ui.bootstrap', 'focaModalVendedores', + 'focaBusquedaProductos', 'focaModalPetroleras', 'focaBusquedaCliente']) + .config(['$routeProvider', function($routeProvider) { + $routeProvider.when('/venta-nota-pedido/crear', { + controller: 'notaPedidoListaCtrl', + templateUrl: 'nota-pedido-lista.html' + }); + }]) + .config(['$routeProvider', function($routeProvider) { + $routeProvider.when('/venta-nota-pedido/abm', { + controller: 'notaPedidoCtrl', + templateUrl: 'nota-pedido.html' + }); + }]); + +angular.module('focaCrearNotaPedido') + .controller('notaPedidoCtrl', + [ + '$scope', + '$uibModal', + '$location', + 'crearNotaPedidoService', + function($scope, $uibModal, $location, crearNotaPedidoService) { + $scope.notaPedido = {}; + $scope.articulosTabla = []; + var idLista; + var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); + $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.flete = ($scope.notaPedido.flete).toString(); + $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); + idLista = $scope.notaPedido.precioCondicion; + crearNotaPedidoService.getArticulosByIdNotaPedido($scope.notaPedido.id).then( + function(res) { + $scope.articulosTabla = res.data; + } + ); + crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( + function(res) { + $scope.notaPedido.domicilio = res.data; + } + ) + } else { + $scope.notaPedido.fechaCarga = new Date(); + $scope.notaPedido.domicilio = [{ id: 0 }] + $scope.notaPedido.bomba = '1'; + $scope.notaPedido.flete = '1'; + idLista = undefined; + } + $scope.addNewDom = function() { + $scope.notaPedido.domicilio.push({ 'id': 0 }); + } + $scope.removeNewChoice = function(choice) { + if ($scope.notaPedido.domicilio.length > 1) { + $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex(c => c.$$hashKey == choice.$$hashKey), 1) + } + } + $scope.crearNotaPedido = function() { + var total = 0; + for (var i = $scope.articulosTabla.length - 1; i >= 0; i--) { + total += $scope.articulosTabla[i].precio * $scope.articulosTabla[i].cantidad; + } + + var notaPedido = { + id: 0, + precioCondicion: $scope.notaPedido.precioCondicion, + fechaCarga: $scope.notaPedido.fechaCarga, + vendedor: $scope.notaPedido.vendedor, + cliente: $scope.notaPedido.cliente, + producto: $scope.notaPedido.producto, + bomba: $scope.notaPedido.bomba, + petrolera: $scope.notaPedido.petrolera, + domicilio: $scope.notaPedido.domicilio, + kilometros: $scope.notaPedido.kilometros, + jurisdiccionIIBB: $scope.notaPedido.jurisdiccionIIBB, + costoFinanciacion: $scope.notaPedido.costoFinanciacion, + flete: $scope.notaPedido.flete, + costoUnitarioKmFlete: $scope.notaPedido.costoUnitarioKmFlete, + total : total + } + crearNotaPedidoService.crearNotaPedido(notaPedido).then( + function(res) { + $location.path('/venta-nota-pedido/crear'); + } + ) + var articulosNotaPedido = $scope.articulosTabla; + for(var i = 0; i< articulosNotaPedido.length;i++) { + crearNotaPedidoService.crearArticulosParaNotaPedido(articulosNotaPedido[i]).then( + function(res) { + return; + } + ) + } + + } + $scope.siguienteTab = function() { + $scope.active = 1; + } + $scope.seleccionarArticulo = function() { + 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', + resolve: { idLista: function() { return idLista } }, + size: 'lg' + } + ) + modalInstance.result.then( + function(producto) { + var newArt = + { + id: 0, + 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) { + $scope.notaPedido.domicilio = res.data; + } + ) + } + $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; + $scope.articulosTabla = []; + } + } + ] + ) + .controller('notaPedidoListaCtrl', [ + '$scope', + 'crearNotaPedidoService', + '$location', + function($scope, crearNotaPedidoService, $location) { + crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { + $scope.notaPedidos = datos.data; + }); + $scope.editar = function(notaPedido) { + crearNotaPedidoService.setNotaPedido(notaPedido); + $location.path('/venta-nota-pedido/abm/'); + } + $scope.crearPedido = function() { + crearNotaPedidoService.clearNotaPedido(); + $location.path('/venta-nota-pedido/abm/'); + } + } + ]) + +angular.module('focaCrearNotaPedido') + .service('crearNotaPedidoService', ['$http', 'API_ENDPOINT',function($http, API_ENDPOINT) { + var route = API_ENDPOINT.URL; + var notaPedido; + return { + crearNotaPedido: function(notaPedido) { + return $http.post(route + '/nota-pedido', {notaPedido: notaPedido}); + }, + obtenerNotaPedido: function() { + return $http.get(route +'/nota-pedido'); + }, + setNotaPedido: function(notaPedido) { + this.notaPedido = notaPedido; + }, + clearNotaPedido: function() { + this.notaPedido = undefined; + }, + getNotaPedido: function() { + return this.notaPedido; + }, + getArticulosByIdNotaPedido: function(id) { + return $http.get(route+'/articulos/nota-pedido/'+id); + }, + crearArticulosParaNotaPedido: function(articuloNotaPedido) { + return $http.post(route + '/articulos/nota-pedido', {articuloNotaPedido}); + }, + getDomiciliosByIdNotaPedido: function(id) { + return $http.get(route +'/nota-pedido/'+id+'/domicilios'); + }, + //EN DESARROLLO + getDomicilios: function(id) { + // return $http.get(route + '/'+id) + var domicilio = [ + { + id: 1, + dom: 'RISSO PATRON 781' + }, + { + id: 2, + dom: 'MARIANO MORENO 533' + }, + { + id: 3, + dom: 'SALTA 796' + } + ] + return domicilio; + }, + getPrecioCondicion: function() { + return $http.get(route + '/precio-condicion') + }, + getPrecioCondicionById: function(id) { + return $http.get(route + '/precio-condicion/' + id) + }, + getPlazoPagoByPrecioCondicion: function(id) { + return $http.get(route + '/plazo-pago/precio-condicion/'+ id) + } + } + }]) + +angular.module('focaCrearNotaPedido').run(['$templateCache', function($templateCache) {$templateCache.put('nota-pedido-lista.html','\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
C\xF3digoVendedorClientePetroleraTotal
\r\n \r\n \r\n
\r\n'); +$templateCache.put('nota-pedido.html','
\r\n \r\n \r\n \r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
$
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
\r\n
\r\n \r\n \r\n
\r\n
\r\n \r\n \r\n
\r\n
\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
\r\n
\r\n \r\n \r\n
\r\n
\r\n \r\n \r\n
\r\n
\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
$
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
\r\n
\r\n \r\n \r\n
\r\n No se encontraron resultados.\r\n
\r\n
\r\n -\r\n +\r\n
\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
C\xF3digoNombrePrecio unitarioCosto unitario brutoCantidadSubtotal
\r\n
\r\n
\r\n
\r\n
');}]); \ No newline at end of file -- 1.9.1