Commit 1b4d71983d1b4266f18e7aafca77caebec1ec8cb

Authored by Luis Suarez
1 parent 2464b3edd4
Exists in develop

evitar undefined en vendedores sin Nombre

Showing 1 changed file with 1 additions and 1 deletions   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.idVendedor + ' - ' + 41 'Vendedor: ' + marcador.idVendedor + ' - ' +
42 ( 42 (
43 marcador.vendedor ? 43 marcador.vendedor.NOM ?
44 marcador.vendedor.NOM : 44 marcador.vendedor.NOM :
45 '' 45 ''
46 ) + '<br/>'; 46 ) + '<br/>';
47 observacion += 'Fecha: ' + 47 observacion += 'Fecha: ' +
48 $filter('date')(marcador.fechaRemito.slice(0,10), 'dd/MM/yyyy') + ' ' + 48 $filter('date')(marcador.fechaRemito.slice(0,10), 'dd/MM/yyyy') + ' ' +
49 marcador.fechaRemito.slice(11,19) + '<br/>'; 49 marcador.fechaRemito.slice(11,19) + '<br/>';
50 observacion += 'Remito Nº: ' + $filter('comprobante')([ 50 observacion += 'Remito Nº: ' + $filter('comprobante')([
51 marcador.sucursal, 51 marcador.sucursal,
52 marcador.numeroRemito 52 marcador.numeroRemito
53 ]) + '<br/>'; 53 ]) + '<br/>';
54 observacion += 'Cliente: ' + 54 observacion += 'Cliente: ' +
55 marcador.cliente.NOM; 55 marcador.cliente.NOM;
56 56
57 // if($scope.parametros.individual) { 57 // if($scope.parametros.individual) {
58 if (marcador.orden) { 58 if (marcador.orden) {
59 observacion = 'Orden: ' + marcador.orden + '<br/>' + observacion; 59 observacion = 'Orden: ' + marcador.orden + '<br/>' + observacion;
60 } 60 }
61 61
62 if (marcador.distancia) { 62 if (marcador.distancia) {
63 observacion += '<br/>Distancia a casa central: ' + 63 observacion += '<br/>Distancia a casa central: ' +
64 marcador.distancia + 'km'; 64 marcador.distancia + 'km';
65 } 65 }
66 var icon; 66 var icon;
67 if (marcador.idUsuarioProceso) { 67 if (marcador.idUsuarioProceso) {
68 observacion += '<br/>'; 68 observacion += '<br/>';
69 observacion += '<strong>'; 69 observacion += '<strong>';
70 observacion += 'Fecha de entrega: ' + marcador 70 observacion += 'Fecha de entrega: ' + marcador
71 .cisternaMovimientos[0].cisternaCarga.fechaReparto.substring(0, 10); 71 .cisternaMovimientos[0].cisternaCarga.fechaReparto.substring(0, 10);
72 observacion += '<br/>'; 72 observacion += '<br/>';
73 observacion += 'Vehículo: ' + marcador 73 observacion += 'Vehículo: ' + marcador
74 .cisternaMovimientos[0].cisternaCarga.cisterna.vehiculo.codigo; 74 .cisternaMovimientos[0].cisternaCarga.cisterna.vehiculo.codigo;
75 observacion += '<br/>'; 75 observacion += '<br/>';
76 observacion += 'Transportista: ' + marcador 76 observacion += 'Transportista: ' + marcador
77 .cisternaMovimientos[0].cisternaCarga.cisterna.vehiculo.transportista 77 .cisternaMovimientos[0].cisternaCarga.cisterna.vehiculo.transportista
78 .NOM; 78 .NOM;
79 observacion += '</strong>'; 79 observacion += '</strong>';
80 //Asignado ROJO 80 //Asignado ROJO
81 icon = new L.Icon({ 81 icon = new L.Icon({
82 iconUrl: 'img/marker-icon-2x-red.png', 82 iconUrl: 'img/marker-icon-2x-red.png',
83 shadowUrl: 'img/marker-shadow.png', 83 shadowUrl: 'img/marker-shadow.png',
84 iconSize: [25, 41], 84 iconSize: [25, 41],
85 iconAnchor: [12, 41], 85 iconAnchor: [12, 41],
86 popupAnchor: [1, -34], 86 popupAnchor: [1, -34],
87 shadowSize: [41, 41] 87 shadowSize: [41, 41]
88 }); 88 });
89 } else { 89 } else {
90 observacion += '<br/>'; 90 observacion += '<br/>';
91 observacion += '<i class="fa fa-map-marker marcador fa-4x" aria-hidden="true"'+ 91 observacion += '<i class="fa fa-map-marker marcador fa-4x" aria-hidden="true"'+
92 'class="form-control" ondragend="dropEnd()" ondragstart=\'drag(event, '+ 92 'class="form-control" ondragend="dropEnd()" ondragstart=\'drag(event, '+
93 JSON.stringify(marcador)+')\' draggable="true"></i><br><b>(Arrastrar icono)</b>'; 93 JSON.stringify(marcador)+')\' draggable="true"></i><br><b>(Arrastrar icono)</b>';
94 observacion += '<button title="Ver productos" class="btn btn-secondary' + 94 observacion += '<button title="Ver productos" class="btn btn-secondary' +
95 ' float-right informacion"'+ 95 ' float-right informacion"'+
96 'ng-click="verProductos('+marcador.id+')">' + //id del Remito 96 'ng-click="verProductos('+marcador.id+')">' + //id del Remito
97 '<i class="fa fa-info" aria-hidden="true"></i>' + 97 '<i class="fa fa-info" aria-hidden="true"></i>' +
98 '</button>'; 98 '</button>';
99 99
100 //Sin asignar VERDE 100 //Sin asignar VERDE
101 icon = new L.Icon({ 101 icon = new L.Icon({
102 iconUrl: 'img/marker-icon-2x-green.png', 102 iconUrl: 'img/marker-icon-2x-green.png',
103 shadowUrl: 'img/marker-shadow.png', 103 shadowUrl: 'img/marker-shadow.png',
104 iconSize: [25, 41], 104 iconSize: [25, 41],
105 iconAnchor: [12, 41], 105 iconAnchor: [12, 41],
106 popupAnchor: [1, -34], 106 popupAnchor: [1, -34],
107 shadowSize: [41, 41] 107 shadowSize: [41, 41]
108 }); 108 });
109 } 109 }
110 110
111 //COMPILO HTML PARA QUE FUNCIONE BOTON EN POPUP 111 //COMPILO HTML PARA QUE FUNCIONE BOTON EN POPUP
112 observacion = '<div class="disable-selection">' + observacion + '</div>'; 112 observacion = '<div class="disable-selection">' + observacion + '</div>';
113 var compiledHtml = $compile(angular.element(observacion))($scope); 113 var compiledHtml = $compile(angular.element(observacion))($scope);
114 //Primero verifico si punto de desscarga, si lo hay extraigo lat y long desde alli 114 //Primero verifico si punto de desscarga, si lo hay extraigo lat y long desde alli
115 if (marcador.remitoPuntoDescarga) { 115 if (marcador.remitoPuntoDescarga) {
116 $scope.markers.push( 116 $scope.markers.push(
117 L.marker( 117 L.marker(
118 [marcador.remitoPuntoDescarga[0].puntoDescarga.latitud, 118 [marcador.remitoPuntoDescarga[0].puntoDescarga.latitud,
119 marcador.remitoPuntoDescarga[0].puntoDescarga.longitud], {icon: icon}) 119 marcador.remitoPuntoDescarga[0].puntoDescarga.longitud], {icon: icon})
120 .addTo($scope.map) 120 .addTo($scope.map)
121 .bindPopup(compiledHtml[0]) 121 .bindPopup(compiledHtml[0])
122 .bindTooltip('Haga click para seleccionar') 122 .bindTooltip('Haga click para seleccionar')
123 ); 123 );
124 } 124 }
125 //Si no existe punto de descarga, se selecciona la primera direccion 125 //Si no existe punto de descarga, se selecciona la primera direccion
126 //con latitud y longitud desde los Datos del cliente. 126 //con latitud y longitud desde los Datos del cliente.
127 else if (marcador.cliente.direcciones) { 127 else if (marcador.cliente.direcciones) {
128 $scope.markers.push( 128 $scope.markers.push(
129 L.marker( 129 L.marker(
130 [marcador.cliente.direcciones[0].DATO, 130 [marcador.cliente.direcciones[0].DATO,
131 marcador.cliente.direcciones[1].DATO], {icon: icon}) 131 marcador.cliente.direcciones[1].DATO], {icon: icon})
132 .addTo($scope.map) 132 .addTo($scope.map)
133 .bindPopup(compiledHtml[0]) 133 .bindPopup(compiledHtml[0])
134 .bindTooltip('Haga click para seleccionar') 134 .bindTooltip('Haga click para seleccionar')
135 ); 135 );
136 } 136 }
137 //abre marcador del primer punto 137 //abre marcador del primer punto
138 //$scope.markers[0].openPopup(); 138 //$scope.markers[0].openPopup();
139 }); 139 });
140 }); 140 });
141 }], 141 }],
142 scope: { 142 scope: {
143 latitud: '=', 143 latitud: '=',
144 longitud: '=', 144 longitud: '=',
145 zoom: '=', 145 zoom: '=',
146 marcadores: '=', 146 marcadores: '=',
147 parametros: '=' 147 parametros: '='
148 } 148 }
149 }; 149 };
150 }); 150 });
151 151