Commit 9374474ca0961d0b5a671e0a4321acdea5ff4480

Authored by Jose Pinto
1 parent c8541c3de1
Exists in master

espacios

Showing 2 changed files with 5 additions and 4 deletions   Show diff stats
1 /node_modules 1 /node_modules
2 /dist 2 /dist
3 /tmp 3 /tmp
4 package-lock\.json 4 package-lock\.json
5 src/etc/develop.js 5 src/etc/develop.js
6 yarn.lock
6 yarn.lock
src/js/controller.js
1 angular.module('focaAgendarVisita') 1 angular.module('focaAgendarVisita')
2 .controller('focaAgendarVisitaController', [ 2 .controller('focaAgendarVisitaController', [
3 '$scope', 'focaAgendarVisitaService', '$location', '$timeout', 3 '$scope', 'focaAgendarVisitaService', '$location', '$timeout',
4 '$uibModal', 'focaBotoneraLateralService', '$filter', 'focaLoginService', 4 '$uibModal', 'focaBotoneraLateralService', '$filter', 'focaLoginService',
5 'focaModalService', 'focaSeguimientoService', 5 'focaModalService', 'focaSeguimientoService',
6 function($scope, focaAgendarVisitaService, $location, $timeout, 6 function($scope, focaAgendarVisitaService, $location, $timeout,
7 $uibModal, focaBotoneraLateralService, $filter, focaLoginService, 7 $uibModal, focaBotoneraLateralService, $filter, focaLoginService,
8 focaModalService, focaSeguimientoService) { 8 focaModalService, focaSeguimientoService
9 ) {
9 $scope.focused = 0; 10 $scope.focused = 0;
10 $scope.rol = 1; 11 $scope.rol = 1;
11 $scope.visita = {}; 12 $scope.visita = {};
12 $scope.now = new Date(); 13 $scope.now = new Date();
13 $scope.botonera = [ 14 $scope.botonera = [
14 { 15 {
15 label: 'Agendar', 16 label: 'Agendar',
16 image: 'precios-condiciones.png' 17 image: 'precios-condiciones.png'
17 } 18 }
18 ]; 19 ];
19 $timeout(function() { 20 $timeout(function() {
20 focaBotoneraLateralService.showSalir(true); 21 focaBotoneraLateralService.showSalir(true);
21 focaBotoneraLateralService.showPausar(true); 22 focaBotoneraLateralService.showPausar(true);
22 focaBotoneraLateralService.showGuardar(true, $scope.guardar); 23 focaBotoneraLateralService.showGuardar(true, $scope.guardar);
23 }); 24 });
24 25
25 $scope.seleccionarCliente = function() { 26 $scope.seleccionarCliente = function() {
26 var modalInstance = $uibModal.open( 27 var modalInstance = $uibModal.open(
27 { 28 {
28 ariaLabelledBy: 'Busqueda de Cliente', 29 ariaLabelledBy: 'Busqueda de Cliente',
29 templateUrl: 'foca-busqueda-cliente-modal.html', 30 templateUrl: 'foca-busqueda-cliente-modal.html',
30 controller: 'focaBusquedaClienteModalController', 31 controller: 'focaBusquedaClienteModalController',
31 resolve: { 32 resolve: {
32 vendedor: function() { return null; } 33 vendedor: function() { return null; }
33 }, 34 },
34 size: 'lg' 35 size: 'lg'
35 } 36 }
36 ); 37 );
37 modalInstance.result.then( 38 modalInstance.result.then(
38 function(cliente) { 39 function(cliente) {
39 $scope.visita.cliente = cliente; 40 $scope.visita.cliente = cliente;
40 } 41 }
41 ); 42 );
42 }; 43 };
43 $scope.seleccionarVisitante = function() { 44 $scope.seleccionarVisitante = function() {
44 var parametrosModal = { 45 var parametrosModal = {
45 query: '/vendedor-cobrador', 46 query: '/vendedor-cobrador',
46 columnas: [ 47 columnas: [
47 { 48 {
48 propiedad: 'NUM', 49 propiedad: 'NUM',
49 nombre: 'Codigo', 50 nombre: 'Codigo',
50 filtro: { 51 filtro: {
51 nombre: 'rellenarDigitos', 52 nombre: 'rellenarDigitos',
52 parametro: 3 53 parametro: 3
53 } 54 }
54 }, 55 },
55 { 56 {
56 propiedad: 'NOM', 57 propiedad: 'NOM',
57 nombre: 'Nombre' 58 nombre: 'Nombre'
58 } 59 }
59 ], 60 ],
60 titulo:'Búsqueda de vendedores y cobradores', 61 titulo:'Búsqueda de vendedores y cobradores',
61 size: 'md' 62 size: 'md'
62 }; 63 };
63 focaModalService.modal(parametrosModal).then(function(vendedorCobrador) { 64 focaModalService.modal(parametrosModal).then(function(vendedorCobrador) {
64 $scope.visita.visitante = vendedorCobrador; 65 $scope.visita.visitante = vendedorCobrador;
65 }); 66 });
66 }; 67 };
67 68
68 $scope.next = function(key) { 69 $scope.next = function(key) {
69 if (key === 13) $scope.focused ++; 70 if (key === 13) $scope.focused ++;
70 }; 71 };
71 72
72 $scope.guardar = function() { 73 $scope.guardar = function() {
73 var rol; 74 var rol;
74 if($scope.visita.visitante.rol === 1){ 75 if ($scope.visita.visitante.rol === 1) {
75 rol = 'Nota de pedido'; 76 rol = 'Nota de pedido';
76 } else if($scope.visita.visitante.rol === 2){ 77 } else if ($scope.visita.visitante.rol === 2) {
77 rol = 'Cobranza'; 78 rol = 'Cobranza';
78 } else { 79 } else {
79 rol = ($scope.rol === 1) ? 'Nota de pedido' : 'Cobranza'; 80 rol = ($scope.rol === 1) ? 'Nota de pedido' : 'Cobranza';
80 } 81 }
81 82
82 focaAgendarVisitaService 83 focaAgendarVisitaService
83 .guardarVisita({ 84 .guardarVisita({
84 idVisitante: $scope.visita.visitante.NUM, 85 idVisitante: $scope.visita.visitante.NUM,
85 tipoVisitante: ($scope.visita.visitante.rol !== 3) ? 86 tipoVisitante: ($scope.visita.visitante.rol !== 3) ?
86 $scope.visita.visitante.rol : $scope.rol, 87 $scope.visita.visitante.rol : $scope.rol,
87 idCliente: $scope.visita.cliente.cod 88 idCliente: $scope.visita.cliente.cod
88 }) 89 })
89 .then(function(data) { 90 .then(function(data) {
90 focaSeguimientoService.guardarPosicion( 91 focaSeguimientoService.guardarPosicion(
91 rol, 92 rol,
92 data.data.id, 93 data.data.id,
93 $scope.visita.observacion, 94 $scope.visita.observacion,
94 true 95 true
95 ); 96 );
96 }) 97 })
97 .then(function() { 98 .then(function() {
98 $location.path('/'); 99 $location.path('/');
99 }); 100 });
100 }; 101 };
101 } 102 }
102 ]); 103 ]);
103 104