Commit 803b4bbc5dab7d2930c12d7b6d7c1b310efecaa6
1 parent
94a9b3dc92
Exists in
master
and in
1 other branch
Le agrego focus al input que agrega plazos.
Showing
2 changed files
with
6 additions
and
2 deletions
Show diff stats
src/js/controller.js
1 | angular.module('focaModalPrecioCondicion') | 1 | angular.module('focaModalPrecioCondicion') |
2 | .controller('focaModalPrecioCondicionController', | 2 | .controller('focaModalPrecioCondicionController', |
3 | [ | 3 | [ |
4 | '$timeout', | 4 | '$timeout', |
5 | '$filter', | 5 | '$filter', |
6 | '$scope', | 6 | '$scope', |
7 | '$uibModal', | 7 | '$uibModal', |
8 | '$uibModalInstance', | 8 | '$uibModalInstance', |
9 | 'focaModalService', | 9 | 'focaModalService', |
10 | 'focaModalPrecioCondicionService', | 10 | 'focaModalPrecioCondicionService', |
11 | 'idListaPrecio', | 11 | 'idListaPrecio', |
12 | 'idCliente', | 12 | 'idCliente', |
13 | function ( | 13 | function ( |
14 | $timeout, $filter, $scope, $uibModal, $uibModalInstance, | 14 | $timeout, $filter, $scope, $uibModal, $uibModalInstance, |
15 | focaModalService, focaModalPrecioCondicionService, idListaPrecio, idCliente | 15 | focaModalService, focaModalPrecioCondicionService, idListaPrecio, idCliente |
16 | ) { | 16 | ) { |
17 | $scope.plazos = [ | 17 | $scope.plazos = [ |
18 | { | 18 | { |
19 | dias: 0, | 19 | dias: 0, |
20 | idCliente: idCliente, | 20 | idCliente: idCliente, |
21 | activo: true | 21 | activo: true |
22 | } | 22 | } |
23 | ]; | 23 | ]; |
24 | $scope.openModalListaDePrecios = false; | 24 | $scope.openModalListaDePrecios = false; |
25 | $scope.associatedList = true; | 25 | $scope.associatedList = true; |
26 | $scope.listaDePreciosAlternativa = null; | 26 | $scope.listaDePreciosAlternativa = null; |
27 | 27 | ||
28 | onInit(); | 28 | onInit(); |
29 | 29 | ||
30 | function onInit() { | 30 | function onInit() { |
31 | //Metodo para traer la lista de precio asociada al cliente | 31 | //Metodo para traer la lista de precio asociada al cliente |
32 | focaModalPrecioCondicionService.getListaPrecio(idListaPrecio) | 32 | focaModalPrecioCondicionService.getListaPrecio(idListaPrecio) |
33 | .then(function (res) { | 33 | .then(function (res) { |
34 | $scope.listaDePreciosAsociada = res.data[0]; | 34 | $scope.listaDePreciosAsociada = res.data[0]; |
35 | }) | 35 | }) |
36 | .catch(function (e) { console.error(e) }); | 36 | .catch(function (e) { console.error(e) }); |
37 | focaModalPrecioCondicionService.getPlazosByIdCliente(idCliente) | 37 | focaModalPrecioCondicionService.getPlazosByIdCliente(idCliente) |
38 | .then(function (res) { | 38 | .then(function (res) { |
39 | res.data.forEach(function (item) { | 39 | res.data.forEach(function (item) { |
40 | $scope.plazos.push(item); | 40 | $scope.plazos.push(item); |
41 | }); | 41 | }); |
42 | }) | 42 | }) |
43 | .catch(function (e) { console.error(e) }); | 43 | .catch(function (e) { console.error(e) }); |
44 | } | 44 | } |
45 | 45 | ||
46 | //#region Metodos para la lista de precios | 46 | //#region Metodos para la lista de precios |
47 | $scope.openListaDePrecios = function () { | 47 | $scope.openListaDePrecios = function () { |
48 | var datos = null; | 48 | var datos = null; |
49 | focaModalPrecioCondicionService.getAllListaPrecio() | 49 | focaModalPrecioCondicionService.getAllListaPrecio() |
50 | .then(function (res) { | 50 | .then(function (res) { |
51 | datos = res.data; | 51 | datos = res.data; |
52 | focaModalService.modal({ | 52 | focaModalService.modal({ |
53 | titulo: 'Lista de precios', | 53 | titulo: 'Lista de precios', |
54 | data: datos, | 54 | data: datos, |
55 | size: 'md', | 55 | size: 'md', |
56 | columnas: [ | 56 | columnas: [ |
57 | { | 57 | { |
58 | propiedad: 'ID', | 58 | propiedad: 'ID', |
59 | nombre: 'Codigo' | 59 | nombre: 'Codigo' |
60 | }, | 60 | }, |
61 | { | 61 | { |
62 | propiedad: 'DES', | 62 | propiedad: 'DES', |
63 | NOMBRE: 'Nombre' | 63 | NOMBRE: 'Nombre' |
64 | } | 64 | } |
65 | ], | 65 | ], |
66 | }).then(function (res) { | 66 | }).then(function (res) { |
67 | $scope.associatedList = false; | 67 | $scope.associatedList = false; |
68 | $scope.listaDePreciosAlternativa = res; | 68 | $scope.listaDePreciosAlternativa = res; |
69 | }).catch(function (e) { | 69 | }).catch(function (e) { |
70 | console.error(e); | 70 | console.error(e); |
71 | }); | 71 | }); |
72 | }); | 72 | }); |
73 | }; | 73 | }; |
74 | $scope.selectListaDePrecios = function () { | 74 | $scope.selectListaDePrecios = function () { |
75 | $scope.associatedList = true; | 75 | $scope.associatedList = true; |
76 | }; | 76 | }; |
77 | $scope.verListaProductos = function (id) { | 77 | $scope.verListaProductos = function (id) { |
78 | $uibModal.open( | 78 | $uibModal.open( |
79 | { | 79 | { |
80 | ariaLabelledBy: 'Busqueda de Productos', | 80 | ariaLabelledBy: 'Busqueda de Productos', |
81 | templateUrl: 'modal-busqueda-productos.html', | 81 | templateUrl: 'modal-busqueda-productos.html', |
82 | controller: 'modalBusquedaProductosCtrl', | 82 | controller: 'modalBusquedaProductosCtrl', |
83 | resolve: { | 83 | resolve: { |
84 | parametroProducto: { | 84 | parametroProducto: { |
85 | idLista: parseInt(id), | 85 | idLista: parseInt(id), |
86 | cotizacion: 1, | 86 | cotizacion: 1, |
87 | simbolo: '$', | 87 | simbolo: '$', |
88 | soloMostrar: true | 88 | soloMostrar: true |
89 | } | 89 | } |
90 | }, | 90 | }, |
91 | size: 'md' | 91 | size: 'md' |
92 | } | 92 | } |
93 | ); | 93 | ); |
94 | }; | 94 | }; |
95 | //#endregion | 95 | //#endregion |
96 | 96 | ||
97 | //#region Metodos para los plazos | 97 | //#region Metodos para los plazos |
98 | $scope.addPlazo = function () { | 98 | $scope.addPlazo = function (key) { |
99 | if (key != 13) return; | ||
99 | if ($scope.plazos.length === 100) return; | 100 | if ($scope.plazos.length === 100) return; |
100 | for (var i = 1; i < $scope.plazos.length; i++) { | 101 | for (var i = 1; i < $scope.plazos.length; i++) { |
101 | if ($scope.plazos[0].dias == $scope.plazos[i].dias && $scope.plazos[i].activo == true) { | 102 | if ($scope.plazos[0].dias == $scope.plazos[i].dias && $scope.plazos[i].activo == true) { |
102 | focaModalService.alert("Ya existe un plazo con este valor"); | 103 | focaModalService.alert("Ya existe un plazo con este valor"); |
103 | return; | 104 | return; |
104 | } | 105 | } |
105 | } | 106 | } |
106 | $scope.plazos.unshift({ dias: 0, idCliente: idCliente, activo: true }); | 107 | $scope.plazos.unshift({ dias: 0, idCliente: idCliente, activo: true }); |
108 | $scope.focused = 1; | ||
107 | }; | 109 | }; |
108 | $scope.deletePlazo = function (index) { | 110 | $scope.deletePlazo = function (index) { |
109 | $scope.plazos[index].activo = false; | 111 | $scope.plazos[index].activo = false; |
110 | }; | 112 | }; |
111 | $scope.validateMinMax = function (plazo, min, max) { | 113 | $scope.validateMinMax = function (plazo, min, max) { |
112 | plazo.dias = parseInt(plazo.dias); | 114 | plazo.dias = parseInt(plazo.dias); |
113 | if (plazo.dias === null || plazo.dias === undefined || isNaN(plazo.dias)) { | 115 | if (plazo.dias === null || plazo.dias === undefined || isNaN(plazo.dias)) { |
114 | plazo.dias = '0'; | 116 | plazo.dias = '0'; |
115 | return; | 117 | return; |
116 | } | 118 | } |
117 | if (parseInt(plazo.dias) < min) { | 119 | if (parseInt(plazo.dias) < min) { |
118 | plazo.dias = '0'; | 120 | plazo.dias = '0'; |
119 | return; | 121 | return; |
120 | } | 122 | } |
121 | if (parseInt(plazo.dias) > max) { | 123 | if (parseInt(plazo.dias) > max) { |
122 | plazo.dias = '365'; | 124 | plazo.dias = '365'; |
123 | return; | 125 | return; |
124 | } | 126 | } |
125 | }; | 127 | }; |
126 | //#endregion | 128 | //#endregion |
127 | 129 | ||
128 | $scope.closeModalPrecioCondicion = function () { | 130 | $scope.closeModalPrecioCondicion = function () { |
129 | $uibModalInstance.dismiss('cancel'); | 131 | $uibModalInstance.dismiss('cancel'); |
130 | }; | 132 | }; |
131 | $scope.guardarPrecioCondicion = function () { | 133 | $scope.guardarPrecioCondicion = function () { |
132 | $scope.plazos.shift(); | 134 | $scope.plazos.shift(); |
133 | focaModalPrecioCondicionService.createPlazo($scope.plazos) | 135 | focaModalPrecioCondicionService.createPlazo($scope.plazos) |
134 | .then(function () { | 136 | .then(function () { |
135 | var precioCondicion = { | 137 | var precioCondicion = { |
136 | listaPrecio: $scope.associatedList ? $scope.listaDePreciosAsociada : $scope.listaDePreciosAlternativa, | 138 | listaPrecio: $scope.associatedList ? $scope.listaDePreciosAsociada : $scope.listaDePreciosAlternativa, |
137 | plazoPago: $filter('filter')($scope.plazos, { activo: true }, true) | 139 | plazoPago: $filter('filter')($scope.plazos, { activo: true }, true) |
138 | }; | 140 | }; |
139 | $uibModalInstance.close(precioCondicion); | 141 | $uibModalInstance.close(precioCondicion); |
140 | }) | 142 | }) |
141 | .catch(function (e) { console.error(e) }) | 143 | .catch(function (e) { console.error(e) }) |
142 | } | 144 | } |
143 | } | 145 | } |
144 | ]); | 146 | ]); |
145 | 147 |
src/views/modal-precio-condicion.html
1 | <div class="modal-header py-1"> | 1 | <div class="modal-header py-1"> |
2 | <div class="row w-100"> | 2 | <div class="row w-100"> |
3 | <div class="col-lg-6"> | 3 | <div class="col-lg-6"> |
4 | <h5 class="modal-title my-1">Precio-Condición</h5> | 4 | <h5 class="modal-title my-1">Precio-Condición</h5> |
5 | </div> | 5 | </div> |
6 | </div> | 6 | </div> |
7 | </div> | 7 | </div> |
8 | <div class="modal-body" id="modal-body"> | 8 | <div class="modal-body" id="modal-body"> |
9 | <div ng-show="!ingreso"> | 9 | <div ng-show="!ingreso"> |
10 | <div class="row" ng-show="listaDePreciosAsociada.length == 0"> | 10 | <div class="row" ng-show="listaDePreciosAsociada.length == 0"> |
11 | <div class="col"> | 11 | <div class="col"> |
12 | No se encontraron resultados. | 12 | No se encontraron resultados. |
13 | </div> | 13 | </div> |
14 | </div> | 14 | </div> |
15 | <div class="row px-2"> | 15 | <div class="row px-2"> |
16 | <div class="col-lg-6"> | 16 | <div class="col-lg-6"> |
17 | <div class="row border-top py-2"> | 17 | <div class="row border-top py-2"> |
18 | <div class="col-lg-9 col-9">Lista asociada al cliente</div> | 18 | <div class="col-lg-9 col-9">Lista asociada al cliente</div> |
19 | <div class="col-lg-3 col-3 text-center"> | 19 | <div class="col-lg-3 col-3 text-center"> |
20 | <button | 20 | <button |
21 | ng-class="{'btn-primary': associatedList, 'btn-default': !associatedList}" | 21 | ng-class="{'btn-primary': associatedList, 'btn-default': !associatedList}" |
22 | class="btn btn-sm p-1" | 22 | class="btn btn-sm p-1" |
23 | ng-click="selectListaDePrecios(listaDePreciosAsociada)"> | 23 | ng-click="selectListaDePrecios(listaDePreciosAsociada)"> |
24 | <span class="fa fa-circle-thin"></span> | 24 | <span class="fa fa-circle-thin"></span> |
25 | </button> | 25 | </button> |
26 | </div> | 26 | </div> |
27 | </div> | 27 | </div> |
28 | <div class="row align-items-center pb-2"> | 28 | <div class="row align-items-center pb-2"> |
29 | <div class="col-lg-2 col-2 text-center" ng-bind="listaDePreciosAsociada.ID"></div> | 29 | <div class="col-lg-2 col-2 text-center" ng-bind="listaDePreciosAsociada.ID"></div> |
30 | <div class="col-lg-7 col-7" ng-bind="listaDePreciosAsociada.DES"></div> | 30 | <div class="col-lg-7 col-7" ng-bind="listaDePreciosAsociada.DES"></div> |
31 | <div class="col-lg-3 col-3 text-center"> | 31 | <div class="col-lg-3 col-3 text-center"> |
32 | <button ng-click="verListaProductos(listaDePreciosAsociada.ID)" class="btn btn-sm p-1"> | 32 | <button ng-click="verListaProductos(listaDePreciosAsociada.ID)" class="btn btn-sm p-1"> |
33 | <span class="fa fa-eye"></span> | 33 | <span class="fa fa-eye"></span> |
34 | </button> | 34 | </button> |
35 | </div> | 35 | </div> |
36 | </div> | 36 | </div> |
37 | <div class="row border-top py-2"> | 37 | <div class="row border-top py-2"> |
38 | <div class="col-lg-9 col-9">Trabajar con otra lista</div> | 38 | <div class="col-lg-9 col-9">Trabajar con otra lista</div> |
39 | <div class="col-lg-3 col-3 text-center"> | 39 | <div class="col-lg-3 col-3 text-center"> |
40 | <button | 40 | <button |
41 | ng-class="{'btn-primary': !associatedList, 'btn-default': associatedList}" | 41 | ng-class="{'btn-primary': !associatedList, 'btn-default': associatedList}" |
42 | class="btn btn-sm btn-default p-1" | 42 | class="btn btn-sm btn-default p-1" |
43 | ng-click="openListaDePrecios()"> | 43 | ng-click="openListaDePrecios()"> |
44 | <span class="fa fa-circle-thin"></span> | 44 | <span class="fa fa-circle-thin"></span> |
45 | </button> | 45 | </button> |
46 | </div> | 46 | </div> |
47 | </div> | 47 | </div> |
48 | <div ng-show="listaDePreciosAlternativa != null" class="row align-items-center pb-1"> | 48 | <div ng-show="listaDePreciosAlternativa != null" class="row align-items-center pb-1"> |
49 | <div class="col-lg-2 col-2 text-center" ng-bind="listaDePreciosAlternativa.ID"></div> | 49 | <div class="col-lg-2 col-2 text-center" ng-bind="listaDePreciosAlternativa.ID"></div> |
50 | <div class="col-lg-7 col-7" ng-bind="listaDePreciosAlternativa.DES"></div> | 50 | <div class="col-lg-7 col-7" ng-bind="listaDePreciosAlternativa.DES"></div> |
51 | <div class="col-lg-3 col-3 text-center"> | 51 | <div class="col-lg-3 col-3 text-center"> |
52 | <button ng-click="verListaProductos(listaDePreciosAlternativa.ID)" class="btn btn-sm p-1"> | 52 | <button ng-click="verListaProductos(listaDePreciosAlternativa.ID)" class="btn btn-sm p-1"> |
53 | <span class="fa fa-eye"></span> | 53 | <span class="fa fa-eye"></span> |
54 | </button> | 54 | </button> |
55 | </div> | 55 | </div> |
56 | </div> | 56 | </div> |
57 | </div> | 57 | </div> |
58 | <div class="col"> | 58 | <div class="col"> |
59 | <div class="row py-1"> | 59 | <div class="row py-1"> |
60 | <div class="col text-center font-weight-bold">Plazos</div> | 60 | <div class="col text-center font-weight-bold">Plazos</div> |
61 | </div> | 61 | </div> |
62 | <div class="row"> | 62 | <div class="row"> |
63 | <div class="col"> | 63 | <div class="col"> |
64 | <table class="table table-sm table-striped"> | 64 | <table class="table table-sm table-striped"> |
65 | <thead> | 65 | <thead> |
66 | <tr> | 66 | <tr> |
67 | <th colspan="2">Dias</th> | 67 | <th colspan="2">Dias</th> |
68 | </tr> | 68 | </tr> |
69 | </thead> | 69 | </thead> |
70 | <tbody> | 70 | <tbody> |
71 | <tr ng-repeat="(i, plazo) in plazos" ng-show="plazo.activo"> | 71 | <tr ng-repeat="(i, plazo) in plazos" ng-show="plazo.activo"> |
72 | <td align="center" ng-class="{'pt-2': i > 0}"> | 72 | <td align="center" ng-class="{'pt-2': i > 0}"> |
73 | <span | 73 | <span |
74 | ng-show="i > 0" | 74 | ng-show="i > 0" |
75 | ng-bind="plazo.dias"> | 75 | ng-bind="plazo.dias"> |
76 | </span> | 76 | </span> |
77 | <input | 77 | <input |
78 | ng-show="i == 0" | 78 | ng-show="i == 0" |
79 | type="text" | 79 | type="text" |
80 | class="form-control form-control-sm text-center" | 80 | class="form-control form-control-sm text-center" |
81 | ng-model="plazo.dias" | 81 | ng-model="plazo.dias" |
82 | limite-numeros-max="3" | 82 | limite-numeros-max="3" |
83 | ng-keyup="validateMinMax(plazo, 0, 365)" | 83 | ng-keyup="validateMinMax(plazo, 0, 365)" |
84 | ng-keypress="addPlazo($event.keyCode)" | ||
85 | foca-focus="focused == 1" | ||
84 | select-on-click | 86 | select-on-click |
85 | teclado-virtual | 87 | teclado-virtual |
86 | foca-tipo-input | 88 | foca-tipo-input |
87 | solo-positivos> | 89 | solo-positivos> |
88 | </td> | 90 | </td> |
89 | <td> | 91 | <td> |
90 | <button | 92 | <button |
91 | ng-show="i === 0" | 93 | ng-show="i === 0" |
92 | class="btn btn-primary" | 94 | class="btn btn-primary" |
93 | ng-click="addPlazo()"> | 95 | ng-click="addPlazo(13)"> |
94 | <span class="fa fa-save"></span> | 96 | <span class="fa fa-save"></span> |
95 | </button> | 97 | </button> |
96 | <button | 98 | <button |
97 | ng-show="i > 0" | 99 | ng-show="i > 0" |
98 | class="btn btn-default" | 100 | class="btn btn-default" |
99 | ng-click="deletePlazo(i)"> | 101 | ng-click="deletePlazo(i)"> |
100 | <span class="fa fa-trash"></span> | 102 | <span class="fa fa-trash"></span> |
101 | </button> | 103 | </button> |
102 | </td> | 104 | </td> |
103 | </tr> | 105 | </tr> |
104 | </tbody> | 106 | </tbody> |
105 | </table> | 107 | </table> |
106 | </div> | 108 | </div> |
107 | </div> | 109 | </div> |
108 | </div> | 110 | </div> |
109 | </div> | 111 | </div> |
110 | </div> | 112 | </div> |
111 | </div> | 113 | </div> |
112 | <div class="modal-footer py-2"> | 114 | <div class="modal-footer py-2"> |
113 | <button class="btn btn-sm btn-secondary" type="button" ng-click="closeModalPrecioCondicion()">Cerrar | 115 | <button class="btn btn-sm btn-secondary" type="button" ng-click="closeModalPrecioCondicion()">Cerrar |
114 | </button> | 116 | </button> |
115 | <button class="btn btn-sm btn-primary" type="button" ng-click="guardarPrecioCondicion()">Guardar | 117 | <button class="btn btn-sm btn-primary" type="button" ng-click="guardarPrecioCondicion()">Guardar |
116 | </button> | 118 | </button> |
117 | </div> | 119 | </div> |
118 | 120 |