Commit fd7984733c81f7e632bd42ef8e0847f0e0492690
Exists in
master
and in
1 other branch
Merge branch 'master' of http://git.focasoftware.com/npm/foca-abm-vehiculo
# Conflicts: # src/js/controller.js # src/views/foca-abm-vehiculos-item.html
Showing
3 changed files
Show diff stats
src/js/controller.js
1 | angular.module('focaAbmVehiculo') | 1 | angular.module('focaAbmVehiculo') |
2 | .controller('focaAbmVehiculosController', [ | 2 | .controller('focaAbmVehiculosController', [ |
3 | '$scope', 'focaAbmVehiculoService', '$location', 'focaModalService', '$uibModal', | 3 | '$scope', 'focaAbmVehiculoService', '$location', 'focaModalService', '$uibModal', |
4 | function($scope, focaAbmVehiculoService, $location, focaModalService, $uibModal) { | 4 | function($scope, focaAbmVehiculoService, $location, focaModalService, $uibModal) { |
5 | $scope.buscar = function(idTransportista) { | 5 | $scope.buscar = function(idTransportista) { |
6 | focaAbmVehiculoService | 6 | focaAbmVehiculoService |
7 | .getVehiculosPorTransportista(idTransportista) | 7 | .getVehiculosPorTransportista(idTransportista) |
8 | .then(function(datos) { | 8 | .then(function(datos) { |
9 | $scope.vehiculos = datos.data; | 9 | $scope.vehiculos = datos.data; |
10 | }); | 10 | }); |
11 | }; | 11 | }; |
12 | $scope.editar = function(id) { | 12 | $scope.editar = function(id) { |
13 | $location.path('/vehiculo/' + id); | 13 | $location.path('/vehiculo/' + id); |
14 | }; | 14 | }; |
15 | $scope.solicitarConfirmacion = function(vehiculo) { | 15 | $scope.solicitarConfirmacion = function(vehiculo) { |
16 | focaModalService.confirm('¿Está seguro que desea borrar el vehiculo ' + | 16 | focaModalService.confirm('¿Está seguro que desea borrar el vehiculo ' + |
17 | vehiculo.id + ' ' + vehiculo.tractor + ' ?').then( | 17 | vehiculo.id + ' ' + vehiculo.tractor + ' ?').then( |
18 | function(data) { | 18 | function(data) { |
19 | if(data) { | 19 | if(data) { |
20 | focaAbmVehiculoService.deleteVehiculo(vehiculo.id); | 20 | focaAbmVehiculoService.deleteVehiculo(vehiculo.id); |
21 | $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); | 21 | $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); |
22 | } | 22 | } |
23 | } | 23 | } |
24 | ); | 24 | ); |
25 | }; | 25 | }; |
26 | $scope.seleccionarTransportista = function() { | 26 | $scope.seleccionarTransportista = function() { |
27 | var modalInstance = $uibModal.open( | 27 | var modalInstance = $uibModal.open( |
28 | { | ||
29 | ariaLabelledBy: 'Busqueda de Transportista', | ||
28 | { | 30 | templateUrl: 'modal-proveedor.html', |
29 | ariaLabelledBy: 'Busqueda de Transportista', | 31 | controller: 'focaModalProveedorCtrl', |
30 | templateUrl: 'modal-proveedor.html', | 32 | size: 'lg', |
33 | resolve: { | ||
34 | transportista: function() { | ||
35 | return true; | ||
36 | } | ||
31 | controller: 'focaModalProveedorCtrl', | 37 | } |
32 | size: 'lg', | 38 | } |
33 | resolve: { | 39 | ); |
40 | modalInstance.result.then( | ||
34 | transportista: function() { | 41 | function(transprotista) { |
35 | return true; | 42 | $scope.buscar(transprotista.COD); |
36 | } | 43 | $scope.filtros = transprotista.NOM.trim(); |
44 | }, function() { | ||
37 | } | 45 | |
38 | } | 46 | } |
39 | ); | 47 | ); |
40 | modalInstance.result.then( | 48 | }; |
41 | function(transprotista) { | 49 | } |
42 | $scope.buscar(transprotista.COD); | 50 | ]) |
43 | $scope.filtros = transprotista.NOM.trim(); | 51 | .controller('focaAbmVehiculoController', [ |
44 | }, function() { | 52 | '$scope', 'focaAbmVehiculoService', '$routeParams', '$location', '$uibModal', |
45 | 53 | 'focaModalService', | |
46 | } | 54 | function($scope, focaAbmVehiculoService, $routeParams, $location, $uibModal, |
47 | ); | 55 | focaModalService) { |
48 | }; | 56 | $scope.nuevo = $routeParams.idVehiculo == 0 ? true : false; |
49 | } | 57 | $scope.vehiculo = {}; |
50 | ]) | 58 | focaAbmVehiculoService.getVehiculo($routeParams.idVehiculo).then(function(res) { |
51 | .controller('focaAbmVehiculoController', [ | 59 | if(res.data) $scope.vehiculo = res.data; |
52 | '$scope', 'focaAbmVehiculoService', '$routeParams', '$location', '$uibModal', | 60 | }); |
53 | 'focaModalService', | 61 | focaAbmVehiculoService.getCisternadoPorVehiculo($routeParams.idVehiculo) |
54 | function($scope, focaAbmVehiculoService, $routeParams, $location, $uibModal, | 62 | .then(function(res) { |
55 | focaModalService) { | 63 | $scope.cisternas = res.data; |
56 | $scope.nuevo = $routeParams.idVehiculo == 0 ? true : false; | 64 | }); |
57 | $scope.vehiculo = {}; | 65 | $scope.cancelar = function() { |
58 | focaAbmVehiculoService.getVehiculo($routeParams.idVehiculo).then(function(res) { | 66 | $location.path('/vehiculo'); |
59 | if(res.data) $scope.vehiculo = res.data; | 67 | }; |
60 | }); | 68 | $scope.editar = function(id) { |
61 | focaAbmVehiculoService.getCisternadoPorVehiculo($routeParams.idVehiculo) | 69 | $location.path('/vehiculo/' + $routeParams.idVehiculo + '/cisterna/' + id); |
62 | .then(function(res) { | 70 | }; |
63 | $scope.cisternas = res.data; | 71 | $scope.guardar = function() { |
64 | }); | 72 | if(!$scope.vehiculo.transportista){ |
65 | $scope.cancelar = function() { | 73 | focaModalService.alert('Elija Transportista'); |
66 | $location.path('/vehiculo'); | 74 | return; |
67 | }; | 75 | } |
68 | $scope.editar = function(id) { | 76 | delete $scope.vehiculo.transportista; |
69 | $location.path('/vehiculo/' + $routeParams.idVehiculo + '/cisterna/' + id); | 77 | focaAbmVehiculoService.guerdarVehiculo($scope.vehiculo).then(function(res) { |
70 | }; | 78 | $location.path('/vehiculo/' + res.data.id); |
71 | $scope.guardar = function() { | 79 | }); |
72 | if(!$scope.vehiculo.transportista){ | 80 | }; |
73 | focaModalService.alert('Elija Transportista'); | 81 | $scope.solicitarConfirmacionCisterna = function(cisterna) { |
74 | return; | 82 | focaModalService.confirm('¿Está seguro que desea borrar la cisterna ' + |
75 | } | 83 | cisterna.id + ' ' + cisterna.codigo + ' ?').then( |
76 | delete $scope.vehiculo.transportista; | 84 | function(data) { |
77 | focaAbmVehiculoService.guerdarVehiculo($scope.vehiculo).then(function(res) { | 85 | if(data) { |
78 | $location.path('/vehiculo/' + res.data.id); | 86 | focaAbmVehiculoService.deleteCisterna(cisterna.id); |
79 | }); | 87 | $scope.cisternas.splice($scope.cisternas.indexOf(cisterna), 1); |
80 | }; | 88 | } |
81 | $scope.solicitarConfirmacionCisterna = function(cisterna) { | 89 | } |
82 | focaModalService.confirm('¿Está seguro que desea borrar la cisterna ' + | 90 | ); |
83 | cisterna.id + ' ' + cisterna.codigo + ' ?').then( | 91 | }; |
84 | function(data) { | 92 | $scope.seleccionarTransportista = function() { |
85 | if(data) { | 93 | var modalInstance = $uibModal.open( |
86 | focaAbmVehiculoService.deleteCisterna(cisterna.id); | 94 | { |
87 | $scope.cisternas.splice($scope.cisternas.indexOf(cisterna), 1); | 95 | ariaLabelledBy: 'Busqueda de Transportista', |
88 | } | 96 | templateUrl: 'modal-proveedor.html', |
89 | } | 97 | controller: 'focaModalProveedorCtrl', |
90 | ); | 98 | size: 'lg', |
91 | }; | 99 | resolve: { |
92 | $scope.seleccionarTransportista = function() { | 100 | transportista: function() { |
93 | var modalInstance = $uibModal.open( | 101 | return true; |
94 | { | 102 | } |
95 | ariaLabelledBy: 'Busqueda de Transportista', | 103 | } |
96 | templateUrl: 'modal-proveedor.html', | 104 | } |
97 | controller: 'focaModalProveedorCtrl', | 105 | ); |
98 | size: 'lg', | 106 | modalInstance.result.then( |
99 | resolve: { | 107 | function(transprotista) { |
100 | transportista: function() { | 108 | $scope.vehiculo.idTransportista = transprotista.COD; |
101 | return true; | 109 | $scope.vehiculo.transportista = transprotista; |
102 | } | 110 | }, function() { |
103 | } | 111 | |
104 | } | 112 | } |
105 | ); | 113 | ); |
106 | modalInstance.result.then( | 114 | }; |
107 | function(transprotista) { | 115 | } |
108 | $scope.vehiculo.idTransportista = transprotista.COD; | 116 | ]); |
109 | $scope.vehiculo.transportista = transprotista; | 117 |
src/views/foca-abm-vehiculos-item.html
1 | <h4>Vehiculo</h4> | 1 | <h4>Vehiculo</h4> |
2 | <form name="formVehiculo"> | 2 | <form name="formVehiculo"> |
3 | <input type="hidden" name="id" ng-model="sector.id" /> | 3 | <input type="hidden" name="id" ng-model="sector.id" /> |
4 | <div class="form-group row"> | 4 | <div class="form-group row"> |
5 | <label class="offset-sm-1 col-sm-2 col-form-label">Transportista</label> | 5 | <label class="offset-sm-1 col-sm-2 col-form-label">Transportista</label> |
6 | <div class="col-sm-4 input-group"> | 6 | <div class="col-sm-4 input-group"> |
7 | <input | 7 | <input |
8 | class="form-control" | 8 | class="form-control" |
9 | type="text" | 9 | type="text" |
10 | ng-model="vehiculo.transportista.NOM" | 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> | ||
21 | </div> | ||
22 | </div> | ||
23 | <div class="form-group row"> | ||
24 | <label class="offset-sm-1 col-sm-2 col-form-label">Código</label> | ||
25 | <div class="col-sm-4"> | ||
26 | <input | ||
27 | class="form-control" | ||
28 | type="text" | 11 | readonly |
29 | teclado-virtual | 12 | /> |
30 | ng-model="vehiculo.codigo" | 13 | <div class="input-group-append"> |
31 | /> | 14 | <button |
32 | </div> | 15 | class="btn btn-outline-secondary form-control" |
33 | </div> | 16 | type="button" |
34 | <div class="form-group row"> | 17 | ng-click="seleccionarTransportista()"> |
35 | <label class="offset-sm-1 col-sm-2 col-form-label">Tractor</label> | 18 | <i class="fa fa-search" aria-hidden="true"></i> |
36 | <div class="col-sm-4"> | 19 | </button> |
37 | <input | 20 | </div> |
38 | class="form-control" | 21 | </div> |
39 | type="text" | 22 | </div> |
40 | teclado-virtual | 23 | <div class="form-group row"> |
41 | ng-model="vehiculo.tractor" | 24 | <label class="offset-sm-1 col-sm-2 col-form-label">Código</label> |
42 | ng-required="true" | 25 | <div class="col-sm-4"> |
43 | /> | 26 | <input |
44 | </div> | 27 | class="form-control" |
45 | </div> | 28 | type="text" |
46 | <div class="form-group row"> | 29 | teclado-virtual |
47 | <label class="offset-sm-1 col-sm-2 col-form-label">Semi</label> | 30 | ng-model="vehiculo.codigo" |
48 | <div class="col-sm-4"> | 31 | /> |
49 | <input | 32 | </div> |
50 | class="form-control" | 33 | </div> |
51 | type="text" | 34 | <div class="form-group row"> |
52 | teclado-virtual | 35 | <label class="offset-sm-1 col-sm-2 col-form-label">Tractor</label> |
53 | ng-model="vehiculo.semi" | 36 | <div class="col-sm-4"> |
54 | ng-required="true" | 37 | <input |
55 | /> | 38 | class="form-control" |
56 | </div> | 39 | type="text" |
57 | </div> | 40 | teclado-virtual |
58 | <div class="form-group row"> | 41 | ng-model="vehiculo.tractor" |
59 | <label class="offset-sm-1 col-sm-2 col-form-label">Capacidad</label> | 42 | ng-required="true" |
60 | <div class="col-sm-4"> | 43 | /> |
61 | <input | 44 | </div> |
62 | class="form-control" | 45 | </div> |
63 | type="text" | 46 | <div class="form-group row"> |
64 | teclado-virtual | 47 | <label class="offset-sm-1 col-sm-2 col-form-label">Semi</label> |
65 | ng-model="vehiculo.capacidad" | 48 | <div class="col-sm-4"> |
66 | ng-required="true" | 49 | <input |
67 | /> | 50 | class="form-control" |
68 | </div> | 51 | type="text" |
69 | </div> | 52 | teclado-virtual |
70 | <div class="form-group row"> | 53 | ng-model="vehiculo.semi" |
71 | <div class="col-sm-7 text-right"> | 54 | ng-required="true" |
72 | <button | 55 | /> |
73 | class="btn btn-primary" | 56 | </div> |
74 | ng-click="guardar()" | 57 | </div> |
75 | ng-disabled="!formVehiculo.$valid" | 58 | <div class="form-group row"> |
76 | >Guardar</button> | 59 | <label class="offset-sm-1 col-sm-2 col-form-label">Capacidad</label> |
77 | <button class="btn btn-default" ng-click="cancelar()">Cancelar</button> | 60 | <div class="col-sm-4"> |
78 | </div> | 61 | <input |
79 | </div> | 62 | class="form-control" |
80 | </form> | 63 | type="text" |
81 | <div class="col-12" ng-show="!nuevo"> | 64 | teclado-virtual |
82 | <h4>Cisternas</h4> | 65 | ng-model="vehiculo.capacidad" |
83 | <table class="table table-sm table-striped table-dark"> | 66 | ng-required="true" |
84 | <thead> | 67 | /> |
85 | <tr> | 68 | </div> |
86 | <th>Código</th> | 69 | </div> |
87 | <th>Unidad de Medida</th> | 70 | <div class="form-group row"> |
88 | <th>Capacidad</th> | 71 | <div class="col-sm-7 text-right"> |
72 | <button | ||
73 | class="btn btn-primary" | ||
74 | ng-click="guardar()" | ||
75 | ng-disabled="!formVehiculo.$valid" | ||
76 | >Guardar</button> | ||
89 | <th>Carga</th> | 77 | <button class="btn btn-default" ng-click="cancelar()">Cancelar</button> |
90 | <th class="text-center"> | 78 | </div> |
91 | <button class="btn btn-default boton-accion" ng-click="editar(0)"> | 79 | </div> |
92 | <i class="fa fa-plus"></i> | 80 | </form> |
93 | </button> | 81 | <div class="col-12" ng-show="!nuevo"> |
94 | </th> | 82 | <h4>Cisternas</h4> |
95 | </tr> | 83 | <table class="table table-sm table-striped table-dark"> |
96 | </thead> | 84 | <thead> |
97 | <tbody> | 85 | <tr> |
98 | <tr ng-repeat="cisterna in cisternas | filter:filtros"> | 86 | <th>Código</th> |
99 | <td ng-bind="cisterna.id"></td> | 87 | <th>Unidad de Medida</th> |
100 | <td ng-bind="cisterna.unidadMedida.NOM"></td> | 88 | <th>Capacidad</th> |
101 | <td ng-bind="cisterna.capacidad"></td> | 89 | <th>Carga</th> |
102 | <td ng-bind="cisterna.cisternaCarga.cantidad || 0"></td> | 90 | <th class="text-center"> |
103 | <td class="text-center"> | 91 | <button class="btn btn-default boton-accion" ng-click="editar(0)"> |
104 | <button | 92 | <i class="fa fa-plus"></i> |
105 | class="btn btn-default boton-accion" | 93 | </button> |
106 | ng-click="editar(cisterna.id)" | 94 | </th> |
107 | > | 95 | </tr> |
108 | <i class="fa fa-pencil"></i> | 96 | </thead> |
109 | </button> | 97 | <tbody> |
110 | <button | 98 | <tr ng-repeat="cisterna in cisternas | filter:filtros"> |
111 | class="btn btn-default boton-accion" | 99 | <td ng-bind="cisterna.id"></td> |
112 | ng-click="solicitarConfirmacionCisterna(cisterna)" | 100 | <td ng-bind="cisterna.unidadMedida.NOM"></td> |
113 | > | 101 | <td ng-bind="cisterna.capacidad"></td> |
114 | <i class="fa fa-trash"></i> | 102 | <td ng-bind="cisterna.cisternaCarga.cantidad || 0"></td> |
115 | </button> | 103 | <td class="text-center"> |
116 | </td> | 104 | <button |
src/views/foca-abm-vehiculos-listado.html
1 | <div class="col-12"> | 1 | <div class="col-12"> |
2 | <h4>Vehiculos</h4> | 2 | <h4>Vehiculos</h4> |
3 | <div class="col-4 form-group input-group"> | 3 | <div class="col-4 form-group input-group"> |
4 | <input | 4 | <input |
5 | class="form-control form-control-sm" | 5 | class="form-control form-control-sm" |
6 | ng-model="filtros" | 6 | ng-model="filtros" |
7 | placeholder="Transportista" | 7 | placeholder="Transportista" |
8 | /> | 8 | /> |
9 | <div class="input-group-append"> | 9 | <div class="input-group-append"> |
10 | <button | 10 | <button |
11 | class="btn btn-outline-secondary form-control-sm" | 11 | class="btn btn-outline-secondary form-control-sm" |
12 | ng-click="seleccionarTransportista()" | 12 | ng-click="seleccionarTransportista()" |
13 | ><i class="fa fa-search" aria-hidden="true"></i></button> | 13 | ><i class="fa fa-search" aria-hidden="true"></i></button> |
14 | </div> | 14 | </div> |
15 | </div> | 15 | </div> |
16 | <!-- <div class="col-6 form-group"> | 16 | <!-- <div class="col-6 form-group"> |
17 | <input | 17 | <input |
18 | type="text" | ||
18 | type="text" | 19 | teclado-virtual |
20 | class="form-control form-control-sm" | ||
19 | teclado-virtual | 21 | placeholder="Búsqueda" |
20 | class="form-control form-control-sm" | 22 | ng-model="filtros" |
21 | placeholder="Búsqueda" | 23 | /> |
22 | ng-model="filtros" | 24 | </div> --> |
23 | /> | 25 | <table class="table table-sm table-striped table-dark"> |
24 | </div> --> | 26 | <thead> |
25 | <table class="table table-sm table-striped table-dark"> | 27 | <tr> |
26 | <thead> | 28 | <th>Código</th> |
27 | <tr> | 29 | <th>Tractor</th> |
28 | <th>Código</th> | 30 | <th>Capacidad</th> |
29 | <th>Tractor</th> | 31 | <th class="text-center"> |
30 | <th>Capacidad</th> | 32 | <button class="btn btn-default boton-accion" ng-click="editar(0)"> |
33 | <i class="fa fa-plus"></i> | ||
31 | <th class="text-center"> | 34 | </button> |
35 | </th> | ||
32 | <button class="btn btn-default boton-accion" ng-click="editar(0)"> | 36 | </tr> |
33 | <i class="fa fa-plus"></i> | 37 | </thead> |
34 | </button> | 38 | <tbody> |
35 | </th> | 39 | <tr ng-repeat="vehiculo in vehiculos | filter:filtros"> |
36 | </tr> | 40 | <td ng-bind="vehiculo.id"></td> |
37 | </thead> | 41 | <td ng-bind="vehiculo.tractor"></td> |
38 | <tbody> | 42 | <td ng-bind="vehiculo.capacidad"></td> |
39 | <tr ng-repeat="vehiculo in vehiculos | filter:filtros"> | 43 | <td class="text-center"> |
40 | <td ng-bind="vehiculo.id"></td> | 44 | <button |
41 | <td ng-bind="vehiculo.tractor"></td> | 45 | class="btn btn-default boton-accion" |
42 | <td ng-bind="vehiculo.capacidad"></td> | 46 | ng-click="editar(vehiculo.id)" |
43 | <td class="text-center"> | 47 | > |
44 | <button | 48 | <i class="fa fa-pencil"></i> |
45 | class="btn btn-default boton-accion" | 49 | </button> |
46 | ng-click="editar(vehiculo.id)" | 50 | <button |
47 | > | 51 | class="btn btn-default boton-accion" |
48 | <i class="fa fa-pencil"></i> | 52 | ng-click="solicitarConfirmacion(vehiculo)" |
53 | > | ||
54 | <i class="fa fa-trash"></i> | ||
55 | </button> | ||
56 | </td> | ||
57 | </tr> | ||
49 | </button> | 58 | </body> |
50 | <button | 59 | </table> |
51 | class="btn btn-default boton-accion" | 60 | </div> |
52 | ng-click="solicitarConfirmacion(vehiculo)" | 61 |