Commit e8c0136f61cf758bf209448ef3674c254e2c12ec

Authored by Jose Pinto
1 parent c2b00fff1b
Exists in master and in 1 other branch develop

si le paso vendedor filtra, sino trae todos los clientes

Showing 2 changed files with 11 additions and 4 deletions   Show diff stats
src/js/controller.js
... ... @@ -5,7 +5,7 @@ angular.module('focaBusquedaCliente')
5 5 function($uibModalInstance, focaBusquedaClienteService, $scope, $filter,
6 6 $uibModal, focaModalService, $timeout, vendedor) {
7 7  
8   - $scope.vendedor = vendedor;
  8 + $scope.vendedor = vendedor ? vendedor : {};
9 9 $scope.filters = '';
10 10 $scope.primerBusqueda = false;
11 11 // pagination
... ... @@ -49,9 +49,12 @@ angular.module('focaBusquedaCliente')
49 49  
50 50 $scope.busquedaPress = function(key) {
51 51 if (key === 13) {
  52 + var funcion = ($scope.vendedor.CodVen) ?
  53 + 'obtenerClientesPorNombreOCuitByVendedor' : 'obtenerClientesPorNombreOCuit';
  54 +
52 55 $scope.searchLoading = true;
53 56 focaBusquedaClienteService
54   - .obtenerClientesPorNombreOCuit($scope.filters, vendedor.CodVen)
  57 + [funcion]($scope.filters, $scope.vendedor.CodVen)
55 58 .then(
56 59 function(res) {
57 60 $scope.primerBusqueda = true;
1 1 angular.module('focaBusquedaCliente')
2 2 .service('focaBusquedaClienteService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) {
3 3 return {
4   - obtenerClientesPorNombreOCuit: function(nombreOCuit, idVendedor) {
5   - return $http.post(API_ENDPOINT.URL + '/cliente',
  4 + obtenerClientesPorNombreOCuitByVendedor: function(nombreOCuit, idVendedor) {
  5 + return $http.post(API_ENDPOINT.URL + '/cliente/listar',
6 6 {nombreOCuit: nombreOCuit, idVendedor: idVendedor});
7 7 },
  8 + obtenerClientesPorNombreOCuit: function(nombreOCuit) {
  9 + return $http.post(API_ENDPOINT.URL + '/cliente/listar',
  10 + {nombreOCuit: nombreOCuit});
  11 + },
8 12 guardarCliente: function(cliente) {
9 13 return $http.post(API_ENDPOINT.URL + '/cliente', {cliente: cliente});
10 14 }