Commit 47bc57f50a176ecc6848dfff9b8c523da933f229
1 parent
7febaeb82a
Exists in
master
and in
1 other branch
agrego llamadas a los modal
varios
Showing
1 changed file
with
101 additions
and
39 deletions
Show diff stats
src/js/controller.js
| ... | ... | @@ -6,44 +6,28 @@ angular.module('focaCrearNotaPedido') |
| 6 | 6 | 'crearNotaPedidoService', |
| 7 | 7 | function ($scope, $uibModal, crearNotaPedidoService) { |
| 8 | 8 | $scope.notaPedido = {}; |
| 9 | + $scope.articulosTabla = []; | |
| 10 | + var idLista; | |
| 9 | 11 | var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); |
| 10 | - var domiciliosCliente = [ | |
| 11 | - { | |
| 12 | - dom: 'sanjuan', | |
| 13 | - id: 3 | |
| 14 | - }, | |
| 15 | - { | |
| 16 | - dom: 'mendoza', | |
| 17 | - id: 2 | |
| 12 | + $scope.domiciliosCliente = crearNotaPedidoService.getDomicilios(1); | |
| 13 | + crearNotaPedidoService.getPrecioCondicion().then( | |
| 14 | + function (res) { | |
| 15 | + $scope.precioCondiciones = res.data; | |
| 18 | 16 | } |
| 19 | - ] | |
| 17 | + ); | |
| 20 | 18 | if (notaPedidoTemp != undefined) { |
| 21 | 19 | notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); |
| 22 | 20 | $scope.notaPedido = notaPedidoTemp; |
| 23 | - $scope.notaPedido.domicilio = domiciliosCliente; | |
| 21 | + $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); | |
| 22 | + $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); | |
| 23 | + $scope.notaPedido.precioCondicion = 2; | |
| 24 | + | |
| 24 | 25 | } else { |
| 25 | 26 | $scope.notaPedido.fechaCarga = new Date(); |
| 26 | - | |
| 27 | - $scope.notaPedido.domicilio = domiciliosCliente; | |
| 27 | + $scope.notaPedido.domicilio = [{ id: 0 }] | |
| 28 | + $scope.notaPedido.bomba = '1'; | |
| 29 | + $scope.notaPedido.flete = '1'; | |
| 28 | 30 | } |
| 29 | - $scope.precioCondiciones = [ | |
| 30 | - { nombre: 'Precio y condicion 1' }, | |
| 31 | - { nombre: 'Precio y condicion 2' }, | |
| 32 | - { nombre: 'Precio y condicion 3' } | |
| 33 | - ] | |
| 34 | - $scope.articulosTabla = [ | |
| 35 | - { | |
| 36 | - codigo: '1', | |
| 37 | - item: 1, | |
| 38 | - nombre: 'naftaaskdahsñodaskdjhañslkdjahslñkjdhalskjdhaksjdhkasjhasddddddddddddddddddddddddddddddddddddddddddddddddd', | |
| 39 | - precio: '14,50', | |
| 40 | - costoUnitario: '14', | |
| 41 | - cantidad: 1, | |
| 42 | - subtotal: '19,22' | |
| 43 | - } | |
| 44 | - ] | |
| 45 | - $scope.notaPedido.bomba = '1'; | |
| 46 | - $scope.notaPedido.flete = '1'; | |
| 47 | 31 | $scope.addNewDom = function () { |
| 48 | 32 | $scope.notaPedido.domicilio.push({ 'id': 0 }); |
| 49 | 33 | } |
| ... | ... | @@ -56,7 +40,7 @@ angular.module('focaCrearNotaPedido') |
| 56 | 40 | var notaPedido = { |
| 57 | 41 | idNotaPedido: 0, |
| 58 | 42 | precioCondicion: $scope.notaPedido.precioCondicion, |
| 59 | - fechaCarga: $scope.notaPedido.clientefechaCarga, | |
| 43 | + fechaCarga: $scope.notaPedido.fechaCarga, | |
| 60 | 44 | vendedor: $scope.notaPedido.vendedor, |
| 61 | 45 | cliente: $scope.notaPedido.cliente, |
| 62 | 46 | producto: $scope.notaPedido.producto, |
| ... | ... | @@ -64,10 +48,11 @@ angular.module('focaCrearNotaPedido') |
| 64 | 48 | petrolera: $scope.notaPedido.petrolera, |
| 65 | 49 | domicilio: $scope.notaPedido.domicilio, |
| 66 | 50 | kilometros: $scope.notaPedido.kilometros, |
| 67 | - jurisdiccionIIBB: $scope.notaPedido.jurisdiccion, | |
| 51 | + jurisdiccionIIBB: $scope.notaPedido.jurisdiccionIIBB, | |
| 68 | 52 | costoFinanciacion: $scope.notaPedido.costoFinanciacion, |
| 69 | 53 | flete: $scope.notaPedido.flete, |
| 70 | - costoUnitarioKmFlete: $scope.costoUnitarioKmFlete | |
| 54 | + costoUnitarioKmFlete: $scope.notaPedido.costoUnitarioKmFlete, | |
| 55 | + articulosTabla: $scope.articulosTabla | |
| 71 | 56 | } |
| 72 | 57 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( |
| 73 | 58 | function (res) { |
| ... | ... | @@ -79,23 +64,87 @@ angular.module('focaCrearNotaPedido') |
| 79 | 64 | $scope.active = 1; |
| 80 | 65 | } |
| 81 | 66 | $scope.seleccionarArticulo = function () { |
| 82 | - var modalIntance = $uibModal.open( | |
| 67 | + if(idLista==undefined){ | |
| 68 | + alert('primero seleccione una lista de precio y condicion'); | |
| 69 | + return; | |
| 70 | + } | |
| 71 | + var modalInstance = $uibModal.open( | |
| 83 | 72 | { |
| 84 | 73 | ariaLabelledBy: 'Busqueda de Productos', |
| 85 | 74 | templateUrl: 'modal-busqueda-productos.html', |
| 86 | 75 | controller: 'modalBusquedaProductosCtrl', |
| 87 | - size: 'md' | |
| 76 | + resolve: {idLista: function() {return idLista}}, | |
| 77 | + size: 'lg' | |
| 88 | 78 | } |
| 89 | 79 | ) |
| 90 | 80 | modalInstance.result.then( |
| 91 | 81 | function (producto) { |
| 92 | - console.info(producto); | |
| 93 | - // variable producto tiene el producto seleccionado en el modal | |
| 82 | + var newArt = | |
| 83 | + { | |
| 84 | + codigo: producto.FiltroSectorCodigo, | |
| 85 | + item: $scope.articulosTabla.length + 1, | |
| 86 | + nombre: producto.descripcion, | |
| 87 | + precio: producto.precio, | |
| 88 | + costoUnitario: producto.costo, | |
| 89 | + cantidad: 1 | |
| 90 | + } | |
| 91 | + $scope.articulosTabla.unshift(newArt); | |
| 94 | 92 | }, function () { |
| 95 | 93 | // funcion ejecutada cuando se cancela el modal |
| 96 | 94 | } |
| 97 | 95 | ); |
| 98 | 96 | } |
| 97 | + $scope.seleccionarVendedor = function () { | |
| 98 | + var modalInstance = $uibModal.open( | |
| 99 | + { | |
| 100 | + ariaLabelledBy: 'Busqueda de Vendedores', | |
| 101 | + templateUrl: 'modal-vendedores.html', | |
| 102 | + controller: 'modalVendedoresCtrl', | |
| 103 | + size: 'lg' | |
| 104 | + } | |
| 105 | + ) | |
| 106 | + modalInstance.result.then( | |
| 107 | + function (vendedor) { | |
| 108 | + $scope.notaPedido.vendedor = vendedor.NomVen; | |
| 109 | + }, function () { | |
| 110 | + | |
| 111 | + } | |
| 112 | + ); | |
| 113 | + } | |
| 114 | + $scope.seleccionarPetrolera = function() { | |
| 115 | + var modalInstance = $uibModal.open( | |
| 116 | + { | |
| 117 | + ariaLabelledBy: 'Busqueda de Petrolera', | |
| 118 | + templateUrl: 'modal-petroleras.html', | |
| 119 | + controller: 'modalPetrolerasCtrl', | |
| 120 | + size: 'lg' | |
| 121 | + } | |
| 122 | + ) | |
| 123 | + modalInstance.result.then( | |
| 124 | + function (petrolera) { | |
| 125 | + $scope.notaPedido.petrolera = petrolera.NOM; | |
| 126 | + }, function () { | |
| 127 | + | |
| 128 | + } | |
| 129 | + ); | |
| 130 | + } | |
| 131 | + $scope.seleccionarCliente = function() { | |
| 132 | + var modalInstance = $uibModal.open( | |
| 133 | + { | |
| 134 | + ariaLabelledBy: 'Busqueda de Cliente', | |
| 135 | + templateUrl: 'foca-busqueda-cliente-modal.html', | |
| 136 | + controller: 'focaBusquedaClienteModalController', | |
| 137 | + size: 'lg' | |
| 138 | + } | |
| 139 | + ) | |
| 140 | + modalInstance.result.then( | |
| 141 | + function (cliente) { | |
| 142 | + $scope.notaPedido.cliente = cliente.nom; | |
| 143 | + }, function () { | |
| 144 | + | |
| 145 | + } | |
| 146 | + ); | |
| 147 | + } | |
| 99 | 148 | $scope.obtenerDomicilios = function (id) { |
| 100 | 149 | crearNotaPedidoService.getDomicilios(id).then( |
| 101 | 150 | function (res) { |
| ... | ... | @@ -103,6 +152,17 @@ angular.module('focaCrearNotaPedido') |
| 103 | 152 | } |
| 104 | 153 | ) |
| 105 | 154 | } |
| 155 | + $scope.getSubTotal = function(item) { | |
| 156 | + var subTotal=0; | |
| 157 | + var array = $scope.articulosTabla.filter(a=>a.item<=item); | |
| 158 | + for(var i = 0; i< array.length; i++) { | |
| 159 | + subTotal+=array[i].precio*array[i].cantidad | |
| 160 | + } | |
| 161 | + return subTotal.toFixed(2); | |
| 162 | + } | |
| 163 | + $scope.cargarArticulos = function() { | |
| 164 | + idLista=$scope.notaPedido.precioCondicion; | |
| 165 | + } | |
| 106 | 166 | } |
| 107 | 167 | ] |
| 108 | 168 | ) |
| ... | ... | @@ -117,7 +177,9 @@ angular.module('focaCrearNotaPedido') |
| 117 | 177 | $scope.editar = function (notaPedido) { |
| 118 | 178 | crearNotaPedidoService.setNotaPedido(notaPedido); |
| 119 | 179 | $location.path('/venta-nota-pedido/abm/'); |
| 120 | - }; | |
| 180 | + } | |
| 181 | + $scope.crearPedido = function () { | |
| 182 | + $location.path('/venta-nota-pedido/abm/'); | |
| 183 | + } | |
| 121 | 184 | } |
| 122 | 185 | ]) |
| 123 | - |