Commit 359d51a957a54a1ff666773500c952711b2fa366

Authored by Jose Pinto
1 parent d1411789ec
Exists in master

capacidad total vehiculo, formato tabla y crear cisternas

src/js/controller.js
... ... @@ -89,6 +89,7 @@ angular.module('focaAbmVehiculo')
89 89 $scope.nuevo = $routeParams.idVehiculo === '0' ? true : false;
90 90 $scope.now = new Date();
91 91 $scope.focused = 1;
  92 + $scope.transportistaStamp = '';
92 93  
93 94 $timeout(function() {
94 95 focaBotoneraLateralService.showSalir(false);
... ... @@ -113,11 +114,13 @@ angular.module('focaAbmVehiculo')
113 114 $scope.vehiculo = {};
114 115 focaAbmVehiculoService.getVehiculo($routeParams.idVehiculo).then(function(res) {
115 116 if(res.data) {
116   - var codigo = ('00000' + res.data.transportista.COD).slice(-5);
  117 + $scope.transportistaStamp = ('00000' + res.data.transportista.COD).slice(-5);
  118 + $scope.transportistaStamp += ' - ' + res.data.transportista.NOM
  119 +
117 120 $scope.vehiculo = res.data;
118 121 $scope.$broadcast('addCabecera', {
119 122 label: 'Transportista:',
120   - valor: codigo + ' - ' + res.data.transportista.NOM
  123 + valor: $scope.transportistaStamp
121 124 });
122 125 $scope.$broadcast('addCabecera', {
123 126 label: 'Unidad:',
src/js/controllerCisterna.js
... ... @@ -16,6 +16,7 @@ angular.module('focaAbmVehiculo')
16 16 $scope.next = function(key) {
17 17 if (key === 13) $scope.focused++;
18 18 };
  19 + $scope.capacidadVechiulo = 0;
19 20  
20 21 //SETEO BOTONERA LATERAL
21 22 $timeout(function() {
... ... @@ -35,6 +36,7 @@ angular.module('focaAbmVehiculo')
35 36 });
36 37 focaAbmVehiculoService.getVehiculo($routeParams.idVehiculo).then(function(res) {
37 38 var codigo = ('00000' + res.data.transportista.COD).slice(-5);
  39 + $scope.capacidadVechiulo = res.data.capacidad;
38 40 $scope.$broadcast('addCabecera', {
39 41 label: 'Transportista:',
40 42 valor: codigo + ' - ' + res.data.transportista.NOM
... ... @@ -52,7 +54,7 @@ angular.module('focaAbmVehiculo')
52 54 focaModalService.alert('Ingrese unidad de medida');
53 55 return;
54 56 }
55   - existeCodigoCisterna().then(function() {
  57 + validaCodigoCapacidad().then(function() {
56 58 $scope.cisterna.idVehiculo = $routeParams.idVehiculo;
57 59 delete $scope.cisterna.vehiculo;
58 60 delete $scope.cisterna.unidadMedida;
... ... @@ -60,38 +62,12 @@ angular.module('focaAbmVehiculo')
60 62 focaAbmVehiculoService.guardarCisterna($scope.cisterna).then(function(){
61 63 $location.path('/vehiculo/' + $routeParams.idVehiculo);
62 64 });
63   - }, function() {
64   - focaModalService.alert('Código de cisterna existente');
  65 + }, function(err) {
  66 + focaModalService.alert(err);
65 67 });
66 68  
67 69 };
68 70  
69   - // $scope.seleccionarArticulo = function() {
70   - // var modalInstance = $uibModal.open(
71   - // {
72   - // ariaLabelledBy: 'Busqueda de Productos',
73   - // templateUrl: 'modal-busqueda-productos.html',
74   - // controller: 'modalBusquedaProductosCtrl',
75   - // resolve: {
76   - // parametroProducto: {
77   - // idLista: -1,
78   - // cotizacion: 1,
79   - // simbolo: '$'
80   - // }
81   - // },
82   - // size: 'lg'
83   - // }
84   - // );
85   - // modalInstance.result.then(
86   - // function(producto) {
87   - // $scope.cisterna.cisternaCarga.idProducto = producto.id,
88   - // $scope.cisterna.cisternaCarga.articulo.DetArt = producto.descripcion;
89   - // }, function() {
90   - // // funcion ejecutada cuando se cancela el modal
91   - // }
92   - // );
93   - // };
94   -
95 71 $scope.seleccionarUnidadMedida = function() {
96 72 var modalInstance = $uibModal.open(
97 73 {
... ... @@ -107,19 +83,30 @@ angular.module('focaAbmVehiculo')
107 83 });
108 84 };
109 85  
110   - function existeCodigoCisterna(){
  86 + function validaCodigoCapacidad(){
111 87 return new Promise(function(resolve, reject) {
112 88 focaAbmVehiculoService
113 89 .getCisternadoPorVehiculo($routeParams.idVehiculo)
114 90 .then(function(res){
115   - //Valida si existe numero de unidad
116   - var existe = res.data.filter(function(cisterna) {
117   - return cisterna.codigo === $scope.cisterna.codigo &&
118   - cisterna.id !== $scope.cisterna.id;
  91 +
  92 + var totalCargado = 0;
  93 +
  94 + res.data.forEach(function(cisterna) {
  95 + //SI EL CODIGO YA EXISTE
  96 + if(cisterna.codigo === $scope.cisterna.codigo &&
  97 + cisterna.id !== $scope.cisterna.id){
  98 + reject('Código de cisterna existente');
  99 + }
  100 + if(cisterna.id !== $scope.cisterna.id){
  101 + totalCargado += cisterna.capacidad;
  102 + }
119 103 });
120 104  
121   - if(existe.length){
122   - reject(existe);
  105 + //SI EL TOTAL DE CAPACIDAD DE CISTERNAS ES MAYOR QUE LA DEL VEHICULO
  106 + totalCargado = totalCargado + parseInt($scope.cisterna.capacidad);
  107 + if(totalCargado > $scope.capacidadVechiulo){
  108 + reject('La capacidad total de las cisternas' +
  109 + ' debe ser menor o igual a la del vehiculo');
123 110 } else {
124 111 resolve();
125 112 }
src/views/foca-abm-cisterna-item.html
... ... @@ -59,37 +59,4 @@
59 59 </div>
60 60 </div>
61 61 </div>
62   - <div class="form-group row">
63   - <label class="offset-sm-1 col-sm-2 col-form-label">Carga</label>
64   - <div class="col-sm-4">
65   - <input
66   - class="form-control"
67   - foca-tipo-input
68   - teclado-virtual
69   - ng-model="cisterna.cisternaCarga.cantidad"
70   - readonly
71   - />
72   - </div>
73   - </div>
74   - <div class="form-group row">
75   - <label class="offset-sm-1 col-sm-2 col-form-label">Producto</label>
76   - <div class="col-sm-4 input-group">
77   - <input
78   - ng-model="cisterna.cisternaCarga.articulo.DetArt"
79   - class="form-control"
80   - readonly
81   - />
82   - <!-- <div class="input-group-append">
83   - <button
84   - ladda="searchLoading"
85   - class="btn btn-outline-secondary form-control"
86   - type="button"
87   - ng-click="seleccionarArticulo(13)"
88   - ng-disabled="editar"
89   - >
90   - <i class="fa fa-search" aria-hidden="true"></i>
91   - </button>
92   - </div> -->
93   - </div>
94   - </div>
95 62 </form>
src/views/foca-abm-vehiculos-item.html
... ... @@ -16,7 +16,7 @@
16 16 <input
17 17 class="form-control"
18 18 type="text"
19   - ng-model="vehiculo.transportista.NOM"
  19 + ng-value="transportistaStamp"
20 20 readonly
21 21 />
22 22 </div>
... ... @@ -29,8 +29,8 @@
29 29 type="text"
30 30 teclado-virtual
31 31 ng-model="vehiculo.codigo"
32   - foca-focus="focused == 2"
33   - ng-focus="focused = 2"
  32 + foca-focus="focused == 3"
  33 + ng-focus="focused = 3"
34 34 ng-keypress="next($event.keyCode)"
35 35 />
36 36 </div>
... ... @@ -59,8 +59,23 @@
59 59 teclado-virtual
60 60 ng-model="vehiculo.semi"
61 61 ng-required="true"
62   - foca-focus="focused == 3"
63   - ng-focus="focused = 3"
  62 + foca-focus="focused == 4"
  63 + ng-focus="focused = 4"
  64 + ng-keypress="next($event.keyCode)"
  65 + />
  66 + </div>
  67 + </div>
  68 + <div class="form-group d-flex mb-2 col-md-6">
  69 + <label class="col-form-label col-md-4">Capacidad total</label>
  70 + <div class="input-group col-md-8 pl-0">
  71 + <input
  72 + class="form-control"
  73 + type="text"
  74 + teclado-virtual
  75 + ng-model="vehiculo.capacidad"
  76 + ng-required="true"
  77 + foca-focus="focused == 2"
  78 + ng-focus="focused = 2"
64 79 ng-keypress="next($event.keyCode)"
65 80 />
66 81 </div>
... ... @@ -74,8 +89,6 @@
74 89 <tr>
75 90 <th class="px-5">Código</th>
76 91 <th class="text-right px-5">Capacidad</th>
77   - <th class="px-5">Unidad de Medida</th>
78   - <th class="text-right px-5">Carga</th>
79 92 <th class="text-center px-4">
80 93 <button
81 94 class="btn btn-outline-debo boton-accion"
... ... @@ -89,9 +102,7 @@
89 102 <tbody>
90 103 <tr ng-repeat="cisterna in cisternas | filter:filtros">
91 104 <td ng-bind="cisterna.codigo" class="px-5"></td>
92   - <td ng-bind="cisterna.capacidad" class="text-right px-5"></td>
93   - <td ng-bind="cisterna.unidadMedida.NOM" class="px-5"></td>
94   - <td ng-bind="cisterna.cisternaCarga.cantidad || 0" class="text-right px-5"></td>
  105 + <td ng-bind="cisterna.capacidad + ' ' + cisterna.unidadMedida.NOM" class="text-right px-5"></td>
95 106 <td class="text-center px-4">
96 107 <button
97 108 class="btn btn-outline-dark boton-accion"