controllerCisterna.js
3.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
angular.module('focaAbmVehiculo')
.controller('focaAbmVehiculoCisternaController', [
'$scope', 'focaAbmVehiculoService', '$routeParams', '$location', '$uibModal',
'focaModalService',
function($scope, focaAbmVehiculoService, $routeParams, $location, $uibModal,
focaModalService) {
$scope.editar = false;
$scope.cisterna = {
cisternaCarga: {
articulo: {}
}
};
focaAbmVehiculoService.getCisterna($routeParams.id).then(function(res) {
if(res.data) {
$scope.cisterna = res.data;
$scope.editar = true;
}else {
$scope.editar = false;
}
});
$scope.cancelar = function() {
$location.path('/vehiculo/' + $routeParams.idVehiculo);
console.log($routeParams.id);
};
$scope.guardar = function() {
if(!$scope.cisterna.unidadMedida) {
focaModalService.alert('Ingrese unidad de medida');
return;
}
if(!$scope.cisterna.cisternaCarga.articulo) {
focaModalService.alert('Ingrese producto');
return;
}
$scope.cisterna.idVehiculo = $routeParams.idVehiculo;
delete $scope.cisterna.unidadMedida;
delete $scope.cisterna.cisternaCarga.articulo;
focaAbmVehiculoService.guardarCisterna($scope.cisterna).then(function() {
$location.path('/vehiculo/' + $routeParams.idVehiculo);
});
};
// $scope.seleccionarArticulo = function() {
// var modalInstance = $uibModal.open(
// {
// ariaLabelledBy: 'Busqueda de Productos',
// templateUrl: 'modal-busqueda-productos.html',
// controller: 'modalBusquedaProductosCtrl',
// resolve: {
// parametroProducto: {
// idLista: -1,
// cotizacion: 1,
// simbolo: '$'
// }
// },
// size: 'lg'
// }
// );
// modalInstance.result.then(
// function(producto) {
// $scope.cisterna.cisternaCarga.idProducto = producto.id,
// $scope.cisterna.cisternaCarga.articulo.DetArt = producto.descripcion;
// }, function() {
// // funcion ejecutada cuando se cancela el modal
// }
// );
// };
$scope.seleccionarUnidadMedida = function() {
var modalInstance = $uibModal.open(
{
ariaLabelledBy: 'Busqueda de Unidades de medida',
templateUrl: 'modal-unidad-medida.html',
controller: 'focaModalUnidadMedidaCtrl',
size: 'lg'
}
);
modalInstance.result.then(function(unidaMedida) {
$scope.cisterna.idUnidadMedida = unidaMedida.ID;
$scope.cisterna.unidadMedida = unidaMedida;
});
}
}
]);