Commit 9e483702bf2e3ea6c07280b8af869d4100c1385e

Authored by Nicolás Guarnieri
Exists in master

Merge branch 'master' into 'master'

refactor servicios

See merge request modulos-npm/foca-hoja-ruta!15
1 { 1 {
2 "name": "foca-hoja-ruta", 2 "name": "foca-hoja-ruta",
3 "version": "0.0.1", 3 "version": "0.0.1",
4 "description": "foca-hoja-ruta", 4 "description": "foca-hoja-ruta",
5 "main": "index.js", 5 "main": "index.js",
6 "scripts": { 6 "scripts": {
7 "test": "echo \"Error: no test specified\" && exit 1", 7 "test": "echo \"Error: no test specified\" && exit 1",
8 "compile": "gulp uglify", 8 "compile": "gulp uglify",
9 "gulp-pre-commit": "gulp pre-commit", 9 "gulp-pre-commit": "gulp pre-commit",
10 "postinstall": "npm run compile && gulp clean-post-install", 10 "postinstall": "npm run compile && gulp clean-post-install",
11 "install-dev": "npm install -D jasmine-core pre-commit angular angular-ladda ladda@1.0.6 angular-route bootstrap ui-bootstrap4 font-awesome gulp gulp-angular-templatecache gulp-connect gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-uglify jquery jshint pump git+https://debo.suite.repo/modulos-npm/foca-directivas.git git+https://debo.suite.repo/modulos-npm/foca-modal-remito.git" 11 "install-dev": "npm install -D jasmine-core pre-commit angular angular-ladda ladda@1.0.6 angular-route bootstrap ui-bootstrap4 font-awesome gulp gulp-angular-templatecache gulp-connect gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-uglify jquery jshint pump git+https://debo.suite.repo/modulos-npm/foca-directivas.git git+https://debo.suite.repo/modulos-npm/foca-modal-remito.git"
12 }, 12 },
13 "pre-commit": [ 13 "pre-commit": [
14 "gulp-pre-commit" 14 "gulp-pre-commit"
15 ], 15 ],
16 "repository": { 16 "repository": {
17 "type": "git", 17 "type": "git",
18 "url": "https://debo.suite.repo/modulos-npm/foca-hoja-ruta.git" 18 "url": "https://debo.suite.repo/modulos-npm/foca-hoja-ruta.git"
19 }, 19 },
20 "author": "Foca Software", 20 "author": "Foca Software",
21 "license": "ISC", 21 "license": "ISC",
22 "devDependencies": { 22 "devDependencies": {
23 "angular": "^1.7.5", 23 "angular": "^1.7.5",
24 "angular-ladda": "^0.4.3", 24 "angular-ladda": "^0.4.3",
25 "angular-route": "^1.7.5", 25 "angular-route": "^1.7.5",
26 "bootstrap": "^4.1.3", 26 "bootstrap": "^4.1.3",
27 "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git", 27 "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git",
28 "foca-modal-remito": "git+https://debo.suite.repo/modulos-npm/foca-modal-remito.git", 28 "foca-modal-remito": "git+https://debo.suite.repo/modulos-npm/foca-modal-remito.git",
29 "font-awesome": "^4.7.0", 29 "font-awesome": "^4.7.0",
30 "gulp": "^3.9.1", 30 "gulp": "^3.9.1",
31 "gulp-angular-templatecache": "2.2.5", 31 "gulp-angular-templatecache": "^2.2.5",
32 "gulp-clean": "^0.4.0", 32 "gulp-clean": "^0.4.0",
33 "gulp-concat": "^2.6.1", 33 "gulp-concat": "^2.6.1",
34 "gulp-connect": "^5.6.1", 34 "gulp-connect": "^5.6.1",
35 "gulp-htmlmin": "5.0.1", 35 "gulp-htmlmin": "^5.0.1",
36 "gulp-jshint": "2.1.0", 36 "gulp-jshint": "^2.1.0",
37 "gulp-rename": "1.4.0", 37 "gulp-rename": "^1.4.0",
38 "gulp-replace": "1.0.0", 38 "gulp-replace": "^1.0.0",
39 "gulp-sequence": "^1.0.0", 39 "gulp-sequence": "^1.0.0",
40 "gulp-uglify": "3.0.1", 40 "gulp-uglify": "^3.0.1",
41 "gulp-uglify-es": "^1.0.4",
41 "jasmine-core": "^3.3.0", 42 "jasmine-core": "^3.3.0",
42 "jquery": "^3.3.1", 43 "jquery": "^3.3.1",
43 "jshint": "2.9.6", 44 "jshint": "^2.9.6",
44 "ladda": "1.0.6", 45 "ladda": "1.0.6",
45 "pre-commit": "^1.2.2", 46 "pre-commit": "^1.2.2",
46 "pump": "3.0.0", 47 "pump": "^3.0.0",
47 "ui-bootstrap4": "^3.0.5" 48 "ui-bootstrap4": "^3.0.5"
48 } 49 }
49 } 50 }
50 51
src/js/controller.js
1 angular.module('focaHojaRuta') 1 angular.module('focaHojaRuta')
2 .controller('listaHojaRutaCtrl', 2 .controller('listaHojaRutaCtrl',
3 ['$scope', '$filter', '$uibModal', 'hojaRutaService', 'focaSeguimientoService', 3 ['$scope', '$filter', '$uibModal', 'hojaRutaService', 'focaSeguimientoService',
4 function($scope, $filter, $uibModal, hojaRutaService, focaSeguimientoService) { 4 function($scope, $filter, $uibModal, hojaRutaService, focaSeguimientoService) {
5 hojaRutaService.getHojasRuta().then(function(res) { 5 hojaRutaService.getHojasRuta().then(function(res) {
6 var hojaRuta = res.data.pop(); 6 var hojaRuta = res.data.pop();
7 $scope.hojasRuta = hojaRuta; 7 $scope.hojasRuta = hojaRuta;
8 $scope.puntoVenta = hojaRuta.sucursal; 8 $scope.puntoVenta = hojaRuta.sucursal;
9 $scope.comprobante = hojaRuta.numeroHojaRuta; 9 $scope.comprobante = hojaRuta.numeroHojaRuta;
10 addCabecera('Transportista:', hojaRuta.transportista[0].nombre); 10 addCabecera('Transportista:', hojaRuta.transportista.NOM);
11 addCabecera('Chofer:', hojaRuta.chofer[0].nombre); 11 addCabecera('Chofer:', hojaRuta.chofer.nombre);
12 addCabecera('Vehículo:', hojaRuta.vehiculo[0].tractor); 12 addCabecera('Vehículo:', hojaRuta.vehiculo.tractor);
13 }); 13 });
14 $scope.cabecera = []; 14 $scope.cabecera = [];
15 $scope.showCabecera = true; 15 $scope.showCabecera = true;
16 16
17 $scope.now = new Date(); 17 $scope.now = new Date();
18 $scope.puntoVenta = '0000'; 18 $scope.puntoVenta = '0000';
19 $scope.comprobante = '00000000'; 19 $scope.comprobante = '00000000';
20 $scope.verDetalle = function(remito) { 20 $scope.verDetalle = function(remito) {
21 var modalInstance = $uibModal.open( 21 var modalInstance = $uibModal.open(
22 { 22 {
23 ariaLabelledBy: 'Detalle hoja ruta', 23 ariaLabelledBy: 'Detalle hoja ruta',
24 templateUrl: 'modal-detalle-hoja-ruta.html', 24 templateUrl: 'modal-detalle-hoja-ruta.html',
25 controller: 'focaModalDetalleHojaRutaController', 25 controller: 'focaModalDetalleHojaRutaController',
26 resolve: { 26 resolve: {
27 parametrosDetalleHojaRuta: function(){ 27 parametrosDetalleHojaRuta: function(){
28 return { 28 return {
29 remito: $filter('comprobante')([ 29 remito: $filter('comprobante')([
30 remito.sucursal, remito.numeroRemito 30 remito.sucursal, remito.numeroRemito
31 ]), 31 ]),
32 cliente: remito.nombreCliente, 32 cliente: remito.nombreCliente,
33 domicilio: remito.domicilioStamp, 33 domicilio: remito.domicilioStamp,
34 producto: 'Super', 34 producto: 'Super',
35 contacto: remito.nombreCliente, 35 contacto: remito.nombreCliente,
36 telefonoContacto: '-', 36 telefonoContacto: '-',
37 litros: remito.carga 37 litros: remito.carga
38 }; 38 };
39 } 39 }
40 }, 40 },
41 size: 'lg' 41 size: 'lg'
42 } 42 }
43 ); 43 );
44 modalInstance.result.then(function(parametros) { 44 modalInstance.result.then(function(parametros) {
45 // Al guardar los datos del producto entregado logueamos la 45 // Al guardar los datos del producto entregado logueamos la
46 // actividad para su seguimiento. 46 // actividad para su seguimiento.
47 focaSeguimientoService.guardarPosicion( 47 focaSeguimientoService.guardarPosicion(
48 $scope.hojasRuta.remito[0].id, 48 $scope.hojasRuta.remito[0].id,
49 'Entrega de producto', 49 'Entrega de producto',
50 'Hoja de ruta: ' + $filter('comprobante')([ 50 'Hoja de ruta: ' + $filter('comprobante')([
51 $scope.hojasRuta.sucursal, 51 $scope.hojasRuta.sucursal,
52 $scope.hojasRuta.numeroHojaRuta 52 $scope.hojasRuta.numeroHojaRuta
53 ]) + '<br/>' + 53 ]) + '<br/>' +
54 'Remito: ' + parametros.remito + '<br/>' + 54 'Remito: ' + parametros.remito + '<br/>' +
55 'Producto: ' + parametros.producto + '<br/>' + 55 'Producto: ' + parametros.producto + '<br/>' +
56 'Cantidad entregada: ' + parametros.litrosDescargados 56 'Cantidad entregada: ' + parametros.litrosDescargados
57 ); 57 );
58 }); 58 });
59 }; 59 };
60 60
61 function addCabecera(label, valor) { 61 function addCabecera(label, valor) {
62 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 62 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
63 if(propiedad.length === 1) { 63 if(propiedad.length === 1) {
64 propiedad[0].valor = valor; 64 propiedad[0].valor = valor;
65 } else { 65 } else {
66 $scope.cabecera.push({label: label, valor: valor}); 66 $scope.cabecera.push({label: label, valor: valor});
67 } 67 }
68 } 68 }
69 //TODO Descomentar cuando se use 69 //TODO Descomentar cuando se use
70 // function removeCabecera(label) { 70 // function removeCabecera(label) {
71 // var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 71 // var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
72 // if(propiedad.length === 1) { 72 // if(propiedad.length === 1) {
73 // $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); 73 // $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1);
74 // } 74 // }
75 // } 75 // }
76 76
77 $scope.rellenar = function(relleno, longitud) { 77 $scope.rellenar = function(relleno, longitud) {
78 relleno = '' + relleno; 78 relleno = '' + relleno;
79 while (relleno.length < longitud) { 79 while (relleno.length < longitud) {
80 relleno = '0' + relleno; 80 relleno = '0' + relleno;
81 } 81 }
82 82
83 return relleno; 83 return relleno;
84 }; 84 };
85 } 85 }
86 ]); 86 ]);
87 87
88 88
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 tabla-articulo table-reponsive table-striped table-sm table-dark"> 64 <table class="table tabla-articulo table-reponsive table-striped table-sm table-dark">
65 <thead> 65 <thead>
66 <tr class="d-flex"> 66 <tr class="d-flex">
67 <th class="col-auto">#</th> 67 <th class="col-auto">#</th>
68 <th class="col">Número</th> 68 <th class="col">Número</th>
69 <th class="col">Razon Social</th> 69 <th class="col">Razon Social</th>
70 <th class="col">Domicilio</th> 70 <th class="col">Domicilio</th>
71 <th class="col text-right">Cantidad</th> 71 <th class="col text-right">Cantidad</th>
72 <th style="width: 50px">&nbsp;</th> 72 <th style="width: 50px">&nbsp;</th>
73 </tr> 73 </tr>
74 </thead> 74 </thead>
75 <tbody class="tabla-articulo-body"> 75 <tbody class="tabla-articulo-body">
76 <tr 76 <tr
77 ng-repeat="(key, remito) in hojasRuta.remito" 77 ng-repeat="(key, remito) in hojasRuta.remitos"
78 > 78 >
79 <td ng-bind="key + 1"></td> 79 <td ng-bind="key + 1"></td>
80 <td 80 <td
81 ng-bind="[remito.sucursal, remito.numeroRemito] | comprobante" 81 ng-bind="[remito.sucursal, remito.numeroRemito] | comprobante"
82 ></td> 82 ></td>
83 <td ng-bind="remito.nombreCliente"></td> 83 <td ng-bind="remito.nombreCliente"></td>
84 <td ng-bind="remito.domicilioStamp"></td> 84 <td ng-bind="remito.domicilioStamp"></td>
85 <td ng-bind="remito.carga"></td> 85 <td ng-bind="remito.carga"></td>
86 <td > 86 <td >
87 <button 87 <button
88 class="btn btn-secondary" 88 class="btn btn-secondary"
89 type="button" 89 type="button"
90 ng-click="verDetalle(remito)" 90 ng-click="verDetalle(remito)"
91 ><i class="fa fa-search" aria-hidden="true"></i> 91 ><i class="fa fa-search" aria-hidden="true"></i>
92 </button> 92 </button>
93 </td> 93 </td>
94 </tr> 94 </tr>
95 </tbody> 95 </tbody>
96 </table> 96 </table>
97 97
98 </div> 98 </div>
99 </div> 99 </div>
100 </div> 100 </div>
101 101