Commit 27cba21f09b3cef2ae3c2c9aa532ab94b24b67a5

Authored by Eric Fernandez
Exists in master and in 2 other branches develop, lab

Merge branch 'master' into 'master'

Master(efernandez)

See merge request !15
src/js/controller.js
... ... @@ -9,10 +9,14 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo
9 9 //Datos Pantalla
10 10 $scope.titulo = 'Logistica de Pedidos';
11 11 var transportista = {
12   - label: 'transportista',
  12 + label: 'Unidad',
13 13 image: 'abmChofer.png'
14 14 };
15   - $scope.botonera = [transportista];
  15 + var fecha = {
  16 + label: 'Fecha Reparto',
  17 + image: 'abmChofer.png'
  18 + };
  19 + $scope.botonera = [transportista, fecha];
16 20 var cabecera = '';
17 21 $scope.now = new Date();
18 22 $scope.idVendedor = 0;
... ... @@ -124,7 +128,7 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo
124 128 getSeguimiento();
125 129 };
126 130  
127   - $scope.seleccionarTransportista = function() {
  131 + $scope.seleccionarUnidad = function() {
128 132 var modalInstance = $uibModal.open(
129 133 {
130 134 ariaLabelledBy: 'Busqueda de Transportista',
... ... @@ -167,6 +171,15 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo
167 171 });
168 172 };
169 173  
  174 + $scope.seleccionarFechaReparto = function() {
  175 + focaModalService.modalFecha('Fecha de reparto').then(function(fecha) {
  176 + $scope.$broadcast('addCabecera',{
  177 + label: 'Fecha:',
  178 + valor: fecha.toLocaleDateString()
  179 + });
  180 + });
  181 + };
  182 +
170 183 function getSeguimiento() {
171 184 var desde = new Date('1900/01/01');
172 185 var hasta = new Date('2099/01/01');
src/js/controllerDetalleVehiculo.js
... ... @@ -11,30 +11,30 @@ angular.module('focaLogisticaPedidoRuta')
11 11 focaLogisticaPedidoRutaService
12 12 ) {
13 13 //seteo variables
  14 + $scope.cargandoDatos = true;
14 15 $scope.idRemito = idRemito;
15 16 $scope.articulos = [];
16 17 $scope.vehiculo = {};
17 18 $scope.remito = {};
18 19 $scope.aCargar = [];
19 20 var cisternaMovimientos = [];
20   - focaLogisticaPedidoRutaService.obtenerVehiculoById(idVehiculo).then(
21   - function(res) {
22   - $scope.vehiculo = res.data;
23   - }
24   - );
  21 + var promesaVehiculo = focaLogisticaPedidoRutaService.obtenerVehiculoById(idVehiculo);
  22 + var promesaRemito;
25 23 if(idRemito !== -1) {
26   - focaLogisticaPedidoRutaService.obtenerRemitoById(idRemito).then(
27   - function(res) {
28   - $scope.remito = res.data;
29   - if($scope.remito.idUsuarioProceso) {
30   - focaModalService.alert('Remito ya asignado');
31   - $uibModalInstance.close();
32   - }
33   - $scope.articulos = res.data.articulosRemito;
34   - $scope.cambioArticulo($scope.articulos[0]);
35   - }
36   - );
  24 + promesaRemito = focaLogisticaPedidoRutaService.obtenerRemitoById(idRemito);
37 25 }
  26 + Promise.all([promesaVehiculo, promesaRemito]).then(function(res) {
  27 + $scope.cargandoDatos = false;
  28 + $scope.vehiculo = res[0].data;
  29 + if(!res[1]) return;
  30 + $scope.remito = res[1].data;
  31 + if($scope.remito.idUsuarioProceso) {
  32 + focaModalService.alert('Remito ya asignado');
  33 + $uibModalInstance.close();
  34 + }
  35 + $scope.articulos = $scope.remito.articulosRemito;
  36 + $scope.cambioArticulo($scope.articulos[0]);
  37 + });
38 38 $scope.aceptar = function() {
39 39 $scope.cargando = true;
40 40 var cisternaCargas = [];
... ... @@ -133,8 +133,17 @@ angular.module('focaLogisticaPedidoRuta')
133 133 }
134 134 };
135 135 $scope.cambioArticulo = function(articulo) {
136   - articulo.checked = true;
  136 + $scope.aCargar = [];
  137 + $filter('filter')($scope.articulos, {id: articulo.id})[0].checked = true;
137 138 $scope.articuloSeleccionado = articulo;
  139 + for(var i = 0; i < $scope.vehiculo.cisternas.length; i++) {
  140 + $scope.vehiculo.cisternas[i] =
  141 + $scope.cisternaDisabled($scope.vehiculo.cisternas[i]);
  142 + }
  143 + var disponible = $filter('filter')($scope.vehiculo.cisternas, {disabled: false});
  144 + var index = $scope.vehiculo.cisternas.indexOf(disponible[0]);
  145 + $scope.aCargar[index] = $scope.articuloSeleccionado.cantidad;
  146 + $scope.actualizarArticulo();
138 147 };
139 148 $scope.actualizarArticulo = function () {
140 149 $scope.articuloSeleccionado.cantidadCargada = 0;
... ... @@ -143,7 +152,44 @@ angular.module(&#39;focaLogisticaPedidoRuta&#39;)
143 152 parseFloat($scope.aCargar[i]) || 0;
144 153 }
145 154 };
  155 + $scope.cisternaDisabled = function(cisterna) {
  156 + if(!$scope.articuloSeleccionado || ($scope.articuloSeleccionado.idArticulo !==
  157 + cisterna.cisternaCarga.idProducto && cisterna.cisternaCarga.idProducto) ||
  158 + !$scope.tieneArticulosPendientes()|| $scope.articuloSeleccionado.cantidad >
  159 + cisterna.disponible) {
  160 + cisterna.disabled = true;
  161 + }else {
  162 + cisterna.disabled = false;
  163 + }
  164 + return cisterna;
  165 + };
  166 + $scope.rellenarInput = function(input = 0) {
  167 + if(!$scope.articuloSeleccionado) return;
  168 + input = parseFloat(input);
  169 + if(input === $scope.articuloSeleccionado.cantidad ||
  170 + $scope.articuloSeleccionado.cantidad -
  171 + $scope.articuloSeleccionado.cantidadCargada === 0) {
  172 + return input;
  173 + }
  174 + input += parseFloat($scope.articuloSeleccionado.cantidad -
  175 + $scope.articuloSeleccionado.cantidadCargada);
  176 + return input;
  177 + };
  178 + $scope.distribucionDisponible = function() {
  179 + if(!$scope.articuloSeleccionado || $scope.articuloSeleccionado.cantidad -
  180 + $scope.articuloSeleccionado.cantidadCargada !== 0 ||
  181 + !$scope.tieneArticulosPendientes()) {
  182 + return false;
  183 + }
  184 + return true;
  185 + };
146 186 $scope.tieneArticulosPendientes = function() {
  187 + var algunValorNegativo = $scope.aCargar.filter(function(p) {
  188 + return p < 0;
  189 + });
  190 + if(algunValorNegativo.length) {
  191 + return false;
  192 + }
147 193 var articulosDescargados = $scope.articulos.filter(function(filter) {
148 194 return filter.cargado === true;
149 195 });
src/js/osm-directive.js
... ... @@ -74,8 +74,8 @@ angular.module(&#39;focaLogisticaPedidoRuta&#39;).directive(&#39;focaLogistica&#39;, function()
74 74 .addTo($scope.map)
75 75 .bindPopup(observacion)
76 76 );
77   -
78   - $scope.markers[0].openPopup();
  77 + //abre marcador del primer punto
  78 + //$scope.markers[0].openPopup();
79 79 });
80 80 });
81 81 }],
src/views/foca-detalle-vehiculo.html
1 1 <div class="modal-header">
2 2 <h4>Detalle de carga</h4>
3   - Transportista <strong ng-bind="vehiculo.transportista.NOM"></strong>
  3 + Transportista
  4 + <strong ng-bind="vehiculo.transportista.COD"></strong>
  5 + <strong ng-bind="vehiculo.transportista.NOM"></strong>
