Commit 9d6b18e7ba11cf5cb25791c703be5d68573da8ae

Authored by Eric Fernandez
1 parent 1278ddcc57
Exists in master and in 2 other branches develop, lab

Datos adicionales

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 function( 11 function(
12 $scope, 12 $scope,
13 $location, 13 $location,
14 $filter, 14 $filter,
15 $uibModal, 15 $uibModal,
16 hojaRutaService, 16 hojaRutaService,
17 focaLoginService, 17 focaLoginService,
18 focaModalService 18 focaModalService
19 ) { 19 ) {
20 var loginData = focaLoginService.getLoginData(); 20 var loginData = focaLoginService.getLoginData();
21 21
22 hojaRutaService.getHojasRuta(loginData.chofer).then(function(res) { 22 hojaRutaService.getHojaRuta(loginData.chofer).then(function(res) {
23 if (res.data) { 23 if (res.data) {
24 var hojaRuta = res.data; 24 var hojaRuta = res.data;
25 $scope.hojasRuta = hojaRuta; 25 $scope.hojaRuta = hojaRuta;
26 $scope.puntoVenta = hojaRuta.sucursal; 26 $scope.puntoVenta = hojaRuta.sucursal;
27 $scope.comprobante = hojaRuta.numeroHojaRuta; 27 $scope.comprobante = hojaRuta.numeroHojaRuta;
28 addCabecera('Transportista:', hojaRuta.transportista.NOM); 28 addCabecera('Transportista:', hojaRuta.transportista.NOM);
29 addCabecera('Chofer:', hojaRuta.chofer.nombre); 29 addCabecera('Chofer:', hojaRuta.chofer.nombre);
30 addCabecera('Vehículo:', hojaRuta.vehiculo.tractor); 30 addCabecera('Vehículo:', hojaRuta.vehiculo.tractor);
31 } else { 31 } else {
32 focaModalService.alert('Sin hoja de ruta asignada'); 32 focaModalService.alert('Sin hoja de ruta asignada');
33 $location.path('/'); 33 $location.path('/');
34 } 34 }
35 }); 35 });
36 36
37 $scope.cabecera = []; 37 $scope.cabecera = [];
38 $scope.showCabecera = true; 38 $scope.showCabecera = true;
39 39
40 $scope.now = new Date(); 40 $scope.now = new Date();
41 $scope.puntoVenta = '0000'; 41 $scope.puntoVenta = '0000';
42 $scope.comprobante = '00000000'; 42 $scope.comprobante = '00000000';
43 $scope.verDetalle = function(remito) { 43 $scope.verDetalle = function(remito) {
44 var modalInstance = $uibModal.open( 44 var modalInstance = $uibModal.open(
45 { 45 {
46 ariaLabelledBy: 'Detalle hoja ruta', 46 ariaLabelledBy: 'Detalle hoja ruta',
47 templateUrl: 'modal-detalle-hoja-ruta.html', 47 templateUrl: 'modal-detalle-hoja-ruta.html',
48 controller: 'focaModalDetalleHojaRutaController', 48 controller: 'focaModalDetalleHojaRutaController',
49 resolve: { 49 resolve: {
50 idRemito : function() {return remito.id;} 50 idRemito : function() {return remito.id;}
51 }, 51 },
52 size: 'lg' 52 size: 'lg'
53 } 53 }
54 ); 54 );
55 modalInstance.result.then(function(detalle) { 55 modalInstance.result.then(function(detalle) {
56 console.log(detalle); 56 console.log(detalle);
57 //función a ejecutar cuando se carga la cisterna 57 //función a ejecutar cuando se carga la cisterna
58 //eliminar console log en produccion cuando sea necesario 58 //eliminar console log en produccion cuando sea necesario
59 }); 59 });
60 }; 60 };
61 61
62 function addCabecera(label, valor) { 62 function addCabecera(label, valor) {
63 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 63 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
64 if(propiedad.length === 1) { 64 if(propiedad.length === 1) {
65 propiedad[0].valor = valor; 65 propiedad[0].valor = valor;
66 } else { 66 } else {
67 $scope.cabecera.push({label: label, valor: valor}); 67 $scope.cabecera.push({label: label, valor: valor});
68 } 68 }
69 } 69 }
70 //TODO Descomentar cuando se use 70 //TODO Descomentar cuando se use
71 // function removeCabecera(label) { 71 // function removeCabecera(label) {
72 // var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 72 // var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
73 // if(propiedad.length === 1) { 73 // if(propiedad.length === 1) {
74 // $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); 74 // $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1);
75 // } 75 // }
76 // } 76 // }
77 77
78 $scope.rellenar = function(relleno, longitud) { 78 $scope.rellenar = function(relleno, longitud) {
79 relleno = '' + relleno; 79 relleno = '' + relleno;
80 while (relleno.length < longitud) { 80 while (relleno.length < longitud) {
81 relleno = '0' + relleno; 81 relleno = '0' + relleno;
82 } 82 }
83 83
84 return relleno; 84 return relleno;
85 }; 85 };
86 $scope.salir = function() { 86 $scope.salir = function() {
87 $location.path('/'); 87 $location.path('/');
88 }; 88 };
89 89
90 $scope.terminarHojaRuta = function() { 90 $scope.terminarHojaRuta = function() {
91 focaModalService 91 focaModalService
92 .confirm('¿Desea terminar la hoja de ruta? No podra realizar ninguna ' + 92 .confirm('¿Desea terminar la hoja de ruta? No podra realizar ninguna ' +
93 'otra descarga ni modificación') 93 'otra descarga ni modificación')
94 .then(function() {$scope.datosExtraCierre(terminar);}); 94 .then(function() {$scope.datosExtraCierre(terminar);});
95 function terminar(hojaRuta) { 95 function terminar(datosExtraCierre) {
96 console.log(hojaRuta); 96 $scope.hojaRuta = angular.extend({}, $scope.hojaRuta, datosExtraCierre);
97 //TODO: refactor servivcio para recibir nuevos parámetros 97 //limpio objeto para guardar
98 // hojaRutaService.terminarHojaRuta($scope.hojasRuta.id).then( 98 delete $scope.hojaRuta.chofer;
99 // function() { 99 delete $scope.hojaRuta.remitos;
100 // focaModalService.alert( 100 delete $scope.hojaRuta.transportista;
101 // 'Hoja de ruta ' + 101 delete $scope.hojaRuta.vehiculo;
102 // $filter('comprobante')([$scope.puntoVenta, 102
103 // $scope.comprobante]) + ' cerrada con éxito'); 103 $scope.hojaRuta.fechaCreacion =
104 // $location.path('/'); 104 $scope.hojaRuta.fechaCreacion.slice(0, 19).replace('T', ' ');
105 // } 105 $scope.hojaRuta.fechaReparto =
106 // ); 106 $scope.hojaRuta.fechaReparto.slice(0, 19).replace('T', ' ');
107 $scope.hojaRuta.estado = 2;
108 hojaRutaService.terminarHojaRuta($scope.hojaRuta).then(
109 function() {
110 focaModalService.alert(
111 'Hoja de ruta ' +
112 $filter('comprobante')([$scope.puntoVenta,
113 $scope.comprobante]) + ' cerrada con éxito');
114 $location.path('/');
115 }
116 );
107 } 117 }
108 }; 118 };
109 119
110 $scope.datosExtraCierre = function(terminar) { 120 $scope.datosExtraCierre = function(terminar) {
111 var modalInstance = $uibModal.open( 121 var modalInstance = $uibModal.open(
112 { 122 {
113 templateUrl: 'focaDatosExtra.html', 123 templateUrl: 'focaDatosExtra.html',
114 controller: 'focaModalDatosExtraCierre', 124 controller: 'focaModalDatosExtraCierre',
115 } 125 }
116 ); 126 );
117 modalInstance.result.then(terminar); 127 modalInstance.result.then(terminar);
118 }; 128 };
119 } 129 }
120 ]); 130 ]);
121 131
1 angular.module('focaHojaRuta') 1 angular.module('focaHojaRuta')
2 .service('hojaRutaService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { 2 .service('hojaRutaService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) {
3 var route = API_ENDPOINT.URL; 3 var route = API_ENDPOINT.URL;
4 return { 4 return {
5 getHojasRuta: function(chofer) { 5 getHojaRuta: function(chofer) {
6 return $http.get(route + '/hoja-ruta/chofer/' + chofer); 6 return $http.get(route + '/hoja-ruta/chofer/' + chofer);
7 }, 7 },
8 terminarHojaRuta: function(hojaRuta) { 8 terminarHojaRuta: function(hojaRuta) {
9 return $http.get(route + '/hoja-ruta/terminar/' + hojaRuta); 9 return $http.post(route + '/hoja-ruta/terminar',{hojaRuta: hojaRuta});
10 } 10 }
11 }; 11 };
12 }]); 12 }]);
13 13
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 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 hojasRuta.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
96 </div> 96 </div>
97 </div> 97 </div>
98 <div class="row d-md-none fixed-bottom"> 98 <div class="row d-md-none fixed-bottom">
99 <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> 99 <div class="w-100 bg-dark d-flex px-3 acciones-mobile">
100 <span class="ml-3 text-muted" ng-click="salir()">Salir</span> 100 <span class="ml-3 text-muted" ng-click="salir()">Salir</span>
101 <span 101 <span
102 class="mr-3 ml-auto" 102 class="mr-3 ml-auto"
103 ng-click="terminarHojaRuta()" 103 ng-click="terminarHojaRuta()"
104 ladda="saveLoading" 104 ladda="saveLoading"
105 data-style="expand-left" 105 data-style="expand-left"
106 >Terminar</span> 106 >Terminar</span>
107 </div> 107 </div>
108 </div> 108 </div>
109 </div> 109 </div>
110 110