Commit a0042a4f2efecf6ef0103967d85d9888de6b1e8f

Authored by Eric Fernandez
1 parent 6a06288d8c
Exists in master

cargar remitos

confeccionar hoja ruta
... ... @@ -50,7 +50,7 @@
50 50 "undef": true,
51 51  
52 52 // Warn when variables are defined but never used.
53   - "unused": true,
  53 + "unused": false,
54 54  
55 55 // Para que funcione en angular
56 56 "predef": ["angular", "alert", "spyOn", "expect", "it", "inject", "beforeEach", "describe", "L"],
src/js/controller.js
... ... @@ -15,6 +15,7 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo
15 15 $scope.idUsuario = 0;
16 16 $scope.marcadores = [];
17 17 $scope.vehiculos = [];
  18 + var idsRemitos = [];
18 19 getSeguimiento();
19 20 $scope.arrastrando = false;
20 21 $scope.general = function() {
... ... @@ -37,7 +38,7 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo
37 38 });
38 39 };
39 40  
40   - $scope.cargar = function(id, punto) {
  41 + $scope.cargar = function(idVehiculo, punto) {
41 42 var idRemito = JSON.parse(punto).notaPedido.remito.id;
42 43 var modalInstance = $uibModal.open(
43 44 {
... ... @@ -46,12 +47,13 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo
46 47 controller: 'focaDetalleVehiculo',
47 48 size: 'lg',
48 49 resolve: {
49   - idVehiculo: function() {return id;},
  50 + idVehiculo: function() {return idVehiculo;},
50 51 idRemito: function() {return idRemito;}
51 52 }
52 53 }
53 54 );
54   - modalInstance.result.then(function() {
  55 + modalInstance.result.then(function(idRemito) {
  56 + idsRemitos.push(idRemito);
55 57 }, function() {
56 58 });
57 59 };
... ... @@ -63,9 +65,24 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo
63 65 });
64 66 };
65 67  
66   - $scope.informacionVehiculo = function(vehiculo) {
67   - focaModalService.alert('EN DESARROLLO : \n información del vehículo ' +
68   - JSON.stringify(vehiculo));
  68 + $scope.hacerHojaRuta = function(vehiculo) {
  69 + var modalInstance = $uibModal.open(
  70 + {
  71 + ariaLabelledBy: 'Creación hoja ruta',
  72 + templateUrl: 'foca-modal-crear-hoja-ruta.html',
  73 + controller: 'focaModalCrearHojaRuta',
  74 + size: 'lg',
  75 + resolve: {
  76 + idVehiculo: function() {return vehiculo.id;},
  77 + idsRemitos: function() {return idsRemitos;}
  78 + }
  79 + }
  80 + );
  81 + modalInstance.result.then(function() {
  82 +
  83 + }, function() {
  84 + //usar cuando se cancela el modal
  85 + });
69 86 };
70 87  
71 88 $scope.arrastra = function() {
... ... @@ -123,6 +140,10 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo
123 140 focaModalService.alert('El vehiculo que intenta cargar ya ha sido cargado');
124 141 return;
125 142 }
  143 + if(!vehiculo.cisternas.length) {
  144 + focaModalService.alert('El vehiculo no tiene cisternas');
  145 + return;
  146 + }
126 147 $scope.vehiculos.push(vehiculo);
127 148 }, function() {
128 149 // funcion ejecutada cuando se cancela el modal
src/js/controllerDetalleVehiculo.js
... ... @@ -10,9 +10,12 @@ angular.module('focaLogisticaPedidoRuta')
10 10 function($scope, $uibModalInstance, idVehiculo, idRemito, focaModalService, $filter,
11 11 focaLogisticaPedidoRutaService
12 12 ) {
  13 + //seteo variables
13 14 $scope.articulos = [];
14 15 $scope.vehiculo = {};
15 16 $scope.remito = {};
  17 + $scope.aCargar = [];
  18 + var cisternaMovimientos = [];
16 19 focaLogisticaPedidoRutaService.obtenerVehiculoById(idVehiculo).then(
17 20 function(res) {
18 21 $scope.vehiculo = res.data;
... ... @@ -24,9 +27,23 @@ angular.module('focaLogisticaPedidoRuta')
24 27 $scope.articulos = res.data.articulosRemito;
25 28 }
26 29 );
27   - $scope.aCargar = [];
28 30 $scope.aceptar = function() {
29   - $uibModalInstance.close();
  31 + $scope.cargando = true;
  32 + var cisternaCargas = [];
  33 + for (var i = 0; i < $scope.vehiculo.cisternas.length; i++) {
  34 + delete $scope.vehiculo.cisternas[i].cisternaCarga.articulo;
  35 + cisternaCargas.push($scope.vehiculo.cisternas[i].cisternaCarga);
  36 + }
  37 + var cisterna = {
  38 + cisternaMovimientos: cisternaMovimientos,
  39 + cisternaCargas: cisternaCargas
  40 + };
  41 + focaLogisticaPedidoRutaService.guardarCisternas(cisterna).then(function() {
  42 + focaModalService.alert('Cisternas cargadas con éxito').then(function() {
  43 + $scope.cargando = false;
  44 + $uibModalInstance.close(idRemito);
  45 + });
  46 + });
30 47 };
31 48  
32 49 $scope.cancelar = function() {
... ... @@ -37,6 +54,7 @@ angular.module(&#39;focaLogisticaPedidoRuta&#39;)
37 54 for(var i = 0; i < vehiculo.cisternas.length; i++) {
38 55 var cisterna = vehiculo.cisternas[i];
39 56 var aCargar = parseFloat($scope.aCargar[i]);
  57 + //validaciones
40 58 if(!aCargar) {
41 59 continue;
42 60 }
... ... @@ -45,6 +63,7 @@ angular.module(&#39;focaLogisticaPedidoRuta&#39;)
45 63 'cisterna ' + cisterna.codigo);
46 64 return;
47 65 }
  66 + //cargar
48 67 if(cisterna.cisternaCarga.cantidad) {
49 68 cisterna.cisternaCarga.cantidad += aCargar;
50 69 }else {
... ... @@ -60,6 +79,15 @@ angular.module(&#39;focaLogisticaPedidoRuta&#39;)
60 79 .cargado = true;
61 80  
62 81 $scope.calcularPorcentaje(cisterna);
  82 + //Guardar
  83 + var now = new Date();
  84 + var cisternaMovimiento = {
  85 + fecha: now.toISOString().slice(0, 19).replace('T', ' '),
  86 + cantidad: aCargar,
  87 + metodo: 'carga',
  88 + idCisternaCarga: cisterna.cisternaCarga.id
  89 + };
  90 + cisternaMovimientos.push(cisternaMovimiento);
63 91 }
64 92 var articuloSiguiente = $scope.articulos.filter(
65 93 function(filter) {
src/js/controllerHojaRuta.js
... ... @@ -0,0 +1,51 @@
  1 +angular.module('focaLogisticaPedidoRuta')
  2 + .controller('focaModalCrearHojaRuta', [
  3 + '$scope',
  4 + '$uibModalInstance',
  5 + '$uibModal',
  6 + 'focaLogisticaPedidoRutaService',
  7 + 'idVehiculo',
  8 + 'idsRemitos',
  9 + function($scope, $uibModalInstance, $uibModal, focaLogisticaPedidoRutaService,
  10 + idVehiculo, idsRemitos) {
  11 + $scope.vehiculo = {};
  12 + $scope.remitos = [];
  13 + focaLogisticaPedidoRutaService.obtenerVehiculoById(idVehiculo).then(function(res) {
  14 + $scope.vehiculo = res.data;
  15 + });
  16 + for (var i = 0; i < idsRemitos.length; i++) {
  17 + focaLogisticaPedidoRutaService.obtenerRemitoById(idsRemitos[i])
  18 + .then(cargarRemito);
  19 + }
  20 + function cargarRemito(res) {
  21 + $scope.remitos.push(res.data);
  22 + }
  23 + focaLogisticaPedidoRutaService.numeroHojaRuta().then(function(res) {
  24 + $scope.sucursal = res.data.sucursal;
  25 + $scope.numero = res.data.numeroHojaRuta;
  26 + });
  27 + $scope.cancelar = function() {
  28 + $uibModalInstance.close();
  29 + };
  30 + $scope.aceptar = function() {
  31 + $uibModalInstance.close();
  32 + };
  33 + $scope.seleccionarChofer = function() {
  34 + var modalInstance = $uibModal.open(
  35 + {
  36 + ariaLabelledBy: 'Busqueda de Chofer',
  37 + templateUrl: 'modal-chofer.html',
  38 + controller: 'focaModalChoferController',
  39 + size: 'lg'
  40 + }
  41 + );
  42 +
  43 + modalInstance.result.then(
  44 + function(chofer) {
  45 + $scope.chofer = chofer;
  46 + }, function() {
  47 + // funcion ejecutada cuando se cancela el modal
  48 + }
  49 + );
  50 + };
  51 + }]);
0 52 \ No newline at end of file
... ... @@ -11,6 +11,12 @@ angular.module(&#39;focaLogisticaPedidoRuta&#39;)
11 11 },
12 12 obtenerRemitoById: function(idRemito) {
13 13 return $http.get(API_ENDPOINT.URL + '/remito/obtener/' + idRemito);
  14 + },
  15 + guardarCisternas: function(cisterna) {
  16 + return $http.post(API_ENDPOINT.URL + '/cisterna/guardar/cargar', cisterna);
  17 + },
  18 + numeroHojaRuta: function() {
  19 + return $http.get(API_ENDPOINT.URL + '/hoja-ruta/numero-siguiente');
14 20 }
15 21 };
16 22 }]);
src/views/foca-detalle-vehiculo.html
1 1 <div class="modal-header">
2 2 <h4>Detalle de carga</h4>
3   - <!-- TODO: quitar llaves {{}} y usar ng-bind -->
4   - <h4>-EN DESARROLLO</h4>
  3 + Vehículo <strong ng-bind="vehiculo.tractor"></strong>
  4 + Transportista <strong ng-bind="vehiculo.transportista.NOM"></strong>
  5 + <br>
5 6 Remito Nº
6   - <strong ng-bind="remito.numeroRemito"></strong>
  7 + <strong ng-bind="[remito.sucursal, remito.numeroRemito] | comprobante"></strong>
7 8 , Cliente
8 9 <strong ng-bind="remito.nombreCliente"></strong>
9 10 , Domicilio
... ... @@ -11,64 +12,87 @@
11 12 </div>
12 13 <div class="modal-body">
13 14 <div>
14   - <div class="col-12" ng-repeat="(key, articulo) in articulos">
15   - <input
16   - type="radio"
17   - name="articuloRadio"
18   - id="{{articulo.id}}"
19   - ng-checked="articulo.checked"
20   - ng-disabled="articulo.cargado"
21   - ng-click="cambioArticulo(articulo)"
22   - >
23   - <span>Articulo: {{articulo.descripcion}},</span>
24   - <span>Total: {{articulo.cantidad}},</span>
25   - <span>Cantidad Cargada: {{articulo.cantidadCargada || 0}},</span>
26   - <span>Pendiente: {{articulo.cantidad - articulo.cantidadCargada}} </span>
27   - </div>
28   - <strong class="col-12" ng-bind="vehiculo.tractor"></strong>
29   - <strong class="col-12">Cisternas:</strong>
30   - <div class="form-group row input-group" ng-repeat="(key, cisterna) in vehiculo.cisternas">
31   - <div class="col-1 mt-2">
32   - <strong>{{cisterna.codigo}}</strong>
33   - </div>
34   - <input
35   - class="form-control col-2 mr-3"
36   - foca-tipo-input
37   - foca-teclado
38   - placeholder="A cargar..."
39   - ng-model="aCargar[key]"
40   - ng-disabled="(articuloSeleccionado.idArticulo !== cisterna.cisternaCarga.idProducto &&
41   - cisterna.cisternaCarga.idProducto) || !tieneArticulosPendientes()"
42   - ng-change="actualizarArticulo()"
43   - >
44   - <div class="progress foca-alto-progress col-4 pl-0 pr-0 mt-1">
45   - <strong class="col-12 mt-1 text-center position-absolute"
46   - >{{cisterna.cisternaCarga.cantidad || 0}} / {{cisterna.capacidad}}</strong>
47   - <div
48   - id="{{cisterna.id}}"
49   - class="progress-bar"
50   - role="progressbar"
51   - aria-valuemin="0"
52   - aria-valuemax="{{cisterna.capacidad}}"
53   - ng-style="{'width':'{{calcularPorcentaje(cisterna)}}'}">
54   - </div>
55   - </div>
56   - <div class="col-4 mt-2">
57   - <strong>{{cisterna.cisternaCarga.articulo.DetArt || 'Sin articulo'}}</strong>
58   - </div>
59   - <!--TODO: descomentar cuando se use-->
60   - <!-- <div class="col-1 mt-1">
61   - <i class="fa fa-info" uib-tooltip="Información cisterna"></i>
62   - </div> -->
63   - </div>
  15 + <table class="table table-sm">
  16 + <thead>
  17 + <tr>
  18 + <th></th>
  19 + <th>Articulo</th>
  20 + <th>Total</th>
  21 + <th>Cargado</th>
  22 + <th>Pendiente</th>
  23 + </tr>
  24 + </thead>
  25 + <tbody>
  26 + <tr ng-repeat="(key, articulo) in articulos">
  27 + <td><input
  28 + type="radio"
  29 + name="articuloRadio"
  30 + id="{{articulo.id}}"
  31 + ng-checked="articulo.checked"
  32 + ng-disabled="articulo.cargado"
  33 + ng-click="cambioArticulo(articulo)"
  34 + ></td>
  35 + <td ng-bind="articulo.descripcion"></td>
  36 + <td ng-bind="articulo.cantidad"></td>
  37 + <td ng-bind="articulo.cantidadCargada || 0"></td>
  38 + <td ng-bind="articulo.cantidad - articulo.cantidadCargada"></td>
  39 + </tr>
  40 + </tbody>
  41 + </table>
  42 + <table class="table table-sm">
  43 + <thead>
  44 + <tr>
  45 + <th>Cisterna</th>
  46 + <th>Cantidad asignada</th>
  47 + <th>Estado</th>
  48 + <th>Articulo cargado</th>
  49 + </tr>
  50 + </thead>
  51 + <tbody>
  52 + <tr ng-repeat="(key, cisterna) in vehiculo.cisternas">
  53 + <td ng-bind="cisterna.codigo"></td>
  54 + <td><input
  55 + class="form-control"
  56 + foca-tipo-input
  57 + foca-teclado
  58 + placeholder="A cargar..."
  59 + ng-model="aCargar[key]"
  60 + ng-disabled="(articuloSeleccionado.idArticulo !== cisterna.cisternaCarga.idProducto &&
  61 + cisterna.cisternaCarga.idProducto) || !tieneArticulosPendientes()"
  62 + ng-change="actualizarArticulo()"
  63 + >
  64 + </td>
  65 + <td colspan="2"><div class="progress foca-alto-progress pl-0 pr-0 mt-1">
  66 + <strong
  67 + class="mt-2 col-3 text-center position-absolute"
  68 + ng-bind="(cisterna.cisternaCarga.cantidad || 0) + '/' + (cisterna.capacidad)">
  69 + </strong>
  70 + <div
  71 + id="{{cisterna.id}}"
  72 + class="progress-bar"
  73 + role="progressbar"
  74 + aria-valuemin="0"
  75 + aria-valuemax="{{cisterna.capacidad}}"
  76 + ng-style="{'width':'{{calcularPorcentaje(cisterna)}}'}">
  77 + </div>
  78 + </div>
  79 + </td>
  80 + <td ng-bind="cisterna.cisternaCarga.articulo.DetArt || 'Sin articulo'"></td>
  81 + </tr>
  82 + </tbody>
  83 + </table>
64 84 <div class="col-12 aling-end">
65 85 <button
66   - class="form-control"
  86 + class="form-control btn btn-success"
  87 + ladda="cargando"
  88 + data-spinner-color="#FF0000"
67 89 type="button"
68 90 ng-disabled="!articuloSeleccionado || articuloSeleccionado.cantidad -
69 91 articuloSeleccionado.cantidadCargada !== 0 || !tieneArticulosPendientes()"
  92 + ng-class="{'btn-light': !articuloSeleccionado || articuloSeleccionado.cantidad -
  93 + articuloSeleccionado.cantidadCargada !== 0 || !tieneArticulosPendientes()}"