4 6 Unidad <strong ng-bind="vehiculo.codigo"></strong>
5 7 Tractor <strong ng-bind="vehiculo.tractor"></strong>
6 8 <br>
... ... @@ -22,9 +24,9 @@
22 24 <tr>
23 25 <th></th>
24 26 <th>Articulo</th>
25   - <th>Total</th>
  27 + <th>Cantidad</th>
26 28 <th>Cargado</th>
27   - <th>Pendiente</th>
  29 + <th>Resta asignar</th>
28 30 </tr>
29 31 </thead>
30 32 <tbody>
... ... @@ -44,34 +46,44 @@
44 46 </tr>
45 47 </tbody>
46 48 </table>
47   - <table class="table table-sm">
  49 + <table class="table table-sm" ladda="cargandoDatos" data-spinner-color="#FF0000">
48 50 <thead>
49 51 <tr>
50 52 <th width="10%">Cisterna</th>
51   - <th width="20%">Cantidad asignada</th>
52   - <th width="35%">Estado</th>
  53 + <th>Capacidad</th>
53 54 <th>Articulo cargado</th>
  55 + <th width="20%">Asignado</th>
  56 + <th>Cargado / Capacidad Disponible</th>
54 57 </tr>
55 58 </thead>
56 59 <tbody>
57 60 <tr ng-repeat="(key, cisterna) in vehiculo.cisternas">
58   - <td ng-bind="cisterna.codigo"></td>
59   - <td><input
  61 + <td class="py-3" ng-bind="cisterna.codigo"></td>
  62 + <td class="py-3" ng-bind="cisterna.capacidad"></td>
  63 + <td class="py-3" ng-bind="cisterna.cisternaCarga.articulo.DetArt || 'Sin asignar'"></td>
  64 + <td ng-if="idRemito != -1">
  65 + <input
