Commit 6a06288d8c841d9ca32d2b3fb88647c8658c0534
1 parent
9ba5c967b7
Exists in
master
code review
Showing
3 changed files
with
5 additions
and
5 deletions
Show diff stats
src/js/arrastrar.js
| 1 | function allowDrop(ev) { | 1 | function allowDrop(ev) { |
| 2 | ev.preventDefault(); | 2 | ev.preventDefault(); |
| 3 | } | 3 | } |
| 4 | function drag(ev, marcador) { | 4 | function drag(ev, marcador) { |
| 5 | marcador = JSON.stringify(marcador); | 5 | marcador = JSON.stringify(marcador); |
| 6 | ev.dataTransfer.setData('marcador', marcador); | 6 | ev.dataTransfer.setData('marcador', marcador); |
| 7 | var elementoDom = document.getElementById('test'); | 7 | var elementoDom = document.getElementById('test'); |
| 8 | var scope = angular.element(elementoDom).scope(); | 8 | var scope = angular.element(elementoDom).scope(); |
| 9 | scope.arrastra(); | 9 | scope.arrastra(); |
| 10 | } | 10 | } |
| 11 | function drop(ev) { | 11 | function drop(ev) { |
| 12 | ev.preventDefault(); | 12 | ev.preventDefault(); |
| 13 | var data = ev.dataTransfer.getData('marcador'); | 13 | var data = ev.dataTransfer.getData('marcador'); |
| 14 | var elementoDom = document.getElementById(ev.target.id); | 14 | var elementoDom = document.getElementById(ev.target.id); |
| 15 | var elementoAngular = angular.element(elementoDom); | 15 | var elementoAngular = angular.element(elementoDom); |
| 16 | var elementoScope = elementoAngular.scope(); | 16 | var elementoScope = elementoAngular.scope(); |
| 17 | elementoScope.cargar(ev.target.id, data); | 17 | elementoScope.cargar(ev.target.id, data); |
| 18 | elementoScope.$digest(); | 18 | elementoScope.$digest(); |
| 19 | } | 19 | } |
| 20 | function dropEnd() { | 20 | function dropEnd() { |
| 21 | console.log('drop'); | 21 | console.log('drop'); |
| 22 | var elementoDom = document.getElementById('test'); | 22 | var elementoDom = document.getElementById('test'); |
| 23 | var scope = angular.element(elementoDom).scope(); | 23 | var scope = angular.element(elementoDom).scope(); |
| 24 | scope.noArrastra(); | 24 | scope.noArrastra(); |
| 25 | } | ||
| 25 | } |
src/js/controller.js
| 1 | angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaController', [ | 1 | angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaController', [ |
| 2 | '$scope', 'focaLogisticaPedidoRutaService', '$location', '$uibModal', '$filter', | 2 | '$scope', 'focaLogisticaPedidoRutaService', '$location', '$uibModal', '$filter', |
| 3 | 'focaModalService', 'focaBotoneraLateralService', | 3 | 'focaModalService', 'focaBotoneraLateralService', |
| 4 | function($scope, focaLogisticaPedidoRutaService, $location, $uibModal, $filter, | 4 | function($scope, focaLogisticaPedidoRutaService, $location, $uibModal, $filter, |
| 5 | focaModalService, focaBotoneraLateralService | 5 | focaModalService, focaBotoneraLateralService |
| 6 | ) { | 6 | ) { |
| 7 | $scope.now = new Date(); | 7 | $scope.now = new Date(); |
| 8 | $scope.actividad = 'Logistica'; | 8 | $scope.actividad = 'Logistica'; |
| 9 | 9 | ||
| 10 | //Datos Pantalla | 10 | //Datos Pantalla |
| 11 | $scope.titulo = 'Logistica de Pedidos'; | 11 | $scope.titulo = 'Logistica de Pedidos'; |
| 12 | $scope.botonera = ['Vehiculo']; | 12 | $scope.botonera = ['Vehiculo']; |
| 13 | var cabecera = ''; | 13 | var cabecera = ''; |
| 14 | 14 | ||
| 15 | $scope.idUsuario = 0; | 15 | $scope.idUsuario = 0; |
| 16 | $scope.marcadores = []; | 16 | $scope.marcadores = []; |
| 17 | $scope.vehiculos = []; | 17 | $scope.vehiculos = []; |
| 18 | getSeguimiento(); | 18 | getSeguimiento(); |
| 19 | $scope.arrastrando = false; | 19 | $scope.arrastrando = false; |
| 20 | $scope.general = function() { | 20 | $scope.general = function() { |
| 21 | $scope.idUsuario = 0; | 21 | $scope.idUsuario = 0; |
| 22 | getSeguimiento(); | 22 | getSeguimiento(); |
| 23 | }; | 23 | }; |
| 24 | 24 | ||
| 25 | //SETEO BOTONERA LATERAL | 25 | //SETEO BOTONERA LATERAL |
| 26 | focaBotoneraLateralService.showSalir(true); | 26 | focaBotoneraLateralService.showSalir(true); |
| 27 | focaBotoneraLateralService.showPausar(false); | 27 | focaBotoneraLateralService.showPausar(false); |
| 28 | focaBotoneraLateralService.showGuardar(false); | 28 | focaBotoneraLateralService.showGuardar(false); |
| 29 | 29 | ||
| 30 | $scope.general = function() { | 30 | $scope.general = function() { |
| 31 | $scope.idUsuario = 0; | 31 | $scope.idUsuario = 0; |
| 32 | getSeguimiento(); | 32 | getSeguimiento(); |
| 33 | $scope.$broadcast('removeCabecera', cabecera); | 33 | $scope.$broadcast('removeCabecera', cabecera); |
| 34 | $scope.$broadcast('addCabecera',{ | 34 | $scope.$broadcast('addCabecera',{ |
| 35 | label: 'General', | 35 | label: 'General', |
| 36 | valor: '' | 36 | valor: '' |
| 37 | }); | 37 | }); |
| 38 | }; | 38 | }; |
| 39 | 39 | ||
| 40 | $scope.cargar = function(id, punto) { | 40 | $scope.cargar = function(id, punto) { |
| 41 | var idRemito = JSON.parse(punto).notaPedido.remito.id; | 41 | var idRemito = JSON.parse(punto).notaPedido.remito.id; |
| 42 | var modalInstance = $uibModal.open( | 42 | var modalInstance = $uibModal.open( |
| 43 | { | 43 | { |
| 44 | ariaLabelledBy: 'Busqueda de Vehiculo', | 44 | ariaLabelledBy: 'Busqueda de Vehiculo', |
| 45 | templateUrl: 'foca-detalle-vehiculo.html', | 45 | templateUrl: 'foca-detalle-vehiculo.html', |
| 46 | controller: 'focaDetalleVehiculo', | 46 | controller: 'focaDetalleVehiculo', |
| 47 | size: 'lg', | 47 | size: 'lg', |
| 48 | resolve: { | 48 | resolve: { |
| 49 | idVehiculo: function() {return id;}, | 49 | idVehiculo: function() {return id;}, |
| 50 | idRemito: function() {return idRemito;} | 50 | idRemito: function() {return idRemito;} |
| 51 | } | 51 | } |
| 52 | } | 52 | } |
| 53 | ); | 53 | ); |
| 54 | modalInstance.result.then(function() { | 54 | modalInstance.result.then(function() { |
| 55 | }, function() { | 55 | }, function() { |
| 56 | }); | 56 | }); |
| 57 | }; | 57 | }; |
| 58 | 58 | ||
| 59 | $scope.quitarVehiculo = function(vehiculo) { | 59 | $scope.quitarVehiculo = function(vehiculo) { |
| 60 | focaModalService.confirm('Esta seguro que desea eliminar el vehículo ' + | 60 | focaModalService.confirm('Esta seguro que desea eliminar el vehículo ' + |
| 61 | vehiculo.codigo + '?').then(function() { | 61 | vehiculo.codigo + '?').then(function() { |
| 62 | $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); | 62 | $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); |
| 63 | }); | 63 | }); |
| 64 | }; | 64 | }; |
| 65 | 65 | ||
| 66 | $scope.informacionVehiculo = function(vehiculo) { | 66 | $scope.informacionVehiculo = function(vehiculo) { |
| 67 | focaModalService.alert('EN DESARROLLO : \n información del vehículo ' + | 67 | focaModalService.alert('EN DESARROLLO : \n información del vehículo ' + |
| 68 | JSON.stringify(vehiculo)); | 68 | JSON.stringify(vehiculo)); |
| 69 | }; | 69 | }; |
| 70 | 70 | ||
| 71 | $scope.arrastra = function() { | 71 | $scope.arrastra = function() { |
| 72 | $scope.arrastrando = true; | 72 | $scope.arrastrando = true; |
| 73 | $scope.$digest(); | 73 | $scope.$digest(); |
| 74 | }; | 74 | }; |
| 75 | 75 | ||
| 76 | $scope.noArrastra = function() { | 76 | $scope.noArrastra = function() { |
| 77 | $scope.arrastrando = false; | 77 | $scope.arrastrando = false; |
| 78 | $scope.$digest(); | 78 | $scope.$digest(); |
| 79 | }; | 79 | }; |
| 80 | 80 | ||
| 81 | $scope.individual = function() { | 81 | $scope.individual = function() { |
| 82 | $scope.idUsuario = -1; | 82 | $scope.idUsuario = -1; |
| 83 | }; | 83 | }; |
| 84 | 84 | ||
| 85 | $scope.mostrarDetalle = function() { | 85 | $scope.mostrarDetalle = function() { |
| 86 | $scope.detalle = true; | 86 | $scope.detalle = true; |
| 87 | }; | 87 | }; |
| 88 | 88 | ||
| 89 | $scope.salir = function() { | 89 | $scope.salir = function() { |
| 90 | $location.path('/'); | 90 | $location.path('/'); |
| 91 | }; | 91 | }; |
| 92 | 92 | ||
| 93 | $scope.search = function(key) { | 93 | $scope.search = function(key) { |
| 94 | if (key === 13) { | 94 | if (key === 13) { |
| 95 | $scope.idUsuario = $scope.idUsuarioInput; | 95 | $scope.idUsuario = $scope.idUsuarioInput; |
| 96 | getSeguimiento(); | 96 | getSeguimiento(); |
| 97 | $scope.$broadcast('removeCabecera', 'General'); | 97 | $scope.$broadcast('removeCabecera', 'General'); |
| 98 | $scope.$broadcast('addCabecera', { | 98 | $scope.$broadcast('addCabecera', { |
| 99 | label: cabecera, | 99 | label: cabecera, |
| 100 | valor: $scope.idUsuarioInput | 100 | valor: $scope.idUsuarioInput |
| 101 | }); | 101 | }); |
| 102 | } | 102 | } |
| 103 | }; | 103 | }; |
| 104 | 104 | ||
| 105 | $scope.fecha = function() { | 105 | $scope.fecha = function() { |
| 106 | getSeguimiento(); | 106 | getSeguimiento(); |
| 107 | }; | 107 | }; |
| 108 | 108 | ||
| 109 | $scope.seleccionarVehiculo = function() { | 109 | $scope.seleccionarVehiculo = function() { |
| 110 | var modalInstance = $uibModal.open( | 110 | var modalInstance = $uibModal.open( |
| 111 | { | 111 | { |
| 112 | ariaLabelledBy: 'Busqueda de Vehiculo', | 112 | ariaLabelledBy: 'Busqueda de Vehiculo', |
| 113 | templateUrl: 'modal-vehiculo.html', | 113 | templateUrl: 'modal-vehiculo.html', |
| 114 | controller: 'focaModalVehiculoController', | 114 | controller: 'focaModalVehiculoController', |
| 115 | size: 'lg' | 115 | size: 'lg' |
| 116 | } | 116 | } |
| 117 | ); | 117 | ); |
| 118 | 118 | ||
| 119 | modalInstance.result.then( | 119 | modalInstance.result.then( |
| 120 | function(vehiculo) { | 120 | function(vehiculo) { |
| 121 | var existe = $filter('filter')($scope.vehiculos, {id: vehiculo.id}); | 121 | var existe = $filter('filter')($scope.vehiculos, {id: vehiculo.id}); |
| 122 | if(existe.length > 0){ | 122 | if(existe.length) { |
| 123 | focaModalService.alert('El vehiculo que intenta cargar ya ha sido cargado'); | 123 | focaModalService.alert('El vehiculo que intenta cargar ya ha sido cargado'); |
| 124 | return; | 124 | return; |
| 125 | } | 125 | } |
| 126 | $scope.vehiculos.push(vehiculo); | 126 | $scope.vehiculos.push(vehiculo); |
| 127 | }, function() { | 127 | }, function() { |
| 128 | // funcion ejecutada cuando se cancela el modal | 128 | // funcion ejecutada cuando se cancela el modal |
| 129 | } | 129 | } |
| 130 | ); | 130 | ); |
| 131 | }; | 131 | }; |
| 132 | 132 | ||
| 133 | function getSeguimiento() { | 133 | function getSeguimiento() { |
| 134 | var now = $scope.now; | 134 | var now = $scope.now; |
| 135 | var desde = new Date(new Date(now.setHours(0)).setMinutes(0)); | 135 | var desde = new Date(new Date(now.setHours(0)).setMinutes(0)); |
| 136 | desde = desde.setDate(desde.getDate() - 1); | 136 | desde = desde.setDate(desde.getDate() - 1); |
| 137 | desde = new Date(desde); | 137 | desde = new Date(desde); |
| 138 | var datos = { | 138 | var datos = { |
| 139 | actividad: $scope.actividad, | 139 | actividad: $scope.actividad, |
| 140 | idUsuario: $scope.idUsuario, | 140 | idUsuario: $scope.idUsuario, |
| 141 | fechaDesde: desde, | 141 | fechaDesde: desde, |
| 142 | fechaHasta: new Date(new Date(now.setHours(23)).setMinutes(59)) | 142 | fechaHasta: new Date(new Date(now.setHours(23)).setMinutes(59)) |
| 143 | }; | 143 | }; |
| 144 | 144 | ||
| 145 | $scope.datosBuscados = { | 145 | $scope.datosBuscados = { |
| 146 | actividad: $scope.actividad, | 146 | actividad: $scope.actividad, |
| 147 | individual: $scope.idUsuario !== 0 ? true : false | 147 | individual: $scope.idUsuario !== 0 ? true : false |
| 148 | }; | 148 | }; |
| 149 | 149 | ||
| 150 | focaLogisticaPedidoRutaService.obtenerActividad(datos).then(function(datos) { | 150 | focaLogisticaPedidoRutaService.obtenerActividad(datos).then(function(datos) { |
| 151 | $scope.marcadores = datos.data; | 151 | $scope.marcadores = datos.data; |
| 152 | }); | 152 | }); |
| 153 | } | 153 | } |
| 154 | } | 154 | } |
| 155 | ]); | 155 | ]); |
| 156 | 156 |
src/js/controllerDetalleVehiculo.js
| 1 | angular.module('focaLogisticaPedidoRuta') | 1 | angular.module('focaLogisticaPedidoRuta') |
| 2 | .controller('focaDetalleVehiculo', | 2 | .controller('focaDetalleVehiculo', |
| 3 | ['$scope', | 3 | ['$scope', |
| 4 | '$uibModalInstance', | 4 | '$uibModalInstance', |
| 5 | 'idVehiculo', | 5 | 'idVehiculo', |
| 6 | 'idRemito', | 6 | 'idRemito', |
| 7 | 'focaModalService', | 7 | 'focaModalService', |
| 8 | '$filter', | 8 | '$filter', |
| 9 | 'focaLogisticaPedidoRutaService', | 9 | 'focaLogisticaPedidoRutaService', |
| 10 | function($scope, $uibModalInstance, idVehiculo, idRemito, focaModalService, $filter, | 10 | function($scope, $uibModalInstance, idVehiculo, idRemito, focaModalService, $filter, |
| 11 | focaLogisticaPedidoRutaService | 11 | focaLogisticaPedidoRutaService |
| 12 | ) { | 12 | ) { |
| 13 | $scope.articulos = []; | 13 | $scope.articulos = []; |
| 14 | $scope.vehiculo = {}; | 14 | $scope.vehiculo = {}; |
| 15 | $scope.remito = {}; | 15 | $scope.remito = {}; |
| 16 | focaLogisticaPedidoRutaService.obtenerVehiculoById(idVehiculo).then( | 16 | focaLogisticaPedidoRutaService.obtenerVehiculoById(idVehiculo).then( |
| 17 | function(res) { | 17 | function(res) { |
| 18 | $scope.vehiculo = res.data; | 18 | $scope.vehiculo = res.data; |
| 19 | } | 19 | } |
| 20 | ); | 20 | ); |
| 21 | focaLogisticaPedidoRutaService.obtenerRemitoById(idRemito).then( | 21 | focaLogisticaPedidoRutaService.obtenerRemitoById(idRemito).then( |
| 22 | function(res) { | 22 | function(res) { |
| 23 | $scope.remito = res.data; | 23 | $scope.remito = res.data; |
| 24 | $scope.articulos = res.data.articulosRemito; | 24 | $scope.articulos = res.data.articulosRemito; |
| 25 | } | 25 | } |
| 26 | ); | 26 | ); |
| 27 | $scope.aCargar = []; | 27 | $scope.aCargar = []; |
| 28 | $scope.aceptar = function() { | 28 | $scope.aceptar = function() { |
| 29 | $uibModalInstance.close(); | 29 | $uibModalInstance.close(); |
| 30 | }; | 30 | }; |
| 31 | 31 | ||
| 32 | $scope.cancelar = function() { | 32 | $scope.cancelar = function() { |
| 33 | $uibModalInstance.close(); | 33 | $uibModalInstance.close(); |
| 34 | }; | 34 | }; |
| 35 | 35 | ||
| 36 | $scope.cargarACisternas = function(vehiculo) { | 36 | $scope.cargarACisternas = function(vehiculo) { |
| 37 | for (var i = 0; i < vehiculo.cisternas.length; i++) { | 37 | for(var i = 0; i < vehiculo.cisternas.length; i++) { |
| 38 | var cisterna = vehiculo.cisternas[i]; | 38 | var cisterna = vehiculo.cisternas[i]; |
| 39 | var aCargar = parseFloat($scope.aCargar[i]); | 39 | var aCargar = parseFloat($scope.aCargar[i]); |
| 40 | if(!aCargar) { | 40 | if(!aCargar) { |
| 41 | continue; | 41 | continue; |
| 42 | } | 42 | } |
| 43 | if(aCargar > cisterna.disponible) { | 43 | if(aCargar > cisterna.disponible) { |
| 44 | focaModalService.alert('La cantidad cargada supera la capacidad de la' + | 44 | focaModalService.alert('La cantidad cargada supera la capacidad de la' + |
| 45 | 'cisterna ' + cisterna.codigo); | 45 | 'cisterna ' + cisterna.codigo); |
| 46 | return; | 46 | return; |
| 47 | } | 47 | } |
| 48 | if(cisterna.cisternaCarga.cantidad) { | 48 | if(cisterna.cisternaCarga.cantidad) { |
| 49 | cisterna.cisternaCarga.cantidad += aCargar; | 49 | cisterna.cisternaCarga.cantidad += aCargar; |
| 50 | }else { | 50 | }else { |
| 51 | cisterna.cisternaCarga.cantidad = aCargar; | 51 | cisterna.cisternaCarga.cantidad = aCargar; |
| 52 | cisterna.cisternaCarga.idProducto = $scope.articuloSeleccionado.idArticulo; | 52 | cisterna.cisternaCarga.idProducto = $scope.articuloSeleccionado.idArticulo; |
| 53 | } | 53 | } |
| 54 | cisterna.disponible = cisterna.capacidad - cisterna.cisternaCarga.cantidad; | 54 | cisterna.disponible = cisterna.capacidad - cisterna.cisternaCarga.cantidad; |
| 55 | 55 | ||
| 56 | cisterna.cisternaCarga.articulo = { | 56 | cisterna.cisternaCarga.articulo = { |
| 57 | DetArt: $scope.articuloSeleccionado.descripcion | 57 | DetArt: $scope.articuloSeleccionado.descripcion |
| 58 | }; | 58 | }; |
| 59 | $filter('filter')($scope.articulos, {id: $scope.articuloSeleccionado.id})[0] | 59 | $filter('filter')($scope.articulos, {id: $scope.articuloSeleccionado.id})[0] |
| 60 | .cargado = true; | 60 | .cargado = true; |
| 61 | 61 | ||
| 62 | $scope.calcularPorcentaje(cisterna); | 62 | $scope.calcularPorcentaje(cisterna); |
| 63 | } | 63 | } |
| 64 | var articuloSiguiente = $scope.articulos.filter( | 64 | var articuloSiguiente = $scope.articulos.filter( |
| 65 | function(filter) { | 65 | function(filter) { |
| 66 | return filter.cargado !== true; | 66 | return filter.cargado !== true; |
| 67 | } | 67 | } |
| 68 | ); | 68 | ); |
| 69 | if(articuloSiguiente.length > 0){ | 69 | if(articuloSiguiente.length > 0) { |
| 70 | $scope.cambioArticulo(articuloSiguiente[0]); | 70 | $scope.cambioArticulo(articuloSiguiente[0]); |
| 71 | } | 71 | } |
| 72 | $scope.aCargar = []; | 72 | $scope.aCargar = []; |
| 73 | }; | 73 | }; |
| 74 | $scope.calcularPorcentaje = function(cisterna) { | 74 | $scope.calcularPorcentaje = function(cisterna) { |
| 75 | if(!cisterna.cisternaCarga.cantidad) { | 75 | if(!cisterna.cisternaCarga.cantidad) { |
| 76 | cisterna.cisternaCarga.cantidad = 0; | 76 | cisterna.cisternaCarga.cantidad = 0; |
| 77 | } | 77 | } |
| 78 | var porcentaje = (cisterna.cisternaCarga.cantidad * 100 / | 78 | var porcentaje = (cisterna.cisternaCarga.cantidad * 100 / |
| 79 | cisterna.capacidad) + '%'; | 79 | cisterna.capacidad) + '%'; |
| 80 | var elementHtml = document.getElementById(cisterna.id); | 80 | var elementHtml = document.getElementById(cisterna.id); |
| 81 | if(elementHtml) { | 81 | if(elementHtml) { |
| 82 | elementHtml.style.width = porcentaje; | 82 | elementHtml.style.width = porcentaje; |
| 83 | } | 83 | } |
| 84 | }; | 84 | }; |
| 85 | $scope.cambioArticulo = function(articulo) { | 85 | $scope.cambioArticulo = function(articulo) { |
| 86 | articulo.checked = true; | 86 | articulo.checked = true; |
| 87 | $scope.articuloSeleccionado = articulo; | 87 | $scope.articuloSeleccionado = articulo; |
| 88 | }; | 88 | }; |
| 89 | $scope.actualizarArticulo = function () { | 89 | $scope.actualizarArticulo = function () { |
| 90 | $scope.articuloSeleccionado.cantidadCargada = 0; | 90 | $scope.articuloSeleccionado.cantidadCargada = 0; |
| 91 | for (var i = 0; i < $scope.aCargar.length; i++) { | 91 | for (var i = 0; i < $scope.aCargar.length; i++) { |
| 92 | $scope.articuloSeleccionado.cantidadCargada += | 92 | $scope.articuloSeleccionado.cantidadCargada += |
| 93 | parseFloat($scope.aCargar[i]) || 0; | 93 | parseFloat($scope.aCargar[i]) || 0; |
| 94 | } | 94 | } |
| 95 | }; | 95 | }; |
| 96 | $scope.tieneArticulosPendientes = function() { | 96 | $scope.tieneArticulosPendientes = function() { |
| 97 | var articulosDescargados = $scope.articulos.filter(function(filter) { | 97 | var articulosDescargados = $scope.articulos.filter(function(filter) { |
| 98 | return filter.cargado === true; | 98 | return filter.cargado === true; |
| 99 | }); | 99 | }); |
| 100 | if(articulosDescargados.length === $scope.articulos.length) { | 100 | if(articulosDescargados.length === $scope.articulos.length) { |
| 101 | return false; | 101 | return false; |
| 102 | } | 102 | } |
| 103 | return true; | 103 | return true; |
| 104 | }; | 104 | }; |
| 105 | }]); | 105 | }]); |
| 106 | 106 |