70 94 ng-click="cargarACisternas(vehiculo)">
71   - Cargar cisternas
  95 + Aplicar distribución de cargas
72 96 </button>
73 97 </div>
74 98 </div>
... ... @@ -76,10 +100,12 @@
76 100 <div class="modal-footer py-1">
77 101 <button
78 102 class="btn btn-sm btn-secondary"
  103 + ladda="cargando"
79 104 type="button"
80 105 ng-click="cancelar()">Cancelar</button>
81 106 <button
82 107 class="btn btn-sm btn-primary"
  108 + ladda="cargando"
83 109 type="button"
84 110 ng-click="aceptar()"
85 111 ng-disabled="tieneArticulosPendientes()">Cargar</button>
src/views/foca-logistica-pedido-ruta.html
... ... @@ -61,7 +61,7 @@
61 61 >
62 62 <div>
63 63 <div class="col-md-3 col-sm-6">
64   - <div class="progress-circle blue" ng-class="{'arrastrando': arrastrando}">
  64 + <div class="progress-circle" ng-class="{'arrastrando': arrastrando}">
65 65 <span class="progress-left">
66 66 <span class="progress-bar"></span>
67 67 </span>
... ... @@ -69,16 +69,17 @@
69 69 <span class="progress-bar"></span>
70 70 </span>
71 71 <div class="progress-value">{{vehiculo.codigo}}</div>
72   - </div>
  72 + </div>
