Commit a78a5ef8bf75cd003105c362f5364cec6aa523f4
1 parent
b2fc56e26e
Exists in
master
Nuevo diseño
Showing
4 changed files
with
247 additions
and
122 deletions
Show diff stats
src/js/controller.js
| ... | ... | @@ -5,7 +5,13 @@ angular.module('focaAbmPreciosCondiciones') |
| 5 | 5 | function($scope, focaAbmPreciosCondicionesService, $location, |
| 6 | 6 | focaModalService, focaBotoneraLateralService, $timeout) { |
| 7 | 7 | focaAbmPreciosCondicionesService.obtenerPreciosCondiciones().then(function(datos) { |
| 8 | + console.log(datos.data); | |
| 8 | 9 | $scope.preciosCondiciones = datos.data; |
| 10 | + $scope.preciosCondiciones.forEach(function(precioCondicion) { | |
| 11 | + precioCondicion.plazoPago.sort(function(a, b) { | |
| 12 | + return a.dias- b.dias; | |
| 13 | + }); | |
| 14 | + }); | |
| 9 | 15 | }); |
| 10 | 16 | |
| 11 | 17 | $timeout(function() { |
| ... | ... | @@ -37,12 +43,15 @@ angular.module('focaAbmPreciosCondiciones') |
| 37 | 43 | ]) |
| 38 | 44 | .controller('focaAbmPrecioCondicionController', [ |
| 39 | 45 | '$scope', 'focaAbmPreciosCondicionesService', 'focaBotoneraLateralService', |
| 40 | - '$routeParams', '$location', 'focaModalService', '$timeout', | |
| 46 | + '$routeParams', '$location', 'focaModalService', '$timeout', '$uibModal', '$window', | |
| 41 | 47 | function( |
| 42 | 48 | $scope, focaAbmPreciosCondicionesService, focaBotoneraLateralService, |
| 43 | - $routeParams, $location, focaModalService, $timeout | |
| 49 | + $routeParams, $location, focaModalService, $timeout, $uibModal, $window | |
| 44 | 50 | ) { |
| 51 | + $scope.plazosAEliminar = []; | |
| 45 | 52 | $scope.mostrarPlazos = $routeParams.id > 0; |
| 53 | + $scope.now = new Date(); | |
| 54 | + $scope.listaPrecioLabel = ''; | |
| 46 | 55 | focaAbmPreciosCondicionesService.obtenerPrecioCondicion($routeParams.id) |
| 47 | 56 | .then(function(datos) { |
| 48 | 57 | $scope.precioCondicion = { |
| ... | ... | @@ -53,11 +62,24 @@ angular.module('focaAbmPreciosCondiciones') |
| 53 | 62 | idListaPrecio: 0, |
| 54 | 63 | vigencia: new Date() |
| 55 | 64 | }; |
| 56 | - if (datos.data.id) { | |
| 65 | + if(datos.data.id) { | |
| 57 | 66 | $scope.precioCondicion = datos.data; |
| 67 | + $scope.listaPrecioLabel = datos.data.listaPrecio.ID.trim() + | |
| 68 | + ' - ' + datos.data.listaPrecio.DES; | |
| 69 | + $scope.$broadcast('addCabecera', { | |
| 70 | + label: 'Precio y condición:', | |
| 71 | + valor: datos.data.nombre | |
| 72 | + }); | |
| 58 | 73 | focaAbmPreciosCondicionesService.obtenerPlazoPago(datos.data.id) |
| 59 | 74 | .then(function(datos) { |
| 60 | 75 | $scope.precioCondicion.plazos = datos.data; |
| 76 | + $scope.precioCondicion.plazos.sort(function(a, b) { | |
| 77 | + return a.dias- b.dias; | |
| 78 | + }); | |
| 79 | + $scope.plazoACargar = | |
| 80 | + { | |
| 81 | + item: datos.data.length + 1 | |
| 82 | + }; | |
| 61 | 83 | }); |
| 62 | 84 | } |
| 63 | 85 | }); |
| ... | ... | @@ -72,17 +94,66 @@ angular.module('focaAbmPreciosCondiciones') |
| 72 | 94 | $scope.cancelar = function() { |
| 73 | 95 | $location.path('/precio-condicion'); |
| 74 | 96 | }; |
| 75 | - $scope.guardar = function(precioCondicion) { | |
| 76 | - focaAbmPreciosCondicionesService.guardarPrecioCondicion(precioCondicion) | |
| 77 | - .then(function() { | |
| 78 | - $location.path('/precio-condicion'); | |
| 97 | + $scope.guardar = function() { | |
| 98 | + var promises = []; | |
| 99 | + var precioCondicion = $scope.precioCondicion; | |
| 100 | + precioCondicion.idListaPrecio = precioCondicion.listaPrecio.ID; | |
| 101 | + delete precioCondicion.listaPrecio; | |
| 102 | + if($scope.mostrarPlazos) { | |
| 103 | + promises.push( | |
| 104 | + focaAbmPreciosCondicionesService | |
| 105 | + .guardarPlazosPago($scope.precioCondicion.plazos) | |
| 106 | + ); | |
| 107 | + $scope.plazosAEliminar.forEach(function(id) { | |
| 108 | + promises.push( | |
| 109 | + focaAbmPreciosCondicionesService | |
| 110 | + .borrarPlazoPago(id) | |
| 111 | + ); | |
| 79 | 112 | }); |
| 80 | - }; | |
| 81 | - $scope.editarPlazoPago = function(id) { | |
| 82 | - $location.path( | |
| 83 | - '/precio-condicion/' + $scope.precioCondicion.id + | |
| 84 | - '/plazo-pago/' + id | |
| 113 | + } | |
| 114 | + promises.push( | |
| 115 | + focaAbmPreciosCondicionesService | |
| 116 | + .guardarPrecioCondicion(precioCondicion) | |
| 85 | 117 | ); |
| 118 | + | |
| 119 | + Promise.all(promises).then(function() { | |
| 120 | + $window.location.assign('/#!/precio-condicion'); | |
| 121 | + }, function(err){ | |
| 122 | + console.error(err); | |
| 123 | + }); | |
| 124 | + }; | |
| 125 | + | |
| 126 | + $scope.agregarPlazo = function(key) { | |
| 127 | + if(key === 13) { | |
| 128 | + if(!$scope.plazoACargar.dias) { | |
| 129 | + focaModalService.alert('Ingrese cantidad de días'); | |
| 130 | + return; | |
| 131 | + } | |
| 132 | + var tieneEseDia = $scope.precioCondicion.plazos.filter(function(a) { | |
| 133 | + return a.dias === $scope.plazoACargar.dias; | |
| 134 | + }); | |
| 135 | + if(tieneEseDia.length > 0) { | |
| 136 | + focaModalService.alert('Ya ha ingresado un plazo con esos días'); | |
| 137 | + return; | |
| 138 | + } | |
| 139 | + $scope.plazoACargar.idPreciosCondiciones = $scope.precioCondicion.id; | |
| 140 | + $scope.plazoACargar.activo = true; | |
| 141 | + $scope.precioCondicion.plazos.push($scope.plazoACargar); | |
| 142 | + $scope.plazoACargar = | |
| 143 | + { | |
| 144 | + item: $scope.precioCondicion.plazos.length + 1 | |
| 145 | + }; | |
| 146 | + } | |
| 147 | + }; | |
| 148 | + $scope.quitarPlazo = function(key) { | |
| 149 | + if($scope.precioCondicion.plazos[key].id) | |
| 150 | + $scope.plazosAEliminar.push($scope.precioCondicion.plazos[key].id); | |
| 151 | + | |
| 152 | + $scope.precioCondicion.plazos.splice(key, 1); | |
| 153 | + $scope.plazoACargar = | |
| 154 | + { | |
| 155 | + item: $scope.precioCondicion.plazos.length + 1 | |
| 156 | + }; | |
| 86 | 157 | }; |
| 87 | 158 | $scope.solicitarConfirmacionPlazoPago = function(plazoPago) { |
| 88 | 159 | focaModalService.confirm('¿Está seguro que desea borrar el plazo de pago ' + |
| ... | ... | @@ -97,5 +168,20 @@ angular.module('focaAbmPreciosCondiciones') |
| 97 | 168 | } |
| 98 | 169 | ); |
| 99 | 170 | }; |
| 171 | + | |
| 172 | + $scope.seleccionarListaPrecio = function() { | |
| 173 | + var modalInstance = $uibModal.open( | |
| 174 | + { | |
| 175 | + ariaLabelledBy: 'Busqueda de Listas de precio', | |
| 176 | + templateUrl: 'modal-lista-precio.html', | |
| 177 | + controller: 'focaModalListaPrecioCtrl', | |
| 178 | + size: 'lg' | |
| 179 | + } | |
| 180 | + ); | |
| 181 | + modalInstance.result.then(function(listaPrecio) { | |
| 182 | + $scope.precioCondicion.listaPrecio = listaPrecio; | |
| 183 | + $scope.listaPrecioLabel = listaPrecio.ID + ' - ' + listaPrecio.DES; | |
| 184 | + }); | |
| 185 | + }; | |
| 100 | 186 | } |
| 101 | 187 | ]); |
src/js/service.js
| ... | ... | @@ -25,6 +25,12 @@ angular.module('focaAbmPreciosCondiciones') |
| 25 | 25 | }, |
| 26 | 26 | borrarPlazoPago: function(id) { |
| 27 | 27 | return $http.delete(API_ENDPOINT.URL + '/plazo-pago/' + id); |
| 28 | + }, | |
| 29 | + guardarPlazosPago: function(plazos){ | |
| 30 | + return $http.post( | |
| 31 | + API_ENDPOINT.URL + '/plazos-pago', | |
| 32 | + {plazosPago: plazos} | |
| 33 | + ); | |
| 28 | 34 | } |
| 29 | 35 | }; |
| 30 | 36 | } |
src/views/foca-abm-precios-condiciones-item.html
| 1 | -<h4>Precios y Condiciones</h4> | |
| 2 | -<form> | |
| 3 | - <input type="hidden" name="id" ng-model="precioCondicion.id" /> | |
| 4 | - <div class="form-group row"> | |
| 5 | - <label class="offset-sm-1 col-sm-2 col-form-label">Código</label> | |
| 6 | - <div class="col-sm-4"> | |
| 7 | - <input | |
| 8 | - class="form-control" | |
| 9 | - type="text" | |
| 10 | - name="codigo" | |
| 11 | - ng-model="precioCondicion.codigo" | |
| 12 | - autocomplete="off" | |
| 13 | - teclado-virtual | |
| 14 | - /> | |
| 15 | - </div> | |
| 16 | - </div> | |
| 17 | - <div class="form-group row"> | |
| 18 | - <label class="offset-sm-1 col-sm-2 col-form-label">Nombre</label> | |
| 19 | - <div class="col-sm-4"> | |
| 20 | - <input | |
| 21 | - class="form-control" | |
| 22 | - type="text" | |
| 23 | - name="nombre" | |
| 24 | - ng-model="precioCondicion.nombre" | |
| 25 | - autocomplete="off" | |
| 26 | - teclado-virtual | |
| 27 | - /> | |
| 1 | +<div class="row"> | |
| 2 | + <foca-cabecera-facturador | |
| 3 | + titulo="'Precios y condiciones'" | |
| 4 | + fecha="now" | |
| 5 | + class="mb-0 col-lg-12" | |
| 6 | + ></foca-cabecera-facturador> | |
| 7 | +</div> | |
| 8 | +<div class="row"> | |
| 9 | + <form class="col-md-10"> | |
| 10 | + <input type="hidden" name="id" ng-model="precioCondicion.id" /> | |
| 11 | + <div class="row mb-3"> | |
| 12 | + <label class="col-sm-2 col-form-label">Código</label> | |
| 13 | + <input | |
| 14 | + class="form-control col-sm-4" | |
| 15 | + type="text" | |
| 16 | + name="codigo" | |
| 17 | + ng-model="precioCondicion.codigo" | |
| 18 | + autocomplete="off" | |
| 19 | + teclado-virtual | |
| 20 | + /> | |
| 21 | + <label class="col-sm-2 col-form-label">Nombre</label> | |
| 22 | + <input | |
| 23 | + class="form-control col-sm-4" | |
| 24 | + type="text" | |
| 25 | + name="nombre" | |
| 26 | + ng-model="precioCondicion.nombre" | |
| 27 | + autocomplete="off" | |
| 28 | + teclado-virtual | |
| 29 | + /> | |
| 28 | 30 | </div> |
| 29 | - </div> | |
| 30 | - <div class="form-group row"> | |
| 31 | - <label class="offset-sm-1 col-sm-2 col-form-label">Descripción</label> | |
| 32 | - <div class="col-sm-4"> | |
| 31 | + <div class="form-group row"> | |
| 32 | + <label class="col-sm-2 col-form-label">Descripción</label> | |
| 33 | 33 | <input |
| 34 | - class="form-control" | |
| 34 | + class="form-control col-sm-10" | |
| 35 | 35 | type="text" |
| 36 | 36 | name="nombre" |
| 37 | 37 | ng-model="precioCondicion.descripcion" |
| ... | ... | @@ -39,53 +39,68 @@ |
| 39 | 39 | teclado-virtual |
| 40 | 40 | /> |
| 41 | 41 | </div> |
| 42 | - </div> | |
| 43 | - <div class="form-group row"> | |
| 44 | - <label class="offset-sm-1 col-sm-2 col-form-label">Lista de precios</label> | |
| 45 | - <div class="col-sm-4"> | |
| 46 | - <input | |
| 47 | - class="form-control" | |
| 48 | - type="text" | |
| 49 | - name="nombre" | |
| 50 | - ng-model="precioCondicion.idListaPrecio" | |
| 51 | - autocomplete="off" | |
| 52 | - /> | |
| 53 | - </div> | |
| 54 | - </div> | |
| 55 | - <div class="form-group row" ng-show="mostrarPlazos"> | |
| 56 | - <label class="offset-sm-1 col-sm-2 col-form-label">Plazos</label> | |
| 57 | - <div class="col-sm-4"> | |
| 58 | - <table class="table table-sm table-hover lista"> | |
| 59 | - <thead> | |
| 60 | - <tr> | |
| 61 | - <th>Item</th> | |
| 62 | - <th>Dias</th> | |
| 63 | - <th colspan="2" class="text-center"> | |
| 64 | - <button class="btn btn-default boton-accion" ng-click="editarPlazoPago(0)"> | |
| 65 | - <i class="fa fa-plus"></i> | |
| 66 | - </button> | |
| 67 | - </th> | |
| 68 | - </tr> | |
| 69 | - </thead> | |
| 70 | - <tbody> | |
| 71 | - <tr ng-repeat="plazo in precioCondicion.plazos"> | |
| 72 | - <td ng-bind="plazo.item"></td> | |
| 73 | - <td ng-bind="plazo.dias"></td> | |
| 74 | - <td class="text-center"> | |
| 75 | - <button class="btn btn-default boton-accion" ng-click="editarPlazoPago(plazo.id)"> | |
| 76 | - <i class="fa fa-pencil"></i> | |
| 77 | - </button> | |
| 78 | - <button | |
| 79 | - class="btn btn-default boton-accion" | |
| 80 | - ng-click="solicitarConfirmacionPlazoPago(plazo)" | |
| 81 | - > | |
| 82 | - <i class="fa fa-trash"></i> | |
| 83 | - </button> | |
| 84 | - </td> | |
| 85 | - </tr> | |
| 86 | - </tbody> | |
| 87 | - </table> | |
| 42 | + <div class="row"> | |
| 43 | + <label class="col-sm-2 col-form-label">Lista de precios</label> | |
| 44 | + <div class="col-sm-4 input-group p-0"> | |
| 45 | + <input | |
| 46 | + ng-model="listaPrecioLabel" | |
| 47 | + class="form-control" | |
| 48 | + readonly | |
| 49 | + /> | |
| 50 | + <div class="input-group-append"> | |
| 51 | + <button | |
| 52 | + ladda="searchLoading" | |
| 53 | + class="btn btn-outline-secondary form-control" | |
| 54 | + title="Buscar" | |
| 55 | + type="button" | |
| 56 | + ng-click="seleccionarListaPrecio()" | |
| 57 | + foca-focus="focused == 3" | |
| 58 | + > | |
| 59 | + <i class="fa fa-search" aria-hidden="true"></i> | |
| 60 | + </button> | |
| 61 | + </div> | |
| 62 | + </div> | |
| 63 | + <label class="col-sm-2 col-form-label" ng-show="mostrarPlazos">Plazos</label> | |
| 64 | + <div class="col-sm-4 p-0" ng-show="mostrarPlazos"> | |
| 65 | + <div class="input-group p-0"> | |
| 66 | + <input | |
| 67 | + type="number" | |
| 68 | + class="form-control text-right" | |
| 69 | + min="0" | |
| 70 | + ng-model="plazoACargar.dias" | |
| 71 | + ng-keypress="agregarPlazo($event.keyCode)" | |
| 72 | + foca-focus="ingreso" | |
| 73 | + placeholder="Días" | |
| 74 | + /> | |
| 75 | + <div class="input-group-append"> | |
| 76 | + <button | |
| 77 | + class="btn btn-outline-secondary form-control" | |
| 78 | + title="Agregar" | |
| 79 | + type="button" | |
| 80 | + ng-click="agregarPlazo(13)" | |
| 81 | + foca-focus="focused == 3" | |
| 82 | + > | |
| 83 | + <i class="fa fa-save" aria-hidden="true"></i> | |
| 84 | + </button> | |
| 85 | + </div> | |
| 86 | + </div> | |
| 87 | + <table class="table table-striped table-sm"> | |
| 88 | + <tbody> | |
| 89 | + <tr ng-repeat="(key, plazo) in precioCondicion.plazos"> | |
| 90 | + <td class="text-right" > | |
| 91 | + <span ng-bind="plazo.dias + ' días'"></span> | |
| 92 | + <button | |
| 93 | + title="Eliminar" | |
| 94 | + class="btn btn-outline-secondary ml-1" | |
| 95 | + ng-click="quitarPlazo(key)" | |
| 96 | + > | |
| 97 | + <i class="fa fa-trash"></i> | |
| 98 | + </button> | |
| 99 | + </td> | |
| 100 | + </tr> | |
| 101 | + </tbody> | |
| 102 | + </table> | |
| 103 | + </div> | |
| 88 | 104 | </div> |
| 89 | - </div> | |
| 90 | -</form> | |
| 91 | - | |
| 105 | + </form> | |
| 106 | +</div> | |
| 92 | 107 | \ No newline at end of file |
src/views/foca-abm-precios-condiciones-listado.html
| 1 | -<foca-cabecera-facturador | |
| 1 | +<div class="row"> | |
| 2 | + <foca-cabecera-facturador | |
| 2 | 3 | titulo="'Precios y condiciones'" |
| 3 | 4 | fecha="now" |
| 4 | 5 | class="mb-0 col-lg-12" |
| 5 | 6 | ></foca-cabecera-facturador> |
| 6 | -<div class="lista"> | |
| 7 | - <table class="table table-sm table-hover table-nonfluid"> | |
| 8 | - <thead> | |
| 9 | - <tr> | |
| 10 | - <th>Código</th> | |
| 11 | - <th>Nombre</th> | |
| 12 | - <th colspan="2" class="text-center"> | |
| 13 | - <button class="btn btn-default boton-accion" ng-click="editar(0)"> | |
| 14 | - <i class="fa fa-plus"></i> | |
| 15 | - </button> | |
| 16 | - </th> | |
| 17 | - </tr> | |
| 18 | - </thead> | |
| 19 | - <tbody> | |
| 20 | - <tr ng-repeat="precioCondicion in preciosCondiciones"> | |
| 21 | - <td ng-bind="precioCondicion.codigo"></td> | |
| 22 | - <td ng-bind="precioCondicion.nombre"></td> | |
| 23 | - <td> | |
| 24 | - <button class="btn btn-default boton-accion" ng-click="editar(precioCondicion.id)"> | |
| 25 | - <i class="fa fa-pencil"></i> | |
| 26 | - </button> | |
| 27 | - <button class="btn btn-default boton-accion" ng-click="solicitarConfirmacion(precioCondicion)"> | |
| 28 | - <i class="fa fa-trash"></i> | |
| 29 | - </button> | |
| 30 | - </td> | |
| 31 | - </tr> | |
| 32 | - </tbody> | |
| 33 | - </table> | |
| 7 | +</div> | |
| 8 | +<div class="row"> | |
| 9 | + <div class="col-12 col-md-10 p-0 mt-4 border border-white rounded"> | |
| 10 | + <table class="table table-default table-hover table-sm table-abm table-striped mb-0"> | |
| 11 | + <thead> | |
| 12 | + <tr> | |
| 13 | + <th>Nombre</th> | |
| 14 | + <th>Lista de precio</th> | |
| 15 | + <th>Plazos</th> | |
| 16 | + <th colspan="2" class="text-center"> | |
| 17 | + <button | |
| 18 | + title="Agregar" | |
| 19 | + class="btn btn-outline-debo boton-accion" | |
| 20 | + ng-click="editar(0)"> | |
| 21 | + <i class="fa fa-plus"></i> | |
| 22 | + </button> | |
| 23 | + </th> | |
| 24 | + </tr> | |
| 25 | + </thead> | |
| 26 | + <tbody> | |
| 27 | + <tr ng-repeat="precioCondicion in preciosCondiciones"> | |
| 28 | + <td ng-bind="precioCondicion.nombre"></td> | |
| 29 | + <td ng-bind="precioCondicion.listaPrecio.ID + ' - ' + precioCondicion.listaPrecio.DES + ' - ' + precioCondicion.listaPrecio.moneda.DETALLE"></td> | |
| 30 | + <td><span | |
| 31 | + ng-repeat="plazo in precioCondicion.plazoPago" | |
| 32 | + ng-if="plazo.activo" | |
| 33 | + ng-bind="$last ? plazo.dias : plazo.dias + ', '"></span></td> | |
| 34 | + <td class="text-center"> | |
| 35 | + <button | |
| 36 | + title="Editar" | |
| 37 | + class="btn btn-outline-dark boton-accion" | |
| 38 | + ng-click="editar(precioCondicion.id)"> | |
| 39 | + <i class="fa fa-pencil"></i> | |
| 40 | + </button> | |
| 41 | + <button | |
| 42 | + title="Eliminar" | |
| 43 | + class="btn btn-outline-dark boton-accion" | |
| 44 | + ng-click="solicitarConfirmacion(precioCondicion)"> | |
| 45 | + <i class="fa fa-trash"></i> | |
| 46 | + </button> | |
| 47 | + </td> | |
| 48 | + </tr> | |
| 49 | + </tbody> | |
| 50 | + </table> | |
| 51 | + </div> | |
| 34 | 52 | </div> |