Commit 7e29034d8c807be04096868e26a43933433f7a50
Exists in
master
and in
2 other branches
Merge branch 'master' into 'develop'
Master(efernandez) See merge request !46
Showing
1 changed file
Show diff stats
src/js/osm-directive.js
1 | angular.module('focaLogisticaPedidoRuta').directive('focaLogistica', function() { | 1 | angular.module('focaLogisticaPedidoRuta').directive('focaLogistica', function() { |
2 | return { | 2 | return { |
3 | restrict: 'E', | 3 | restrict: 'E', |
4 | link: function(scope, el, attrs) { | 4 | link: function(scope, el, attrs) { |
5 | var contenedor = document.createElement('div'); | 5 | var contenedor = document.createElement('div'); |
6 | contenedor.className = 'border border-light rounded'; | 6 | contenedor.className = 'border border-light rounded'; |
7 | el.append(contenedor); | 7 | el.append(contenedor); |
8 | scope.map = L.map(contenedor).setView([attrs.latitud, attrs.longitud], attrs.zoom); | 8 | scope.map = L.map(contenedor).setView([attrs.latitud, attrs.longitud], attrs.zoom); |
9 | L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map); | 9 | L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map); |
10 | }, | 10 | }, |
11 | controller: ['$scope', '$filter', '$compile', 'focaModalService', | 11 | controller: ['$scope', '$filter', '$compile', 'focaModalService', |
12 | function($scope, $filter, $compile, focaModalService) { | 12 | function($scope, $filter, $compile, focaModalService) { |
13 | $scope.markers = []; | 13 | $scope.markers = []; |
14 | $scope.verProductos = function(id) { | 14 | $scope.verProductos = function(id) { |
15 | var parametrosModal = { | 15 | var parametrosModal = { |
16 | titulo: 'Productos', | 16 | titulo: 'Productos', |
17 | query: '/articulos/remito/' + id, | 17 | query: '/articulos/remito/' + id, |
18 | soloMostrar: true, | 18 | soloMostrar: true, |
19 | size: 'md', | 19 | size: 'md', |
20 | columnas: [ | 20 | columnas: [ |
21 | { | 21 | { |
22 | nombre: 'Producto', | 22 | nombre: 'Producto', |
23 | propiedad: 'descripcion' | 23 | propiedad: 'descripcion' |
24 | }, | 24 | }, |
25 | { | 25 | { |
26 | nombre: 'Cantidad', | 26 | nombre: 'Cantidad', |
27 | propiedad: 'cantidad' | 27 | propiedad: 'cantidad' |
28 | } | 28 | } |
29 | ] | 29 | ] |
30 | }; | 30 | }; |
31 | focaModalService.modal(parametrosModal).then(); | 31 | focaModalService.modal(parametrosModal).then(); |
32 | }; | 32 | }; |
33 | $scope.$watch('marcadores', function() { | 33 | $scope.$watch('marcadores', function() { |
34 | for(var i in $scope.markers) { | 34 | for(var i in $scope.markers) { |
35 | $scope.map.removeLayer($scope.markers[i]); | 35 | $scope.map.removeLayer($scope.markers[i]); |
36 | } | 36 | } |
37 | $scope.markers = []; | 37 | $scope.markers = []; |
38 | 38 | ||
39 | angular.forEach($scope.marcadores, function(marcador) { | 39 | angular.forEach($scope.marcadores, function(marcador) { |
40 | var observacion = | 40 | var observacion = |
41 | 'Vendedor: ' + marcador.notaPedido.idVendedor + ' - ' + | 41 | 'Vendedor: ' + marcador.notaPedido.idVendedor + ' - ' + |
42 | ( | 42 | ( |
43 | marcador.notaPedido.vendedor ? | 43 | marcador.notaPedido.vendedor ? |
44 | marcador.notaPedido.vendedor.NomVen : | 44 | marcador.notaPedido.vendedor.NOM : |
45 | '' | 45 | '' |
46 | ) + '<br/>'; | 46 | ) + '<br/>'; |
47 | observacion += 'Fecha: ' + | 47 | observacion += 'Fecha: ' + |
48 | $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + ' ' + | 48 | $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + ' ' + |
49 | marcador.fecha.slice(11,19) + '<br/>'; | 49 | marcador.fecha.slice(11,19) + '<br/>'; |
50 | observacion += 'Remito Nº: ' + $filter('comprobante')([ | 50 | observacion += 'Remito Nº: ' + $filter('comprobante')([ |
51 | marcador.notaPedido.remito.sucursal, | 51 | marcador.notaPedido.remito.sucursal, |
52 | marcador.notaPedido.remito.numeroRemito | 52 | marcador.notaPedido.remito.numeroRemito |
53 | ]) + '<br/>'; | 53 | ]) + '<br/>'; |
54 | observacion += 'Cliente: ' + | 54 | observacion += 'Cliente: ' + |
55 | marcador.notaPedido.cliente.NOM; | 55 | marcador.notaPedido.cliente.NOM; |
56 | 56 | ||
57 | // if($scope.parametros.individual) { | 57 | // if($scope.parametros.individual) { |
58 | observacion = 'Orden: ' + marcador.orden + '<br/>' + observacion; | 58 | observacion = 'Orden: ' + marcador.orden + '<br/>' + observacion; |
59 | 59 | ||
60 | if (marcador.distancia) { | 60 | if (marcador.distancia) { |
61 | observacion += '<br/>Distancia a casa central: ' + | 61 | observacion += '<br/>Distancia a casa central: ' + |
62 | marcador.distancia + 'km'; | 62 | marcador.distancia + 'km'; |
63 | } | 63 | } |
64 | var icon; | 64 | var icon; |
65 | if (marcador.notaPedido.remito.idUsuarioProceso) { | 65 | if (marcador.notaPedido.remito.idUsuarioProceso) { |
66 | observacion += '<br/>'; | 66 | observacion += '<br/>'; |
67 | observacion += '<strong>'; | 67 | observacion += '<strong>'; |
68 | observacion += 'Fecha de entrega: ' + marcador.notaPedido.remito | 68 | observacion += 'Fecha de entrega: ' + marcador.notaPedido.remito |
69 | .cisternaMovimientos[0].cisternaCarga.fechaReparto.substring(0, 10); | 69 | .cisternaMovimientos[0].cisternaCarga.fechaReparto.substring(0, 10); |
70 | observacion += '<br/>'; | 70 | observacion += '<br/>'; |
71 | observacion += 'Vehículo: ' + marcador.notaPedido.remito | 71 | observacion += 'Vehículo: ' + marcador.notaPedido.remito |
72 | .cisternaMovimientos[0].cisternaCarga.cisterna.vehiculo.codigo; | 72 | .cisternaMovimientos[0].cisternaCarga.cisterna.vehiculo.codigo; |
73 | observacion += '<br/>'; | 73 | observacion += '<br/>'; |
74 | observacion += 'Transportista: ' + marcador.notaPedido.remito | 74 | observacion += 'Transportista: ' + marcador.notaPedido.remito |
75 | .cisternaMovimientos[0].cisternaCarga.cisterna.vehiculo.transportista | 75 | .cisternaMovimientos[0].cisternaCarga.cisterna.vehiculo.transportista |
76 | .NOM; | 76 | .NOM; |
77 | observacion += '</strong>'; | 77 | observacion += '</strong>'; |
78 | //Asignado ROJO | 78 | //Asignado ROJO |
79 | icon = new L.Icon({ | 79 | icon = new L.Icon({ |
80 | iconUrl: 'img/marker-icon-2x-red.png', | 80 | iconUrl: 'img/marker-icon-2x-red.png', |
81 | shadowUrl: 'img/marker-shadow.png', | 81 | shadowUrl: 'img/marker-shadow.png', |
82 | iconSize: [25, 41], | 82 | iconSize: [25, 41], |
83 | iconAnchor: [12, 41], | 83 | iconAnchor: [12, 41], |
84 | popupAnchor: [1, -34], | 84 | popupAnchor: [1, -34], |
85 | shadowSize: [41, 41] | 85 | shadowSize: [41, 41] |
86 | }); | 86 | }); |
87 | } else { | 87 | } else { |
88 | observacion += '<br/>'; | 88 | observacion += '<br/>'; |
89 | observacion += '<i class="fa fa-map-marker fa-3x" aria-hidden="true"'+ | 89 | observacion += '<i class="fa fa-map-marker fa-3x" aria-hidden="true"'+ |
90 | 'class="form-control" ondragend="dropEnd()" ondragstart=\'drag(event, '+ | 90 | 'class="form-control" ondragend="dropEnd()" ondragstart=\'drag(event, '+ |
91 | JSON.stringify(marcador)+')\' draggable="true"></i>(Arrastrar icono)'; | 91 | JSON.stringify(marcador)+')\' draggable="true"></i>(Arrastrar icono)'; |
92 | observacion += '<button title="Ver productos" class="btn btn-secondary' + | 92 | observacion += '<button title="Ver productos" class="btn btn-secondary' + |
93 | ' float-right mt-2"'+ | 93 | ' float-right mt-2"'+ |
94 | 'ng-click="verProductos('+marcador.notaPedido.remito.id+')">' + | 94 | 'ng-click="verProductos('+marcador.notaPedido.remito.id+')">' + |
95 | '<i class="fa fa-info" aria-hidden="true"></i>' + | 95 | '<i class="fa fa-info" aria-hidden="true"></i>' + |
96 | '</button>'; | 96 | '</button>'; |
97 | 97 | ||
98 | //Sin asignar VERDE | 98 | //Sin asignar VERDE |
99 | icon = new L.Icon({ | 99 | icon = new L.Icon({ |
100 | iconUrl: 'img/marker-icon-2x-green.png', | 100 | iconUrl: 'img/marker-icon-2x-green.png', |
101 | shadowUrl: 'img/marker-shadow.png', | 101 | shadowUrl: 'img/marker-shadow.png', |
102 | iconSize: [25, 41], | 102 | iconSize: [25, 41], |
103 | iconAnchor: [12, 41], | 103 | iconAnchor: [12, 41], |
104 | popupAnchor: [1, -34], | 104 | popupAnchor: [1, -34], |
105 | shadowSize: [41, 41] | 105 | shadowSize: [41, 41] |
106 | }); | 106 | }); |
107 | } | 107 | } |
108 | 108 | ||
109 | //COMPILO HTML PARA QUE FUNCIONE BOTON EN POPUP | 109 | //COMPILO HTML PARA QUE FUNCIONE BOTON EN POPUP |
110 | observacion = '<div>' + observacion + '</div>'; | 110 | observacion = '<div>' + observacion + '</div>'; |
111 | var compiledHtml = $compile(angular.element(observacion))($scope); | 111 | var compiledHtml = $compile(angular.element(observacion))($scope); |
112 | 112 | ||
113 | $scope.markers.push( | 113 | $scope.markers.push( |
114 | L.marker( | 114 | L.marker( |
115 | [marcador.latitud, marcador.longitud], {icon: icon}) | 115 | [marcador.latitud, marcador.longitud], {icon: icon}) |
116 | .addTo($scope.map) | 116 | .addTo($scope.map) |
117 | .bindPopup(compiledHtml[0]) | 117 | .bindPopup(compiledHtml[0]) |
118 | .bindTooltip('Haga click para seleccionar') | 118 | .bindTooltip('Haga click para seleccionar') |
119 | ); | 119 | ); |
120 | //abre marcador del primer punto | 120 | //abre marcador del primer punto |
121 | //$scope.markers[0].openPopup(); | 121 | //$scope.markers[0].openPopup(); |
122 | }); | 122 | }); |
123 | }); | 123 | }); |
124 | }], | 124 | }], |
125 | scope: { | 125 | scope: { |
126 | latitud: '=', | 126 | latitud: '=', |
127 | longitud: '=', | 127 | longitud: '=', |
128 | zoom: '=', | 128 | zoom: '=', |
129 | marcadores: '=', | 129 | marcadores: '=', |
130 | parametros: '=' | 130 | parametros: '=' |
131 | } | 131 | } |
132 | }; | 132 | }; |
133 | }); | 133 | }); |
134 | 134 |