Commit 94397333ee37f4476212c2f009883c083fe9aaaa
1 parent
d83b461aa9
Exists in
master
and in
1 other branch
Actualizar campo MOD al cambiar de lista
Showing
3 changed files
with
27 additions
and
16 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 | focaModalService.confirm('¿Desea cambiar la lista de precios?\n'+ | 67 | focaModalService.confirm('¿Desea cambiar la lista de precios?\n'+ |
| 68 | 'Se perderan los productos ingresados').then(function (data){ | 68 | 'Se perderan los productos ingresados').then(function (data){ |
| 69 | if (data) { | 69 | if (data) { |
| 70 | $scope.associatedList = false; | 70 | $scope.associatedList = false; |
| 71 | $scope.listaDePreciosAlternativa = res; | 71 | $scope.listaDePreciosAlternativa = res; |
| 72 | } | 72 | } |
| 73 | }); | 73 | }); |
| 74 | }).catch(function (e) { | 74 | }).catch(function (e) { |
| 75 | console.error(e); | 75 | console.error(e); |
| 76 | }); | 76 | }); |
| 77 | }); | 77 | }); |
| 78 | }; | 78 | }; |
| 79 | $scope.selectListaDePrecios = function () { | 79 | $scope.selectListaDePrecios = function () { |
| 80 | $scope.associatedList = true; | 80 | $scope.associatedList = true; |
| 81 | }; | 81 | }; |
| 82 | $scope.verListaProductos = function (id) { | 82 | $scope.verListaProductos = function (id) { |
| 83 | $uibModal.open( | 83 | $uibModal.open( |
| 84 | { | 84 | { |
| 85 | ariaLabelledBy: 'Busqueda de Productos', | 85 | ariaLabelledBy: 'Busqueda de Productos', |
| 86 | templateUrl: 'modal-busqueda-productos.html', | 86 | templateUrl: 'modal-busqueda-productos.html', |
| 87 | controller: 'modalBusquedaProductosCtrl', | 87 | controller: 'modalBusquedaProductosCtrl', |
| 88 | resolve: { | 88 | resolve: { |
| 89 | parametroProducto: { | 89 | parametroProducto: { |
| 90 | idLista: parseInt(id), | 90 | idLista: parseInt(id), |
| 91 | cotizacion: 1, | 91 | cotizacion: 1, |
| 92 | simbolo: '$', | 92 | simbolo: '$', |
| 93 | soloMostrar: true | 93 | soloMostrar: true |
| 94 | } | 94 | } |
| 95 | }, | 95 | }, |
| 96 | size: 'md' | 96 | size: 'md' |
| 97 | } | 97 | } |
| 98 | ); | 98 | ); |
| 99 | }; | 99 | }; |
| 100 | //#endregion | 100 | //#endregion |
| 101 | 101 | ||
| 102 | //#region Metodos para los plazos | 102 | //#region Metodos para los plazos |
| 103 | $scope.addPlazo = function (key) { | 103 | $scope.addPlazo = function (key) { |
| 104 | if (key != 13) return; | 104 | if (key != 13) return; |
| 105 | if ($scope.plazos.length === 100) return; | 105 | if ($scope.plazos.length === 100) return; |
| 106 | for (var i = 1; i < $scope.plazos.length; i++) { | 106 | for (var i = 1; i < $scope.plazos.length; i++) { |
| 107 | if ($scope.plazos[0].dias == $scope.plazos[i].dias && $scope.plazos[i].activo == true) { | 107 | if ($scope.plazos[0].dias == $scope.plazos[i].dias && $scope.plazos[i].activo == true) { |
| 108 | focaModalService.alert("Ya existe un plazo con este valor"); | 108 | focaModalService.alert("Ya existe un plazo con este valor"); |
| 109 | return; | 109 | return; |
| 110 | } | 110 | } |
| 111 | } | 111 | } |
| 112 | $scope.plazos.unshift({ dias: 0, idCliente: idCliente, activo: true }); | 112 | $scope.plazos.unshift({ dias: 0, idCliente: idCliente, activo: true }); |
| 113 | $scope.focused = 1; | 113 | $scope.focused = 1; |
| 114 | }; | 114 | }; |
| 115 | $scope.deletePlazo = function (index) { | 115 | $scope.deletePlazo = function (index) { |
| 116 | $scope.plazos[index].activo = false; | 116 | $scope.plazos[index].activo = false; |
| 117 | }; | 117 | }; |
| 118 | $scope.validateMinMax = function (plazo, min, max) { | 118 | $scope.validateMinMax = function (plazo, min, max) { |
| 119 | plazo.dias = parseInt(plazo.dias); | 119 | plazo.dias = parseInt(plazo.dias); |
| 120 | if (plazo.dias === null || plazo.dias === undefined || isNaN(plazo.dias)) { | 120 | if (plazo.dias === null || plazo.dias === undefined || isNaN(plazo.dias)) { |
| 121 | plazo.dias = '0'; | 121 | plazo.dias = '0'; |
| 122 | return; | 122 | return; |
| 123 | } | 123 | } |
| 124 | if (parseInt(plazo.dias) < min) { | 124 | if (parseInt(plazo.dias) < min) { |
| 125 | plazo.dias = '0'; | 125 | plazo.dias = '0'; |
| 126 | return; | 126 | return; |
| 127 | } | 127 | } |
| 128 | if (parseInt(plazo.dias) > max) { | 128 | if (parseInt(plazo.dias) > max) { |
| 129 | plazo.dias = '365'; | 129 | plazo.dias = '365'; |
| 130 | return; | 130 | return; |
| 131 | } | 131 | } |
| 132 | }; | 132 | }; |
| 133 | //#endregion | 133 | //#endregion |
| 134 | 134 | ||
| 135 | $scope.closeModalPrecioCondicion = function () { | 135 | $scope.closeModalPrecioCondicion = function () { |
| 136 | $uibModalInstance.dismiss('cancel'); | 136 | $uibModalInstance.dismiss('cancel'); |
| 137 | }; | 137 | }; |
| 138 | $scope.guardarPrecioCondicion = function () { | 138 | $scope.guardarPrecioCondicion = function () { |
| 139 | $scope.plazos.shift(); | 139 | var mod = $scope.associatedList ? parseInt($scope.listaDePreciosAsociada.ID) : parseInt($scope.listaDePreciosAlternativa.ID); |
| 140 | focaModalPrecioCondicionService.createPlazo($scope.plazos) | 140 | focaModalPrecioCondicionService.actualizarLista(idCliente, mod).then(function (){ |
| 141 | .then(function () { | 141 | $scope.plazos.shift(); |
| 142 | var precioCondicion = { | 142 | focaModalPrecioCondicionService.createPlazo($scope.plazos) |
| 143 | listaPrecio: $scope.associatedList ? $scope.listaDePreciosAsociada : $scope.listaDePreciosAlternativa, | 143 | .then(function () { |
| 144 | plazoPago: $filter('filter')($scope.plazos, { activo: true }, true) | 144 | var precioCondicion = { |
| 145 | }; | 145 | listaPrecio: $scope.associatedList ? $scope.listaDePreciosAsociada : $scope.listaDePreciosAlternativa, |
| 146 | $uibModalInstance.close(precioCondicion); | 146 | plazoPago: $filter('filter')($scope.plazos, { activo: true }, true) |
| 147 | }) | 147 | }; |
| 148 | .catch(function (e) { console.error(e) }) | 148 | $uibModalInstance.close(precioCondicion); |
| 149 | } | 149 | }) |
| 150 | .catch(function (e) { console.error(e) }) | ||
| 151 | }); | ||
| 152 | }; | ||
| 150 | } | 153 | } |
| 151 | ]); | 154 | ]); |
| 152 | 155 |
src/js/controllerCliente.js
| 1 | angular.module('focaModalPrecioCondicion') | 1 | angular.module('focaModalPrecioCondicion') |
| 2 | .controller('focaModalListaPreciosController', | 2 | .controller('focaModalListaPreciosController', |
| 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.openModalListaDePrecios = false; | 17 | $scope.openModalListaDePrecios = false; |
| 17 | $scope.associatedList = true; | 18 | $scope.associatedList = true; |
| 18 | $scope.listaDePreciosAlternativa = null; | 19 | $scope.listaDePreciosAlternativa = null; |
| 19 | 20 | ||
| 20 | onInit(); | 21 | onInit(); |
| 21 | 22 | ||
| 22 | function onInit() { | 23 | function onInit() { |
| 23 | //Metodo para traer la lista de precio asociada al cliente | 24 | //Metodo para traer la lista de precio asociada al cliente |
| 24 | focaModalPrecioCondicionService.getListaPrecio(idListaPrecio) | 25 | focaModalPrecioCondicionService.getListaPrecio(idListaPrecio) |
| 25 | .then(function (res) { | 26 | .then(function (res) { |
| 26 | $scope.listaDePreciosAsociada = res.data[0]; | 27 | $scope.listaDePreciosAsociada = res.data[0]; |
| 27 | }) | 28 | }) |
| 28 | .catch(function (e) { console.error(e) }); | 29 | .catch(function (e) { console.error(e) }); |
| 29 | } | 30 | } |
| 30 | 31 | ||
| 31 | //#region Metodos para la lista de precios | 32 | //#region Metodos para la lista de precios |
| 32 | $scope.openListaDePrecios = function () { | 33 | $scope.openListaDePrecios = function () { |
| 33 | var datos = null; | 34 | var datos = null; |
| 34 | focaModalPrecioCondicionService.getAllListaPrecio() | 35 | focaModalPrecioCondicionService.getAllListaPrecio() |
| 35 | .then(function (res) { | 36 | .then(function (res) { |
| 36 | datos = res.data; | 37 | datos = res.data; |
| 37 | focaModalService.modal({ | 38 | focaModalService.modal({ |
| 38 | titulo: 'Lista de precios', | 39 | titulo: 'Lista de precios', |
| 39 | data: datos, | 40 | data: datos, |
| 40 | size: 'md', | 41 | size: 'md', |
| 41 | columnas: [ | 42 | columnas: [ |
| 42 | { | 43 | { |
| 43 | propiedad: 'ID', | 44 | propiedad: 'ID', |
| 44 | nombre: 'Codigo' | 45 | nombre: 'Codigo' |
| 45 | }, | 46 | }, |
| 46 | { | 47 | { |
| 47 | propiedad: 'DES', | 48 | propiedad: 'DES', |
| 48 | NOMBRE: 'Nombre' | 49 | NOMBRE: 'Nombre' |
| 49 | } | 50 | } |
| 50 | ], | 51 | ], |
| 51 | }).then(function (res) { | 52 | }).then(function (res) { |
| 52 | $scope.associatedList = false; | 53 | $scope.associatedList = false; |
| 53 | $scope.listaDePreciosAlternativa = res; | 54 | $scope.listaDePreciosAlternativa = res; |
| 54 | }).catch(function (e) { | 55 | }).catch(function (e) { |
| 55 | console.error(e); | 56 | console.error(e); |
| 56 | }); | 57 | }); |
| 57 | }); | 58 | }); |
| 58 | }; | 59 | }; |
| 59 | $scope.selectListaDePrecios = function () { | 60 | $scope.selectListaDePrecios = function () { |
| 60 | $scope.associatedList = true; | 61 | $scope.associatedList = true; |
| 61 | }; | 62 | }; |
| 62 | $scope.verListaProductos = function (id) { | 63 | $scope.verListaProductos = function (id) { |
| 63 | $uibModal.open( | 64 | $uibModal.open( |
| 64 | { | 65 | { |
| 65 | ariaLabelledBy: 'Busqueda de Productos', | 66 | ariaLabelledBy: 'Busqueda de Productos', |
| 66 | templateUrl: 'modal-busqueda-productos.html', | 67 | templateUrl: 'modal-busqueda-productos.html', |
| 67 | controller: 'modalBusquedaProductosCtrl', | 68 | controller: 'modalBusquedaProductosCtrl', |
| 68 | resolve: { | 69 | resolve: { |
| 69 | parametroProducto: { | 70 | parametroProducto: { |
| 70 | idLista: parseInt(id), | 71 | idLista: parseInt(id), |
| 71 | cotizacion: 1, | 72 | cotizacion: 1, |
| 72 | simbolo: '$', | 73 | simbolo: '$', |
| 73 | soloMostrar: true | 74 | soloMostrar: true |
| 74 | } | 75 | } |
| 75 | }, | 76 | }, |
| 76 | size: 'md' | 77 | size: 'md' |
| 77 | } | 78 | } |
| 78 | ); | 79 | ); |
| 79 | }; | 80 | }; |
| 80 | //#endregion | 81 | //#endregion |
| 81 | $scope.closeModalPrecioCondicion = function () { | 82 | $scope.closeModalPrecioCondicion = function () { |
| 82 | $uibModalInstance.dismiss('cancel'); | 83 | $uibModalInstance.dismiss('cancel'); |
| 83 | }; | 84 | }; |
| 84 | $scope.guardarPrecioCondicion = function () { | 85 | $scope.guardarPrecioCondicion = function () { |
| 85 | var precioCondicion = { | 86 | var mod = $scope.associatedList ? parseInt($scope.listaDePreciosAsociada.ID) : parseInt($scope.listaDePreciosAlternativa.ID); |
| 86 | listaPrecio: $scope.associatedList ? $scope.listaDePreciosAsociada : $scope.listaDePreciosAlternativa, | 87 | |
| 87 | }; | 88 | focaModalPrecioCondicionService.actualizarLista(idCliente, mod).then(function (){ |
| 88 | $uibModalInstance.close(precioCondicion); | 89 | var precioCondicion = { |
| 90 | listaPrecio: $scope.associatedList ? $scope.listaDePreciosAsociada : $scope.listaDePreciosAlternativa, | ||
| 91 | }; | ||
| 92 | $uibModalInstance.close(precioCondicion); | ||
| 93 | }); | ||
| 89 | }; | 94 | }; |
| 90 | } | 95 | } |
| 91 | ]) | 96 | ]) |
| 92 | 97 | ||
| 93 | .controller('focaModalListaPlazosController', | 98 | .controller('focaModalListaPlazosController', |
| 94 | [ | 99 | [ |
| 95 | '$timeout', | 100 | '$timeout', |
| 96 | '$filter', | 101 | '$filter', |
| 97 | '$scope', | 102 | '$scope', |
| 98 | '$uibModal', | 103 | '$uibModal', |
| 99 | '$uibModalInstance', | 104 | '$uibModalInstance', |
| 100 | 'focaModalService', | 105 | 'focaModalService', |
| 101 | 'focaModalPrecioCondicionService', | 106 | 'focaModalPrecioCondicionService', |
| 102 | 'idCliente', | 107 | 'idCliente', |
| 103 | function ( | 108 | function ( |
| 104 | $timeout, $filter, $scope, $uibModal, $uibModalInstance, | 109 | $timeout, $filter, $scope, $uibModal, $uibModalInstance, |
| 105 | focaModalService, focaModalPrecioCondicionService,idCliente | 110 | focaModalService, focaModalPrecioCondicionService,idCliente |
| 106 | ) { | 111 | ) { |
| 107 | $scope.plazos = [ | 112 | $scope.plazos = [ |
| 108 | { | 113 | { |
| 109 | dias: 0, | 114 | dias: 0, |
| 110 | idCliente: idCliente, | 115 | idCliente: idCliente, |
| 111 | activo: true | 116 | activo: true |
| 112 | } | 117 | } |
| 113 | ]; | 118 | ]; |
| 114 | 119 | ||
| 115 | onInit(); | 120 | onInit(); |
| 116 | 121 | ||
| 117 | function onInit() { | 122 | function onInit() { |
| 118 | focaModalPrecioCondicionService.getPlazosByIdCliente(idCliente) | 123 | focaModalPrecioCondicionService.getPlazosByIdCliente(idCliente) |
| 119 | .then(function (res) { | 124 | .then(function (res) { |
| 120 | res.data.forEach(function (item) { | 125 | res.data.forEach(function (item) { |
| 121 | $scope.plazos.push(item); | 126 | $scope.plazos.push(item); |
| 122 | }); | 127 | }); |
| 123 | }) | 128 | }) |
| 124 | .catch(function (e) { console.error(e) }); | 129 | .catch(function (e) { console.error(e) }); |
| 125 | } | 130 | } |
| 126 | 131 | ||
| 127 | //#region Metodos para los plazos | 132 | //#region Metodos para los plazos |
| 128 | $scope.addPlazo = function (key) { | 133 | $scope.addPlazo = function (key) { |
| 129 | if (key != 13) return; | 134 | if (key != 13) return; |
| 130 | if ($scope.plazos.length === 100) return; | 135 | if ($scope.plazos.length === 100) return; |
| 131 | for (var i = 1; i < $scope.plazos.length; i++) { | 136 | for (var i = 1; i < $scope.plazos.length; i++) { |
| 132 | if ($scope.plazos[0].dias == $scope.plazos[i].dias && $scope.plazos[i].activo == true) { | 137 | if ($scope.plazos[0].dias == $scope.plazos[i].dias && $scope.plazos[i].activo == true) { |
| 133 | focaModalService.alert("Ya existe un plazo con este valor"); | 138 | focaModalService.alert("Ya existe un plazo con este valor"); |
| 134 | return; | 139 | return; |
| 135 | } | 140 | } |
| 136 | } | 141 | } |
| 137 | $scope.plazos.unshift({ dias: 0, idCliente: idCliente, activo: true }); | 142 | $scope.plazos.unshift({ dias: 0, idCliente: idCliente, activo: true }); |
| 138 | $scope.focused = 1; | 143 | $scope.focused = 1; |
| 139 | }; | 144 | }; |
| 140 | $scope.deletePlazo = function (index) { | 145 | $scope.deletePlazo = function (index) { |
| 141 | $scope.plazos[index].activo = false; | 146 | $scope.plazos[index].activo = false; |
| 142 | }; | 147 | }; |
| 143 | $scope.validateMinMax = function (plazo, min, max) { | 148 | $scope.validateMinMax = function (plazo, min, max) { |
| 144 | plazo.dias = parseInt(plazo.dias); | 149 | plazo.dias = parseInt(plazo.dias); |
| 145 | if (plazo.dias === null || plazo.dias === undefined || isNaN(plazo.dias)) { | 150 | if (plazo.dias === null || plazo.dias === undefined || isNaN(plazo.dias)) { |
| 146 | plazo.dias = '0'; | 151 | plazo.dias = '0'; |
| 147 | return; | 152 | return; |
| 148 | } | 153 | } |
| 149 | if (parseInt(plazo.dias) < min) { | 154 | if (parseInt(plazo.dias) < min) { |
| 150 | plazo.dias = '0'; | 155 | plazo.dias = '0'; |
| 151 | return; | 156 | return; |
| 152 | } | 157 | } |
| 153 | if (parseInt(plazo.dias) > max) { | 158 | if (parseInt(plazo.dias) > max) { |
| 154 | plazo.dias = '365'; | 159 | plazo.dias = '365'; |
| 155 | return; | 160 | return; |
| 156 | } | 161 | } |
| 157 | }; | 162 | }; |
| 158 | //#endregion | 163 | //#endregion |
| 159 | 164 | ||
| 160 | $scope.closeModalPrecioCondicion = function () { | 165 | $scope.closeModalPrecioCondicion = function () { |
| 161 | $uibModalInstance.dismiss('cancel'); | 166 | $uibModalInstance.dismiss('cancel'); |
| 162 | }; | 167 | }; |
| 163 | $scope.guardarPlazos = function () { | 168 | $scope.guardarPlazos = function () { |
| 164 | $scope.plazos.shift(); | 169 | $scope.plazos.shift(); |
| 165 | focaModalPrecioCondicionService.createPlazo($scope.plazos) | 170 | focaModalPrecioCondicionService.createPlazo($scope.plazos) |
| 166 | .then(function () { | 171 | .then(function () { |
| 167 | var precioCondicion = { | 172 | var precioCondicion = { |
| 168 | plazoPago: $filter('filter')($scope.plazos, { activo: true }, true) | 173 | plazoPago: $filter('filter')($scope.plazos, { activo: true }, true) |
| 169 | }; | 174 | }; |
| 170 | $uibModalInstance.close(precioCondicion); | 175 | $uibModalInstance.close(precioCondicion); |
| 171 | }) | 176 | }) |
| 172 | .catch(function (e) { console.error(e) }) | 177 | .catch(function (e) { console.error(e) }) |
| 173 | }; | 178 | }; |
| 174 | } | 179 | } |
| 175 | ]); | 180 | ]); |
| 176 | 181 |
src/js/service.js
| 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 | }, | 23 | }, |
| 24 | getPlazosByIdCliente: function (id) { | 24 | getPlazosByIdCliente: function (id) { |
| 25 | return $http.get(API_ENDPOINT.URL + '/plazo-pago/cliente/' + id); | 25 | return $http.get(API_ENDPOINT.URL + '/plazo-pago/cliente/' + id); |
| 26 | }, | 26 | }, |
| 27 | createPlazo: function (plazosPago){ | 27 | createPlazo: function (plazosPago){ |
| 28 | return $http.post(API_ENDPOINT.URL + '/plazos-pago', { plazosPago: plazosPago }); | 28 | return $http.post(API_ENDPOINT.URL + '/plazos-pago', { plazosPago: plazosPago }); |
| 29 | }, | ||
| 30 | actualizarLista: function(id , mod) { | ||
| 31 | return $http.post(API_ENDPOINT.URL + '/cliente/update/mod', { id: id, mod: mod}); | ||
| 29 | } | 32 | } |
| 30 | }; | 33 | }; |
| 31 | } | 34 | } |
| 32 | ]); | 35 | ]); |
| 33 | 36 |