From 7097ef0a5a1d617c4ce5d7de74382034c273ee3b Mon Sep 17 00:00:00 2001 From: Luigi Date: Mon, 3 Jun 2019 11:03:00 -0300 Subject: [PATCH] Modal Plazos y Precios separados ( Cliente ) --- package.json | 4 +- src/js/controllerCliente.js | 175 +++++++++++++++++++++++++++++++++++++++++++ src/views/modal-plazos.html | 72 ++++++++++++++++++ src/views/modal-precios.html | 66 ++++++++++++++++ 4 files changed, 315 insertions(+), 2 deletions(-) create mode 100644 src/js/controllerCliente.js create mode 100644 src/views/modal-plazos.html create mode 100644 src/views/modal-precios.html diff --git a/package.json b/package.json index 49e2835..ee79002 100644 --- a/package.json +++ b/package.json @@ -23,8 +23,8 @@ "devDependencies": { "angular": "^1.7.5", "bootstrap": "^4.1.3", - "foca-directivas": "git+ssh://git@git.focasoftware.com:npm/foca-directivas.git", - "foca-modal": "git+ssh://git@git.focasoftware.com:npm/foca-modal.git", + "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", + "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git", "font-awesome": "^4.7.0", "gulp": "^3.9.1", "gulp-angular-templatecache": "^2.2.2", diff --git a/src/js/controllerCliente.js b/src/js/controllerCliente.js new file mode 100644 index 0000000..c25f6b0 --- /dev/null +++ b/src/js/controllerCliente.js @@ -0,0 +1,175 @@ +angular.module('focaModalPrecioCondicion') + .controller('focaModalListaPreciosController', + [ + '$timeout', + '$filter', + '$scope', + '$uibModal', + '$uibModalInstance', + 'focaModalService', + 'focaModalPrecioCondicionService', + 'idListaPrecio', + function ( + $timeout, $filter, $scope, $uibModal, $uibModalInstance, + focaModalService, focaModalPrecioCondicionService, idListaPrecio + ) { + $scope.openModalListaDePrecios = false; + $scope.associatedList = true; + $scope.listaDePreciosAlternativa = null; + + onInit(); + + function onInit() { + //Metodo para traer la lista de precio asociada al cliente + focaModalPrecioCondicionService.getListaPrecio(idListaPrecio) + .then(function (res) { + $scope.listaDePreciosAsociada = res.data[0]; + }) + .catch(function (e) { console.error(e) }); + } + + //#region Metodos para la lista de precios + $scope.openListaDePrecios = function () { + var datos = null; + focaModalPrecioCondicionService.getAllListaPrecio() + .then(function (res) { + datos = res.data; + focaModalService.modal({ + titulo: 'Lista de precios', + data: datos, + size: 'md', + columnas: [ + { + propiedad: 'ID', + nombre: 'Codigo' + }, + { + propiedad: 'DES', + NOMBRE: 'Nombre' + } + ], + }).then(function (res) { + $scope.associatedList = false; + $scope.listaDePreciosAlternativa = res; + }).catch(function (e) { + console.error(e); + }); + }); + }; + $scope.selectListaDePrecios = function () { + $scope.associatedList = true; + }; + $scope.verListaProductos = function (id) { + $uibModal.open( + { + ariaLabelledBy: 'Busqueda de Productos', + templateUrl: 'modal-busqueda-productos.html', + controller: 'modalBusquedaProductosCtrl', + resolve: { + parametroProducto: { + idLista: parseInt(id), + cotizacion: 1, + simbolo: '$', + soloMostrar: true + } + }, + size: 'md' + } + ); + }; + //#endregion + $scope.closeModalPrecioCondicion = function () { + $uibModalInstance.dismiss('cancel'); + }; + $scope.guardarPrecioCondicion = function () { + var precioCondicion = { + listaPrecio: $scope.associatedList ? $scope.listaDePreciosAsociada : $scope.listaDePreciosAlternativa, + }; + $uibModalInstance.close(precioCondicion); + }; + } + ]) + + .controller('focaModalListaPlazosController', + [ + '$timeout', + '$filter', + '$scope', + '$uibModal', + '$uibModalInstance', + 'focaModalService', + 'focaModalPrecioCondicionService', + 'idCliente', + function ( + $timeout, $filter, $scope, $uibModal, $uibModalInstance, + focaModalService, focaModalPrecioCondicionService,idCliente + ) { + $scope.plazos = [ + { + dias: 0, + idCliente: idCliente, + activo: true + } + ]; + + onInit(); + + function onInit() { + focaModalPrecioCondicionService.getPlazosByIdCliente(idCliente) + .then(function (res) { + res.data.forEach(function (item) { + $scope.plazos.push(item); + }); + }) + .catch(function (e) { console.error(e) }); + } + + //#region Metodos para los plazos + $scope.addPlazo = function (key) { + if (key != 13) return; + if ($scope.plazos.length === 100) return; + for (var i = 1; i < $scope.plazos.length; i++) { + if ($scope.plazos[0].dias == $scope.plazos[i].dias && $scope.plazos[i].activo == true) { + focaModalService.alert("Ya existe un plazo con este valor"); + return; + } + } + $scope.plazos.unshift({ dias: 0, idCliente: idCliente, activo: true }); + $scope.focused = 1; + }; + $scope.deletePlazo = function (index) { + $scope.plazos[index].activo = false; + }; + $scope.validateMinMax = function (plazo, min, max) { + plazo.dias = parseInt(plazo.dias); + if (plazo.dias === null || plazo.dias === undefined || isNaN(plazo.dias)) { + plazo.dias = '0'; + return; + } + if (parseInt(plazo.dias) < min) { + plazo.dias = '0'; + return; + } + if (parseInt(plazo.dias) > max) { + plazo.dias = '365'; + return; + } + }; + //#endregion + + $scope.closeModalPrecioCondicion = function () { + $uibModalInstance.dismiss('cancel'); + }; + $scope.guardarPlazos = function () { + $scope.plazos.shift(); + focaModalPrecioCondicionService.createPlazo($scope.plazos) + .then(function () { + var precioCondicion = { + plazoPago: $filter('filter')($scope.plazos, { activo: true }, true) + }; + $uibModalInstance.close(precioCondicion); + }) + .catch(function (e) { console.error(e) }) + }; + } + ]); diff --git a/src/views/modal-plazos.html b/src/views/modal-plazos.html new file mode 100644 index 0000000..9d21afc --- /dev/null +++ b/src/views/modal-plazos.html @@ -0,0 +1,72 @@ + + + diff --git a/src/views/modal-precios.html b/src/views/modal-precios.html new file mode 100644 index 0000000..14df3ff --- /dev/null +++ b/src/views/modal-precios.html @@ -0,0 +1,66 @@ + + + -- 1.9.1