73 73 </div>
74   - <div class="row">
75   - <div class="text-left col-6">
76   - <i
77   - class="fa fa-info fa-2x"
78   - uib-tooltip="Ver información del vehículo"
79   - ng-click="informacionVehiculo(vehiculo)"></i>
  74 + <div class="row px-4">
  75 + <div class="text-left col-6 ml-1 position-absolute">
  76 + <img
  77 + src="img/hojaRutaVolante.png"
  78 + width="34%"
  79 + uib-tooltip="Confeccionar hoja de ruta"
  80 + ng-click="hacerHojaRuta(vehiculo)">
80 81 </div>
81   - <div class="text-right col-6">
  82 + <div class="text-right ml-5 col-6 position-absolute">
82 83 <i
83 84 class="fa fa-trash fa-2x"
84 85 uib-tooltip="Eliminar vehiculo"
... ... @@ -86,7 +87,7 @@
86 87 </div>
87 88 </div>
88 89 <div
89   - class="col-12 border border-dark text-center"
  90 + class="col-12 mt-5 border border-dark text-center"
90 91 ng-show="arrastrando"
91 92 id="{{vehiculo.id}}"
92 93 ondrop="drop(event)"
src/views/foca-modal-crear-hoja-ruta.html
... ... @@ -0,0 +1,96 @@
  1 +<div class="modal-header">
  2 + <h4>-en desarrollo</h4>
  3 + <h4>Confeccionar hoja de ruta</h4>
  4 + Hoja de ruta Nº <strong ng-bind="[numero, sucursal] | comprobante"></strong>
  5 + <br>
  6 +</div>
  7 +<div class="modal-body">
  8 + <form class="row" name="formHojaRuta">
  9 +
  10 +
  11 + <div class="col-2 form-group">
  12 + <label>Vehículo</label>
  13 + </div>
  14 + <div class="col-4">
  15 + <input
  16 + class="form-control"
  17 + readonly
  18 + ng-model="vehiculo.tractor"
  19 + >
  20 + </div>
  21 + <div class="col-2">
  22 + <label>Transportista</label>
  23 + </div>
  24 + <div class="col-4">
  25 + <input
  26 + class="form-control"
  27 + readonly
  28 + ng-model="vehiculo.transportista.NOM"
  29 + >
  30 + </div>
  31 + <div class="col-2 form-group">
  32 + <label>Chofer</label>
  33 + </div>
  34 + <div class="col-4 input-group">
  35 + <input
  36 + class="form-control"
  37 + ng-model="chofer.nombre"
  38 + ng-click="seleccionarChofer()"
  39 + ng-required="true"
  40 + >
  41 + <div class="input-group-append">
  42 + <button
  43 + class="brn btn-outline-secondary form-control"
  44 + ng-click="seleccionarChofer()"
  45 + ><i class="fa fa-search"></i>
  46 + </button>
  47 + </div>
  48 + </div>
  49 + <div class="col-2">
  50 + <label>Tarifa</label>
  51 + </div>
  52 + <div class="col-4">
  53 + <input
  54 + class="form-control"
  55 + ng-model="tarifaFlete"
  56 + ng-required="true"
  57 + foca-teclado
  58 + foca-tipo-input
  59 + >
  60 + </div>
  61 + </form>
  62 + <strong>Remitos:</strong>
  63 + <table class="table">
  64 + <thead>
  65 + <tr>
  66 + <th>Remito Nº</th>
  67 + <th>Cliente</th>
  68 + <th>Domicilio</th>
  69 + </tr>
  70 + </thead>
  71 + <tbody>
  72 + <tr ng-repeat="remito in remitos">
  73 + <td ng-bind="[remito.numeroRemito, remito.sucursal] | comprobante"></td>
  74 + <td ng-bind="remito.nombreCliente"></td>
  75 + <td ng-bind="remito.domicilioStamp"></td>
  76 + </tr>
  77 + <!-- <tr>
  78 + <td>Remito ejemplo</td>
  79 + <td>Domicilio ejemplo</td>
  80 + </tr> -->
  81 + </tbody>
  82 + </table>
  83 +</div>
  84 +<div class="modal-footer py-1">
  85 + <button
  86 + class="btn btn-sm btn-secondary"
  87 + ladda="cargando"
  88 + type="button"
  89 + ng-click="cancelar()">Cancelar</button>
  90 + <button
  91 + class="btn btn-sm btn-primary"
  92 + ladda="cargando"
  93 + type="button"
  94 + ng-disabled="!formHojaRuta.$valid"
  95 + ng-click="aceptar()">Crear hoja ruta</button>
  96 +</div>