Commit f4c819c10638d75d8fa71c24bb27c718233ff32f
Exists in
master
and in
1 other branch
Merge branch 'master' into 'master'
Master See merge request modulos-npm/foca-crear-nota-pedido!13
Showing
3 changed files
 
Show diff stats
src/js/controller.js
| ... | ... | @@ -3,7 +3,7 @@ angular.module('focaCrearNotaPedido') | 
| 3 | 3 | ['$scope', '$uibModal', '$location', 'crearNotaPedidoService', 'focaModalService', | 
| 4 | 4 | function($scope, $uibModal, $location, crearNotaPedidoService, focaModalService) { | 
| 5 | 5 | $scope.show = false; | 
| 6 | - $scope.edit = false; | |
| 6 | + $scope.cargando = true; | |
| 7 | 7 | $scope.dateOptions = { | 
| 8 | 8 | maxDate: new Date(), | 
| 9 | 9 | minDate: new Date(2010, 0, 1) | 
| ... | ... | @@ -60,25 +60,28 @@ angular.module('focaCrearNotaPedido') | 
| 60 | 60 | $scope.crearNotaPedido = function() { | 
| 61 | 61 | var notaPedido = { | 
| 62 | 62 | id: 0, | 
| 63 | - precioCondicion: $scope.notaPedido.precioCondicion, | |
| 64 | 63 | fechaCarga: $scope.notaPedido.fechaCarga, | 
| 65 | - vendedor: $scope.notaPedido.vendedor, | |
| 66 | - cliente: $scope.notaPedido.cliente, | |
| 67 | - producto: $scope.notaPedido.producto, | |
| 64 | + vendedor: $scope.notaPedido.vendedor.nombre, | |
| 65 | + cliente: $scope.notaPedido.cliente.nombre, | |
| 66 | + domicilio: $scope.notaPedido.domicilio.id, | |
| 67 | + precioCondicion: $scope.notaPedido.precioCondicion, | |
| 68 | 68 | bomba: $scope.notaPedido.bomba, | 
| 69 | - petrolera: $scope.notaPedido.petrolera, | |
| 70 | - domicilio: $scope.notaPedido.domicilio, | |
| 71 | - kilometros: $scope.notaPedido.kilometros, | |
| 72 | - jurisdiccionIIBB: $scope.notaPedido.jurisdiccionIIBB, | |
| 73 | - costoFinanciacion: $scope.notaPedido.costoFinanciacion, | |
| 74 | 69 | flete: $scope.notaPedido.flete, | 
| 75 | - costoUnitarioKmFlete: $scope.notaPedido.costoUnitarioKmFlete, | |
| 76 | - total: $scope.articulosTabla[0].subTotal | |
| 70 | + total: $scope.getTotal() | |
| 77 | 71 | }; | 
| 78 | 72 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( | 
| 79 | 73 | function() { | 
| 80 | - focaModalService('Nota pedido creada'); | |
| 81 | - $location.path('/venta-nota-pedido'); | |
| 74 | + focaModalService.alert('Nota pedido creada'); | |
| 75 | + // $location.path('/venta-nota-pedido'); | |
| 76 | + // var flete = { | |
| 77 | + // idNotaPedido: data.data.id, | |
| 78 | + // idTransportista: $scope.notaPedido.fleteId, | |
| 79 | + // idChofer: $scope.chofer.id, | |
| 80 | + // idVehiculo: $scope.vehiculo.id, | |
| 81 | + // kilometros: $scope.notaPedido.kilometros, | |
| 82 | + // costoKilometro: $scope.notaPedido.costoUnitarioKmFlete | |
| 83 | + // }; | |
| 84 | + //TO DO - Insert de flete | |
| 82 | 85 | } | 
| 83 | 86 | ); | 
| 84 | 87 | var articulosNotaPedido = $scope.articulosTabla; | 
| ... | ... | @@ -90,6 +93,7 @@ angular.module('focaCrearNotaPedido') | 
| 90 | 93 | } | 
| 91 | 94 | ); | 
| 92 | 95 | } | 
| 96 | + | |
| 93 | 97 | }; | 
| 94 | 98 | $scope.siguienteTab = function() { | 
| 95 | 99 | $scope.active = 1; | 
| ... | ... | @@ -121,9 +125,10 @@ angular.module('focaCrearNotaPedido') | 
| 121 | 125 | nombre: producto.descripcion, | 
| 122 | 126 | precio: producto.precio.toFixed(2), | 
| 123 | 127 | costoUnitario: producto.costo, | 
| 124 | - cantidad: 1 | |
| 128 | + edit: false | |
| 125 | 129 | }; | 
| 126 | 130 | $scope.articuloACargar = newArt; | 
| 131 | + $scope.cargando = false; | |
| 127 | 132 | }, function() { | 
| 128 | 133 | // funcion ejecutada cuando se cancela el modal | 
| 129 | 134 | } | 
| ... | ... | @@ -247,8 +252,11 @@ angular.module('focaCrearNotaPedido') | 
| 247 | 252 | function(flete) { | 
| 248 | 253 | $scope.choferes = ''; | 
| 249 | 254 | $scope.vehiculos = ''; | 
| 255 | + $scope.notaPedido.chofer = ''; | |
| 256 | + $scope.notaPedido.vehiculo = ''; | |
| 257 | + $scope.notaPedido.costoUnitarioKmFlete = ''; | |
| 250 | 258 | $scope.notaPedido.fleteNombre = flete.nombre; | 
| 251 | - $scope.notaPedido.costoUnitarioKmFlete = flete.costoKilometro; | |
| 259 | + $scope.notaPedido.fleteId = flete.id; | |
| 252 | 260 | $scope.choferes = flete.chofer; | 
| 253 | 261 | $scope.vehiculos = flete.vehiculo; | 
| 254 | 262 | }, function() { | 
| ... | ... | @@ -259,20 +267,31 @@ angular.module('focaCrearNotaPedido') | 
| 259 | 267 | }; | 
| 260 | 268 | $scope.agregarATabla = function(key) { | 
| 261 | 269 | if(key === 13) { | 
| 270 | + if($scope.articuloACargar.cantidad === undefined || | |
| 271 | + $scope.articuloACargar.cantidad === 0 || | |
| 272 | + $scope.articuloACargar.cantidad === null ){ | |
| 273 | + focaModalService.alert('El valor debe ser al menos 1'); | |
| 274 | + return; | |
| 275 | + } | |
| 262 | 276 | $scope.articulosTabla.unshift($scope.articuloACargar); | 
| 263 | - $scope.articuloACargar = undefined; | |
| 277 | + $scope.cargando = true; | |
| 264 | 278 | } | 
| 265 | 279 | }; | 
| 266 | 280 | $scope.quitarArticulo = function(key) { | 
| 267 | 281 | $scope.articulosTabla.splice(key, 1); | 
| 268 | 282 | }; | 
| 269 | - $scope.editarArticulo = function(key) { | |
| 283 | + $scope.editarArticulo = function(key, articulo) { | |
| 270 | 284 | if(key === 13) { | 
| 271 | - $scope.edit = false; | |
| 272 | - } | |
| 285 | + if(articulo.cantidad === null || articulo.cantidad === 0 || | |
| 286 | + articulo.cantidad === undefined){ | |
| 287 | + focaModalService.alert('El valor debe ser al menos 1'); | |
| 288 | + return; | |
| 289 | + } | |
| 290 | + articulo.edit = false; | |
| 291 | + } | |
| 273 | 292 | }; | 
| 274 | - $scope.cambioEdit = function() { | |
| 275 | - $scope.edit = !$scope.edit ? true : false; | |
| 293 | + $scope.cambioEdit = function(articulo) { | |
| 294 | + articulo.edit = true; | |
| 276 | 295 | }; | 
| 277 | 296 | $scope.limpiarFlete = function() { | 
| 278 | 297 | $scope.notaPedido.fleteNombre = ''; | 
| ... | ... | @@ -295,6 +314,10 @@ angular.module('focaCrearNotaPedido') | 
| 295 | 314 | $scope.domicilio.dom = ''; | 
| 296 | 315 | $scope.notaPedido.flete = 0; | 
| 297 | 316 | }; | 
| 317 | + $scope.resetFilter = function() { | |
| 318 | + $scope.articuloACargar = {}; | |
| 319 | + $scope.cargando = true; | |
| 320 | + }; | |
| 298 | 321 | } | 
| 299 | 322 | ] | 
| 300 | 323 | ) | 
src/js/service.js
| ... | ... | @@ -55,6 +55,9 @@ angular.module('focaCrearNotaPedido') | 
| 55 | 55 | }, | 
| 56 | 56 | getPlazoPagoByPrecioCondicion: function(id) { | 
| 57 | 57 | return $http.get(route + '/plazo-pago/precio-condicion/'+ id); | 
| 58 | + }, | |
| 59 | + crearFlete: function(flete) { | |
| 60 | + return $http.post(route + '/flete', {flete : flete}); | |
| 58 | 61 | } | 
| 59 | 62 | }; | 
| 60 | 63 | }]); | 
src/views/nota-pedido.html
| ... | ... | @@ -59,15 +59,10 @@ | 
| 59 | 59 | <input | 
| 60 | 60 | class="form-control selectable" | 
| 61 | 61 | type="text" | 
| 62 | - ng-model="domicilio.dom" | |
| 63 | - ng-click="abrirModalDomicilio()" | |
| 62 | + ng-model="domicilio" | |
| 64 | 63 | placeholder="Seleccione Domicilio" | 
| 65 | - uib-typeahead=" | |
| 66 | - domi.dom | |
| 67 | - for domi | |
| 68 | - in domiciliosCliente | |
| 69 | - " | |
| 70 | 64 | typeahead-min-length="0" | 
| 65 | + uib-typeahead="domi as domi.dom for domi in domiciliosCliente" | |
| 71 | 66 | > | 
| 72 | 67 | </div> | 
| 73 | 68 | <div class="form-group col-12 col-sm-6 col-md-4"> | 
| ... | ... | @@ -141,7 +136,7 @@ | 
| 141 | 136 | ng-show="notaPedido.flete == 1" | 
| 142 | 137 | ng-model="notaPedido.chofer" | 
| 143 | 138 | placeholder="Seleccione Chofer" | 
| 144 | - uib-typeahead="chofer.nombre for chofer in choferes" | |
| 139 | + uib-typeahead="chofer as chofer.nombre for chofer in choferes" | |
| 145 | 140 | typeahead-min-length="0" | 
| 146 | 141 | > | 
| 147 | 142 | </div> | 
| ... | ... | @@ -152,7 +147,7 @@ | 
| 152 | 147 | ng-show="notaPedido.flete == 1" | 
| 153 | 148 | ng-model="notaPedido.vehiculo" | 
| 154 | 149 | placeholder="Seleccione Vehรญculo" | 
| 155 | - uib-typeahead="vehiculo.tractor for vehiculo in vehiculos" | |
| 150 | + uib-typeahead="vehiculo as vehiculo.tractor for vehiculo in vehiculos" | |
| 156 | 151 | typeahead-min-length="0" | 
| 157 | 152 | > | 
| 158 | 153 | </div> | 
| ... | ... | @@ -179,7 +174,13 @@ | 
| 179 | 174 | </div> | 
| 180 | 175 | </div> | 
| 181 | 176 | <div class="col-auto my-2"> | 
| 182 | - <button ng-click="crearPedidoDemo()" type="button" title="Crear nota pedido" class="btn btn-primary float-right">Crear</button> | |
| 177 | + <button | |
| 178 | + ng-click="crearNotaPedido()" | |
| 179 | + type="button" | |
| 180 | + title="Crear nota pedido" | |
| 181 | + class="btn btn-primary float-right"> | |
| 182 | + Guardar | |
| 183 | + </button> | |
| 183 | 184 | </div> | 
| 184 | 185 | </div> | 
| 185 | 186 | <div class="row"> | 
| ... | ... | @@ -205,15 +206,19 @@ | 
| 205 | 206 | </tr> | 
| 206 | 207 | </thead> | 
| 207 | 208 | <tbody> | 
| 208 | - <tr ng-show="!articuloACargar"> | |
| 209 | - <td colspan="2"><input placeholder="Seleccione Articulo" class="form-control" readonly ng-click="seleccionarArticulo()"></td> | |
| 209 | + <tr ng-show="cargando"> | |
| 210 | + <td colspan="2"><input | |
| 211 | + placeholder="Seleccione Articulo" | |
| 212 | + class="form-control" | |
| 213 | + readonly | |
| 214 | + ng-click="seleccionarArticulo()"></td> | |
| 210 | 215 | <td></td> | 
| 211 | 216 | <td></td> | 
| 212 | 217 | <td></td> | 
| 213 | 218 | <td></td> | 
| 214 | 219 | <td></td> | 
| 215 | 220 | </tr> | 
| 216 | - <tr ng-show="articuloACargar"> | |
| 221 | + <tr ng-show="!cargando"> | |
| 217 | 222 | <td><input | 
| 218 | 223 | class="form-control" | 
| 219 | 224 | ng-model="articuloACargar.sector" | 
| ... | ... | @@ -234,9 +239,9 @@ | 
| 234 | 239 | class="form-control" | 
| 235 | 240 | type="number" | 
| 236 | 241 | min="1" | 
| 237 | - value="1" | |
| 238 | 242 | ng-model="articuloACargar.cantidad" | 
| 239 | - foca-focus="articuloACargar.cantidad == 1" | |
| 243 | + foca-focus="!cargando" | |
| 244 | + esc-key="resetFilter()" | |
| 240 | 245 | ng-keypress="agregarATabla($event.keyCode)"></td> | 
| 241 | 246 | <td><input | 
| 242 | 247 | class="form-control" | 
| ... | ... | @@ -254,15 +259,19 @@ | 
| 254 | 259 | <td ng-bind="articulo.descripcion"></td> | 
| 255 | 260 | <td ng-bind="articulo.precio | currency:'$'"></td> | 
| 256 | 261 | <td><input | 
| 257 | - ng-show="edit" | |
| 262 | + ng-show="articulo.edit" | |
| 258 | 263 | ng-model="articulo.cantidad" | 
| 259 | 264 | class="form-control" | 
| 260 | 265 | type="number" | 
| 261 | 266 | min="1" | 
| 262 | - value="1" | |
| 263 | - foca-focus="edit" | |
| 264 | - ng-keypress="editarArticulo($event.keyCode)"> | |
| 265 | - <i class="selectable" ng-click="cambioEdit()" ng-hide="edit" ng-bind="articulo.cantidad"></i> | |
| 267 | + foca-focus="articulo.edit" | |
| 268 | + ng-keypress="editarArticulo($event.keyCode, articulo)"> | |
| 269 | + <i | |
| 270 | + class="selectable" | |
| 271 | + ng-click="cambioEdit(articulo)" | |
| 272 | + ng-hide="articulo.edit" | |
| 273 | + ng-bind="articulo.cantidad"> | |
| 274 | + </i> | |
| 266 | 275 | </td> | 
| 267 | 276 | <td ng-bind="(articulo.precio * articulo.cantidad) | currency: '$'"></td> | 
| 268 | 277 | <td class="text-center"> |