Commit 7319717d4a83692d523bdab06a2152e4318f3ae1
1 parent
13bfe86ad8
Exists in
master
busca en la base, no con filtros
Showing
3 changed files
with
19 additions
and
24 deletions
 
Show diff stats
src/js/controller.js
| ... | ... | @@ -10,7 +10,7 @@ angular.module('focaAbmVendedorCobrador') | 
| 10 | 10 | $scope.filters = ''; | 
| 11 | 11 | $scope.numPerPage = 10; | 
| 12 | 12 | $scope.currentPageVendedoresCobradores = []; | 
| 13 | - $scope.filteredVendedoresCobradores = []; | |
| 13 | + $scope.vendedoresCobradores = []; | |
| 14 | 14 | |
| 15 | 15 | //SETEO BOTONERA LATERAL | 
| 16 | 16 | focaBotoneraLateralService.showSalir(true); | 
| ... | ... | @@ -18,8 +18,6 @@ angular.module('focaAbmVendedorCobrador') | 
| 18 | 18 | focaBotoneraLateralService.showCancelar(false); | 
| 19 | 19 | focaBotoneraLateralService.showGuardar(false); | 
| 20 | 20 | |
| 21 | - actualizarTabla(); | |
| 22 | - | |
| 23 | 21 | $scope.editar = function(id) { | 
| 24 | 22 | $location.path('/vendedor-cobrador/' + id); | 
| 25 | 23 | }; | 
| ... | ... | @@ -33,7 +31,7 @@ angular.module('focaAbmVendedorCobrador') | 
| 33 | 31 | focaAbmVendedorCobradorService | 
| 34 | 32 | .eliminarVendedorCobrador(vendedorCobrador.CodVen) | 
| 35 | 33 | .then(function() { | 
| 36 | - actualizarTabla(); | |
| 34 | + $scope.search(13); | |
| 37 | 35 | }); | 
| 38 | 36 | } | 
| 39 | 37 | }); | 
| ... | ... | @@ -45,7 +43,7 @@ angular.module('focaAbmVendedorCobrador') | 
| 45 | 43 | $scope.paginas = []; | 
| 46 | 44 | $scope.paginas = calcularPages(page); | 
| 47 | 45 | $scope.currentPageVendedoresCobradores = | 
| 48 | - $scope.filteredVendedoresCobradores.slice(start, end); | |
| 46 | + $scope.vendedoresCobradores.slice(start, end); | |
| 49 | 47 | $scope.currentPage = page; | 
| 50 | 48 | }; | 
| 51 | 49 | |
| ... | ... | @@ -54,16 +52,20 @@ angular.module('focaAbmVendedorCobrador') | 
| 54 | 52 | $scope.selectPage(1); | 
| 55 | 53 | }; | 
| 56 | 54 | |
| 57 | - $scope.search = function() { | |
| 58 | - $scope.filteredVendedoresCobradores = $filter('filter')( | |
| 59 | - $scope.vendedoresCobradores, {$: $scope.filters} | |
| 60 | - ); | |
| 55 | + $scope.search = function(key) { | |
| 56 | + if(key !== 13) return; | |
| 61 | 57 | |
| 62 | - $scope.lastPage = Math.ceil( | |
| 63 | - $scope.filteredVendedoresCobradores.length / $scope.numPerPage | |
| 64 | - ); | |
| 58 | + focaAbmVendedorCobradorService | |
| 59 | + .getVendedoresCobradores($scope.filters) | |
| 60 | + .then(function(res) { | |
| 61 | + $scope.vendedoresCobradores = res.data; | |
| 65 | 62 | |
| 66 | - $scope.resetPage(); | |
| 63 | + $scope.lastPage = Math.ceil( | |
| 64 | + $scope.vendedoresCobradores.length / $scope.numPerPage | |
| 65 | + ); | |
| 66 | + | |
| 67 | + $scope.resetPage(); | |
| 68 | + }); | |
| 67 | 69 | }; | 
| 68 | 70 | |
| 69 | 71 | function calcularPages(paginaActual) { | 
| ... | ... | @@ -129,13 +131,6 @@ angular.module('focaAbmVendedorCobrador') | 
| 129 | 131 | $scope.selectedClientes = 0; | 
| 130 | 132 | } | 
| 131 | 133 | } | 
| 132 | - | |
| 133 | - function actualizarTabla() { | |
| 134 | - focaAbmVendedorCobradorService.getVendedoresCobradores().then(function(res) { | |
| 135 | - $scope.vendedoresCobradores = res.data; | |
| 136 | - $scope.search(); | |
| 137 | - }); | |
| 138 | - } | |
| 139 | 134 | } | 
| 140 | 135 | ]) | 
| 141 | 136 | .controller('focaAbmVendedorCobradorController', [ | 
src/js/service.js
| 1 | 1 | angular.module('focaAbmVendedorCobrador') | 
| 2 | 2 | .factory('focaAbmVendedorCobradorService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { | 
| 3 | 3 | return { | 
| 4 | - getVendedoresCobradores: function() { | |
| 5 | - return $http.get(API_ENDPOINT.URL + '/vendedor-cobrador'); | |
| 4 | + getVendedoresCobradores: function(nombre) { | |
| 5 | + return $http.post(API_ENDPOINT.URL + '/vendedor-cobrador/list', {nombre: nombre}); | |
| 6 | 6 | }, | 
| 7 | 7 | getVendedorCobradorById: function(id) { | 
| 8 | 8 | return $http.get(API_ENDPOINT.URL + '/vendedor-cobrador/' + id); | 
src/views/foca-abm-vendedor-cobrador-listado.html
| ... | ... | @@ -14,7 +14,7 @@ | 
| 14 | 14 | id="search" | 
| 15 | 15 | placeholder="Búsqueda" | 
| 16 | 16 | teclado-virtual | 
| 17 | - ng-change="search()" | |
| 17 | + ng-keypress="search($event.keyCode)" | |
| 18 | 18 | ng-model="filters" | 
| 19 | 19 | /> | 
| 20 | 20 | <div class="input-group-append"> | 
| ... | ... | @@ -22,7 +22,7 @@ | 
| 22 | 22 | ladda="searchLoading" | 
| 23 | 23 | class="btn btn-outline-secondary" | 
| 24 | 24 | type="button" | 
| 25 | - ng-click="busquedaPress(13)" | |
| 25 | + ng-click="search(13)" | |
| 26 | 26 | > | 
| 27 | 27 | <i class="fa fa-search" aria-hidden="true"></i> | 
| 28 | 28 | </button> |