Commit a8e9947cb735b1bf8960f174123c8a43472754f3
1 parent
75f00ec889
Exists in
master
and in
2 other branches
parametros
Showing
2 changed files
with
92 additions
and
11 deletions
Show diff stats
src/js/controller.js
... | ... | @@ -33,8 +33,22 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
33 | 33 | focaBotoneraLateralService.addCustomButton('Salir', salir); |
34 | 34 | }); |
35 | 35 | |
36 | + focaCrearHojaRutaService.getParametros().then(function(res) { | |
37 | + | |
38 | + var parametros = JSON.parse(res.data[0].jsonText); | |
39 | + | |
40 | + if ($localStorage.hojaRuta) { | |
41 | + $timeout(function() {getLSHojaRuta();}); | |
42 | + } else { | |
43 | + | |
44 | + for(var property in parametros) { | |
45 | + $scope.hojaRuta[property] = parametros[property]; | |
46 | + } | |
47 | + | |
48 | + setearHojaRuta($scope.hojaRuta); | |
49 | + } | |
50 | + }); | |
36 | 51 | init(); |
37 | - $timeout(function() {getLSHojaRuta();}); | |
38 | 52 | } |
39 | 53 | |
40 | 54 | function init() { |
... | ... | @@ -48,9 +62,6 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
48 | 62 | capacidad: 0 |
49 | 63 | }, |
50 | 64 | transportista: {}, |
51 | - tarifario: { | |
52 | - costo: null | |
53 | - }, | |
54 | 65 | remitosTabla: [] |
55 | 66 | }; |
56 | 67 | $scope.idLista = undefined; |
... | ... | @@ -70,6 +81,19 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
70 | 81 | } |
71 | 82 | |
72 | 83 | $scope.$watch('hojaRuta', function(newValue) { |
84 | + | |
85 | + // Seteo checked en remitos | |
86 | + if ($scope.hojaRuta.remitosTabla.length) { | |
87 | + | |
88 | + $filter('filter')($scope.botonera, { | |
89 | + label: 'Remitos', | |
90 | + })[0].checked = true; | |
91 | + } else { | |
92 | + $filter('filter')($scope.botonera, { | |
93 | + label: 'Remitos', | |
94 | + })[0].checked = false; | |
95 | + } | |
96 | + | |
73 | 97 | focaBotoneraLateralService.setPausarData({ |
74 | 98 | label: 'hojaRuta', |
75 | 99 | val: newValue |
... | ... | @@ -93,7 +117,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
93 | 117 | focaModalService.alert('Ingrese Transportista'); |
94 | 118 | return; |
95 | 119 | } |
96 | - if (!$scope.hojaRuta.tarifario.costo) { | |
120 | + if (!$scope.hojaRuta.tarifario) { | |
97 | 121 | focaModalService.alert('Ingrese Tarifario'); |
98 | 122 | return; |
99 | 123 | } |
... | ... | @@ -110,7 +134,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
110 | 134 | idTransportista: $scope.hojaRuta.transportista.COD, |
111 | 135 | idChofer: $scope.hojaRuta.chofer.id, |
112 | 136 | idVehiculo: $scope.hojaRuta.vehiculo.id, |
113 | - tarifaFlete: $scope.hojaRuta.tarifario.costo, | |
137 | + tarifaFlete: $scope.hojaRuta.tarifario, | |
114 | 138 | fechaReparto: |
115 | 139 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10), |
116 | 140 | estado: 0 |
... | ... | @@ -126,7 +150,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
126 | 150 | $filter('rellenarDigitos')(data.data.numeroHojaRuta, 8) |
127 | 151 | ); |
128 | 152 | |
129 | - init(); | |
153 | + config(); | |
130 | 154 | }, |
131 | 155 | function(error) { |
132 | 156 | focaModalService.alert('Hubo un error al crear la hoja de ruta'); |
... | ... | @@ -163,6 +187,10 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
163 | 187 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + |
164 | 188 | proveedor.NOM |
165 | 189 | }); |
190 | + | |
191 | + $filter('filter')($scope.botonera, { | |
192 | + label: 'Transportista', | |
193 | + })[0].checked = true; | |
166 | 194 | }, function() { |
167 | 195 | |
168 | 196 | } |
... | ... | @@ -203,6 +231,10 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
203 | 231 | label: 'Chofer:', |
204 | 232 | valor: $filter('rellenarDigitos')(chofer.id, 3) + ' - ' +chofer.nombre |
205 | 233 | }); |
234 | + | |
235 | + $filter('filter')($scope.botonera, { | |
236 | + label: 'Chofer', | |
237 | + })[0].checked = true; | |
206 | 238 | }, function() { |
207 | 239 | // funcion ejecutada cuando se cancela el modal |
208 | 240 | } |
... | ... | @@ -218,7 +250,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
218 | 250 | focaModalService |
219 | 251 | .prompt({ |
220 | 252 | titulo: 'Tarifa flete', |
221 | - value: $scope.hojaRuta.tarifario.costo | |
253 | + value: $scope.hojaRuta.tarifario | |
222 | 254 | }) |
223 | 255 | .then(function(costo) { |
224 | 256 | if (isNaN(costo)) { |
... | ... | @@ -231,11 +263,15 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
231 | 263 | return; |
232 | 264 | } |
233 | 265 | |
234 | - $scope.hojaRuta.tarifario.costo = costo; | |
266 | + $scope.hojaRuta.tarifario = costo; | |
235 | 267 | $scope.$broadcast('addCabecera', { |
236 | 268 | label: 'Tarifario:', |
237 | 269 | valor: costo |
238 | 270 | }); |
271 | + | |
272 | + $filter('filter')($scope.botonera, { | |
273 | + label: 'Tarifario', | |
274 | + })[0].checked = true; | |
239 | 275 | }); |
240 | 276 | }; |
241 | 277 | |
... | ... | @@ -372,6 +408,11 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
372 | 408 | } |
373 | 409 | ); |
374 | 410 | return modalInstance.result.then(function(datosExtra) { |
411 | + | |
412 | + $filter('filter')($scope.botonera, { | |
413 | + label: 'Datos extra', | |
414 | + })[0].checked = true; | |
415 | + | |
375 | 416 | $scope.hojaRuta.datosExtra = datosExtra; |
376 | 417 | }, function() { |
377 | 418 | //se ejecuta cuando se cancela el modal |
... | ... | @@ -420,10 +461,16 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
420 | 461 | minDate: new Date() |
421 | 462 | }; |
422 | 463 | focaModalService.modalFecha(fechaEntrega).then(function(fecha) { |
464 | + | |
423 | 465 | $scope.$broadcast('addCabecera', { |
424 | 466 | label: 'Fecha de entrega: ', |
425 | 467 | valor: fecha.toLocaleDateString() |
426 | 468 | }); |
469 | + | |
470 | + $filter('filter')($scope.botonera, { | |
471 | + label: 'Fecha Entrega', | |
472 | + })[0].checked = true; | |
473 | + | |
427 | 474 | $scope.hojaRuta.fechaReparto = fecha; |
428 | 475 | }); |
429 | 476 | } |
... | ... | @@ -491,12 +538,22 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
491 | 538 | focaCrearHojaRutaService |
492 | 539 | .getRemitosByIdVehiculo(vehiculo.id, $scope.hojaRuta.fechaReparto) |
493 | 540 | .then(function(res) { |
541 | + | |
542 | + $filter('filter')($scope.botonera, { | |
543 | + label: 'Vehiculos precargados', | |
544 | + })[0].checked = true; | |
545 | + | |
494 | 546 | $scope.hojaRuta.remitosTabla = res.data; |
495 | 547 | }); |
496 | 548 | } else { |
497 | 549 | focaCrearHojaRutaService |
498 | 550 | .getRemitosByIdVehiculo(vehiculo.id, $scope.hojaRuta.fechaReparto, true) |
499 | 551 | .then(function(res) { |
552 | + | |
553 | + $filter('filter')($scope.botonera, { | |
554 | + label: 'Vehiculo', | |
555 | + })[0].checked = true; | |
556 | + | |
500 | 557 | $scope.hojaRuta.remitosTabla = res.data; |
501 | 558 | }); |
502 | 559 | } |
... | ... | @@ -512,6 +569,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
512 | 569 | label: 'Capacidad:', |
513 | 570 | valor: vehiculo.capacidad |
514 | 571 | }); |
572 | + | |
515 | 573 | }); |
516 | 574 | } |
517 | 575 | |
... | ... | @@ -563,6 +621,10 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
563 | 621 | label: 'Fecha de entrega:', |
564 | 622 | valor: $filter('date')(hojaRuta.fechaReparto, 'dd/MM/yyyy') |
565 | 623 | }); |
624 | + | |
625 | + $filter('filter')( $scope.botonera, { | |
626 | + label: 'Fecha Entrega' | |
627 | + })[0].checked = true; | |
566 | 628 | } |
567 | 629 | if (hojaRuta.transportista.COD) { |
568 | 630 | cabeceras.push({ |
... | ... | @@ -570,6 +632,10 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
570 | 632 | valor: $filter('rellenarDigitos')(hojaRuta.transportista.COD, 5) + ' - ' + |
571 | 633 | hojaRuta.transportista.NOM |
572 | 634 | }); |
635 | + | |
636 | + $filter('filter')( $scope.botonera, { | |
637 | + label: 'Transportista' | |
638 | + })[0].checked = true; | |
573 | 639 | } |
574 | 640 | if (hojaRuta.chofer.id) { |
575 | 641 | cabeceras.push({ |
... | ... | @@ -577,6 +643,10 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
577 | 643 | valor: $filter('rellenarDigitos')(hojaRuta.chofer.id, 3) + |
578 | 644 | ' - ' + hojaRuta.chofer.nombre |
579 | 645 | }); |
646 | + | |
647 | + $filter('filter')( $scope.botonera, { | |
648 | + label: 'Chofer' | |
649 | + })[0].checked = true; | |
580 | 650 | } |
581 | 651 | if (hojaRuta.vehiculo.id) { |
582 | 652 | cabeceras.push({ |
... | ... | @@ -591,12 +661,20 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
591 | 661 | label: 'Capacidad:', |
592 | 662 | valor: hojaRuta.vehiculo.capacidad |
593 | 663 | }); |
664 | + | |
665 | + $filter('filter')( $scope.botonera, { | |
666 | + label: 'Vehiculo' | |
667 | + })[0].checked = true; | |
594 | 668 | } |
595 | - if (hojaRuta.tarifario.costo) { | |
669 | + if (hojaRuta.tarifario) { | |
596 | 670 | cabeceras.push({ |
597 | 671 | label: 'Tarifario:', |
598 | - valor: hojaRuta.tarifario.costo | |
672 | + valor: hojaRuta.tarifario | |
599 | 673 | }); |
674 | + | |
675 | + $filter('filter')( $scope.botonera, { | |
676 | + label: 'Tarifario' | |
677 | + })[0].checked = true; | |
600 | 678 | } |
601 | 679 | |
602 | 680 | addArrayCabecera(cabeceras); |
src/js/service.js