Commit aae6047799d8ca4db9240065fe3a7ef96673d4b7

Authored by Marcelo Puebla
1 parent 0598143049
Exists in master and in 1 other branch develop

Agregado metodo para consultar los plazos con el id del cliente.

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 function ( 13 function (
13 $timeout, $filter, $scope, $uibModal, $uibModalInstance, 14 $timeout, $filter, $scope, $uibModal, $uibModalInstance,
14 focaModalService, focaModalPrecioCondicionService, idListaPrecio 15 focaModalService, focaModalPrecioCondicionService, idListaPrecio, idCliente
15 ) { 16 ) {
16 $scope.plazos = [{ dias: 0 }]; 17 $scope.plazos = [{ dias: 0 }];
17 $scope.editingPlazo = false; 18 $scope.editingPlazo = false;
18 $scope.openModalListaDePrecios = false; 19 $scope.openModalListaDePrecios = false;
19 $scope.chosenClientList = true; 20 $scope.associatedList = true;
20 $scope.listaDePreciosAlternativa = null; 21 $scope.listaDePreciosAlternativa = null;
21 22
22 onInit(); 23 onInit();
23 24
24 function onInit() { 25 function onInit() {
25 //Metodo para traer la lista de precio asociada al cliente 26 //Metodo para traer la lista de precio asociada al cliente
26 focaModalPrecioCondicionService.getListaPrecio(idListaPrecio) 27 focaModalPrecioCondicionService.getListaPrecio(idListaPrecio)
27 .then(function (res) { 28 .then(function (res) {
28 console.log("Lista de precios", res); 29 console.log("Lista de precios", res);
29 $scope.listaDePreciosAsociada = res.data[0]; 30 $scope.listaDePreciosAsociada = res.data[0];
30 }); 31 })
32 .catch(function (e) { console.log(e) });
33 focaModalPrecioCondicionService.getPlazosByIdCliente(idCliente)
34 .then(function (res) {
35 console.log(res);
36 $scope.plazos = res.data;
37 })
38 .catch(function (e) { console.log(e) });
31 } 39 }
32 40
33 //#region Metodos para la lista de precios 41 //#region Metodos para la lista de precios
34 $scope.openListaDePrecios = function () { 42 $scope.openListaDePrecios = function () {
35 var datos = null; 43 var datos = null;
36 focaModalPrecioCondicionService.getAllListaPrecio() 44 focaModalPrecioCondicionService.getAllListaPrecio()
37 .then(function (res) { 45 .then(function (res) {
38 datos = res.data; 46 datos = res.data;
39 focaModalService.modal({ 47 focaModalService.modal({
40 titulo: 'Lista de precios', 48 titulo: 'Lista de precios',
41 data: datos, 49 data: datos,
42 size: 'md', 50 size: 'md',
43 columnas: [ 51 columnas: [
44 { 52 {
45 propiedad: 'ID', 53 propiedad: 'ID',
46 nombre: 'Codigo' 54 nombre: 'Codigo'
47 }, 55 },
48 { 56 {
49 propiedad: 'DES', 57 propiedad: 'DES',
50 NOMBRE: 'Nombre' 58 NOMBRE: 'Nombre'
51 } 59 }
52 ], 60 ],
53 }).then(function (res) { 61 }).then(function (res) {
54 $scope.chosenClientList = false; 62 $scope.associatedList = false;
55 $scope.listaDePreciosAlternativa = res; 63 $scope.listaDePreciosAlternativa = res;
56 console.log(res); 64 console.log(res);
57 }).catch(function (e) { 65 }).catch(function (e) {
58 console.log(e); 66 console.log(e);
59 }); 67 });
60 }); 68 });
61 }; 69 };
62 $scope.selectListaDePrecios = function (listaDePrecios) { 70 $scope.selectListaDePrecios = function (listaDePrecios) {
63 $scope.chosenClientList = true; 71 $scope.associatedList = true;
64 }; 72 };
65 $scope.verListaProductos = function (id) { 73 $scope.verListaProductos = function (id) {
66 var modalInstance = $uibModal.open( 74 var modalInstance = $uibModal.open(
67 { 75 {
68 ariaLabelledBy: 'Busqueda de Productos', 76 ariaLabelledBy: 'Busqueda de Productos',
69 templateUrl: 'modal-busqueda-productos.html', 77 templateUrl: 'modal-busqueda-productos.html',
70 controller: 'modalBusquedaProductosCtrl', 78 controller: 'modalBusquedaProductosCtrl',
71 resolve: { 79 resolve: {
72 parametroProducto: { 80 parametroProducto: {
73 idLista: parseInt(id), 81 idLista: parseInt(id),
74 cotizacion: 1, 82 cotizacion: 1,
75 simbolo: '$', 83 simbolo: '$',
76 soloMostrar: true 84 soloMostrar: true
77 } 85 }
78 }, 86 },
79 size: 'md' 87 size: 'md'
80 } 88 }
81 ); 89 );
82 modalInstance.result 90 modalInstance.result
83 .then(function (res) { 91 .then(function (res) {
84 console.log("Producto => ", res); 92 console.log("Producto => ", res);
85 }) 93 })
86 .catch(function (e) { console.log(e) }); 94 .catch(function (e) { console.log(e) });
87 }; 95 };
88 $scope.closeModalPrecioCondicion = function () { 96 $scope.closeModalPrecioCondicion = function () {
89 $uibModalInstance.dismiss('cancel'); 97 $uibModalInstance.dismiss('cancel');
90 }; 98 };
99 $scope.guardarPrecioCondicion = function () {
100 $uibModalInstance.close(!$scope.associatedList ? $scope.listaDePreciosAsociada : $scope.listaDePreciosAlternativa);
101 }
91 //#endregion 102 //#endregion
92 103
93 //#region Metodos para los plazos 104 //#region Metodos para los plazos
94 $scope.addMorePlazos = function () { 105 $scope.addMorePlazos = function () {
95 if ($scope.plazos.length < 4) { 106 if ($scope.plazos.length < 4) {
96 $scope.plazos.unshift({ dias: 0 }); 107 $scope.plazos.unshift({ dias: 0 });
97 } 108 }
98 }; 109 };
99 $scope.editPlazo = function () { 110 $scope.editPlazo = function () {
100 $scope.editingPlazo = true; 111 $scope.editingPlazo = true;
101 }; 112 };
102 $scope.validateMinMax = function (plazo, min, max) { 113 $scope.validateMinMax = function (plazo, min, max) {
103 plazo.dias = parseInt(plazo.dias); 114 plazo.dias = parseInt(plazo.dias);
104 if (plazo.dias === null || plazo.dias === undefined || isNaN(plazo.dias)) { 115 if (plazo.dias === null || plazo.dias === undefined || isNaN(plazo.dias)) {
105 plazo.dias = '0'; 116 plazo.dias = '0';
106 return; 117 return;
107 } 118 }
108 if (parseInt(plazo.dias) < min) { 119 if (parseInt(plazo.dias) < min) {
109 plazo.dias = '0'; 120 plazo.dias = '0';
110 return; 121 return;
111 } 122 }
112 if (parseInt(plazo.dias) > max) { 123 if (parseInt(plazo.dias) > max) {
113 plazo.dias = '365'; 124 plazo.dias = '365';
114 return; 125 return;
115 } 126 }
116 }; 127 };
117 //#endregion 128 //#endregion
118 } 129 }
119 ] 130 ]
120 ); 131 );
121 132
1 angular.module('focaModalPrecioCondicion') 1 angular.module('focaModalPrecioCondicion')
2 .service('focaModalPrecioCondicionService', [ 2 .service('focaModalPrecioCondicionService', [
3 '$http', 3 '$http',
4 'API_ENDPOINT', 4 'API_ENDPOINT',
5 function ($http, API_ENDPOINT) { 5 function ($http, API_ENDPOINT) {
6 return { 6 return {
7 getPlazosByIdPrecioCondicion: function (id) { 7 getPlazosByIdPrecioCondicion: function (id) {
8 return $http.get(API_ENDPOINT.URL + '/plazo-pago/precio-condicion/' + id); 8 return $http.get(API_ENDPOINT.URL + '/plazo-pago/precio-condicion/' + id);
9 }, 9 },
10 getPreciosCondiciones: function () { 10 getPreciosCondiciones: function () {
11 return $http.get(API_ENDPOINT.URL + '/precio-condicion/plazo-pago'); 11 return $http.get(API_ENDPOINT.URL + '/precio-condicion/plazo-pago');
12 }, 12 },
13 getPreciosCondicionesByIdListaPrecio: function (idListaPrecio) { 13 getPreciosCondicionesByIdListaPrecio: function (idListaPrecio) {
14 return $http.get(API_ENDPOINT.URL + '/precio-condicion/plazo-pago/' + 14 return $http.get(API_ENDPOINT.URL + '/precio-condicion/plazo-pago/' +
15 idListaPrecio); 15 idListaPrecio);
16 }, 16 },
17 getListaPrecio: function (idListaPrecio) { 17 getListaPrecio: function (idListaPrecio) {
18 return $http.get(API_ENDPOINT.URL + '/lista-precio/' + 18 return $http.get(API_ENDPOINT.URL + '/lista-precio/' +
19 idListaPrecio); 19 idListaPrecio);
20 }, 20 },
21 getAllListaPrecio: function () { 21 getAllListaPrecio: function () {
22 return $http.get(API_ENDPOINT.URL + '/lista-precio'); 22 return $http.get(API_ENDPOINT.URL + '/lista-precio');
23 },
24 getPlazosByIdCliente: function (id) {
25 return $http.get(API_ENDPOINT.URL + '/plazo-pago/cliente/' + id);
23 } 26 }
24 }; 27 };
25 } 28 }
26 ]); 29 ]);
27 30
src/views/modal-precio-condicion.html
1 <div> 1 <div class="modal-header py-1">
2 <div class="modal-header py-1"> 2 <div class="row w-100">
3 <div class="row w-100"> 3 <div class="col-lg-6">
4 <div class="col-lg-6"> 4 <h5 class="modal-title my-1">Precio-Condición</h5>
5 <h5 class="modal-title my-1">Precio-Condición</h5>
6 </div>
7 </div> 5 </div>
8 </div> 6 </div>
9 <div class="modal-body" id="modal-body"> 7 </div>
10 <div ng-show="!ingreso"> 8 <div class="modal-body" id="modal-body">
11 <div class="row" ng-show="listaDePreciosAsociada.length == 0"> 9 <div ng-show="!ingreso">
12 <div class="col"> 10 <div class="row" ng-show="listaDePreciosAsociada.length == 0">
13 No se encontraron resultados. 11 <div class="col">
14 </div> 12 No se encontraron resultados.
15 </div> 13 </div>
16 <div class="row px-2"> 14 </div>
17 <div class="col-lg-6"> 15 <div class="row px-2">
18 <div class="row border-top py-2"> 16 <div class="col-lg-6">
19 <div class="col-lg-9 col-9">Lista asociada al cliente</div> 17 <div class="row border-top py-2">
20 <div class="col-lg-3 col-3 text-center"> 18 <div class="col-lg-9 col-9">Lista asociada al cliente</div>
21 <button 19 <div class="col-lg-3 col-3 text-center">
22 ng-class="{'btn-primary': chosenClientList, 'btn-default': !chosenClientList}" 20 <button
23 class="btn btn-sm p-1" 21 ng-class="{'btn-primary': associatedList, 'btn-default': !associatedList}"
24 ng-click="selectListaDePrecios(listaDePreciosAsociada)"> 22 class="btn btn-sm p-1"
25 <span class="fa fa-circle-thin"></span> 23 ng-click="selectListaDePrecios(listaDePreciosAsociada)">
26 </button> 24 <span class="fa fa-circle-thin"></span>
27 </div> 25 </button>
28 </div> 26 </div>
29 <div class="row align-items-center pb-2"> 27 </div>
30 <div class="col-lg-2 col-2 text-center" ng-bind="listaDePreciosAsociada.ID"></div> 28 <div class="row align-items-center pb-2">
31 <div class="col-lg-7 col-7" ng-bind="listaDePreciosAsociada.DES"></div> 29 <div class="col-lg-2 col-2 text-center" ng-bind="listaDePreciosAsociada.ID"></div>
32 <div class="col-lg-3 col-3 text-center"> 30 <div class="col-lg-7 col-7" ng-bind="listaDePreciosAsociada.DES"></div>
33 <button ng-click="verListaProductos(listaDePreciosAsociada.ID)" class="btn btn-sm p-1"> 31 <div class="col-lg-3 col-3 text-center">
34 <span class="fa fa-eye"></span> 32 <button ng-click="verListaProductos(listaDePreciosAsociada.ID)" class="btn btn-sm p-1">
35 </button> 33 <span class="fa fa-eye"></span>
36 </div> 34 </button>
37 </div> 35 </div>
38 <div class="row border-top py-2"> 36 </div>
39 <div class="col-lg-9 col-9">Trabajar con otra lista</div> 37 <div class="row border-top py-2">
40 <div class="col-lg-3 col-3 text-center"> 38 <div class="col-lg-9 col-9">Trabajar con otra lista</div>
41 <button 39 <div class="col-lg-3 col-3 text-center">
42 ng-class="{'btn-primary': !chosenClientList, 'btn-default': chosenClientList}" 40 <button
43 class="btn btn-sm btn-default p-1" 41 ng-class="{'btn-primary': !associatedList, 'btn-default': associatedList}"
44 ng-click="openListaDePrecios()"> 42 class="btn btn-sm btn-default p-1"
45 <span class="fa fa-circle-thin"></span> 43 ng-click="openListaDePrecios()">
46 </button> 44 <span class="fa fa-circle-thin"></span>
47 </div> 45 </button>
48 </div> 46 </div>
49 <div ng-show="listaDePreciosAlternativa != null" class="row align-items-center pb-1"> 47 </div>
50 <div class="col-lg-2 col-2 text-center" ng-bind="listaDePreciosAlternativa.ID"></div> 48 <div ng-show="listaDePreciosAlternativa != null" class="row align-items-center pb-1">
51 <div class="col-lg-7 col-7" ng-bind="listaDePreciosAlternativa.DES"></div> 49 <div class="col-lg-2 col-2 text-center" ng-bind="listaDePreciosAlternativa.ID"></div>
52 <div class="col-lg-3 col-3 text-center"> 50 <div class="col-lg-7 col-7" ng-bind="listaDePreciosAlternativa.DES"></div>
53 <button ng-click="verListaProductos(listaDePreciosAlternativa.ID)" class="btn btn-sm p-1"> 51 <div class="col-lg-3 col-3 text-center">
54 <span class="fa fa-eye"></span> 52 <button ng-click="verListaProductos(listaDePreciosAlternativa.ID)" class="btn btn-sm p-1">
55 </button> 53 <span class="fa fa-eye"></span>
56 </div> 54 </button>
57 </div> 55 </div>
58 </div> 56 </div>
59 <div class="col"> 57 </div>
60 <div class="row border-bottom py-1"> 58 <div class="col">
61 <div class="col text-center font-weight-bold">Plazos</div> 59 <div class="row border-bottom py-1">
60 <div class="col text-center font-weight-bold">Plazos</div>
61 </div>
62 <div ng-if="!editingPlazo" class="row align-items-center justify-content-end py-2">
63 <div
64 class="col-lg-9 col-9 text-center"
65 ng-repeat="plazo in plazos">
66 {{plazo.dias}},
62 </div> 67 </div>
63 <div ng-if="!editingPlazo" class="row align-items-center justify-content-end py-2"> 68 <div class="col-lg-9 col-9 text-center" ng-if="plazos.length == 0">
64 <div class="col-lg-9 col-9 text-center">300, 254, 215, 265, 300, 300</div> 69 No hay plazos cargados.
65 <div class="col-lg-3 col-3">
66 <button class="btn btn-sm text-center" ng-click="editPlazo()">
67 <span class="fa fa-pencil"></span>
68 </button>
69 </div>
70 </div> 70 </div>
71 <div ng-if="editingPlazo" class="row align-items-center justify-content-end py-2"> 71 <div class="col-lg-3 col-3">
72 <div class="col-2 col-sm-2 px-2" ng-repeat="plazo in plazos" ng-show="plazos.length > 0"> 72 <button class="btn btn-sm text-center" ng-click="editPlazo()">
73 <input 73 <span ng-class="{'fa-pencil': plazos.length > 0, 'fa-plus': plazos.length == 0}" class="fa"></span>
74 type="text" 74 </button>
75 class="form-control form-control-sm text-center" 75 </div>
76 ng-model="plazo.dias" 76 </div>
77 limite-numeros-max="3" 77 <div ng-if="editingPlazo" class="row align-items-center justify-content-end py-2">
78 ng-keyup="validateMinMax(plazo, 0, 365)" 78 <div class="col-2 col-sm-2 px-2" ng-repeat="plazo in plazos" ng-show="plazos.length > 0">
79 select-on-click 79 <input
80 teclado-virtual 80 type="text"
81 foca-tipo-input 81 class="form-control form-control-sm text-center"
82 solo-positivos> 82 ng-model="plazo.dias"
83 </div> 83 limite-numeros-max="3"
84 <div class="col-lg-2 col-2 text-center"> 84 ng-keyup="validateMinMax(plazo, 0, 365)"
85 <button 85 select-on-click
86 class="btn btn-outline-debo" 86 teclado-virtual
87 ng-click="addMorePlazos()" 87 foca-tipo-input
88 ng-disabled="plazos.length == 4"> 88 solo-positivos>
89 <span class="fa fa-plus"></span> 89 </div>
90 </button> 90 <div class="col-lg-2 col-2 text-center">
91 </div> 91 <button
92 <div class="col-lg-2 col-2 text-center"> 92 class="btn btn-outline-debo"
93 <button class="btn btn-primary"> 93 ng-click="addMorePlazos()"
94 <span class="fa fa-save"></span> 94 ng-disabled="plazos.length == 4">
95 </button> 95 <span class="fa fa-plus"></span>
96 </div> 96 </button>
97 </div>
98 <div class="col-lg-2 col-2 text-center">
99 <button class="btn btn-primary">
100 <span class="fa fa-save"></span>
101 </button>
97 </div> 102 </div>
98 </div> 103 </div>
99 </div> 104 </div>
100 </div> 105 </div>
101 </div> 106 </div>
102 <div class="modal-footer py-2">