Commit bd83950814297e5a4e63fb222a15f906bee83757
1 parent
30faa1e57c
Exists in
master
refactor código, fixs
Showing
6 changed files
with
90 additions
and
50 deletions
Show diff stats
src/js/controller.js
1 | 1 | angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaController', [ |
2 | 2 | '$scope', 'focaLogisticaPedidoRutaService', '$location', '$uibModal', '$filter', |
3 | - 'focaModalService', 'focaBotoneraLateralService', '$cookies', | |
3 | + 'focaModalService', 'focaBotoneraLateralService', '$interval', | |
4 | 4 | function($scope, focaLogisticaPedidoRutaService, $location, $uibModal, $filter, |
5 | - focaModalService, focaBotoneraLateralService, $cookies | |
5 | + focaModalService, focaBotoneraLateralService, $interval | |
6 | 6 | ) { |
7 | - $scope.now = new Date(); | |
8 | 7 | $scope.actividad = 'Logistica'; |
9 | 8 | |
10 | 9 | //Datos Pantalla |
11 | 10 | $scope.titulo = 'Logistica de Pedidos'; |
12 | - $scope.botonera = ['Vehiculo']; | |
11 | + $scope.botonera = ['Transportista']; | |
13 | 12 | var cabecera = ''; |
14 | 13 | |
15 | 14 | $scope.idVendedor = 0; |
... | ... | @@ -121,13 +120,35 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo |
121 | 120 | getSeguimiento(); |
122 | 121 | }; |
123 | 122 | |
124 | - $scope.seleccionarVehiculo = function() { | |
123 | + $scope.seleccionarTransportista = function() { | |
124 | + var modalInstance = $uibModal.open( | |
125 | + { | |
126 | + ariaLabelledBy: 'Busqueda de Transportista', | |
127 | + templateUrl: 'modal-proveedor.html', | |
128 | + controller: 'focaModalProveedorCtrl', | |
129 | + size: 'lg', | |
130 | + resolve: { | |
131 | + transportista: function() { | |
132 | + return true; | |
133 | + } | |
134 | + } | |
135 | + } | |
136 | + ); | |
137 | + modalInstance.result.then(function(transportista) { | |
138 | + $scope.seleccionarVehiculo(transportista.COD); | |
139 | + }); | |
140 | + }; | |
141 | + | |
142 | + $scope.seleccionarVehiculo = function(idTransportista) { | |
125 | 143 | var modalInstance = $uibModal.open( |
126 | 144 | { |
127 | 145 | ariaLabelledBy: 'Busqueda de Vehiculo', |
128 | 146 | templateUrl: 'modal-vehiculo.html', |
129 | 147 | controller: 'focaModalVehiculoController', |
130 | - size: 'lg' | |
148 | + size: 'lg', | |
149 | + resolve: { | |
150 | + idTransportista: function() {return idTransportista;} | |
151 | + } | |
131 | 152 | } |
132 | 153 | ); |
133 | 154 | |
... | ... | @@ -135,7 +156,7 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo |
135 | 156 | function(vehiculo) { |
136 | 157 | var existe = $filter('filter')($scope.vehiculos, {id: vehiculo.id}); |
137 | 158 | if(existe.length) { |
138 | - focaModalService.alert('El vehiculo que intenta cargar ya ha sido cargado'); | |
159 | + focaModalService.alert('El vehiculo que ya ha sido cargado'); | |
139 | 160 | return; |
140 | 161 | } |
141 | 162 | if(!vehiculo.cisternas.length) { |
... | ... | @@ -150,15 +171,19 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo |
150 | 171 | }; |
151 | 172 | |
152 | 173 | function getSeguimiento() { |
153 | - var now = $scope.now; | |
154 | - var desde = new Date(new Date(now.setHours(0)).setMinutes(0)); | |
155 | - desde = desde.setDate(desde.getDate() - 1); | |
156 | - desde = new Date(desde); | |
174 | + var desde = new Date('1900/01/01'); | |
175 | + var hasta = new Date('2099/01/01'); | |
176 | + if ($scope.now) { | |
177 | + var now = $scope.now; | |
178 | + desde = new Date(new Date(now.setHours(0)).setMinutes(0)); | |
179 | + desde = desde.setDate(desde.getDate() - 1); | |
180 | + desde = new Date(desde); | |
181 | + } | |
157 | 182 | var datos = { |
158 | 183 | actividad: $scope.actividad, |
159 | 184 | idUsuario: $scope.idVendedor, |
160 | 185 | fechaDesde: desde, |
161 | - fechaHasta: new Date(new Date(now.setHours(23)).setMinutes(59)) | |
186 | + fechaHasta: hasta | |
162 | 187 | }; |
163 | 188 | |
164 | 189 | $scope.datosBuscados = { |
... | ... | @@ -167,8 +192,13 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo |
167 | 192 | }; |
168 | 193 | |
169 | 194 | focaLogisticaPedidoRutaService.obtenerActividad(datos).then(function(datos) { |
170 | - $scope.marcadores = datos.data; | |
195 | + if(JSON.stringify(datos.data) !== JSON.stringify($scope.marcadores)) { | |
196 | + $scope.marcadores = datos.data; | |
197 | + } | |
171 | 198 | }); |
172 | 199 | } |
200 | + $interval(function() { | |
201 | + getSeguimiento(); | |
202 | + }, 5000); | |
173 | 203 | } |
174 | 204 | ]); |
src/js/controllerDetalleVehiculo.js
... | ... | @@ -24,7 +24,8 @@ angular.module('focaLogisticaPedidoRuta') |
24 | 24 | focaLogisticaPedidoRutaService.obtenerRemitoById(idRemito).then( |
25 | 25 | function(res) { |
26 | 26 | $scope.remito = res.data; |
27 | - if($scope.remito.idUsuarioProceso !== focaLogisticaPedidoRutaService.idUsuario) | |
27 | + if($scope.remito.idUsuarioProceso && $scope.remito.idUsuarioProceso !== | |
28 | + focaLogisticaPedidoRutaService.idUsuario) | |
28 | 29 | { |
29 | 30 | focaModalService.alert('El remito esta siendo cargado por otro usario'); |
30 | 31 | $uibModalInstance.close(); |
... | ... | @@ -50,7 +51,7 @@ angular.module('focaLogisticaPedidoRuta') |
50 | 51 | $scope.cargando = false; |
51 | 52 | $uibModalInstance.close(); |
52 | 53 | }); |
53 | - }).catch(function(error) { | |
54 | + }).catch(function(error) { | |
54 | 55 | $scope.cargando = false; |
55 | 56 | $uibModalInstance.close(); |
56 | 57 | if (error.status === 403.1) { |
src/js/controllerHojaRuta.js
... | ... | @@ -17,24 +17,9 @@ angular.module('focaLogisticaPedidoRuta') |
17 | 17 | }); |
18 | 18 | //TODO: refactor código esta rre feo |
19 | 19 | focaLogisticaPedidoRutaService.getRemitos(idVehiculo).then(function(res) { |
20 | - for(var i = 0; i < res.data.cisternas.length; i++) { | |
21 | - for(var j = 0; j < res.data.cisternas[i].cisternaCarga.cisternaMovimientos.length; | |
22 | - j++) { | |
23 | - if(!!res.data.cisternas[i].cisternaCarga.cisternaMovimientos[j].remito && | |
24 | - !res.data.cisternas[i].cisternaCarga.cisternaMovimientos[j].remito | |
25 | - .idHojaRuta) { | |
26 | - var remito = res.data.cisternas[i].cisternaCarga | |
27 | - .cisternaMovimientos[j].remito; | |
28 | - var yaEstaCargado = $filter('filter')($scope.remitos, {id: remito.id}); | |
29 | - if(!yaEstaCargado.length && | |
30 | - res.data.cisternas[i].cisternaCarga.cisternaMovimientos[j].metodo === | |
31 | - 'carga') { | |
32 | - $scope.remitos.push(remito); | |
33 | - } | |
34 | - } | |
35 | - } | |
36 | - } | |
20 | + $scope.remitos = focaLogisticaPedidoRutaService.obtenerRemitosDeCarga(res.data); | |
37 | 21 | }); |
22 | + | |
38 | 23 | focaLogisticaPedidoRutaService.numeroHojaRuta().then(function(res) { |
39 | 24 | $scope.sucursal = res.data.sucursal; |
40 | 25 | $scope.numero = res.data.numeroHojaRuta; |
... | ... | @@ -57,7 +42,7 @@ angular.module('focaLogisticaPedidoRuta') |
57 | 42 | }; |
58 | 43 | focaLogisticaPedidoRutaService.crearHojaRuta(save).then(function() { |
59 | 44 | $uibModalInstance.close(); |
60 | - focaModalService.alert('Hoja de ruta guardada con éxito'); | |
45 | + focaModalService.alert('Hoja de ruta guardada con éxito'); | |
61 | 46 | }); |
62 | 47 | }; |
63 | 48 | $scope.seleccionarChofer = function() { |
src/js/osm-directive.js
... | ... | @@ -26,28 +26,28 @@ angular.module('focaLogisticaPedidoRuta').directive('focaLogistica', function() |
26 | 26 | observacion += 'Fecha: ' + |
27 | 27 | $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + ' ' + |
28 | 28 | marcador.fecha.slice(11,19) + '<br/>'; |
29 | - observacion += 'Nº: ' + $filter('comprobante')([ | |
29 | + observacion += 'Remito Nº: ' + $filter('comprobante')([ | |
30 | 30 | marcador.notaPedido.remito.sucursal, |
31 | 31 | marcador.notaPedido.remito.numeroRemito |
32 | 32 | ]) + '<br/>'; |
33 | 33 | observacion += 'Cliente: ' + |
34 | 34 | marcador.notaPedido.cliente.NOM + '<br/>'; |
35 | 35 | |
36 | - if($scope.parametros.individual) { | |
37 | - observacion += | |
38 | - 'Total: ' + $filter('currency')(marcador.notaPedido.total, '$'); | |
39 | - observacion = 'Orden: ' + marcador.orden + '<br/>' + observacion; | |
36 | + // if($scope.parametros.individual) { | |
37 | + observacion += | |
38 | + 'Total: ' + $filter('currency')(marcador.notaPedido.remito.total, '$'); | |
39 | + observacion = 'Orden: ' + marcador.orden + '<br/>' + observacion; | |
40 | 40 | |
41 | - if(marcador.distancia) { | |
42 | - observacion += '<br/>Distancia a casa central: ' + | |
43 | - marcador.distancia + 'km'; | |
44 | - } | |
45 | - }else { | |
46 | - observacion += 'Cantidad de nota de remitos: ' + | |
47 | - marcador.cantidad + '<br/>'; | |
48 | - observacion += 'Total Vendido: ' + | |
49 | - $filter('currency')(marcador.total, '$'); | |
41 | + if(marcador.distancia) { | |
42 | + observacion += '<br/>Distancia a casa central: ' + | |
43 | + marcador.distancia + 'km'; | |
50 | 44 | } |
45 | + // }else { | |
46 | + // observacion += 'Cantidad de remitos: ' + | |
47 | + // marcador.cantidad + '<br/>'; | |
48 | + // observacion += 'Total Vendido: ' + | |
49 | + // $filter('currency')(marcador.total, '$'); | |
50 | + // } | |
51 | 51 | observacion += '<br/>'; |
52 | 52 | observacion += '<i class="fa fa-map-marker fa-3x" aria-hidden="true"'+ |
53 | 53 | 'class="form-control" ondragend="dropEnd()" ondragstart=\'drag(event, '+ |
src/js/service.js
... | ... | @@ -4,7 +4,8 @@ angular.module('focaLogisticaPedidoRuta') |
4 | 4 | '$http', |
5 | 5 | '$cookies', |
6 | 6 | 'API_ENDPOINT', |
7 | - function($http, $cookies, API_ENDPOINT) { | |
7 | + '$filter', | |
8 | + function($http, $cookies, API_ENDPOINT, $filter) { | |
8 | 9 | return { |
9 | 10 | idUsuario: $cookies.get('idUsuario'), |
10 | 11 | obtenerActividad: function(parametros) { |
... | ... | @@ -28,6 +29,29 @@ angular.module('focaLogisticaPedidoRuta') |
28 | 29 | }, |
29 | 30 | crearHojaRuta: function(hojaRuta) { |
30 | 31 | return $http.post(API_ENDPOINT.URL + '/hoja-ruta', hojaRuta); |
32 | + }, | |
33 | + obtenerRemitosDeCarga: function(remitos) { | |
34 | + var remitosRes = []; | |
35 | + for(var i = 0; i < remitos.cisternas.length; i++) { | |
36 | + procesoCistena(remitos.cisternas[i]); | |
37 | + } | |
38 | + function procesoCistena(cisterna) { | |
39 | + for(var j = 0; j < cisterna.cisternaCarga.cisternaMovimientos.length; | |
40 | + j++) { | |
41 | + procesoMovimiento( | |
42 | + cisterna.cisternaCarga.cisternaMovimientos[j]); | |
43 | + } | |
44 | + } | |
45 | + function procesoMovimiento(movimiento) { | |
46 | + if(movimiento.remito && !movimiento.remito.idHojaRuta) { | |
47 | + var remito = movimiento.remito; | |
48 | + var yaEstaCargado = $filter('filter')(remitosRes, {id: remito.id}); | |
49 | + if(!yaEstaCargado.length && movimiento.metodo === 'carga') { | |
50 | + remitosRes.push(remito); | |
51 | + } | |
52 | + } | |
53 | + } | |
54 | + return remitosRes; | |
31 | 55 | } |
32 | 56 | }; |
33 | 57 | }]); |
src/views/foca-modal-crear-hoja-ruta.html
1 | 1 | <div class="modal-header"> |
2 | 2 | <h4>-en desarrollo</h4> |
3 | 3 | <h4>Confeccionar hoja de ruta</h4> |
4 | - Hoja de ruta Nº <strong ng-bind="[numero, sucursal] | comprobante"></strong> | |
4 | + Hoja de ruta Nº <strong ng-bind="[sucursal, numero] | comprobante"></strong> | |
5 | 5 | Fecha: |
6 | 6 | <input |
7 | 7 | type="date" |
... | ... | @@ -81,7 +81,7 @@ |
81 | 81 | </td> |
82 | 82 | </tr> |
83 | 83 | <tr ng-repeat="remito in remitos"> |
84 | - <td ng-bind="[remito.numeroRemito, remito.sucursal] | comprobante"></td> | |
84 | + <td ng-bind="[remito.sucursal, remito.numeroRemito] | comprobante"></td> | |
85 | 85 | <td ng-bind="remito.nombreCliente"></td> |
86 | 86 | <td ng-bind="remito.domicilioStamp"></td> |
87 | 87 | </tr> |