From aaecbd022e08c0a856bf45f674947332a479d735 Mon Sep 17 00:00:00 2001 From: Luigi Date: Mon, 8 Jul 2019 13:00:14 -0300 Subject: [PATCH] Mejora logistica de pedidos --- src/js/controller.js | 86 +++++++++++++++++++++++++++-- src/js/controllerBusquedaAvanzada.js | 75 +++++++++++++++++++++++++ src/js/service.js | 6 ++ src/views/foca-logistica-pedido-ruta.html | 23 ++++++-- src/views/foca-modal-busqueda-avanzada.html | 76 +++++++++++++++++++++++++ 5 files changed, 256 insertions(+), 10 deletions(-) create mode 100644 src/js/controllerBusquedaAvanzada.js create mode 100644 src/views/foca-modal-busqueda-avanzada.html diff --git a/src/js/controller.js b/src/js/controller.js index 0a2590d..cb0f7f4 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -154,6 +154,29 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo }); }; + $scope.busquedaAvanzada = function () { + var modalInstance = $uibModal.open( + { + ariaLabelledBy: 'Busqueda Avanzada', + templateUrl: 'foca-modal-busqueda-avanzada.html', + controller: 'focaModalBusquedaAvanzadaController', + resolve: { + parametrosModal: function () { + return { + remitos: $scope.marcadores + }; + } + } + } + ); + modalInstance.result.then(function(data) { + actualizarMarcadores(data); + }, function () { + // funcion ejecutada cuando se cancela el modal + } + ); + }; + $scope.selectVehiculo = function(idTransportista, nombreTransportista) { var parametrosModal = { columnas: [ @@ -194,13 +217,65 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo // funcion ejecutada cuando se cancela el modal }); }; - $scope.seleccionarFechaReparto = function() { focaModalService.modalFecha('Fecha de reparto').then(function(fecha) { setearFecha(fecha); }); }; + function actualizarMarcadores (filtros) { + var marcadores = []; + if (filtros.cliente && filtros.remito === undefined) { + + $scope.marcadores.forEach( function (marcador) { + if (marcador.notaPedido.cliente.NOM === filtros.cliente) { + marcadores.push(marcador); + } + }); + + if (marcadores.length === 0) { + focaModalService.alert('No se encontraron coincidencias en la busqueda') + .then(function (data) { + if (data) { + $scope.marcadoresFiltro = marcadores; + } + }); + $scope.$broadcast('cleanCabecera'); + setearFecha(new Date()); + return; + } else { + $scope.marcadoresFiltro = marcadores; + $scope.$broadcast('addCabecera', { + label: 'Cliente:', + valor: filtros.cliente + }); + } + } else { + $scope.marcadores.forEach( function (marcador) { + if (filtros.remito.id === marcador.notaPedido.remito.id) { + marcadores.push(marcador); + } + }); + if (marcadores.length === 0) { + focaModalService.alert('No se encontraron coincidencias en la busqueda') + .then(function (data) { + if (data) { + $scope.marcadoresFiltro = marcadores; + } + }); + $scope.$broadcast('cleanCabecera'); + setearFecha(new Date()); + return; + } else { + $scope.marcadoresFiltro = marcadores; + $scope.$broadcast('addCabecera', { + label: 'Cliente:', + valor: filtros.cliente + }); + } + } + } + function setearFecha(fecha) { $scope.fechaReparto = fecha; focaLogisticaPedidoRutaService.setFechaReparto(fecha); @@ -242,8 +317,9 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo }; focaLogisticaPedidoRutaService.obtenerActividad(datos).then(function(datos) { - if (JSON.stringify(datos.data) !== JSON.stringify($scope.marcadores)) { + if (!angular.equals($scope.marcadores, datos.data)) { $scope.marcadores = datos.data; + $scope.marcadoresFiltro = $scope.marcadores; } }); } @@ -285,8 +361,8 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo } return false; } - $interval(function() { - getSeguimiento(); - }, 5000); + // $interval(function() { + // getSeguimiento(); + // }, 5000); } ]); diff --git a/src/js/controllerBusquedaAvanzada.js b/src/js/controllerBusquedaAvanzada.js new file mode 100644 index 0000000..0f4de15 --- /dev/null +++ b/src/js/controllerBusquedaAvanzada.js @@ -0,0 +1,75 @@ +angular.module('focaLogisticaPedidoRuta') .controller('focaModalBusquedaAvanzadaController', [ + '$scope', 'focaLogisticaPedidoRutaService', '$uibModal', '$filter', + 'focaModalService', '$uibModalInstance', 'parametrosModal', + function($scope, focaLogisticaPedidoRutaService, $uibModal, $filter, + focaModalService, $uibModalInstance, parametrosModal + ) { + $scope.cliente = ''; + $scope.seleccionarCliente = function (key) { + if (key !== 13) { + return; + } + focaModalService.modal({ + titulo: 'Clientes', + searchText: $scope.cliente, + query: '/cliente', + size: 'md', + columnas: [ + { + propiedad: 'COD', + nombre: 'Codigo' + }, + { + propiedad: 'NOM', + nombre: 'Nombre' + }, + { + propiedad: 'CUIT', + nombre: 'CUIT' + } + ], + }).then(function (res) { + $scope.cliente = res.NOM; + }).catch(function (e) { + console.log(e); + }); + }; + + $scope.seleccionarRemito = function () { + var modalInstance = $uibModal.open( + { + ariaLabelledBy: 'Busqueda de Remito', + templateUrl: 'foca-modal-remito.html', + controller: 'focaModalRemitoController', + size: 'lg', + resolve: { usadoPor: function () { return 'remito'; } } + } + ); + modalInstance.result.then(function(remito) { + $scope.remito = remito; + $scope.remito.numero = $filter('rellenarDigitos')(remito.lugar, 4) + '-' + + $filter('rellenarDigitos')(remito.numeroRemito, 6); + $scope.cliente = remito.cliente.NOM; + }, function () { + // funcion ejecutada cuando se cancela el modal + } + ); + }; + + $scope.cancel = function () { + $uibModalInstance.dismiss('close'); + }; + + $scope.buscar = function () { + $uibModalInstance.close(datos()); + }; + + function datos () { + var datos = { + cliente: $scope.cliente, + remito: $scope.remito + }; + return datos; + } + } +]); diff --git a/src/js/service.js b/src/js/service.js index 4724734..1f4f4e8 100644 --- a/src/js/service.js +++ b/src/js/service.js @@ -21,6 +21,12 @@ angular.module('focaLogisticaPedidoRuta') cerrarDistribuicion: function(remitos) { return $http.post(url + '/vehiculo/cierre-distribuicion', remitos); }, + getArticulos: function () { + return $http.get(url + '/articulos'); + }, + getAllClientes: function () { + return $http.get(url + '/cliente'); + }, desasociarRemitos: function(remitos, idVehiculo, sinRemitos) { var idsRemitos = []; for (var i = 0; i < remitos.length; i++) { diff --git a/src/views/foca-logistica-pedido-ruta.html b/src/views/foca-logistica-pedido-ruta.html index d936af8..aabcb32 100644 --- a/src/views/foca-logistica-pedido-ruta.html +++ b/src/views/foca-logistica-pedido-ruta.html @@ -10,7 +10,7 @@
-
+
Ver Remitos
Fecha Desde @@ -78,6 +78,19 @@ Asignado
+
+ +
@@ -86,7 +99,7 @@ latitud="-34.7152975" longitud="-65.9053867" zoom="5" - marcadores="marcadores" + marcadores="marcadoresFiltro" parametros= "datosBuscados" />
@@ -105,21 +118,21 @@
diff --git a/src/views/foca-modal-busqueda-avanzada.html b/src/views/foca-modal-busqueda-avanzada.html new file mode 100644 index 0000000..44598f0 --- /dev/null +++ b/src/views/foca-modal-busqueda-avanzada.html @@ -0,0 +1,76 @@ + + + \ No newline at end of file -- 1.9.1