60 66 class="form-control"
61 67 foca-tipo-input
62 68 foca-teclado
63 69 placeholder="A cargar..."
64 70 ng-model="aCargar[key]"
65   - ng-disabled="(articuloSeleccionado.idArticulo !== cisterna.cisternaCarga.idProducto &&
66   - cisterna.cisternaCarga.idProducto) || !tieneArticulosPendientes()
67   - || articuloSeleccionado.cantidad > cisterna.disponible"
  71 + ng-disabled="cisterna.disabled"
  72 + ng-focus="aCargar[key] = rellenarInput(aCargar[key]); actualizarArticulo()"
68 73 ng-change="actualizarArticulo()"
69 74 >
70 75 </td>
  76 + <td ng-if="idRemito == -1">
  77 + <input
  78 + class="form-control"
  79 + placeholder="A cargar..."
  80 + readonly>
  81 + </td>
71 82 <td><div class="progress foca-alto-progress pl-0 pr-0 mt-1">
72 83 <strong
73 84 class="mt-2 col-4 text-center position-absolute"
74   - ng-bind="(cisterna.cisternaCarga.cantidad || 0) + '/' + (cisterna.capacidad)">
  85 + ng-bind="(cisterna.cisternaCarga.cantidad || 0) + '/' +
  86 + (cisterna.capacidad - cisterna.cisternaCarga.cantidad)">
75 87 </strong>
76 88 <div
77 89 id="{{cisterna.id}}"
... ... @@ -83,7 +95,6 @@
83 95 </div>
84 96 </div>
85 97 </td>
86   - <td ng-bind="cisterna.cisternaCarga.articulo.DetArt || 'Sin asignar'"></td>
87 98 </tr>
88 99 </tbody>
89 100 </table>
... ... @@ -93,11 +104,10 @@
93 104 ladda="cargando"
94 105 data-spinner-color="#FF0000"
95 106 type="button"
96   - ng-disabled="!articuloSeleccionado || articuloSeleccionado.cantidad -
97   - articuloSeleccionado.cantidadCargada !== 0 || !tieneArticulosPendientes()"
98   - ng-class="{'btn-light': !articuloSeleccionado || articuloSeleccionado.cantidad -
99   - articuloSeleccionado.cantidadCargada !== 0 || !tieneArticulosPendientes()}"
100   - ng-click="cargarACisternas(vehiculo)">
  107 + ng-disabled="!distribucionDisponible()"
  108 + ng-class="{'btn-light': !distribucionDisponible()}"
  109 + ng-click="cargarACisternas(vehiculo)"
  110 + foca-focus="distribucionDisponible()">
101 111 Aplicar distribución de cargas
102 112 </button>
103 113 </div>
src/views/foca-logistica-pedido-ruta.html
... ... @@ -8,7 +8,7 @@
8 8 </div>
9 9 <div class="row px-5 py-2 botonera-secundaria">
10 10 <div class="col-12">
11   - <foca-botonera-facturador botones="botonera" extra="5" class="row"></foca-botonera-facturador>
  11 + <foca-botonera-facturador botones="botonera" extra="4" class="row"></foca-botonera-facturador>
12 12 </div>
13 13 </div>
14 14 <div class="row">