diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e552918 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/node_modules +/dist +package-lock\.json diff --git a/index.html b/index.html new file mode 100644 index 0000000..299cd21 --- /dev/null +++ b/index.html @@ -0,0 +1,25 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/package.json b/package.json new file mode 100644 index 0000000..39728a6 --- /dev/null +++ b/package.json @@ -0,0 +1,38 @@ +{ + "name": "foca-crear-nota-pedido", + "version": "0.0.2", + "description": "Módulo foca", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "compile": "gulp uglify && gulp html", + "postinstall": "npm run compile && rm -R src && rm index.html && rm .jshintrc && rm gulpfile.js" + }, + "repository": { + "type": "git", + "url": "https://192.168.0.11/modulos-npm/foca-crear-nota-pedido.git" + }, + "author": "Foca Software", + "license": "ISC", + "dependencies": { + "angular": "^1.7.x", + "angular-route": "^1.7.4", + "bootstrap": "^4.1.x", + "font-awesome": "^4.7.x", + "gulp": "^3.9.x", + "gulp-concat": "2.6.x", + "gulp-jshint": "^2.1.x", + "gulp-rename": "^1.4.x", + "gulp-replace": "^1.0.x", + "gulp-uglify-es": "^1.0.x", + "jquery": "^3.3.x", + "jshint": "^2.9.x", + "pump": "^3.0.x", + "ui-bootstrap4": "^3.0.5" + }, + "devDependencies": { + "gulp-connect": "^5.6.1", + "jasmine-core": "3.2.1", + "pre-commit": "^1.2.2" + } +} diff --git a/src/js/app.js b/src/js/app.js new file mode 100644 index 0000000..39c6f4d --- /dev/null +++ b/src/js/app.js @@ -0,0 +1,13 @@ +angular.module('focaCrearNotaPedido', ['ngRoute', 'ui.bootstrap']) + .config(['$routeProvider', function($routeProvider) { + $routeProvider.when('/venta-nota-pedido', { + controller: 'notaPedidoListaCtrl', + templateUrl: 'src/views/nota-pedido-lista.html' + }); + }]) + .config(['$routeProvider', function($routeProvider) { + $routeProvider.when('/venta-nota-pedido/abm', { + controller: 'notaPedidoCtrl', + templateUrl: 'src/views/nota-pedido.html' + }); + }]); diff --git a/src/js/controller.js b/src/js/controller.js new file mode 100644 index 0000000..f35452c --- /dev/null +++ b/src/js/controller.js @@ -0,0 +1,123 @@ +angular.module('focaCrearNotaPedido') + .controller('notaPedidoCtrl', + [ + '$scope', + '$uibModal', + 'crearNotaPedidoService', + function ($scope, $uibModal, crearNotaPedidoService) { + $scope.notaPedido = {}; + var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); + var domiciliosCliente = [ + { + dom: 'sanjuan', + id: 3 + }, + { + dom: 'mendoza', + id: 2 + } + ] + if (notaPedidoTemp != undefined) { + notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); + $scope.notaPedido = notaPedidoTemp; + $scope.notaPedido.domicilio = domiciliosCliente; + } else { + $scope.notaPedido.fechaCarga = new Date(); + + $scope.notaPedido.domicilio = domiciliosCliente; + } + $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 }); + } + $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 notaPedido = { + idNotaPedido: 0, + precioCondicion: $scope.notaPedido.precioCondicion, + fechaCarga: $scope.notaPedido.clientefechaCarga, + 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.jurisdiccion, + costoFinanciacion: $scope.notaPedido.costoFinanciacion, + flete: $scope.notaPedido.flete, + costoUnitarioKmFlete: $scope.costoUnitarioKmFlete + } + crearNotaPedidoService.crearNotaPedido(notaPedido).then( + function (res) { + alert('Nota pedido creada') + } + ) + } + $scope.siguienteTab = function () { + $scope.active = 1; + } + $scope.seleccionarArticulo = function () { + var modalIntance = $uibModal.open( + { + ariaLabelledBy: 'Busqueda de Productos', + templateUrl: 'modal-busqueda-productos.html', + controller: 'modalBusquedaProductosCtrl', + size: 'md' + } + ) + modalInstance.result.then( + function (producto) { + console.info(producto); + // variable producto tiene el producto seleccionado en el modal + }, function () { + // funcion ejecutada cuando se cancela el modal + } + ); + } + $scope.obtenerDomicilios = function (id) { + crearNotaPedidoService.getDomicilios(id).then( + function (res) { + $scope.notaPedido.domicilio = res.data; + } + ) + } + } + ] + ) + .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/'); + }; + } + ]) + diff --git a/src/js/service.js b/src/js/service.js new file mode 100644 index 0000000..619b804 --- /dev/null +++ b/src/js/service.js @@ -0,0 +1,38 @@ +angular.module('focaCrearNotaPedido') + .service('crearNotaPedidoService', ['$http',function($http) { + var route = 'http://192.168.0.23:9900'; + var notaPedido; + return { + crearNotaPedido: function(obj) { + return; + }, + obtenerNotaPedido: function() { + return $http.get(route +'/nota-pedido'); + }, + setNotaPedido: function(notaPedido) { + this.notaPedido = notaPedido; + }, + getNotaPedido: function() { + return this.notaPedido; + }, + getDomicilios: function(id) { + // return $http.get(route + '/'+id) + var domicilio = [ + { + id: 1, + nombre: 'godoy Cruz' + }, + { + id: 2, + nombre: 'capital' + }, + { + id: 3, + nombre: 'mendoza' + } + ] + return + } + } + }]) + \ No newline at end of file diff --git a/src/views/nota-pedido-lista.html b/src/views/nota-pedido-lista.html new file mode 100644 index 0000000..5aa12bf --- /dev/null +++ b/src/views/nota-pedido-lista.html @@ -0,0 +1,23 @@ +Código | +Vendedor | +Cliente | +Petrolera | ++ |
---|---|---|---|---|
+ | + | + | + | + + + | +