Commit 7097ef0a5a1d617c4ce5d7de74382034c273ee3b

Authored by Luigi
1 parent b6970f6cf2
Exists in master

Modal Plazos y Precios separados ( Cliente )

... ... @@ -23,8 +23,8 @@
23 23 "devDependencies": {
24 24 "angular": "^1.7.5",
25 25 "bootstrap": "^4.1.3",
26   - "foca-directivas": "git+ssh://git@git.focasoftware.com:npm/foca-directivas.git",
27   - "foca-modal": "git+ssh://git@git.focasoftware.com:npm/foca-modal.git",
  26 + "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git",
  27 + "foca-modal": "git+http://git.focasoftware.com/npm/foca-modal.git",
28 28 "font-awesome": "^4.7.0",
29 29 "gulp": "^3.9.1",
30 30 "gulp-angular-templatecache": "^2.2.2",
src/js/controllerCliente.js
... ... @@ -0,0 +1,175 @@
  1 +angular.module('focaModalPrecioCondicion')
  2 + .controller('focaModalListaPreciosController',
  3 + [
  4 + '$timeout',
  5 + '$filter',
  6 + '$scope',
  7 + '$uibModal',
  8 + '$uibModalInstance',
  9 + 'focaModalService',
  10 + 'focaModalPrecioCondicionService',
  11 + 'idListaPrecio',
  12 + function (
  13 + $timeout, $filter, $scope, $uibModal, $uibModalInstance,
  14 + focaModalService, focaModalPrecioCondicionService, idListaPrecio
  15 + ) {
  16 + $scope.openModalListaDePrecios = false;
  17 + $scope.associatedList = true;
  18 + $scope.listaDePreciosAlternativa = null;
  19 +
  20 + onInit();
  21 +
  22 + function onInit() {
  23 + //Metodo para traer la lista de precio asociada al cliente
  24 + focaModalPrecioCondicionService.getListaPrecio(idListaPrecio)
  25 + .then(function (res) {
  26 + $scope.listaDePreciosAsociada = res.data[0];
  27 + })
  28 + .catch(function (e) { console.error(e) });
  29 + }
  30 +
  31 + //#region Metodos para la lista de precios
  32 + $scope.openListaDePrecios = function () {
  33 + var datos = null;
  34 + focaModalPrecioCondicionService.getAllListaPrecio()
  35 + .then(function (res) {
  36 + datos = res.data;
  37 + focaModalService.modal({
  38 + titulo: 'Lista de precios',
  39 + data: datos,
  40 + size: 'md',
  41 + columnas: [
  42 + {
  43 + propiedad: 'ID',
  44 + nombre: 'Codigo'
  45 + },
  46 + {
  47 + propiedad: 'DES',
  48 + NOMBRE: 'Nombre'
  49 + }
  50 + ],
  51 + }).then(function (res) {
  52 + $scope.associatedList = false;
  53 + $scope.listaDePreciosAlternativa = res;
  54 + }).catch(function (e) {
  55 + console.error(e);
  56 + });
  57 + });
  58 + };
  59 + $scope.selectListaDePrecios = function () {
  60 + $scope.associatedList = true;
  61 + };
  62 + $scope.verListaProductos = function (id) {
  63 + $uibModal.open(
  64 + {
  65 + ariaLabelledBy: 'Busqueda de Productos',
  66 + templateUrl: 'modal-busqueda-productos.html',
  67 + controller: 'modalBusquedaProductosCtrl',
  68 + resolve: {
  69 + parametroProducto: {
  70 + idLista: parseInt(id),
  71 + cotizacion: 1,
  72 + simbolo: '$',
  73 + soloMostrar: true
  74 + }
  75 + },
  76 + size: 'md'
  77 + }
  78 + );
  79 + };
  80 + //#endregion
  81 + $scope.closeModalPrecioCondicion = function () {
  82 + $uibModalInstance.dismiss('cancel');
  83 + };
  84 + $scope.guardarPrecioCondicion = function () {
  85 + var precioCondicion = {
  86 + listaPrecio: $scope.associatedList ? $scope.listaDePreciosAsociada : $scope.listaDePreciosAlternativa,
  87 + };
  88 + $uibModalInstance.close(precioCondicion);
  89 + };
  90 + }
  91 + ])
  92 +
  93 + .controller('focaModalListaPlazosController',
  94 + [
  95 + '$timeout',
  96 + '$filter',
  97 + '$scope',
  98 + '$uibModal',
  99 + '$uibModalInstance',
  100 + 'focaModalService',
  101 + 'focaModalPrecioCondicionService',
  102 + 'idCliente',
  103 + function (
  104 + $timeout, $filter, $scope, $uibModal, $uibModalInstance,
  105 + focaModalService, focaModalPrecioCondicionService,idCliente
  106 + ) {
  107 + $scope.plazos = [
  108 + {
  109 + dias: 0,
  110 + idCliente: idCliente,
  111 + activo: true
  112 + }
  113 + ];
  114 +
  115 + onInit();
  116 +
  117 + function onInit() {
  118 + focaModalPrecioCondicionService.getPlazosByIdCliente(idCliente)
  119 + .then(function (res) {
  120 + res.data.forEach(function (item) {
  121 + $scope.plazos.push(item);
  122 + });
  123 + })
  124 + .catch(function (e) { console.error(e) });
  125 + }
  126 +
  127 + //#region Metodos para los plazos
  128 + $scope.addPlazo = function (key) {
  129 + if (key != 13) return;
  130 + if ($scope.plazos.length === 100) return;
  131 + for (var i = 1; i < $scope.plazos.length; i++) {
  132 + if ($scope.plazos[0].dias == $scope.plazos[i].dias && $scope.plazos[i].activo == true) {
  133 + focaModalService.alert("Ya existe un plazo con este valor");
  134 + return;
  135 + }
  136 + }
  137 + $scope.plazos.unshift({ dias: 0, idCliente: idCliente, activo: true });
  138 + $scope.focused = 1;
  139 + };
  140 + $scope.deletePlazo = function (index) {
  141 + $scope.plazos[index].activo = false;
  142 + };
  143 + $scope.validateMinMax = function (plazo, min, max) {
  144 + plazo.dias = parseInt(plazo.dias);
  145 + if (plazo.dias === null || plazo.dias === undefined || isNaN(plazo.dias)) {
  146 + plazo.dias = '0';
  147 + return;
  148 + }
  149 + if (parseInt(plazo.dias) < min) {
  150 + plazo.dias = '0';
  151 + return;
  152 + }
  153 + if (parseInt(plazo.dias) > max) {
  154 + plazo.dias = '365';
  155 + return;
  156 + }
  157 + };
  158 + //#endregion
  159 +
  160 + $scope.closeModalPrecioCondicion = function () {
  161 + $uibModalInstance.dismiss('cancel');
  162 + };
  163 + $scope.guardarPlazos = function () {
  164 + $scope.plazos.shift();
  165 + focaModalPrecioCondicionService.createPlazo($scope.plazos)
  166 + .then(function () {
  167 + var precioCondicion = {
  168 + plazoPago: $filter('filter')($scope.plazos, { activo: true }, true)
  169 + };
  170 + $uibModalInstance.close(precioCondicion);
  171 + })
  172 + .catch(function (e) { console.error(e) })
  173 + };
  174 + }
  175 + ]);
src/views/modal-plazos.html
... ... @@ -0,0 +1,72 @@
  1 +<div class="modal-header py-1">
  2 + <div class="row w-100">
  3 + <div class="col-lg-6">
  4 + <h5 class="modal-title my-1">Precio-Condición: Plazos</h5>
  5 + </div>
  6 + </div>
  7 +</div>
  8 +<div class="modal-body" id="modal-body">
  9 + <div ng-show="!ingreso">
  10 + <div class="row px-2">
  11 + <div class="col-lg-12">
  12 + <div class="row py-1">
  13 + <div class="col text-center font-weight-bold">Plazos</div>
  14 + </div>
  15 + <div class="row">
  16 + <div class="col">
  17 + <table class="table table-sm table-striped">
  18 + <thead>
  19 + <tr>
  20 + <th colspan="2">Dias</th>
  21 + </tr>
  22 + </thead>
  23 + <tbody>
  24 + <tr ng-repeat="(i, plazo) in plazos" ng-show="plazo.activo">
  25 + <td align="center" ng-class="{'pt-2': i > 0}">
  26 + <span
  27 + ng-show="i > 0"
  28 + ng-bind="plazo.dias">
  29 + </span>
  30 + <input
  31 + ng-show="i == 0"
  32 + type="text"
  33 + class="form-control form-control-sm text-center"
  34 + ng-model="plazo.dias"
  35 + limite-numeros-max="3"
  36 + ng-keyup="validateMinMax(plazo, 0, 365)"
  37 + ng-keypress="addPlazo($event.keyCode)"
  38 + foca-focus="focused == 1"
  39 + select-on-click
  40 + teclado-virtual
  41 + foca-tipo-input
  42 + solo-positivos>
  43 + </td>
  44 + <td>
  45 + <button
  46 + ng-show="i === 0"
  47 + class="btn btn-primary"
  48 + ng-click="addPlazo(13)">
  49 + <span class="fa fa-save"></span>
  50 + </button>
  51 + <button
  52 + ng-show="i > 0"
  53 + class="btn btn-default"
  54 + ng-click="deletePlazo(i)">
  55 + <span class="fa fa-trash"></span>
  56 + </button>
  57 + </td>
  58 + </tr>
  59 + </tbody>
  60 + </table>
  61 + </div>
  62 + </div>
  63 + </div>
  64 + </div>
  65 + </div>
  66 +</div>
  67 +<div class="modal-footer py-2">
  68 + <button class="btn btn-sm btn-secondary" type="button" ng-click="closeModalPrecioCondicion()">Cerrar
  69 + </button>
  70 + <button class="btn btn-sm btn-primary" type="button" ng-click="guardarPlazos()">Guardar
  71 + </button>
  72 +</div>
src/views/modal-precios.html
... ... @@ -0,0 +1,66 @@
  1 +<div class="modal-header py-1">
  2 + <div class="row w-100">
  3 + <div class="col-lg-6">
  4 + <h5 class="modal-title my-1">Precio-Condición: Listas</h5>
  5 + </div>
  6 + </div>
  7 +</div>
  8 +<div class="modal-body" id="modal-body">
  9 + <div ng-show="!ingreso">
  10 + <div class="row" ng-show="listaDePreciosAsociada.length == 0">
  11 + <div class="col">
  12 + No se encontraron resultados.
  13 + </div>
  14 + </div>
  15 + <div class="row px-2">
  16 + <div class="col-lg-12">
  17 + <div class="row border-top py-2">
  18 + <div class="col-lg-9 col-9">Lista asociada al cliente</div>
  19 + <div class="col-lg-3 col-3 text-center">
  20 + <button
  21 + ng-class="{'btn-primary': associatedList, 'btn-default': !associatedList}"
  22 + class="btn btn-sm p-1"
  23 + ng-click="selectListaDePrecios(listaDePreciosAsociada)">
  24 + <span class="fa fa-circle-thin"></span>
  25 + </button>
  26 + </div>
  27 + </div>
  28 + <div class="row align-items-center pb-2">
  29 + <div class="col-lg-2 col-2 text-center" ng-bind="listaDePreciosAsociada.ID"></div>
  30 + <div class="col-lg-7 col-7" ng-bind="listaDePreciosAsociada.DES"></div>
  31 + <div class="col-lg-3 col-3 text-center">
  32 + <button ng-click="verListaProductos(listaDePreciosAsociada.ID)" class="btn btn-sm p-1">
  33 + <span class="fa fa-eye"></span>
  34 + </button>
  35 + </div>
  36 + </div>
  37 + <div class="row border-top py-2">
  38 + <div class="col-lg-9 col-9">Trabajar con otra lista</div>
  39 + <div class="col-lg-3 col-3 text-center">
  40 + <button
  41 + ng-class="{'btn-primary': !associatedList, 'btn-default': associatedList}"
  42 + class="btn btn-sm btn-default p-1"
  43 + ng-click="openListaDePrecios()">
  44 + <span class="fa fa-circle-thin"></span>
  45 + </button>
  46 + </div>
  47 + </div>
  48 + <div ng-show="listaDePreciosAlternativa != null" class="row align-items-center pb-1">
  49 + <div class="col-lg-2 col-2 text-center" ng-bind="listaDePreciosAlternativa.ID"></div>
  50 + <div class="col-lg-7 col-7" ng-bind="listaDePreciosAlternativa.DES"></div>
  51 + <div class="col-lg-3 col-3 text-center">
  52 + <button ng-click="verListaProductos(listaDePreciosAlternativa.ID)" class="btn btn-sm p-1">
  53 + <span class="fa fa-eye"></span>
  54 + </button>
  55 + </div>
  56 + </div>
  57 + </div>
  58 + </div>
  59 + </div>
  60 +</div>
  61 +<div class="modal-footer py-2">
  62 + <button class="btn btn-sm btn-secondary" type="button" ng-click="closeModalPrecioCondicion()">Cerrar
  63 + </button>
  64 + <button class="btn btn-sm btn-primary" type="button" ng-click="guardarPrecioCondicion()">Guardar
  65 + </button>
  66 +</div>