Commit 0e13a3f82824b0e66ad1b223220b63d30efa0af3
Exists in
master
and in
1 other branch
Merge branch 'master' into 'master'
Master(efernandez) See merge request !9
Showing
3 changed files
Show diff stats
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 | 'focaSeguimientoService', | ||
| 10 | 'focaLoginService', | 9 | 'focaLoginService', |
| 11 | 'focaModalService', | 10 | 'focaModalService', |
| 12 | function( | 11 | function( |
| 13 | $scope, | 12 | $scope, |
| 14 | $location, | 13 | $location, |
| 15 | $filter, | 14 | $filter, |
| 16 | $uibModal, | 15 | $uibModal, |
| 17 | hojaRutaService, | 16 | hojaRutaService, |
| 18 | focaSeguimientoService, | ||
| 19 | focaLoginService, | 17 | focaLoginService, |
| 20 | focaModalService | 18 | focaModalService |
| 21 | ) { | 19 | ) { |
| 22 | var loginData = focaLoginService.getLoginData(); | 20 | var loginData = focaLoginService.getLoginData(); |
| 23 | 21 | ||
| 24 | hojaRutaService.getHojasRuta(loginData.chofer).then(function(res) { | 22 | hojaRutaService.getHojasRuta(loginData.chofer).then(function(res) { |
| 25 | if (res.data) { | 23 | if (res.data) { |
| 26 | var hojaRuta = res.data; | 24 | var hojaRuta = res.data; |
| 27 | $scope.hojasRuta = hojaRuta; | 25 | $scope.hojasRuta = hojaRuta; |
| 28 | $scope.puntoVenta = hojaRuta.sucursal; | 26 | $scope.puntoVenta = hojaRuta.sucursal; |
| 29 | $scope.comprobante = hojaRuta.numeroHojaRuta; | 27 | $scope.comprobante = hojaRuta.numeroHojaRuta; |
| 30 | addCabecera('Transportista:', hojaRuta.transportista.NOM); | 28 | addCabecera('Transportista:', hojaRuta.transportista.NOM); |
| 31 | addCabecera('Chofer:', hojaRuta.chofer.nombre); | 29 | addCabecera('Chofer:', hojaRuta.chofer.nombre); |
| 32 | addCabecera('Vehículo:', hojaRuta.vehiculo.tractor); | 30 | addCabecera('Vehículo:', hojaRuta.vehiculo.tractor); |
| 33 | } else { | 31 | } else { |
| 34 | focaModalService.alert('Sin hoja de ruta asignada'); | 32 | focaModalService.alert('Sin hoja de ruta asignada'); |
| 35 | $location.path('/'); | 33 | $location.path('/'); |
| 36 | } | 34 | } |
| 37 | }); | 35 | }); |
| 38 | 36 | ||
| 39 | $scope.cabecera = []; | 37 | $scope.cabecera = []; |
| 40 | $scope.showCabecera = true; | 38 | $scope.showCabecera = true; |
| 41 | 39 | ||
| 42 | $scope.now = new Date(); | 40 | $scope.now = new Date(); |
| 43 | $scope.puntoVenta = '0000'; | 41 | $scope.puntoVenta = '0000'; |
| 44 | $scope.comprobante = '00000000'; | 42 | $scope.comprobante = '00000000'; |
| 45 | $scope.verDetalle = function(remito) { | 43 | $scope.verDetalle = function(remito) { |
| 46 | var modalInstance = $uibModal.open( | 44 | var modalInstance = $uibModal.open( |
| 47 | { | 45 | { |
| 48 | ariaLabelledBy: 'Detalle hoja ruta', | 46 | ariaLabelledBy: 'Detalle hoja ruta', |
| 49 | templateUrl: 'modal-detalle-hoja-ruta.html', | 47 | templateUrl: 'modal-detalle-hoja-ruta.html', |
| 50 | controller: 'focaModalDetalleHojaRutaController', | 48 | controller: 'focaModalDetalleHojaRutaController', |
| 51 | resolve: { | 49 | resolve: { |
| 52 | idRemito : function() {return remito.id;} | 50 | idRemito : function() {return remito.id;} |
| 53 | }, | 51 | }, |
| 54 | size: 'lg' | 52 | size: 'lg' |
| 55 | } | 53 | } |
| 56 | ); | 54 | ); |
| 57 | modalInstance.result.then(function(detalle) { | 55 | modalInstance.result.then(function(detalle) { |
| 58 | console.log(detalle); | 56 | console.log(detalle); |
| 59 | //función a ejecutar cuando se carga la cisterna | 57 | //función a ejecutar cuando se carga la cisterna |
| 60 | //eliminar console log en produccion cuando sea necesario | 58 | //eliminar console log en produccion cuando sea necesario |
| 61 | }); | 59 | }); |
| 62 | }; | 60 | }; |
| 63 | 61 | ||
| 64 | function addCabecera(label, valor) { | 62 | function addCabecera(label, valor) { |
| 65 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 63 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
| 66 | if(propiedad.length === 1) { | 64 | if(propiedad.length === 1) { |
| 67 | propiedad[0].valor = valor; | 65 | propiedad[0].valor = valor; |
| 68 | } else { | 66 | } else { |
| 69 | $scope.cabecera.push({label: label, valor: valor}); | 67 | $scope.cabecera.push({label: label, valor: valor}); |
| 70 | } | 68 | } |
| 71 | } | 69 | } |
| 72 | //TODO Descomentar cuando se use | 70 | //TODO Descomentar cuando se use |
| 73 | // function removeCabecera(label) { | 71 | // function removeCabecera(label) { |
| 74 | // var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 72 | // var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
| 75 | // if(propiedad.length === 1) { | 73 | // if(propiedad.length === 1) { |
| 76 | // $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); | 74 | // $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); |
| 77 | // } | 75 | // } |
| 78 | // } | 76 | // } |
| 79 | 77 | ||
| 80 | $scope.rellenar = function(relleno, longitud) { | 78 | $scope.rellenar = function(relleno, longitud) { |
| 81 | relleno = '' + relleno; | 79 | relleno = '' + relleno; |
| 82 | while (relleno.length < longitud) { | 80 | while (relleno.length < longitud) { |
| 83 | relleno = '0' + relleno; | 81 | relleno = '0' + relleno; |
| 84 | } | 82 | } |
| 85 | 83 | ||
| 86 | return relleno; | 84 | return relleno; |
| 87 | }; | 85 | }; |
| 88 | $scope.salir = function() { | 86 | $scope.salir = function() { |
| 89 | $location.path('/'); | 87 | $location.path('/'); |
| 90 | }; | 88 | }; |
| 91 | 89 | ||
| 92 | $scope.terminarHojaRuta = function() { | 90 | $scope.terminarHojaRuta = function() { |
| 93 | focaModalService | 91 | focaModalService |
| 94 | .confirm('¿Desea terminar la hoja de ruta? No podra realizar ninguna ' + | 92 | .confirm('¿Desea terminar la hoja de ruta? No podra realizar ninguna ' + |
| 95 | 'otra descarga ni modificación') | 93 | 'otra descarga ni modificación') |
| 96 | .then(terminar); | 94 | .then(function() {$scope.datosExtraCierre(terminar);}); |
| 97 | function terminar() { | 95 | function terminar(hojaRuta) { |
| 98 | hojaRutaService.terminarHojaRuta($scope.hojasRuta.id).then( | 96 | console.log(hojaRuta); |
| 99 | function() { | 97 | //TODO: refactor servivcio para recibir nuevos parámetros |
| 100 | focaModalService.alert( | 98 | // hojaRutaService.terminarHojaRuta($scope.hojasRuta.id).then( |
| 101 | 'Hoja de ruta ' + | 99 | // function() { |
| 102 | $filter('comprobante')([$scope.puntoVenta, | 100 | // focaModalService.alert( |
| 103 | $scope.comprobante]) + ' cerrada con éxito'); | 101 | // 'Hoja de ruta ' + |
| 104 | $location.path('/'); | 102 | // $filter('comprobante')([$scope.puntoVenta, |
| 105 | } | 103 | // $scope.comprobante]) + ' cerrada con éxito'); |
| 106 | ); | 104 | // $location.path('/'); |
| 105 | // } | ||
| 106 | // ); | ||
| 107 | } | 107 | } |
| 108 | }; | 108 | }; |
| 109 | |||
| 110 | $scope.datosExtraCierre = function(terminar) { | ||
| 111 | var modalInstance = $uibModal.open( | ||
| 112 | { | ||
| 113 | templateUrl: 'focaDatosExtra.html', | ||
| 114 | controller: 'focaModalDatosExtraCierre', | ||
| 115 | } | ||
| 116 | ); | ||
| 117 | modalInstance.result.then(terminar); | ||
| 118 | }; | ||
| 109 | } | 119 | } |
src/js/controllerDatosExtra.js
| File was created | 1 | angular.module('focaHojaRuta') | |
| 2 | .controller('focaModalDatosExtraCierre', | ||
| 3 | [ | ||
| 4 | '$scope', | ||
| 5 | '$uibModalInstance', | ||
| 6 | 'focaModalService', | ||
| 7 | function($scope, $uibModalInstance, focaModalService) { | ||
| 8 | $scope.datosHojaRutaCierre = {}; | ||
| 9 | $scope.focused = 0; | ||
| 10 | |||
| 11 | $scope.aceptar = function(key) { | ||
| 12 | if(key === 13) { | ||
| 13 | if(!$scope.formDatosHojaRutaCierre.$valid) { | ||
| 14 | focaModalService.alert('Formulario inválido'); | ||
| 15 | return; | ||
| 16 | } | ||
| 17 | $uibModalInstance.close($scope.datosHojaRutaCierre); | ||
| 18 | } | ||
| 19 | }; | ||
| 20 | |||
| 21 | $scope.next = function(key) { | ||
| 22 | if(key === 13) $scope.focused++; | ||
| 23 | }; | ||
| 24 | |||
| 25 | $scope.cancel = function() { | ||
| 26 | $uibModalInstance.dismiss('cancel'); | ||
| 27 | }; | ||
| 28 | } | ||
| 29 | ] | ||
| 30 | ); | ||
| 31 |
src/views/focaDatosExtra.html
| File was created | 1 | <div class="modal-header"> | |
| 2 | <h3 class="modal-title">Datos de la hoja de ruta</h3> | ||
| 3 | </div> | ||
| 4 | <div class="modal-body" id="modal-body"> | ||
| 5 | <form name="formDatosHojaRutaCierre"> | ||
| 6 | <div class="row"> | ||
| 7 | <div class="col-12"> | ||
| 8 | <label class="form-control-sm">Kilómetros finales del vehículo:</label> | ||
| 9 | </div> | ||
| 10 | <div class="col-12"> | ||
| 11 | <input | ||
| 12 | type="number" | ||
| 13 | foca-focus="focused === 0" | ||
| 14 | ng-focus="focused = 0" | ||
| 15 | teclado-virtual | ||
| 16 | class="form-control form-control-sm" | ||
| 17 | placeholder="Kilómetros finales" | ||
| 18 | ng-model="datosHojaRutaCierre.kmFinalVehiculo" | ||
| 19 | ng-required="true" | ||
| 20 | ng-keypress="next($event.keyCode)" | ||
| 21 | /> | ||
| 22 | </div> | ||
| 23 | <div class="col-12"> | ||
| 24 | <label class="form-control-sm">Aforador final del vehículo:</label> | ||
| 25 | </div> | ||
| 26 | <div class="col-12"> | ||
| 27 | <input | ||
| 28 | foca-tipo-input | ||
| 29 | teclado-virtual | ||
| 30 | foca-focus="focused === 1" | ||
| 31 | ng-focus="focused = 1" | ||
| 32 | class="form-control form-control-sm" | ||
| 33 | placeholder="Aforador final" | ||
| 34 | ng-model="datosHojaRutaCierre.aforadorFinalVehiculo" | ||
| 35 | ng-required="true" | ||
| 36 | ng-keypress="next($event.keyCode)"/> | ||
| 37 | </div> | ||
| 38 | <div class="col-12"> | ||
| 39 | <label class="form-control-sm">Litros descargados por gravedad:</label> | ||
| 40 | </div> | ||
| 41 | <div class="col-12"> | ||
| 42 | <input | ||
| 43 | foca-tipo-input | ||
| 44 | teclado-virtual | ||
| 45 | foca-focus="focused === 2" | ||
| 46 | ng-focus="focused = 2" | ||
| 47 | class="form-control form-control-sm" | ||
| 48 | placeholder="Listros descargados por gravedad" | ||
| 49 | ng-model="datosHojaRutaCierre.litrosDescargadosPorGravedad" | ||
| 50 | ng-required="true" | ||
| 51 | ng-keypress="aceptar($event.keyCode)"/> | ||
| 52 | </div> | ||
| 53 | </form> | ||
| 54 | </div> | ||
| 55 | <div class="modal-footer"> | ||
| 56 | <button | ||
| 57 | class="btn btn-primary" | ||
| 58 | type="button" | ||
| 59 | ng-click="aceptar(13)" | ||
| 60 | ng-disabled="!formDatosHojaRutaCierre.$valid" | ||
| 61 | >Aceptar</button> | ||
| 62 | <button class="btn btn-secondary" type="button" ng-click="cancel()">Cancelar</button> | ||
| 63 | </div> | ||
| 64 |