Commit 21c867b266657f9c780cc6b532ba4f4da3434c28
1 parent
1f7d4c0aba
Exists in
master
fix bug al seleccionar vehiculo
Showing
1 changed file
with
1 additions
and
1 deletions
Show diff stats
src/js/controller.js
1 | angular.module('focaEstadoCisternas') | 1 | angular.module('focaEstadoCisternas') |
2 | .controller('focaEstadoCisternasController', [ | 2 | .controller('focaEstadoCisternasController', [ |
3 | '$scope', 'focaEstadoCisternasService', 'focaModalService', | 3 | '$scope', 'focaEstadoCisternasService', 'focaModalService', |
4 | '$uibModal', 'focaBotoneraLateralService', '$timeout', | 4 | '$uibModal', 'focaBotoneraLateralService', '$timeout', |
5 | function($scope, focaEstadoCisternasService, focaModalService, | 5 | function($scope, focaEstadoCisternasService, focaModalService, |
6 | $uibModal, focaBotoneraLateralService, $timeout) { | 6 | $uibModal, focaBotoneraLateralService, $timeout) { |
7 | 7 | ||
8 | $scope.now = new Date(); | 8 | $scope.now = new Date(); |
9 | $scope.fecha = new Date(); | 9 | $scope.fecha = new Date(); |
10 | $scope.cisternas = []; | 10 | $scope.cisternas = []; |
11 | $scope.botonera = focaEstadoCisternasService.getBotonera(); | 11 | $scope.botonera = focaEstadoCisternasService.getBotonera(); |
12 | 12 | ||
13 | //SETEO BOTONERA LATERAL | 13 | //SETEO BOTONERA LATERAL |
14 | focaBotoneraLateralService.showSalir(true); | 14 | focaBotoneraLateralService.showSalir(true); |
15 | focaBotoneraLateralService.showPausar(false); | 15 | focaBotoneraLateralService.showPausar(false); |
16 | focaBotoneraLateralService.showCancelar(false); | 16 | focaBotoneraLateralService.showCancelar(false); |
17 | focaBotoneraLateralService.showGuardar(false); | 17 | focaBotoneraLateralService.showGuardar(false); |
18 | 18 | ||
19 | $timeout(function() { | 19 | $timeout(function() { |
20 | $scope.$broadcast('addCabecera', { | 20 | $scope.$broadcast('addCabecera', { |
21 | label: 'Fecha:', | 21 | label: 'Fecha:', |
22 | valor: $scope.fecha.toLocaleDateString() | 22 | valor: $scope.fecha.toLocaleDateString() |
23 | }); | 23 | }); |
24 | }); | 24 | }); |
25 | 25 | ||
26 | $scope.seleccionarTransportista = function() { | 26 | $scope.seleccionarTransportista = function() { |
27 | var modalInstance = $uibModal.open( | 27 | var modalInstance = $uibModal.open( |
28 | { | 28 | { |
29 | ariaLabelledBy: 'Busqueda de Transportista', | 29 | ariaLabelledBy: 'Busqueda de Transportista', |
30 | templateUrl: 'modal-proveedor.html', | 30 | templateUrl: 'modal-proveedor.html', |
31 | controller: 'focaModalProveedorCtrl', | 31 | controller: 'focaModalProveedorCtrl', |
32 | size: 'lg', | 32 | size: 'lg', |
33 | resolve: { | 33 | resolve: { |
34 | transportista: function() { | 34 | transportista: function() { |
35 | return true; | 35 | return true; |
36 | } | 36 | } |
37 | } | 37 | } |
38 | } | 38 | } |
39 | ); | 39 | ); |
40 | return modalInstance.result; | 40 | return modalInstance.result; |
41 | }; | 41 | }; |
42 | 42 | ||
43 | $scope.seleccionarVehiculo = function() { | 43 | $scope.seleccionarVehiculo = function() { |
44 | $scope.seleccionarTransportista().then( | 44 | $scope.seleccionarTransportista().then( |
45 | function(transportista) { | 45 | function(transportista) { |
46 | elegirTransportista(transportista); | 46 | elegirTransportista(transportista); |
47 | 47 | ||
48 | var query = '/vehiculo/transportista/' + $scope.idTransportista; | 48 | var query = '/vehiculo/transportista/' + $scope.idTransportista; |
49 | var columnas = { | 49 | var columnas = { |
50 | nombre: ['Código', 'tractor', 'Semi', 'Capacidad'], | 50 | nombre: ['Código', 'tractor', 'Semi', 'Capacidad'], |
51 | propiedad: ['codigo', 'tractor', 'semi', 'capacidadTotalCisternas'] | 51 | propiedad: ['codigo', 'tractor', 'semi', 'capacidadTotalCisternas'] |
52 | }; | 52 | }; |
53 | var titulo = 'Búsqueda de vehículos'; | 53 | var titulo = 'Búsqueda de vehículos'; |
54 | 54 | ||
55 | focaModalService.modal(columnas, query, titulo).then( | 55 | focaModalService.modal(columnas, query, titulo).then( |
56 | function(vehiculo) { | 56 | function(vehiculo) { |
57 | $scope.$broadcast('addCabecera', { | 57 | $scope.$broadcast('addCabecera', { |
58 | label: 'Vehículo:', | 58 | label: 'Vehículo:', |
59 | valor: vehiculo.codigo | 59 | valor: vehiculo.codigo |
60 | }); | 60 | }); |
61 | $scope.cisternas = vehiculo.cisternas; | 61 | $scope.cisternas = vehiculo.cisternas; |
62 | getEstadosCisternas($scope.cisternas); | 62 | getEstadosCisternas($scope.cisternas); |
63 | }, function() { | 63 | }, function() { |
64 | $scope.seleccionarTransportista(); | 64 | $scope.seleccionarVehiculo(); |
65 | }); | 65 | }); |
66 | }); | 66 | }); |
67 | }; | 67 | }; |
68 | 68 | ||
69 | $scope.seleccionarFechaEntrega = function() { | 69 | $scope.seleccionarFechaEntrega = function() { |
70 | focaModalService.modalFecha('Fecha').then(function(fecha) { | 70 | focaModalService.modalFecha('Fecha').then(function(fecha) { |
71 | $scope.$broadcast('addCabecera', { | 71 | $scope.$broadcast('addCabecera', { |
72 | label: 'Fecha:', | 72 | label: 'Fecha:', |
73 | valor: fecha.toLocaleDateString() | 73 | valor: fecha.toLocaleDateString() |
74 | }); | 74 | }); |
75 | $scope.fecha = fecha; | 75 | $scope.fecha = fecha; |
76 | if($scope.cisternas) | 76 | if($scope.cisternas) |
77 | getEstadosCisternas($scope.cisternas); | 77 | getEstadosCisternas($scope.cisternas); |
78 | }); | 78 | }); |
79 | }; | 79 | }; |
80 | 80 | ||
81 | $scope.seleccionarGrafico = function() { | 81 | $scope.seleccionarGrafico = function() { |
82 | if(!$scope.cisternas.length){ | 82 | if(!$scope.cisternas.length){ |
83 | focaModalService.alert('Primero seleccione un vehículo con cisternas'); | 83 | focaModalService.alert('Primero seleccione un vehículo con cisternas'); |
84 | return; | 84 | return; |
85 | } | 85 | } |
86 | $uibModal.open( | 86 | $uibModal.open( |
87 | { | 87 | { |
88 | ariaLabelledBy: 'Grafico de cisternas', | 88 | ariaLabelledBy: 'Grafico de cisternas', |
89 | templateUrl: 'modal-grafico-cisternas.html', | 89 | templateUrl: 'modal-grafico-cisternas.html', |
90 | controller: 'focaModalGraficoCisternasController', | 90 | controller: 'focaModalGraficoCisternasController', |
91 | size: 'md', | 91 | size: 'md', |
92 | resolve:{ | 92 | resolve:{ |
93 | filters: { | 93 | filters: { |
94 | cisternas: $scope.cisternas | 94 | cisternas: $scope.cisternas |
95 | } | 95 | } |
96 | } | 96 | } |
97 | } | 97 | } |
98 | ); | 98 | ); |
99 | }; | 99 | }; |
100 | 100 | ||
101 | function elegirTransportista(transportista) { | 101 | function elegirTransportista(transportista) { |
102 | var codigo = ('00000' + transportista.COD).slice(-5); | 102 | var codigo = ('00000' + transportista.COD).slice(-5); |
103 | $scope.idTransportista = transportista.COD; | 103 | $scope.idTransportista = transportista.COD; |
104 | $scope.filtros = transportista.NOM.trim(); | 104 | $scope.filtros = transportista.NOM.trim(); |
105 | $scope.$broadcast('addCabecera', { | 105 | $scope.$broadcast('addCabecera', { |
106 | label: 'Transportista:', | 106 | label: 'Transportista:', |
107 | valor: codigo + ' - ' + transportista.NOM | 107 | valor: codigo + ' - ' + transportista.NOM |
108 | }); | 108 | }); |
109 | } | 109 | } |
110 | 110 | ||
111 | function getEstadosCisternas(cisternas) { | 111 | function getEstadosCisternas(cisternas) { |
112 | cisternas.forEach(function(cisterna) { | 112 | cisternas.forEach(function(cisterna) { |
113 | focaEstadoCisternasService | 113 | focaEstadoCisternasService |
114 | .getEstadoCisterna(cisterna.id, $scope.fecha) | 114 | .getEstadoCisterna(cisterna.id, $scope.fecha) |
115 | .then(function(res) { | 115 | .then(function(res) { |
116 | cisterna.estado = res.data; | 116 | cisterna.estado = res.data; |
117 | }); | 117 | }); |
118 | }); | 118 | }); |
119 | } | 119 | } |
120 | } | 120 | } |
121 | ]); | 121 | ]); |
122 | 122 |