From ba5693e55950309bc6a804c828c80df24f5e4630 Mon Sep 17 00:00:00 2001 From: efernandez Date: Fri, 21 Dec 2018 17:54:08 -0300 Subject: [PATCH] progreso logistica --- src/js/controllerDetalleVehiculo.js | 34 +++++++++++++++++- src/js/osm-directive.js | 39 +++++++++++++++++++-- src/views/foca-detalle-vehiculo.html | 58 ++++++++++++++++++++++++------- src/views/foca-logistica-pedido-ruta.html | 5 +-- 4 files changed, 117 insertions(+), 19 deletions(-) diff --git a/src/js/controllerDetalleVehiculo.js b/src/js/controllerDetalleVehiculo.js index 846c481..5b32ddf 100644 --- a/src/js/controllerDetalleVehiculo.js +++ b/src/js/controllerDetalleVehiculo.js @@ -1,9 +1,41 @@ angular.module('focaLogisticaPedidoRuta') - .controller('focaDetalleVehiculo', ['$scope', '$uibModalInstance', 'vehiculo', 'marcador', + .controller('focaDetalleVehiculo', + ['$scope', + '$uibModalInstance', + 'vehiculo', + 'marcador', function($scope, $uibModalInstance, vehiculo, marcador) { $scope.articulos = marcador.notaPedido.articulosNotaPedido; + $scope.articuloSeleccionado = {}; $scope.vehiculo = vehiculo; $scope.aceptar = function() { $uibModalInstance.close(); }; + + $scope.cargarACisterna = function(cisterna) { + if(!$scope.articuloSeleccionado.id) { + //TODO: usar modal de foca + alert('Debe seleccionar un articulo'); + return; + } + if(cisterna.cisternaCarga.cantidad) { + cisterna.cisternaCarga.cantidad += parseFloat(cisterna.aCargar); + }else { + cisterna.cisternaCarga.cantidad = parseFloat(cisterna.aCargar); + cisterna.cisternaCarga.idProducto = $scope.articuloSeleccionado.id; + } + cisterna.disponible = cisterna.capacidad - cisterna.cisternaCarga.cantidad; + cisterna.aCargar = ''; + }; + $scope.calcularPorcentaje = function(cisterna) { + if(!cisterna.cisternaCarga.cantidad) { + cisterna.cisternaCarga.cantidad = 0; + } + var porcentaje = (cisterna.cisternaCarga.cantidad * 100 / + cisterna.capacidad) + '%'; + document.getElementById(cisterna.id).style.width = porcentaje; + }; + $scope.cambioArticulo = function(articulo) { + $scope.articuloSeleccionado = articulo; + }; }]); diff --git a/src/js/osm-directive.js b/src/js/osm-directive.js index 3e330ab..e189c93 100644 --- a/src/js/osm-directive.js +++ b/src/js/osm-directive.js @@ -7,7 +7,7 @@ angular.module('focaLogisticaPedidoRuta').directive('foca', function() { scope.map = L.map(contenedor).setView([attrs.latitud, attrs.longitud], attrs.zoom); L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map); }, - controller: ['$scope', function($scope) { + controller: ['$scope', '$filter', function($scope, $filter) { $scope.markers = []; $scope.$watch('marcadores', function() { for(var i in $scope.markers) { @@ -15,8 +15,41 @@ angular.module('focaLogisticaPedidoRuta').directive('foca', function() { } $scope.markers = []; - angular.forEach($scope.marcadores, function(marcador) { - var observacion = '