Commit 1029ba679b39a59b9662ae813f1b4be5ca76d93e

Authored by Nicolás Guarnieri
Exists in master and in 1 other branch develop

Merge branch 'master' into 'master'

Master

See merge request !4
src/js/controller.js
1 1 angular.module('focaAbmVehiculo')
2 2 .controller('focaAbmVehiculosController', [
3   - '$scope', 'focaAbmVehiculoService', '$location', 'focaModalService',
4   - function($scope, focaAbmVehiculoService, $location, focaModalService) {
5   - focaAbmVehiculoService.getVehiculos().then(function(datos) {
6   - $scope.vehiculos = datos.data;
7   - $scope.vehiculosFiltrados = $scope.vehiculos;
8   - });
  3 + '$scope', 'focaAbmVehiculoService', '$location', 'focaModalService', '$uibModal',
  4 + function($scope, focaAbmVehiculoService, $location, focaModalService, $uibModal) {
  5 + $scope.buscar = function(idTransportista) {
  6 + focaAbmVehiculoService
  7 + .getVehiculosPorTransportista(idTransportista)
  8 + .then(function(datos) {
  9 + $scope.vehiculos = datos.data;
  10 + });
  11 + };
9 12 $scope.editar = function(id) {
10   - $location.path('/vehiculo/' + id);
  13 + $location.path('/vehiculo/' + id + '/' + $scope.idTransportista);
11 14 };
12 15 $scope.solicitarConfirmacion = function(vehiculo) {
13 16 focaModalService.confirm('¿Está seguro que desea borrar el vehiculo ' +
... ... @@ -20,37 +23,104 @@ angular.module('focaAbmVehiculo')
20 23 }
21 24 );
22 25 };
  26 + $scope.seleccionarTransportista = function() {
  27 + var modalInstance = $uibModal.open(
  28 + {
  29 + ariaLabelledBy: 'Busqueda de Transportista',
  30 + templateUrl: 'modal-proveedor.html',
  31 + controller: 'focaModalProveedorCtrl',
  32 + size: 'lg',
  33 + resolve: {
  34 + transportista: function() {
  35 + return true;
  36 + }
  37 + }
  38 + }
  39 + );
  40 + modalInstance.result.then(
  41 + function(transprotista) {
  42 + $scope.idTransportista = transprotista.COD;
  43 + $scope.filtros = transprotista.NOM.trim();
  44 + $scope.buscar(transprotista.COD);
  45 + }, function() {
  46 +
  47 + }
  48 + );
  49 + };
23 50 }
24 51 ])
25 52 .controller('focaAbmVehiculoController', [
26   - '$scope', 'focaAbmVehiculoService', '$routeParams', '$location',
27   - function($scope, focaAbmVehiculoService, $routeParams, $location) {
28   - $scope.transportistas = [];
29   -
30   - focaAbmVehiculoService.getVehiculo($routeParams.id).then(function(res) {
31   - if (res.data.length > 0) {
32   - if(!res.data[0].transportista.COD) {
33   - res.data[0].transportista = '';
34   - }
35   -
36   - $scope.vehiculo = res.data[0];
37   - }
38   -
  53 + '$scope', 'focaAbmVehiculoService', '$routeParams', '$location', '$uibModal',
  54 + 'focaModalService',
  55 + function($scope, focaAbmVehiculoService, $routeParams, $location, $uibModal,
  56 + focaModalService) {
  57 + $scope.nuevo = $routeParams.idVehiculo == 0 ? true : false;
  58 + if($scope.nuevo) {
  59 + focaAbmVehiculoService
  60 + .getTransportistaPorId($routeParams.idTransportista)
  61 + .then(function(res) {
  62 + $scope.vehiculo.idTransportista = res.data.COD;
  63 + $scope.vehiculo.transportista = res.data;
  64 + })
  65 + }
  66 + $scope.vehiculo = {};
  67 + focaAbmVehiculoService.getVehiculo($routeParams.idVehiculo).then(function(res) {
  68 + if(res.data) $scope.vehiculo = res.data;
39 69 });
40   -
41   - focaAbmVehiculoService.getTransportistas().then(function(res) {
42   - $scope.transportistas = res.data;
  70 + focaAbmVehiculoService.getCisternadoPorVehiculo($routeParams.idVehiculo)
  71 + .then(function(res) {
  72 + $scope.cisternas = res.data;
43 73 });
44   -
45 74 $scope.cancelar = function() {
46 75 $location.path('/vehiculo');
47 76 };
  77 + $scope.editar = function(id) {
  78 + $location.path('/vehiculo/' + $routeParams.idVehiculo + '/cisterna/' + id);
  79 + };
48 80 $scope.guardar = function() {
49   - $scope.vehiculo.idTransportista = $scope.vehiculo.transportista.COD;
  81 + if(!$scope.vehiculo.transportista) {
  82 + focaModalService.alert('Elija Transportista');
  83 + return;
  84 + }
50 85 delete $scope.vehiculo.transportista;
51   - focaAbmVehiculoService.guerdarVehiculo($scope.vehiculo).then(function() {
52   - $location.path('/vehiculo');
  86 + focaAbmVehiculoService.guerdarVehiculo($scope.vehiculo).then(function(res) {
  87 + console.log(res.data);
  88 + $location.path('/vehiculo/' + res.data.id + '/' + res.data.idTransportista);
53 89 });
54 90 };
  91 + $scope.solicitarConfirmacionCisterna = function(cisterna) {
  92 + focaModalService.confirm('¿Está seguro que desea borrar la cisterna ' +
  93 + cisterna.id + ' ' + cisterna.codigo + ' ?').then(
  94 + function(data) {
  95 + if(data) {
  96 + focaAbmVehiculoService.deleteCisterna(cisterna.id);
  97 + $scope.cisternas.splice($scope.cisternas.indexOf(cisterna), 1);
  98 + }
  99 + }
  100 + );
  101 + };
  102 + $scope.seleccionarTransportista = function() {
  103 + var modalInstance = $uibModal.open(
  104 + {
  105 + ariaLabelledBy: 'Busqueda de Transportista',
  106 + templateUrl: 'modal-proveedor.html',
  107 + controller: 'focaModalProveedorCtrl',
  108 + size: 'lg',
  109 + resolve: {
  110 + transportista: function() {
  111 + return true;
  112 + }
  113 + }
  114 + }
  115 + );
  116 + modalInstance.result.then(
  117 + function(transprotista) {
  118 + $scope.vehiculo.idTransportista = transprotista.COD;
  119 + $scope.vehiculo.transportista = transprotista;
  120 + }, function() {
  121 +
  122 + }
  123 + );
  124 + };
55 125 }
56 126 ]);
src/js/controllerCisterna.js
... ... @@ -0,0 +1,84 @@
  1 +angular.module('focaAbmVehiculo')
  2 + .controller('focaAbmVehiculoCisternaController', [
  3 + '$scope', 'focaAbmVehiculoService', '$routeParams', '$location', '$uibModal',
  4 + 'focaModalService',
  5 + function($scope, focaAbmVehiculoService, $routeParams, $location, $uibModal,
  6 + focaModalService) {
  7 + $scope.editar = false;
  8 + $scope.cisterna = {
  9 + cisternaCarga: {
  10 + articulo: {}
  11 + }
  12 + };
  13 +
  14 + focaAbmVehiculoService.getCisterna($routeParams.id).then(function(res) {
  15 + if(res.data) {
  16 + $scope.cisterna = res.data;
  17 + $scope.editar = true;
  18 + }else {
  19 + $scope.editar = false;
  20 + }
  21 + });
  22 + $scope.cancelar = function() {
  23 + $location.path('/vehiculo/' + $routeParams.idVehiculo);
  24 + console.log($routeParams.id);
  25 + };
  26 + $scope.guardar = function() {
  27 + if(!$scope.cisterna.unidadMedida) {
  28 + focaModalService.alert('Ingrese unidad de medida');
  29 + return;
  30 + }
  31 + if(!$scope.cisterna.cisternaCarga.articulo) {
  32 + focaModalService.alert('Ingrese producto');
  33 + return;
  34 + }
  35 + $scope.cisterna.idVehiculo = $routeParams.idVehiculo;
  36 + delete $scope.cisterna.unidadMedida;
  37 + delete $scope.cisterna.cisternaCarga.articulo;
  38 + focaAbmVehiculoService.guardarCisterna($scope.cisterna).then(function() {
  39 + $location.path('/vehiculo/' + $routeParams.idVehiculo);
  40 + });
  41 + };
  42 +
  43 + // $scope.seleccionarArticulo = function() {
  44 + // var modalInstance = $uibModal.open(
  45 + // {
  46 + // ariaLabelledBy: 'Busqueda de Productos',
  47 + // templateUrl: 'modal-busqueda-productos.html',
  48 + // controller: 'modalBusquedaProductosCtrl',
  49 + // resolve: {
  50 + // parametroProducto: {
  51 + // idLista: -1,
  52 + // cotizacion: 1,
  53 + // simbolo: '$'
  54 + // }
  55 + // },
  56 + // size: 'lg'
  57 + // }
  58 + // );
  59 + // modalInstance.result.then(
  60 + // function(producto) {
  61 + // $scope.cisterna.cisternaCarga.idProducto = producto.id,
  62 + // $scope.cisterna.cisternaCarga.articulo.DetArt = producto.descripcion;
  63 + // }, function() {
  64 + // // funcion ejecutada cuando se cancela el modal
  65 + // }
  66 + // );
  67 + // };
  68 +
  69 + $scope.seleccionarUnidadMedida = function() {
  70 + var modalInstance = $uibModal.open(
  71 + {
  72 + ariaLabelledBy: 'Busqueda de Unidades de medida',
  73 + templateUrl: 'modal-unidad-medida.html',
  74 + controller: 'focaModalUnidadMedidaCtrl',
  75 + size: 'lg'
  76 + }
  77 + );
  78 + modalInstance.result.then(function(unidaMedida) {
  79 + $scope.cisterna.idUnidadMedida = unidaMedida.ID;
  80 + $scope.cisterna.unidadMedida = unidaMedida;
  81 + });
  82 + }
  83 + }
  84 + ]);
... ... @@ -11,9 +11,27 @@ angular.module('focaAbmVehiculo')
11 11 .config([
12 12 '$routeProvider',
13 13 function($routeProvider) {
14   - $routeProvider.when('/vehiculo/:id', {
  14 + $routeProvider.when('/vehiculo/:idVehiculo/:idTransportista', {
15 15 controller: 'focaAbmVehiculoController',
16 16 templateUrl: 'src/views/foca-abm-vehiculos-item.html'
17 17 });
18 18 }
  19 + ])
  20 + .config([
  21 + '$routeProvider',
  22 + function($routeProvider) {
  23 + $routeProvider.when('/vehiculo/:idVehiculo', {
  24 + controller: 'focaAbmVehiculoController',
  25 + templateUrl: 'src/views/foca-abm-vehiculos-item.html'
  26 + });
  27 + }
  28 + ])
  29 + .config([
  30 + '$routeProvider',
  31 + function($routeProvider) {
  32 + $routeProvider.when('/vehiculo/:idVehiculo/cisterna/:id', {
  33 + controller: 'focaAbmVehiculoCisternaController',
  34 + templateUrl: 'src/views/foca-abm-cisterna-item.html'
  35 + });
  36 + }
19 37 ]);
... ... @@ -15,6 +15,24 @@ angular.module('focaAbmVehiculo')
15 15 },
16 16 deleteVehiculo: function(id) {
17 17 return $http.delete(API_ENDPOINT.URL + '/vehiculo/' + id);
  18 + },
  19 + getCisternadoPorVehiculo: function(idVehiculo) {
  20 + return $http.get(API_ENDPOINT.URL + '/cisterna/listar/' + idVehiculo);
  21 + },
  22 + getCisterna: function(id) {
  23 + return $http.get(API_ENDPOINT.URL + '/cisterna/' + id);
  24 + },
  25 + guardarCisterna: function(cisterna) {
  26 + return $http.post(API_ENDPOINT.URL + '/cisterna/guardar', {cisterna: cisterna});
  27 + },
  28 + deleteCisterna: function(id) {
  29 + return $http.delete(API_ENDPOINT.URL + '/cisterna/borrar/' + id);
  30 + },
  31 + getVehiculosPorTransportista: function(id) {
  32 + return $http.get(API_ENDPOINT.URL + '/vehiculo/transportista/' + id);
  33 + },
  34 + getTransportistaPorId: function(id) {
  35 + return $http.get(API_ENDPOINT.URL + '/transportista/' + id);
18 36 }
19 37 };
20 38 }]);
src/views/foca-abm-cisterna-item.html
... ... @@ -0,0 +1,92 @@
  1 +<h4>Cisterna</h4>
  2 +<form name="formCisterna">
  3 + <div class="form-group row">
  4 + <label class="offset-sm-1 col-sm-2 col-form-label">Código</label>
  5 + <div class="col-sm-4">
  6 + <input
  7 + class="form-control"
  8 + type="text"
  9 + teclado-virtual
  10 + ng-required="true"
  11 + ng-model="cisterna.codigo"
  12 + />
  13 + </div>
  14 + </div>
  15 + <div class="form-group row">
  16 + <label class="offset-sm-1 col-sm-2 col-form-label">Capacidad</label>
  17 + <div class="col-sm-4">
  18 + <input
  19 + class="form-control"
  20 + type="text"
  21 + teclado-virtual
  22 + foca-tipo-input
  23 + ng-model="cisterna.capacidad"
  24 + ng-required="true"
  25 + />
  26 + </div>
  27 + </div>
  28 + <div class="form-group row">
  29 + <label class="offset-sm-1 col-sm-2 col-form-label">Unidad de medida</label>
  30 + <div class="col-sm-4 input-group">
  31 + <input
  32 + ng-model="cisterna.unidadMedida.NOM"
  33 + class="form-control"
  34 + readonly
  35 + />
  36 + <div class="input-group-append">
  37 + <button
  38 + ladda="searchLoading"
  39 + class="btn btn-outline-secondary form-control"
  40 + type="button"
  41 + ng-click="seleccionarUnidadMedida()"
  42 + ng-disabled="editar"
  43 + >
  44 + <i class="fa fa-search" aria-hidden="true"></i>
  45 + </button>
  46 + </div>
  47 + </div>
  48 + </div>
  49 + <div class="form-group row">
  50 + <label class="offset-sm-1 col-sm-2 col-form-label">Carga</label>
  51 + <div class="col-sm-4">
  52 + <input
  53 + class="form-control"
  54 + foca-tipo-input
  55 + teclado-virtual
  56 + ng-model="cisterna.cisternaCarga.cantidad"
  57 + readonly
  58 + />
  59 + </div>
  60 + </div>
  61 + <div class="form-group row">
  62 + <label class="offset-sm-1 col-sm-2 col-form-label">Producto</label>
  63 + <div class="col-sm-4 input-group">
  64 + <input
  65 + ng-model="cisterna.cisternaCarga.articulo.DetArt"
  66 + class="form-control"
  67 + readonly
  68 + />
  69 + <!-- <div class="input-group-append">
  70 + <button
  71 + ladda="searchLoading"
  72 + class="btn btn-outline-secondary form-control"
  73 + type="button"
  74 + ng-click="seleccionarArticulo(13)"
  75 + ng-disabled="editar"
  76 + >
  77 + <i class="fa fa-search" aria-hidden="true"></i>
  78 + </button>
  79 + </div> -->
  80 + </div>
  81 + </div>
  82 + <div class="form-group row">
  83 + <div class="col-sm-7 text-right">
  84 + <button
  85 + class="btn btn-primary"
  86 + ng-click="guardar()"
  87 + ng-disabled="!formCisterna.$valid"
  88 + >Guardar</button>
  89 + <button class="btn btn-default" ng-click="cancelar()">Cancelar</button>
  90 + </div>
  91 + </div>
  92 +</form>
src/views/foca-abm-vehiculos-item.html
... ... @@ -3,57 +3,66 @@
3 3 <input type="hidden" name="id" ng-model="sector.id" />
4 4 <div class="form-group row">
5 5 <label class="offset-sm-1 col-sm-2 col-form-label">Transportista</label>
6   - <div class="col-sm-4">
7   - <select class="form-control" ng-model="vehiculo.transportista"
8   - ng-options="transportista as transportista.NOM for transportista in transportistas"
9   - >
10   - </select>
  6 + <div class="col-sm-4 input-group">
  7 + <input
  8 + class="form-control"
  9 + type="text"
  10 + ng-model="vehiculo.transportista.NOM"
  11 + readonly
  12 + />
  13 + <!-- <div class="input-group-append">
  14 + <button
  15 + class="btn btn-outline-secondary form-control"
  16 + type="button"
  17 + ng-click="seleccionarTransportista()">
  18 + <i class="fa fa-search" aria-hidden="true"></i>
  19 + </button>
  20 + </div> -->
11 21 </div>
12 22 </div>
13 23 <div class="form-group row">
14   - <label class="offset-sm-1 col-sm-2 col-form-label">Tractor</label>
  24 + <label class="offset-sm-1 col-sm-2 col-form-label">Código</label>
15 25 <div class="col-sm-4">
16 26 <input
17 27 class="form-control"
18 28 type="text"
19 29 teclado-virtual
20   - ng-model="vehiculo.tractor"
21   - ng-required="true"
  30 + ng-model="vehiculo.codigo"
22 31 />
23 32 </div>
24 33 </div>
25 34 <div class="form-group row">
26   - <label class="offset-sm-1 col-sm-2 col-form-label">Semi</label>
  35 + <label class="offset-sm-1 col-sm-2 col-form-label">Dominio tractor</label>
27 36 <div class="col-sm-4">
28 37 <input
29 38 class="form-control"
30 39 type="text"
31 40 teclado-virtual
32   - ng-model="vehiculo.semi"
  41 + ng-model="vehiculo.tractor"
33 42 ng-required="true"
34 43 />
35 44 </div>
36 45 </div>
37 46 <div class="form-group row">
38   - <label class="offset-sm-1 col-sm-2 col-form-label">Capacidad</label>
  47 + <label class="offset-sm-1 col-sm-2 col-form-label">Dominio semi</label>
39 48 <div class="col-sm-4">
40 49 <input
41 50 class="form-control"
42 51 type="text"
43 52 teclado-virtual
44   - ng-model="vehiculo.capacidad"
  53 + ng-model="vehiculo.semi"
45 54 ng-required="true"
46 55 />
47 56 </div>
48 57 </div>
49 58 <div class="form-group row">
50   - <label class="offset-sm-1 col-sm-2 col-form-label">Cisternado</label>
  59 + <label class="offset-sm-1 col-sm-2 col-form-label">Capacidad</label>
51 60 <div class="col-sm-4">
52 61 <input
53 62 class="form-control"
54 63 type="text"
55 64 teclado-virtual
56   - ng-model="vehiculo.cisternado"
  65 + ng-model="vehiculo.capacidad"
57 66 ng-required="true"
58 67 />
59 68 </div>
... ... @@ -69,8 +78,43 @@
69 78 </div>
70 79 </div>
71 80 </form>
72   -<a href="#!/" title="Salir"
73   - class="btn btn-secondary btn-block float-right col-md-2"
74   ->
75   - Salir
76   -</a>
77 81 \ No newline at end of file
  82 +<div class="col-12" ng-show="!nuevo">
  83 + <h4>Cisternas</h4>
  84 + <table class="table table-sm table-striped table-dark">
  85 + <thead>
  86 + <tr>
  87 + <th>Código</th>
  88 + <th>Unidad de Medida</th>
  89 + <th>Capacidad</th>
  90 + <th>Carga</th>
  91 + <th class="text-center">
  92 + <button class="btn btn-default boton-accion" ng-click="editar(0)">
  93 + <i class="fa fa-plus"></i>
  94 + </button>
  95 + </th>
  96 + </tr>
  97 + </thead>
  98 + <tbody>
  99 + <tr ng-repeat="cisterna in cisternas | filter:filtros">
  100 + <td ng-bind="cisterna.id"></td>
  101 + <td ng-bind="cisterna.unidadMedida.NOM"></td>
  102 + <td ng-bind="cisterna.capacidad"></td>
  103 + <td ng-bind="cisterna.cisternaCarga.cantidad || 0"></td>
  104 + <td class="text-center">
  105 + <button
  106 + class="btn btn-default boton-accion"
  107 + ng-click="editar(cisterna.id)"
  108 + >
  109 + <i class="fa fa-pencil"></i>
  110 + </button>
  111 + <button
  112 + class="btn btn-default boton-accion"
  113 + ng-click="solicitarConfirmacionCisterna(cisterna)"
  114 + >
  115 + <i class="fa fa-trash"></i>
  116 + </button>
  117 + </td>
  118 + </tr>
  119 + </body>
  120 + </table>
  121 +</div>
src/views/foca-abm-vehiculos-listado.html
1 1 <div class="col-12">
2 2 <h4>Vehiculos</h4>
3   - <div class="form-group">
  3 + <div class="col-4 form-group input-group">
  4 + <input
  5 + class="form-control form-control-sm"
  6 + ng-model="filtros"
  7 + placeholder="Transportista"
  8 + />
  9 + <div class="input-group-append">
  10 + <button
  11 + class="btn btn-outline-secondary form-control-sm"
  12 + ng-click="seleccionarTransportista()"
  13 + ><i class="fa fa-search" aria-hidden="true"></i></button>
  14 + </div>
  15 + </div>
  16 + <!-- <div class="col-6 form-group">
4 17 <input
5 18 type="text"
6 19 teclado-virtual
... ... @@ -8,27 +21,28 @@
8 21 placeholder="Búsqueda"
9 22 ng-model="filtros"
10 23 />
11   - </div>
  24 + </div> -->
12 25 <table class="table table-sm table-striped table-dark">
13 26 <thead>
14 27 <tr>
15 28 <th>Código</th>
16   - <th>Transportista</th>
17 29 <th>Tractor</th>
18 30 <th>Semi</th>
19 31 <th>Capacidad</th>
20 32 <th>Cisternado</th>
21 33 <th class="text-center">
22   - <button class="btn btn-default boton-accion" ng-click="editar(0)">
23   - <i class="fa fa-plus"></i>
  34 + <button
  35 + ng-disabled="!idTransportista"
  36 + class="btn btn-default boton-accion"
  37 + ng-click="editar(0)"
  38 + ><i class="fa fa-plus"></i>
24 39 </button>
25 40 </th>
26 41 </tr>
27 42 </thead>
28 43 <tbody>
29   - <tr ng-repeat="vehiculo in vehiculosFiltrados | filter:filtros">
  44 + <tr ng-repeat="vehiculo in vehiculos | filter:filtros">
30 45 <td ng-bind="vehiculo.id"></td>
31   - <td ng-bind="vehiculo.transportista.NOM || 'No tiene'"></td>
32 46 <td ng-bind="vehiculo.tractor"></td>
33 47 <td ng-bind="vehiculo.semi"></td>
34 48 <td ng-bind="vehiculo.capacidad"></td>