Commit 05f7ff0a7c414b3f19c3b38938f2c6caa5d6ceb0
Exists in
demo
Merge branch 'facturador' into 'demo'
Facturador(mpuebla) See merge request !26
Showing
5 changed files
Show diff stats
src/js/controller.js
1 | angular.module('focaLogin') | 1 | angular.module('focaLogin') |
2 | .controller('focaLoginController', [ | 2 | .controller('focaLoginController', [ |
3 | '$scope', 'focaLoginService', '$location', '$cookies', 'focaModalService', 'md5', 'APP', | 3 | '$scope', 'focaLoginService', '$location', '$cookies', 'focaModalService', 'md5', 'APP', '$uibModal', |
4 | function ($scope, focaLoginService, $location, $cookies, focaModalService, md5, APP) { | 4 | function ($scope, focaLoginService, $location, $cookies, focaModalService, md5, APP, $uibModal) { |
5 | |||
5 | $scope.paso = 1; | 6 | $scope.paso = 1; |
6 | $scope.hidePassword = true; | 7 | $scope.hidePassword = true; |
8 | $scope.timer = 0; | ||
9 | |||
7 | $scope.enviar = function () { | 10 | $scope.enviar = function () { |
11 | |||
8 | angular.element('#password').blur(); | 12 | angular.element('#password').blur(); |
9 | focaLoginService.login({ | 13 | focaLoginService.login({ |
10 | idUsuario: $scope.usuario.idUsuario, | 14 | idUsuario: $scope.usuario.idUsuario, |
11 | clave: APP != 'facturador' ? md5.createHash($scope.usuario.clave) : | 15 | clave: APP != 'facturador' ? md5.createHash($scope.usuario.clave) : |
12 | $scope.usuario.clave | 16 | $scope.usuario.clave |
13 | }).then(function (datos) { | 17 | }).then(function (datos) { |
18 | |||
14 | if (datos.data.chofer && datos.data.chofer.id) { | 19 | if (datos.data.chofer && datos.data.chofer.id) { |
15 | $cookies.put('chofer', datos.data.chofer.id); | 20 | $cookies.put('chofer', datos.data.chofer.id); |
16 | $cookies.put('nombreUsuario', datos.data.chofer.nombre); | 21 | $cookies.put('nombreUsuario', datos.data.chofer.nombre); |
17 | } else if (datos.data.vendedorCobrador && datos.data.vendedorCobrador.id) { | 22 | } else if (datos.data.vendedorCobrador && datos.data.vendedorCobrador.id) { |
18 | $cookies.put('vendedorCobrador', datos.data.vendedorCobrador.id); | 23 | $cookies.put('vendedorCobrador', datos.data.vendedorCobrador.id); |
19 | $cookies.put('nombreUsuario', datos.data.vendedorCobrador.NOM); | 24 | $cookies.put('nombreUsuario', datos.data.vendedorCobrador.NOM); |
20 | } else if (datos.data.vendedorPlaya) { | 25 | } else if (datos.data.vendedorPlaya) { |
21 | $cookies.put('vendedorPlaya', datos.data.vendedorPlaya.CodVen); | 26 | $cookies.put('vendedorPlaya', datos.data.vendedorPlaya.CodVen); |
22 | $cookies.put('nombreUsuario', datos.data.vendedorPlaya.NomVen.trim()); | 27 | $cookies.put('nombreUsuario', datos.data.vendedorPlaya.NomVen.trim()); |
23 | } else { | 28 | } else { |
24 | focaModalService.alert('Existe un error con el usuario ingresado'); | 29 | focaModalService.alert('Existe un error con el usuario ingresado'); |
25 | return; | 30 | return; |
26 | } | 31 | } |
27 | |||
28 | console.info(datos.data); | ||
29 | $cookies.put('token', datos.data.token); | 32 | $cookies.put('token', datos.data.token); |
30 | $location.path('/'); | 33 | $location.path('/'); |
31 | $scope.$emit('blur'); | 34 | $scope.$emit('blur'); |
32 | }, function (error) { | 35 | }, function (error) { |
36 | |||
33 | if (error.status === 401) { | 37 | if (error.status === 401) { |
34 | focaModalService | 38 | focaModalService |
35 | .alert('El usuario o la contraseña han sido mal introducidos'); | 39 | .alert('El usuario o la contraseña han sido mal introducidos'); |
36 | } | 40 | } |
37 | 41 | ||
38 | if (error.status === -1) { | 42 | if (error.status === -1) { |
39 | focaModalService.alert('Sin servicio'); | 43 | focaModalService.alert('Sin servicio'); |
40 | return; | 44 | return; |
41 | } | 45 | } |
42 | }); | 46 | }); |
43 | }; | 47 | }; |
48 | |||
44 | $scope.irPaso = function (numeroPaso) { | 49 | $scope.irPaso = function (numeroPaso) { |
50 | |||
45 | $scope.paso = numeroPaso; | 51 | $scope.paso = numeroPaso; |
46 | }; | 52 | }; |
53 | |||
54 | $scope.abrirModalConfiguracion = function () { | ||
55 | |||
56 | $scope.timer++; | ||
57 | if ($scope.timer < 5) { return; } | ||
58 | $scope.timer = 0; | ||
59 | |||
60 | $uibModal.open({ | ||
61 | templateUrl: 'modal-configuracion.html', | ||
62 | controller: 'focaModalConfiguracionController', | ||
63 | size: 'md', | ||
64 | backdrop: false, | ||
65 | }); | ||
66 | }; | ||
47 | } | 67 | } |
48 | ]) | 68 | ]) |
49 | .controller('focaLogoutController', [ | 69 | .controller('focaLogoutController', [ |
50 | '$cookies', '$location', | 70 | '$cookies', '$location', |
51 | function ($cookies, $location) { | 71 | function ($cookies, $location) { |
72 | |||
52 | $cookies.remove('chofer'); | 73 | $cookies.remove('chofer'); |
53 | $cookies.remove('vendedorCobrador'); | 74 | $cookies.remove('vendedorCobrador'); |
54 | $cookies.remove('vendedorPlaya'); | 75 | $cookies.remove('vendedorPlaya'); |
55 | $cookies.remove('nombreUsuario'); | 76 | $cookies.remove('nombreUsuario'); |
56 | $cookies.remove('token'); | 77 | $cookies.remove('token'); |
57 | //Cierra ventana | 78 | //Cierra ventana |
58 | window.open('', '_self', ''); //bug fix | 79 | window.open('', '_self', ''); //bug fix |
59 | window.close(); | 80 | window.close(); |
60 | $location.path('/login'); | 81 | $location.path('/login'); |
61 | } | 82 | } |
src/js/controllerConfiguracion.js
File was created | 1 | angular.module('focaLogin') | |
2 | .controller('focaModalConfiguracionController', [ | ||
3 | '$scope', '$uibModalInstance', 'focaLoginService', '$timeout', '$localStorage', | ||
4 | function ($scope, $uibModalInstance, focaLoginService, $timeout, $localStorage) { | ||
5 | |||
6 | $scope.puntosVenta = []; | ||
7 | $scope.impresoras = []; | ||
8 | $scope.selectedPuntoVenta = localStorage.pve ? localStorage.pve : null; | ||
9 | $scope.selectedImpresora = $localStorage.impresoraPVE ? $localStorage.impresoraPVE : null; | ||
10 | $scope.usePlanillaPropia = false; | ||
11 | |||
12 | init(); | ||
13 | |||
14 | function init() { | ||
15 | |||
16 | var promisePuntosVenta = focaLoginService.getAllPuntoVenta(); | ||
17 | var promiseImpresoras = focaLoginService.getAllImpresoras(); | ||
18 | |||
19 | Promise.all([promisePuntosVenta, promiseImpresoras]) | ||
20 | .then(function (res) { | ||
21 | |||
22 | $timeout(function () { | ||
23 | |||
24 | $scope.puntosVenta = res[0].data; | ||
25 | $scope.impresoras = res[1].data; | ||
26 | }); | ||
27 | }) | ||
28 | .catch(function (err) { | ||
29 | console.error(err); | ||
30 | }); | ||
31 | } | ||
32 | |||
33 | $scope.cancel = function () { | ||
34 | |||
35 | $uibModalInstance.dismiss('cancel'); | ||
36 | }; | ||
37 | |||
38 | $scope.acept = function () { | ||
39 | |||
40 | $localStorage.pve = $scope.selectedPuntoVenta ? parseInt($scope.selectedPuntoVenta) : null; | ||
41 | $localStorage.impresoraPVE = $scope.selectedImpresora ? parseInt($scope.selectedImpresora) : null; | ||
42 | $scope.cancel(); | ||
43 | } | ||
44 | } | ||
45 | ]); | ||
46 |
src/js/service.js
1 | angular.module('focaLogin') | 1 | angular.module('focaLogin') |
2 | .factory('focaLoginService', [ | 2 | .factory('focaLoginService', [ |
3 | '$http', 'API_ENDPOINT', 'APP', '$cookies', | 3 | '$http', 'API_ENDPOINT', 'APP', '$cookies', |
4 | function($http, API_ENDPOINT, APP, $cookies) { | 4 | function ($http, API_ENDPOINT, APP, $cookies) { |
5 | return { | 5 | return { |
6 | login: function(usuario) { | 6 | login: function (usuario) { |
7 | var param = ''; | ||
8 | 7 | ||
9 | if (APP) { | 8 | var param = APP ? '/' + APP : ''; |
10 | param = '/' + APP; | 9 | return $http.post(API_ENDPOINT.URL + '/usuario/login' + param, usuario); |
11 | } | ||
12 | |||
13 | return $http.post(API_ENDPOINT.URL + '/usuario/login' + param , usuario); | ||
14 | }, | 10 | }, |
15 | getLoginData: function() { | 11 | getLoginData: function () { |
12 | |||
16 | if ($cookies.get('chofer')) { | 13 | if ($cookies.get('chofer')) { |
17 | return {chofer: $cookies.get('chofer')}; | 14 | return { chofer: $cookies.get('chofer') }; |
18 | } | 15 | } |
19 | 16 | ||
20 | if ($cookies.get('vendedorCobrador')) { | 17 | if ($cookies.get('vendedorCobrador')) { |
21 | return {vendedorCobrador: $cookies.get('vendedorCobrador')}; | 18 | return { vendedorCobrador: $cookies.get('vendedorCobrador') }; |
22 | } | 19 | } |
23 | 20 | ||
24 | if ($cookies.get('vendedorPlaya')) { | 21 | if ($cookies.get('vendedorPlaya')) { |
25 | return {vendedorPlaya: $cookies.get('vendedorPlaya')}; | 22 | return { vendedorPlaya: $cookies.get('vendedorPlaya') }; |
26 | } | 23 | } |
27 | } | 24 | }, |
25 | getAllPuntoVenta: function () { | ||
26 | |||
27 | return $http.get(API_ENDPOINT.URL_AUTOSERVICIO + '/get/puntos-venta'); | ||
28 | }, | ||
29 | getAllImpresoras: function () { | ||
30 | |||
31 | return $http.get(API_ENDPOINT.URL_AUTOSERVICIO + '/get/impresoras'); | ||
32 | }, | ||
33 | getByIdPuntoVenta: function (id) { | ||
34 | |||
35 | return $http.get(API_ENDPOINT.URL_AUTOSERVICIO + '/get/punto-venta/' + id); | ||
36 | }, |
src/views/foca-login.html
1 | <div class="row justify-content-center align-items-center"> | 1 | <div class="row m-0 justify-content-center align-items-center"> |
2 | <div class="col-12 my-2"> | 2 | <div class="col-12 p-0 my-2"> |
3 | <img src="img/logo.png" class="img-login mx-auto d-block"> | 3 | <img |
4 | draggable="false" | ||
5 | ondragstart="return false;" | ||
6 | (contextmenu)="false" | ||
7 | on-mouse-hold="abrirModalConfiguracion" | ||
8 | ng-mouseup="timer = 0" | ||
9 | src="img/logo.png" | ||
10 | class="img-login mx-auto d-block disable-user-select"> | ||
4 | </div> | 11 | </div> |
5 | <div class="col-8 col-sm-6 col-md-4 col-lg-3 my-2 align-self-stretch"> | 12 | <div class="col-8 col-sm-6 col-md-4 col-lg-3 p-0 my-2 align-self-stretch"> |
6 | <div class="bg-gradient-login border-0 rounded shadow-sm text-center"> | 13 | <div class="bg-gradient-login border-0 rounded-lg shadow text-center"> |
7 | <form class="p-3 m-0" name="login"> | 14 | <form class="p-3 m-0" name="login"> |
8 | <div class="pt-3 pb-2 mb-3 border-bottom border-white"> | ||
9 | <span>Ingreso de usuario</span> | ||
10 | </div> | ||
11 | <!-- USUARIO --> | 15 | <!-- USUARIO --> |
12 | <label | 16 | <div class="input-group mt-5 mb-4"> |
13 | for="user" | ||
14 | class="login-small-text m-0"> | ||
15 | Usuario | ||
16 | </label> | ||
17 | <div class="input-group mb-2"> | ||
18 | <input | 17 | <input |
19 | class="form-control form-control-sm rounded-pill text-transform-none" | 18 | class="form-control form-control-sm rounded-pill text-transform-none" |
20 | type="text" | 19 | type="text" |
20 | placeholder="Ingrese su usuario" | ||
21 | id="user" | 21 | id="user" |
22 | ng-model="usuario.idUsuario" | 22 | ng-model="usuario.idUsuario" |
23 | ng-focus="paso = 1" | 23 | ng-focus="paso = 1" |
24 | foca-focus="paso === 1" | 24 | foca-focus="paso === 1" |
25 | ng-keyup="$event.keyCode == 13 && irPaso(2)" | 25 | ng-keyup="$event.keyCode == 13 && irPaso(2)" |
26 | ladda="loginLoading" | 26 | ladda="loginLoading" |
27 | teclado-virtual | 27 | teclado-virtual |
28 | /> | 28 | /> |
29 | </div> | 29 | </div> |
30 | <!-- CONTRASEÑA --> | 30 | <!-- CONTRASEÑA --> |
31 | <label | 31 | <div class="input-group mb-4"> |
32 | for="password" | ||
33 | class="login-small-text m-0"> | ||
34 | Contraseña | ||
35 | </label> | ||
36 | <div class="input-group mb-2"> | ||
37 | <input | 32 | <input |
38 | class="form-control form-control-sm rounded-pill text-transform-none pr-5" | 33 | class="form-control form-control-sm rounded-pill text-transform-none pr-5" |
39 | id="password" | 34 | id="password" |
40 | type="{{hidePassword ? 'password' : 'text'}}" | 35 | type="{{hidePassword ? 'password' : 'text'}}" |
36 | placeholder="Ingrese su contraseña" | ||
41 | ng-model="usuario.clave" | 37 | ng-model="usuario.clave" |
42 | foca-focus="paso == 2" | 38 | foca-focus="paso == 2" |
43 | ng-keyup="$event.keyCode == 13 && enviar()" | 39 | ng-keyup="$event.keyCode == 13 && enviar()" |
44 | ladda="loginLoading" | 40 | ladda="loginLoading" |
45 | teclado-virtual | 41 | teclado-virtual |
46 | /> | 42 | /> |
47 | <div class="input-icon px-3"> | 43 | <div class="input-icon px-3"> |
48 | <div ng-show="!hidePassword" ng-click="hidePassword = !hidePassword"> | 44 | <div ng-show="!hidePassword" ng-click="hidePassword = !hidePassword"> |
49 | <i class="fade-in fa fa-eye"></i> | 45 | <i class="fade-in fa fa-eye"></i> |
50 | </div> | 46 | </div> |
51 | <div ng-show="hidePassword" ng-click="hidePassword = !hidePassword"> | 47 | <div ng-show="hidePassword" ng-click="hidePassword = !hidePassword"> |
52 | <i class="fade-in fa fa-eye-slash"></i> | 48 | <i class="fade-in fa fa-eye-slash"></i> |
53 | </div> | 49 | </div> |
54 | </div> | 50 | </div> |
55 | </div> | 51 | </div> |
56 | <button | 52 | <button |
57 | type="button" | 53 | type="button" |
58 | ng-click="enviar()" | 54 | ng-click="enviar()" |
59 | class="btn btn-primary btn-block my-3" | 55 | class="btn btn-primary btn-sm btn-block mb-3" |
60 | ladda="loginLoading"> | 56 | ladda="loginLoading"> |
61 | Ingresar | 57 | Ingresar |
src/views/modal-configuracion.html
File was created | 1 | <div class="modal-header"> | |
2 | <div class="row w-100"> | ||
3 | <div class="col-lg-6"> | ||
4 | <h5 class="modal-title my-1"><b>Configuración</b></h5> | ||
5 | </div> | ||
6 | </div> | ||
7 | </div> | ||
8 | |||
9 | <form class="modal-body" id="modal-body"> | ||
10 | |||
11 | <div class="row"> | ||
12 | <div class="col-12"> | ||
13 | |||
14 | <p>¿Este punto de venta trabaja con planilla propia?</p> | ||
15 | |||
16 | <!-- RADIO BUTTONS --> | ||
17 | <div class="text-center"> | ||
18 | <div class="disabled form-check form-check-inline"> | ||
19 | <input | ||
20 | class="form-check-input" | ||
21 | type="radio" | ||
22 | id="radio1" | ||
23 | ng-model="usePlanillaPropia" | ||
24 | ng-value="true"> | ||
25 | <label class="form-check-label" for="radio1">Si</label> | ||
26 | </div> | ||
27 | <div class="form-check form-check-inline"> | ||
28 | <input | ||
29 | class="form-check-input" | ||
30 | type="radio" | ||
31 | id="radio2" | ||
32 | ng-model="usePlanillaPropia" | ||
33 | ng-value="false"> | ||
34 | <label class="form-check-label" for="radio2">No</label> | ||
35 | </div> | ||
36 | </div> | ||
37 | <div class="form-group"> | ||
38 | <select | ||
39 | ng-model="selectedPuntoVenta" | ||
40 | class="form-control form-control-sm w-50 mx-auto mt-2"> | ||
41 | <option ng-value="null" selected disabled>Seleccione una opción</option> | ||
42 | <option ng-repeat="ptoVenta in puntosVenta" value="{{ptoVenta.ID}}"> | ||
43 | {{ptoVenta.ID}} {{ptoVenta.NOM}} | ||
44 | </option> | ||
45 | </select> | ||
46 | </div> | ||
47 | </div> | ||
48 | </div> | ||
49 | |||
50 | <div class="row"> | ||
51 | <div class="col-12"> | ||
52 | <p>Salida de impresión de comprobantes</p> | ||
53 | <select | ||
54 | ng-model="selectedImpresora" | ||
55 | class="form-control form-control-sm w-50 mx-auto mt-2"> | ||
56 | <option ng-value="null" selected disabled>Seleccione una opción</option> | ||
57 | <option ng-repeat="imp in impresoras" value="{{imp.PVE}}"> | ||
58 | {{imp.PVE}} {{imp.DES}} | ||
59 | </option> | ||
60 | </select> | ||
61 | </div> | ||
62 | </div> | ||
63 | |||
64 | </form> | ||
65 | |||
66 | <div class="modal-footer py-1"> | ||
67 | <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar | ||
68 | </button> | ||
69 | <button class="btn btn-sm btn-primary" type="button" ng-click="acept()">Aceptar | ||
70 | </button> | ||
71 | </div> | ||
72 |