Commit 4c0293733ba3ac773b9543fdfe250fb51e3cf1b3
1 parent
599b49f2f7
Exists in
master
arreglos para demo
Showing
3 changed files
with
26 additions
and
25 deletions
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', | 3 | '$scope', 'focaAbmVehiculoService', '$location', 'focaModalService', |
4 | function($scope, focaAbmVehiculoService, $location, focaModalService) { | 4 | function($scope, focaAbmVehiculoService, $location, focaModalService) { |
5 | focaAbmVehiculoService.getVehiculos().then(function(datos) { | 5 | focaAbmVehiculoService.getVehiculos().then(function(datos) { |
6 | $scope.vehiculos = datos.data; | 6 | $scope.vehiculos = datos.data; |
7 | $scope.vehiculosFiltrados = $scope.vehiculos; | 7 | $scope.vehiculosFiltrados = $scope.vehiculos; |
8 | }); | 8 | }); |
9 | $scope.editar = function(id) { | 9 | $scope.editar = function(id) { |
10 | $location.path('/vehiculo/' + id); | 10 | $location.path('/vehiculo/' + id); |
11 | }; | 11 | }; |
12 | $scope.solicitarConfirmacion = function(vehiculo) { | 12 | $scope.solicitarConfirmacion = function(vehiculo) { |
13 | focaModalService.confirm('¿Está seguro que desea borrar el vehiculo ' + | 13 | focaModalService.confirm('¿Está seguro que desea borrar el vehiculo ' + |
14 | vehiculo.id + ' ' + vehiculo.tractor + ' ?').then( | 14 | vehiculo.id + ' ' + vehiculo.tractor + ' ?').then( |
15 | function(data) { | 15 | function(data) { |
16 | if(data) { | 16 | if(data) { |
17 | focaAbmVehiculoService.deleteVehiculo(vehiculo.id); | 17 | focaAbmVehiculoService.deleteVehiculo(vehiculo.id); |
18 | $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); | 18 | $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); |
19 | } | 19 | } |
20 | } | 20 | } |
21 | ); | 21 | ); |
22 | }; | 22 | }; |
23 | } | 23 | } |
24 | ]) | 24 | ]) |
25 | .controller('focaAbmVehiculoController', [ | 25 | .controller('focaAbmVehiculoController', [ |
26 | '$scope', 'focaAbmVehiculoService', '$routeParams', '$location', | 26 | '$scope', 'focaAbmVehiculoService', '$routeParams', '$location', |
27 | function($scope, focaAbmVehiculoService, $routeParams, $location) { | 27 | function($scope, focaAbmVehiculoService, $routeParams, $location) { |
28 | $scope.transportistas = []; | ||
29 | |||
28 | focaAbmVehiculoService.getVehiculo($routeParams.id).then(function(res) { | 30 | focaAbmVehiculoService.getVehiculo($routeParams.id).then(function(res) { |
29 | if(!res.data[0].transportista.COD) { | 31 | if (res.data.length > 0) { |
30 | res.data[0].transportista = ''; | 32 | if(!res.data[0].transportista.COD) { |
33 | res.data[0].transportista = ''; | ||
34 | } | ||
35 | |||
36 | $scope.vehiculo = res.data[0]; | ||
31 | } | 37 | } |
32 | $scope.vehiculo = res.data[0]; | 38 | |
33 | }); | 39 | }); |
40 | |||
34 | focaAbmVehiculoService.getTransportistas().then(function(res) { | 41 | focaAbmVehiculoService.getTransportistas().then(function(res) { |
35 | $scope.transportistas = res.data; | 42 | $scope.transportistas = res.data; |
36 | }); | 43 | }); |
44 | |||
37 | $scope.cancelar = function() { | 45 | $scope.cancelar = function() { |
38 | $location.path('/vehiculo'); | 46 | $location.path('/vehiculo'); |
39 | }; | 47 | }; |
40 | $scope.guardar = function() { | 48 | $scope.guardar = function() { |
41 | $scope.vehiculo.idTransportista = $scope.vehiculo.transportista.COD; | 49 | $scope.vehiculo.idTransportista = $scope.vehiculo.transportista.COD; |
42 | delete $scope.vehiculo.transportista; | 50 | delete $scope.vehiculo.transportista; |
43 | focaAbmVehiculoService.guerdarVehiculo($scope.vehiculo).then(function() { | 51 | focaAbmVehiculoService.guerdarVehiculo($scope.vehiculo).then(function() { |
44 | $location.path('/vehiculo'); | 52 | $location.path('/vehiculo'); |
45 | }); | 53 | }); |
46 | }; | 54 | }; |
47 | } | 55 | } |
48 | ]); | 56 | ]); |
49 | 57 |
src/views/foca-abm-vehiculos-item.html
1 | <h4>Sectores</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"> | 6 | <div class="col-sm-4"> |
7 | <input | 7 | <select class="form-control" ng-model="vehiculo.transportista" |
8 | class="form-control" | 8 | ng-options="transportista as transportista.NOM for transportista in transportistas" |
9 | type="text" | 9 | > |
10 | teclado-virtual | 10 | </select> |
11 | ng-model="vehiculo.transportista" | ||
12 | ng-model-options="{allowInvalid: false}" | ||
13 | uib-typeahead="transportista as transportista.COD + ' ' + | ||
14 | transportista.NOM for transportista in transportistas | filter:$viewValue" | ||
15 | /> | ||
16 | </div> | ||
17 | </div> | ||
18 | <div class="form-group row"> | ||
19 | <label class="offset-sm-1 col-sm-2 col-form-label">Código</label> | ||
20 | <div class="col-sm-4"> | ||
21 | <input | ||
22 | class="form-control" | ||
23 | type="text" | ||
24 | teclado-virtual | ||
25 | ng-model="vehiculo.id" | ||
26 | readonly | ||
27 | /> | ||
28 | </div> | 11 | </div> |
29 | </div> | 12 | </div> |
30 | <div class="form-group row"> | 13 | <div class="form-group row"> |
31 | <label class="offset-sm-1 col-sm-2 col-form-label">Tractor</label> | 14 | <label class="offset-sm-1 col-sm-2 col-form-label">Tractor</label> |
32 | <div class="col-sm-4"> | 15 | <div class="col-sm-4"> |
33 | <input | 16 | <input |
34 | class="form-control" | 17 | class="form-control" |
35 | type="text" | 18 | type="text" |
36 | teclado-virtual | 19 | teclado-virtual |
37 | ng-model="vehiculo.tractor" | 20 | ng-model="vehiculo.tractor" |
38 | ng-required="true" | 21 | ng-required="true" |
39 | /> | 22 | /> |
40 | </div> | 23 | </div> |
41 | </div> | 24 | </div> |
42 | <div class="form-group row"> | 25 | <div class="form-group row"> |
43 | <label class="offset-sm-1 col-sm-2 col-form-label">Semi</label> | 26 | <label class="offset-sm-1 col-sm-2 col-form-label">Semi</label> |
44 | <div class="col-sm-4"> | 27 | <div class="col-sm-4"> |
45 | <input | 28 | <input |
46 | class="form-control" | 29 | class="form-control" |
47 | type="text" | 30 | type="text" |
48 | teclado-virtual | 31 | teclado-virtual |
49 | ng-model="vehiculo.semi" | 32 | ng-model="vehiculo.semi" |
50 | ng-required="true" | 33 | ng-required="true" |
51 | /> | 34 | /> |
52 | </div> | 35 | </div> |
53 | </div> | 36 | </div> |
54 | <div class="form-group row"> | 37 | <div class="form-group row"> |
55 | <label class="offset-sm-1 col-sm-2 col-form-label">Capacidad</label> | 38 | <label class="offset-sm-1 col-sm-2 col-form-label">Capacidad</label> |
56 | <div class="col-sm-4"> | 39 | <div class="col-sm-4"> |
57 | <input | 40 | <input |
58 | class="form-control" | 41 | class="form-control" |
59 | type="text" | 42 | type="text" |
60 | teclado-virtual | 43 | teclado-virtual |
61 | ng-model="vehiculo.capacidad" | 44 | ng-model="vehiculo.capacidad" |
62 | ng-required="true" | 45 | ng-required="true" |
63 | /> | 46 | /> |
64 | </div> | 47 | </div> |
65 | </div> | 48 | </div> |
66 | <div class="form-group row"> | 49 | <div class="form-group row"> |
67 | <label class="offset-sm-1 col-sm-2 col-form-label">Cisternado</label> | 50 | <label class="offset-sm-1 col-sm-2 col-form-label">Cisternado</label> |
68 | <div class="col-sm-4"> | 51 | <div class="col-sm-4"> |
69 | <input | 52 | <input |
70 | class="form-control" | 53 | class="form-control" |
71 | type="text" | 54 | type="text" |
72 | teclado-virtual | 55 | teclado-virtual |
73 | ng-model="vehiculo.cisternado" | 56 | ng-model="vehiculo.cisternado" |
74 | ng-required="true" | 57 | ng-required="true" |
75 | /> | 58 | /> |
76 | </div> | 59 | </div> |
77 | </div> | 60 | </div> |
78 | <div class="form-group row"> | 61 | <div class="form-group row"> |
79 | <div class="col-sm-7 text-right"> | 62 | <div class="col-sm-7 text-right"> |
80 | <button | 63 | <button |
81 | class="btn btn-primary" | 64 | class="btn btn-primary" |
82 | ng-click="guardar()" | 65 | ng-click="guardar()" |
83 | ng-disabled="!formVehiculo.$valid" | 66 | ng-disabled="!formVehiculo.$valid" |
84 | >Guardar</button> | 67 | >Guardar</button> |
85 | <button class="btn btn-default" ng-click="cancelar()">Cancelar</button> | 68 | <button class="btn btn-default" ng-click="cancelar()">Cancelar</button> |
86 | </div> | 69 | </div> |
87 | </div> | 70 | </div> |
88 | </form> | 71 | </form> |
72 | <a href="#!/" title="Salir" |
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="form-group"> | 3 | <div class="form-group"> |
4 | <input | 4 | <input |
5 | type="text" | 5 | type="text" |
6 | teclado-virtual | 6 | teclado-virtual |
7 | class="form-control form-control-sm" | 7 | class="form-control form-control-sm" |
8 | placeholder="Búsqueda" | 8 | placeholder="Búsqueda" |
9 | ng-model="filtros" | 9 | ng-model="filtros" |
10 | /> | 10 | /> |
11 | </div> | 11 | </div> |
12 | <table class="table table-sm table-striped table-dark"> | 12 | <table class="table table-sm table-striped table-dark"> |
13 | <thead> | 13 | <thead> |
14 | <tr> | 14 | <tr> |
15 | <th>Código</th> | 15 | <th>Código</th> |
16 | <th>Transportista</th> | 16 | <th>Transportista</th> |
17 | <th>Tractor</th> | 17 | <th>Tractor</th> |
18 | <th>Capacidad</th> | 18 | <th>Capacidad</th> |
19 | <th class="text-center"> | 19 | <th class="text-center"> |
20 | <button class="btn btn-default boton-accion" ng-click="editar(0)"> | 20 | <button class="btn btn-default boton-accion" ng-click="editar(0)"> |
21 | <i class="fa fa-plus"></i> | 21 | <i class="fa fa-plus"></i> |
22 | </button> | 22 | </button> |
23 | </th> | 23 | </th> |
24 | </tr> | 24 | </tr> |
25 | </thead> | 25 | </thead> |
26 | <tbody> | 26 | <tbody> |
27 | <tr ng-repeat="vehiculo in vehiculosFiltrados | filter:filtros"> | 27 | <tr ng-repeat="vehiculo in vehiculosFiltrados | filter:filtros"> |
28 | <td ng-bind="vehiculo.id"></td> | 28 | <td ng-bind="vehiculo.id"></td> |
29 | <td ng-bind="vehiculo.transportista.NOM || 'No tiene'"></td> | 29 | <td ng-bind="vehiculo.transportista.NOM || 'No tiene'"></td> |
30 | <td ng-bind="vehiculo.tractor"></td> | 30 | <td ng-bind="vehiculo.tractor"></td> |
31 | <td ng-bind="vehiculo.capacidad"></td> | 31 | <td ng-bind="vehiculo.capacidad"></td> |
32 | <td class="text-center"> | 32 | <td class="text-center"> |
33 | <button | 33 | <button |
34 | class="btn btn-default boton-accion" | 34 | class="btn btn-default boton-accion" |
35 | ng-click="editar(vehiculo.id)" | 35 | ng-click="editar(vehiculo.id)" |
36 | > | 36 | > |
37 | <i class="fa fa-pencil"></i> | 37 | <i class="fa fa-pencil"></i> |
38 | </button> | 38 | </button> |
39 | <button | 39 | <button |
40 | class="btn btn-default boton-accion" | 40 | class="btn btn-default boton-accion" |
41 | ng-click="solicitarConfirmacion(vehiculo)" | 41 | ng-click="solicitarConfirmacion(vehiculo)" |
42 | > | 42 | > |
43 | <i class="fa fa-trash"></i> | 43 | <i class="fa fa-trash"></i> |
44 | </button> | 44 | </button> |
45 | </td> | 45 | </td> |
46 | </tr> | 46 | </tr> |
47 | </body> | 47 | </body> |
48 | </table> | 48 | </table> |
49 | <a href="#!/" title="Salir" | ||
50 | class="btn btn-secondary btn-block float-right col-md-2" | ||
51 | > | ||
52 | Salir | ||
53 | </a> | ||
49 | </div> | 54 | </div> |
50 | 55 |