Commit cd78befe42f7f5ce10330ebafaa659527d9764d9

Authored by Eric Fernandez
1 parent b364166962
Exists in master

avances

src/js/controller.js
1 angular.module('focaHojaRuta') 1 angular.module('focaHojaRuta')
2 .controller('listaHojaRutaCtrl', 2 .controller('listaHojaRutaCtrl',
3 [ 3 [
4 '$scope', 4 '$scope',
5 '$location', 5 '$location',
6 '$filter', 6 '$filter',
7 '$uibModal', 7 '$uibModal',
8 'hojaRutaService', 8 'hojaRutaService',
9 'focaLoginService', 9 'focaLoginService',
10 'focaModalService', 10 'focaModalService',
11 '$rootScope', 11 '$rootScope',
12 '$localStorage', 12 '$localStorage',
13 function( 13 function(
14 $scope, 14 $scope,
15 $location, 15 $location,
16 $filter, 16 $filter,
17 $uibModal, 17 $uibModal,
18 hojaRutaService, 18 hojaRutaService,
19 focaLoginService, 19 focaLoginService,
20 focaModalService, 20 focaModalService,
21 $rootScope, 21 $rootScope,
22 $localStorage 22 $localStorage
23 ) { 23 ) {
24 24
25 var loginData = focaLoginService.getLoginData(); 25 var loginData = focaLoginService.getLoginData();
26 26
27 config(); 27 config();
28 28
29 function config() { 29 function config() {
30 30
31 $scope.cabecera = []; 31 $scope.cabecera = [];
32 $scope.showCabecera = true; 32 $scope.showCabecera = true;
33 $scope.now = new Date(); 33 $scope.now = new Date();
34 $scope.puntoVenta = '0000'; 34 $scope.puntoVenta = '0000';
35 $scope.comprobante = '00000000'; 35 $scope.comprobante = '00000000';
36 } 36 }
37 37
38 hojaRutaService.getHojaRuta(loginData.chofer).then(function(res) { 38 hojaRutaService.getHojaRuta(loginData.chofer).then(function(res) {
39 39
40 if (res.data) { 40 if (res.data) {
41 var hojaRuta = res.data; 41 var hojaRuta = res.data;
42 $scope.hojaRuta = hojaRuta; 42 $scope.hojaRuta = hojaRuta;
43 $scope.hojaRuta.abierta = true;
43 $scope.puntoVenta = hojaRuta.sucursal; 44 $scope.puntoVenta = hojaRuta.sucursal;
44 $scope.comprobante = hojaRuta.numeroHojaRuta; 45 $scope.comprobante = hojaRuta.numeroHojaRuta;
45 addCabecera('Transportista:', hojaRuta.transportista.NOM); 46 addCabecera('Transportista:', hojaRuta.transportista.NOM);
46 addCabecera('Chofer:', hojaRuta.chofer.nombre); 47 addCabecera('Chofer:', hojaRuta.chofer.nombre);
47 addCabecera('Vehículo:', hojaRuta.vehiculo.tractor); 48 addCabecera('Vehículo:', hojaRuta.vehiculo.tractor);
48 } else { 49 } else {
49 focaModalService.alert('Sin hoja de ruta asignada'); 50 focaModalService.alert('Sin hoja de ruta asignada');
50 $location.path('/'); 51 $location.path('/');
51 } 52 }
52 53
53 watch(); 54 watch();
54 55
55 if (!$scope.esatadoRed) { 56 if (!$scope.esatadoRed) {
56 getLSHojaRuta(); 57 getLSHojaRuta();
57 } 58 }
58 59
59 }); 60 });
60 61
61 function watch() { 62 function watch() {
62 63
63 $scope.$watch('hojaRuta', function(nuevoValor) { 64 $scope.$watch('hojaRuta', function(nuevoValor) {
64 $localStorage.hojaRuta = JSON.stringify(nuevoValor); 65 $localStorage.hojaRuta = JSON.stringify(nuevoValor);
65 }, true); 66 }, true);
66 } 67 }
67 68
68 $scope.verDetalle = function(remito) { 69 $scope.verDetalle = function(remito) {
69 var modalInstance = $uibModal.open( 70 var modalInstance = $uibModal.open(
70 { 71 {
71 ariaLabelledBy: 'Detalle hoja ruta', 72 ariaLabelledBy: 'Detalle hoja ruta',
72 templateUrl: 'modal-detalle-hoja-ruta.html', 73 templateUrl: 'modal-detalle-hoja-ruta.html',
73 controller: 'focaModalDetalleHojaRutaController', 74 controller: 'focaModalDetalleHojaRutaController',
74 resolve: { 75 resolve: {
75 parametros: { 76 parametros: {
76 remito: remito, 77 remito: remito,
77 } 78 }
78 }, 79 },
79 size: 'lg' 80 size: 'lg'
80 } 81 }
81 ); 82 );
82 modalInstance.result.then(function() { 83 modalInstance.result.then(function() {
83 //funcion se ejecuta cuando se carga pantalla 84 //funcion se ejecuta cuando se carga pantalla
84 }); 85 });
85 }; 86 };
86 87
87 function addCabecera(label, valor) { 88 function addCabecera(label, valor) {
88 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 89 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
89 if(propiedad.length === 1) { 90 if(propiedad.length === 1) {
90 propiedad[0].valor = valor; 91 propiedad[0].valor = valor;
91 } else { 92 } else {
92 $scope.cabecera.push({label: label, valor: valor}); 93 $scope.cabecera.push({label: label, valor: valor});
93 } 94 }
94 } 95 }
95 96
96 $scope.rellenar = function(relleno, longitud) { 97 $scope.rellenar = function(relleno, longitud) {
97 relleno = '' + relleno; 98 relleno = '' + relleno;
98 while (relleno.length < longitud) { 99 while (relleno.length < longitud) {
99 relleno = '0' + relleno; 100 relleno = '0' + relleno;
100 } 101 }
101 102
102 return relleno; 103 return relleno;
103 }; 104 };
104 105
105 $scope.salir = function() { 106 $scope.salir = function() {
106 $location.path('/'); 107 $location.path('/');
107 }; 108 };
108 109
109 $scope.terminarHojaRuta = function() { 110 $scope.terminarHojaRuta = function() {
110 focaModalService 111 focaModalService
111 .confirm('¿Desea terminar la hoja de ruta? No podra realizar ninguna ' + 112 .confirm('¿Desea terminar la hoja de ruta? No podra realizar ninguna ' +
112 'otra descarga ni modificación') 113 'otra descarga ni modificación')
113 .then(function() {$scope.datosExtraCierre(terminar);}); 114 .then(function() {$scope.datosExtraCierre(terminar);});
114 function terminar(datosExtraCierre) { 115 function terminar(datosExtraCierre) {
115 $scope.hojaRuta = angular.extend({}, $scope.hojaRuta, datosExtraCierre); 116 $scope.hojaRuta = angular.extend({}, $scope.hojaRuta, datosExtraCierre);
116 //limpio objeto para guardar 117 //limpio objeto para guardar
117 delete $scope.hojaRuta.chofer; 118 delete $scope.hojaRuta.chofer;
118 delete $scope.hojaRuta.remitos; 119 delete $scope.hojaRuta.remitos;
119 delete $scope.hojaRuta.transportista; 120 delete $scope.hojaRuta.transportista;
120 delete $scope.hojaRuta.vehiculo; 121 delete $scope.hojaRuta.vehiculo;
121 122
122 $scope.hojaRuta.fechaCreacion = 123 $scope.hojaRuta.fechaCreacion =
123 $scope.hojaRuta.fechaCreacion.slice(0, 19).replace('T', ' '); 124 $scope.hojaRuta.fechaCreacion.slice(0, 19).replace('T', ' ');
124 $scope.hojaRuta.fechaReparto = 125 $scope.hojaRuta.fechaReparto =
125 $scope.hojaRuta.fechaReparto.slice(0, 19).replace('T', ' '); 126 $scope.hojaRuta.fechaReparto.slice(0, 19).replace('T', ' ');
126 $scope.hojaRuta.estado = 2; 127 $scope.hojaRuta.estado = 2;
127 hojaRutaService.terminarHojaRuta($scope.hojaRuta).then( 128 hojaRutaService.terminarHojaRuta($scope.hojaRuta).then(
128 function() { 129 function() {
129 focaModalService.alert( 130 focaModalService.alert(
130 'Hoja de ruta ' + 131 'Hoja de ruta ' +
131 $filter('comprobante')([$scope.puntoVenta, 132 $filter('comprobante')([$scope.puntoVenta,
132 $scope.comprobante]) + ' cerrada con éxito'); 133 $scope.comprobante]) + ' cerrada con éxito');
133 $location.path('/'); 134 $location.path('/');
134 } 135 }
135 ); 136 );
136 } 137 }
137 }; 138 };
138 139
139 $scope.datosExtraCierre = function(terminar) { 140 $scope.datosExtraCierre = function(terminar) {
140 var modalInstance = $uibModal.open( 141 var modalInstance = $uibModal.open(
141 { 142 {
142 templateUrl: 'focaDatosExtra.html', 143 templateUrl: 'focaDatosExtra.html',
143 controller: 'focaModalDatosExtraCierre', 144 controller: 'focaModalDatosExtraCierre',
144 } 145 }
145 ); 146 );
146 modalInstance.result.then(terminar); 147 modalInstance.result.then(terminar);
147 }; 148 };
148 149
150 $scope.modalDescargas = function() {
151
152 var modalInstance = $uibModal.open(
153 {
154 templateUrl: 'foca-modal-descarga.html',
155 controller: 'focaModalDescargaCtrl'
156 }
157 );
158
159 modalInstance.result.then(function(data) {
160
161 console.log(data);
162 });
163 };
164
149 $rootScope.$on('estadoRed', function(event, value) { 165 $rootScope.$on('estadoRed', function(event, value) {
150 $scope.esatadoRed = value; 166 $scope.esatadoRed = value;
151 }); 167 });
152 168
153 function getLSHojaRuta() { 169 function getLSHojaRuta() {
154 170
155 var hojaRuta = JSON.parse($localStorage.hojaRuta || null); 171 var hojaRuta = JSON.parse($localStorage.hojaRuta || null);
156 172
157 if (hojaRuta) { 173 if (hojaRuta) {
158 $scope.hojaRuta = hojaRuta; 174 $scope.hojaRuta = hojaRuta;
159 delete $localStorage.hojaRuta; 175 delete $localStorage.hojaRuta;
160 } 176 }
161 } 177 }
162 178
163 } 179 }
164 ]); 180 ]);
165 181
src/views/lista-hoja-ruta.html
1 <div> 1 <div>
2 <div class="col-md-10 offset-md-1 col-lg-8 offset-lg-2"> 2 <div class="col-md-10 offset-md-1 col-lg-8 offset-lg-2">
3 <div class="row p-1 panel-informativo"> 3 <div class="row p-1 panel-informativo">
4 <div class="col-12"> 4 <div class="col-12">
5 <div class="row"> 5 <div class="row">
6 <div class="col-12 col-sm-4 nota-pedido"> 6 <div class="col-12 col-sm-4 nota-pedido">
7 <h5>Hojas de ruta</h5> 7 <h5>Hojas de ruta</h5>
8 </div> 8 </div>
9 <div class="col-5 col-sm-4 numero-pedido"> 9 <div class="col-5 col-sm-4 numero-pedido">
10 Nº <span ng-bind="[puntoVenta, comprobante] | comprobante"></span> 10 Nº <span ng-bind="[puntoVenta, comprobante] | comprobante"></span>
11 </div> 11 </div>
12 <div class="col-7 col-sm-4 text-right"> 12 <div class="col-7 col-sm-4 text-right">
13 Fecha: 13 Fecha:
14 <span 14 <span
15 ng-show="!datepickerAbierto" 15 ng-show="!datepickerAbierto"
16 ng-bind="now | date:'dd/MM/yyyy HH:mm'" 16 ng-bind="now | date:'dd/MM/yyyy HH:mm'"
17 ng-click="datepickerAbierto = true" 17 ng-click="datepickerAbierto = true"
18 > 18 >
19 </span> 19 </span>
20 <input 20 <input
21 ng-show="datepickerAbierto" 21 ng-show="datepickerAbierto"
22 type="date" 22 type="date"
23 ng-model="now" 23 ng-model="now"
24 ng-change="datepickerAbierto = false" 24 ng-change="datepickerAbierto = false"
25 ng-blur="datepickerAbierto = false" 25 ng-blur="datepickerAbierto = false"
26 class="form-control form-control-sm col-8 float-right" 26 class="form-control form-control-sm col-8 float-right"
27 foca-focus="datepickerAbierto" 27 foca-focus="datepickerAbierto"
28 hasta-hoy 28 hasta-hoy
29 /> 29 />
30 </div> 30 </div>
31 </div> 31 </div>
32 <div class="row"> 32 <div class="row">
33 <div class="col-auto" ng-repeat="cab in cabecera" ng-show="showCabecera"> 33 <div class="col-auto" ng-repeat="cab in cabecera" ng-show="showCabecera">
34 <span class="label" ng-bind="cab.label"></span> 34 <span class="label" ng-bind="cab.label"></span>
35 <span class="valor" ng-bind="cab.valor"></span> 35 <span class="valor" ng-bind="cab.valor"></span>
36 </div> 36 </div>
37 </div> 37 </div>
38 </div> 38 </div>
39 </div> 39 </div>
40 <div class="row p-1 botonera-secundaria"> 40 <div class="row p-1 botonera-secundaria">
41 <div class="col-12"> 41 <div class="col-12">
42 <div class="row"> 42 <div class="row">
43 <div class="col-6 col-sm-3 px-0 py-0" ng-repeat="boton in botonera"> 43 <div class="col-6 col-sm-3 px-0 py-0" ng-repeat="boton in botonera">
44 <button 44 <button
45 type="button" 45 type="button"
46 class="btn btn-default btn-block btn-xs text-left py-2" 46 class="btn btn-default btn-block btn-xs text-left py-2"
47 ng-click="boton.accion()" 47 ng-click="boton.accion()"
48 ng-class="{'d-none d-sm-block': boton.texto == ''}" 48 ng-class="{'d-none d-sm-block': boton.texto == ''}"
49 > 49 >
50 <i 50 <i
51 class="fa fa-arrow-circle-right" 51 class="fa fa-arrow-circle-right"
52 ng-show="boton.texto != ''" 52 ng-show="boton.texto != ''"
53 ></i> 53 ></i>
54 &nbsp; 54 &nbsp;
55 {{boton.texto}} 55 {{boton.texto}}
56 </button> 56 </button>
57 </div> 57 </div>
58 </div> 58 </div>
59 </div> 59 </div>
60 </div> 60 </div>
61 </div> 61 </div>
62 <div class="col-12 col-md-10 col-lg-8 offset-md-1 offset-lg-2"> 62 <div class="col-12 col-md-10 col-lg-8 offset-md-1 offset-lg-2">
63 <div class="row grilla-articulo"> 63 <div class="row grilla-articulo">
64 <table class="table table-responsive table-striped table-sm table-dark"> 64 <table ng-hide="hojaRuta.abierta" class="table table-responsive table-striped table-sm table-dark">
65 <thead> 65 <thead>
66 <tr> 66 <tr>
67 <th>#</th> 67 <th>#</th>
68 <th>Número</th> 68 <th>Número</th>
69 <th>Razon Social</th> 69 <th>Razon Social</th>
70 <th>Domicilio</th> 70 <th>Domicilio</th>
71 <th>&nbsp;</th> 71 <th>&nbsp;</th>
72 </tr> 72 </tr>
73 </thead> 73 </thead>
74 <tbody class="tabla-articulo-body"> 74 <tbody class="tabla-articulo-body">
75 <tr 75 <tr
76 ng-repeat="(key, remito) in hojaRuta.remitos" 76 ng-repeat="(key, remito) in hojaRuta.remitos"
77 > 77 >
78 <td ng-bind="key + 1"></td> 78 <td ng-bind="key + 1"></td>
79 <td 79 <td
80 ng-bind="[remito.sucursal, remito.numeroRemito] | comprobante" 80 ng-bind="[remito.sucursal, remito.numeroRemito] | comprobante"
81 ></td> 81 ></td>
82 <td ng-bind="remito.nombreCliente"></td> 82 <td ng-bind="remito.nombreCliente"></td>
83 <td ng-bind="remito.domicilioStamp"></td> 83 <td ng-bind="remito.domicilioStamp"></td>
84 <td> 84 <td>
85 <button 85 <button
86 class="btn btn-secondary" 86 class="btn btn-secondary"
87 type="button" 87 type="button"
88 ng-click="verDetalle(remito)" 88 ng-click="verDetalle(remito)"
89 ><i class="fa fa-search" aria-hidden="true"></i> 89 ><i class="fa fa-search" aria-hidden="true"></i>
90 </button> 90 </button>
91 </td> 91 </td>
92 </tr> 92 </tr>
93 </tbody> 93 </tbody>
94 </table> 94 </table>
95 95 </div>
96 <div ng-show="hojaRuta.abierta" class="row grilla-articulo">
97 <table class="table table-striped table-sm table-dark">
98 <thead>
99 <tr>
100 <th colspan="3" class="text-center">Remito abierto Nº
101 {{[hojaRuta.remitos[0].sucursal, hojaRuta.remitos[0].numeroRemito] | comprobante}}
102 </th>
103 </tr>
104 <tr>
105 <th>Cisterna</th>
106 <th>Producto</th>
107 <th>Disponibles</th>
108 </tr>
109 </thead>
110 <tbody>
111 <tr ng-repeat="cisterna in hojaRuta.remitos[0].cisternas">
112 <td ng-bind="cisterna.codigo"></td>
113 <td ng-bind="cisterna.cisternaCarga.articulo.DetArt"></td>
114 <td ng-bind="cisterna.cisternaCarga.cantidad"></td>
115 </tr>
116 </tbody>
117 </table>
118 <table class="table table-striped table-sm table-dark">
119 <thead>
120 <tr>
121 <th>Descarga en cliente</th>
122 <th>
123 <button class="btn btn-outline-debo" ng-click="modalDescargas()">
124 <i class="fa fa-plus"></i>
125 </button>
126 </th>
127 </tr>
128 <tr></tr>
129 </thead>
130 <tbody>
131 <tr ng-repeat="remito in remitos"></tr>
132 </tbody>
133 </table>
96 </div> 134 </div>
97 </div> 135 </div>
98 <div class="row d-md-none fixed-bottom"> 136 <div class="row d-md-none fixed-bottom">
99 <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> 137 <div class="w-100 bg-dark d-flex px-3 acciones-mobile">
100 <span class="ml-3 text-muted" ng-click="salir()">Salir</span> 138 <span class="ml-3 text-muted" ng-click="salir()">Salir</span>
101 <span 139 <span
102 class="mr-3 ml-auto" 140 class="mr-3 ml-auto"
103 ng-click="terminarHojaRuta()" 141 ng-click="terminarHojaRuta()"
104 ladda="saveLoading" 142 ladda="saveLoading"
105 data-style="expand-left" 143 data-style="expand-left"
106 >Terminar</span> 144 >Terminar</span>
107 </div> 145 </div>
108 </div> 146 </div>
109 </div> 147 </div>
110 148