Commit 8a4d6cf29c72dfedfee1445ede4663ca9a363c56
Exists in
master
Merge branch 'master' into 'develop'
Master(mpuebla) See merge request !68
Showing
2 changed files
Show diff stats
package.json
| ... | ... | @@ -4,6 +4,7 @@ |
| 4 | 4 | "description": "foca-crear-hoja-ruta", |
| 5 | 5 | "main": "index.js", |
| 6 | 6 | "scripts": { |
| 7 | + "refresh" : "gulp uglify && cp tmp/foca-crear-hoja-ruta.js ../wrapper-demo/node_modules/foca-crear-hoja-ruta/dist/foca-crear-hoja-ruta.min.js", | |
| 7 | 8 | "test": "test.html", |
| 8 | 9 | "compile": "gulp uglify", |
| 9 | 10 | "gulp-pre-commit": "gulp pre-commit", |
src/js/controller.js
| ... | ... | @@ -48,13 +48,13 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 48 | 48 | |
| 49 | 49 | var parametros = JSON.parse(res.data[0].jsonText); |
| 50 | 50 | |
| 51 | - $timeout(function () { | |
| 51 | + $timeout(function () { | |
| 52 | 52 | getLSBotoneraPrincipal(); |
| 53 | 53 | }); |
| 54 | 54 | |
| 55 | 55 | if ($localStorage.data) { |
| 56 | - $timeout(function () { | |
| 57 | - getLSHojaRuta(); | |
| 56 | + $timeout(function () { | |
| 57 | + getLSHojaRuta(); | |
| 58 | 58 | }); |
| 59 | 59 | |
| 60 | 60 | } else { |
| ... | ... | @@ -99,14 +99,15 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 99 | 99 | $scope.inicial = angular.copy($scope.hojaRuta); |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - $scope.$watchGroup(['hojaRuta','precargado','cargaRemito','remitoAbierto'], function(newValues) { | |
| 103 | - focaBotoneraLateralService.setPausarData( | |
| 104 | - { | |
| 105 | - label: 'data', | |
| 106 | - val: newValues | |
| 107 | - } | |
| 108 | - ); | |
| 109 | - }); | |
| 102 | + $scope.$watchGroup(['hojaRuta', 'precargado', 'cargaRemito', 'remitoAbierto'], | |
| 103 | + function (newValues) { | |
| 104 | + focaBotoneraLateralService.setPausarData( | |
| 105 | + { | |
| 106 | + label: 'data', | |
| 107 | + val: newValues | |
| 108 | + } | |
| 109 | + ); | |
| 110 | + }); | |
| 110 | 111 | |
| 111 | 112 | $scope.seleccionarRemitoAbierto = function () { |
| 112 | 113 | $scope.remitoAbierto = true; |
| ... | ... | @@ -271,7 +272,7 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 271 | 272 | |
| 272 | 273 | function getImporte(propiedad) { |
| 273 | 274 | var importe = 0; |
| 274 | - | |
| 275 | + | |
| 275 | 276 | $scope.articulos.forEach(function (articulo) { |
| 276 | 277 | |
| 277 | 278 | if (articulo[propiedad]) { |
| ... | ... | @@ -328,6 +329,9 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 328 | 329 | estado: 0, |
| 329 | 330 | destinoVenta: 0,//TODO |
| 330 | 331 | operacionTipo: 0, //TODO |
| 332 | + flete: false, | |
| 333 | + fob: false, | |
| 334 | + bomba: false, | |
| 331 | 335 | }, |
| 332 | 336 | notaPedido: { |
| 333 | 337 | id: 0 |
| ... | ... | @@ -347,17 +351,17 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 347 | 351 | idVehiculo: $scope.hojaRuta.vehiculo.id |
| 348 | 352 | }, data.data.id); |
| 349 | 353 | $scope.remito.numeroRemito = data.data.numero; |
| 350 | - | |
| 354 | + | |
| 351 | 355 | // if ($scope.remito.remitoPuntoDescarga.length > 0) { |
| 352 | 356 | // remitoBusinessService.addPuntosDescarga(data.data.id, |
| 353 | 357 | // $scope.remito.remitoPuntoDescarga); |
| 354 | 358 | // } |
| 355 | - | |
| 359 | + | |
| 356 | 360 | hojaRutaBusinessService.addArticulos($scope.articulosRecibidos, |
| 357 | 361 | data.data.id, $scope.hojaRuta.cotizacion.VENDEDOR); |
| 358 | 362 | |
| 359 | 363 | guardarHojaRuta(data.data.id); |
| 360 | - | |
| 364 | + | |
| 361 | 365 | }, function (error) { |
| 362 | 366 | focaModalService.alert( |
| 363 | 367 | error.data || 'Hubo un error al crear el remito'); |
| ... | ... | @@ -368,7 +372,7 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 368 | 372 | ); |
| 369 | 373 | |
| 370 | 374 | function guardarHojaRuta(idRemito) { |
| 371 | - | |
| 375 | + | |
| 372 | 376 | var save2 = { |
| 373 | 377 | hojaRuta: { |
| 374 | 378 | id: 0, |
| ... | ... | @@ -384,7 +388,7 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 384 | 388 | estado: 0, |
| 385 | 389 | abierta: 1 |
| 386 | 390 | }, |
| 387 | - remitos: [{id: idRemito}] | |
| 391 | + remitos: [{ id: idRemito }] | |
| 388 | 392 | }; |
| 389 | 393 | |
| 390 | 394 | save2.hojaRuta = angular |
| ... | ... | @@ -392,7 +396,7 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 392 | 396 | focaCrearHojaRutaService.crearHojaRuta(save2).then( |
| 393 | 397 | function (data) { |
| 394 | 398 | var remitoNumero; |
| 395 | - data.data.remitos.forEach(function(idRemitos) { | |
| 399 | + data.data.remitos.forEach(function (idRemitos) { | |
| 396 | 400 | remitoNumero = idRemitos; |
| 397 | 401 | }); |
| 398 | 402 | focaModalService.alert( |
| ... | ... | @@ -401,20 +405,20 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 401 | 405 | $filter('rellenarDigitos')(data.data.numeroHojaRuta, 8) + |
| 402 | 406 | '\nRemito Abierto Nยบ: ' + |
| 403 | 407 | $filter('rellenarDigitos')(remitoNumero.sucursal, 4) + '-' + |
| 404 | - $filter('rellenarDigitos')(remitoNumero.numeroRemito,8) | |
| 405 | - ); | |
| 406 | - | |
| 407 | - config(); | |
| 408 | - }, | |
| 409 | - function (error) { | |
| 410 | - | |
| 411 | - focaModalService | |
| 408 | + $filter('rellenarDigitos')(remitoNumero.numeroRemito, 8) | |
| 409 | + ); | |
| 410 | + | |
| 411 | + config(); | |
| 412 | + }, | |
| 413 | + function (error) { | |
| 414 | + | |
| 415 | + focaModalService | |
| 412 | 416 | .alert('Hubo un error al crear la hoja de ruta'); |
| 413 | 417 | |
| 414 | - console.info(error); | |
| 415 | - } | |
| 416 | - ); | |
| 417 | - } | |
| 418 | + console.info(error); | |
| 419 | + } | |
| 420 | + ); | |
| 421 | + } | |
| 418 | 422 | } |
| 419 | 423 | } |
| 420 | 424 | |
| ... | ... | @@ -472,7 +476,7 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 472 | 476 | $scope.$broadcast('addCabecera', { |
| 473 | 477 | label: 'Vendedor:', |
| 474 | 478 | valor: $filter('rellenarDigitos')($scope.hojaRuta.vendedor |
| 475 | - .NUM, 3) +' - ' + $scope.hojaRuta.vendedor.NOM | |
| 479 | + .NUM, 3) + ' - ' + $scope.hojaRuta.vendedor.NOM | |
| 476 | 480 | }); |
| 477 | 481 | } |
| 478 | 482 | var domicilioStamp = |
| ... | ... | @@ -537,9 +541,9 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 537 | 541 | } |
| 538 | 542 | ); |
| 539 | 543 | modalInstance.result.then( |
| 540 | - function(puntosDescarga) { | |
| 544 | + function (puntosDescarga) { | |
| 541 | 545 | |
| 542 | - puntosDescarga.forEach(function(punto) { | |
| 546 | + puntosDescarga.forEach(function (punto) { | |
| 543 | 547 | $scope.hojaRuta.remitoPuntoDescarga.push( |
| 544 | 548 | { |
| 545 | 549 | puntoDescarga: punto |
| ... | ... | @@ -623,43 +627,43 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 623 | 627 | }; |
| 624 | 628 | |
| 625 | 629 | $scope.seleccionarProveedor = function () { |
| 626 | - var parametrosModal = { | |
| 627 | - titulo: 'Bรบsqueda de Proveedor', | |
| 628 | - query: '/proveedor', | |
| 629 | - columnas: [ | |
| 630 | - { | |
| 631 | - nombre: 'Cรณdigo', | |
| 632 | - propiedad: 'COD', | |
| 633 | - filtro: { | |
| 634 | - nombre: 'rellenarDigitos', | |
| 635 | - parametro: 5 | |
| 636 | - } | |
| 637 | - }, | |
| 638 | - { | |
| 639 | - nombre: 'Nombre', | |
| 640 | - propiedad: 'NOM' | |
| 641 | - }, | |
| 642 | - { | |
| 643 | - nombre: 'CUIT', | |
| 644 | - propiedad: 'CUIT' | |
| 630 | + var parametrosModal = { | |
| 631 | + titulo: 'Bรบsqueda de Proveedor', | |
| 632 | + query: '/proveedor', | |
| 633 | + columnas: [ | |
| 634 | + { | |
| 635 | + nombre: 'Cรณdigo', | |
| 636 | + propiedad: 'COD', | |
| 637 | + filtro: { | |
| 638 | + nombre: 'rellenarDigitos', | |
| 639 | + parametro: 5 | |
| 645 | 640 | } |
| 646 | - ], | |
| 647 | - tipo: 'POST', | |
| 648 | - json: { razonCuitCod: '' } | |
| 649 | - }; | |
| 650 | - focaModalService.modal(parametrosModal).then( | |
| 651 | - function (proveedor) { | |
| 652 | - $filter('filter')($scope.botonera, { | |
| 653 | - label: 'Proveedor', | |
| 654 | - })[0].checked = true; | |
| 641 | + }, | |
| 642 | + { | |
| 643 | + nombre: 'Nombre', | |
| 644 | + propiedad: 'NOM' | |
| 645 | + }, | |
| 646 | + { | |
| 647 | + nombre: 'CUIT', | |
| 648 | + propiedad: 'CUIT' | |
| 649 | + } | |
| 650 | + ], | |
| 651 | + tipo: 'POST', | |
| 652 | + json: { razonCuitCod: '' } | |
| 653 | + }; | |
| 654 | + focaModalService.modal(parametrosModal).then( | |
| 655 | + function (proveedor) { | |
| 656 | + $filter('filter')($scope.botonera, { | |
| 657 | + label: 'Proveedor', | |
| 658 | + })[0].checked = true; | |
| 655 | 659 | |
| 656 | - $scope.$broadcast('addCabecera', { | |
| 657 | - label: 'Proveedor:', | |
| 658 | - valor: proveedor.COD + ' - ' + proveedor.NOM | |
| 659 | - }); | |
| 660 | - $scope.hojaRuta.proveedor = proveedor; | |
| 661 | - }, function () { } | |
| 662 | - ); | |
| 660 | + $scope.$broadcast('addCabecera', { | |
| 661 | + label: 'Proveedor:', | |
| 662 | + valor: proveedor.COD + ' - ' + proveedor.NOM | |
| 663 | + }); | |
| 664 | + $scope.hojaRuta.proveedor = proveedor; | |
| 665 | + }, function () { } | |
| 666 | + ); | |
| 663 | 667 | }; |
| 664 | 668 | |
| 665 | 669 | $scope.seleccionarTransportista = function () { |
| ... | ... | @@ -791,8 +795,8 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 791 | 795 | resolve: { usadoPor: function () { return 'hojaRuta'; } } |
| 792 | 796 | } |
| 793 | 797 | ); |
| 794 | - modalInstance.result.then( | |
| 795 | - function (remito) { | |
| 798 | + modalInstance.result | |
| 799 | + .then(function (remito) { | |
| 796 | 800 | // TODO: borrar cuando no se use definitivamente |
| 797 | 801 | // for (var i = $scope.hojaRuta.remitosTabla.length - 1; i >= 0; i--) { |
| 798 | 802 | // if ($scope.hojaRuta.remitosTabla[i].id === remito.id) { |
| ... | ... | @@ -825,19 +829,20 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 825 | 829 | |
| 826 | 830 | // remito.litros = litros; |
| 827 | 831 | // $scope.hojaRuta.litros = $scope.hojaRuta.litros + litros; |
| 828 | - $scope.cargarCisterna(remito.id).then(function () { | |
| 829 | - $scope.hojaRuta.remitosTabla.push(remito); | |
| 830 | - $filter('filter')($scope.botonera, { | |
| 831 | - label: 'Remitos', | |
| 832 | - })[0].checked = true; | |
| 832 | + $scope.cargarCisterna(remito.id) | |
| 833 | + .then(function () { | |
| 834 | + $scope.hojaRuta.remitosTabla.push(remito); | |
| 835 | + $filter('filter')($scope.botonera, { | |
| 836 | + label: 'Remitos', | |
| 837 | + })[0].checked = true; | |
| 833 | 838 | |
| 834 | - }, function (error) { | |
| 835 | - $scope.seleccionarRemitos(); | |
| 836 | - }); | |
| 837 | - }, function () { | |
| 838 | - // funcion ejecutada cuando se cancela el modal | |
| 839 | - } | |
| 840 | - ); | |
| 839 | + }) | |
| 840 | + .catch(function (error) { | |
| 841 | + console.error(error); | |
| 842 | + $scope.seleccionarRemitos(); | |
| 843 | + }); | |
| 844 | + }) | |
| 845 | + .catch(function (e) { console.error(e); }); | |
| 841 | 846 | }; |
| 842 | 847 | |
| 843 | 848 | $scope.seleccionarVehiculosPrecargados = function () { |
| ... | ... | @@ -856,8 +861,8 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 856 | 861 | resolve: { |
| 857 | 862 | idVehiculo: function () { return $scope.hojaRuta.vehiculo.id; }, |
| 858 | 863 | idRemito: function () { return idRemito; }, |
| 859 | - fechaReparto: function () { return $scope.hojaRuta.fechaReparto;}, | |
| 860 | - orden: function() { return $scope.hojaRuta.orden } | |
| 864 | + fechaReparto: function () { return $scope.hojaRuta.fechaReparto; }, | |
| 865 | + orden: function () { return $scope.hojaRuta.orden; } | |
| 861 | 866 | } |
| 862 | 867 | } |
| 863 | 868 | ); |
| ... | ... | @@ -968,8 +973,7 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 968 | 973 | }; |
| 969 | 974 | |
| 970 | 975 | $scope.mostrarDetalle = function (hojasRutas) { |
| 971 | - | |
| 972 | - var modalInstance =$uibModal.open( | |
| 976 | + var modalInstance = $uibModal.open( | |
| 973 | 977 | { |
| 974 | 978 | ariaLabelledBy: '', |
| 975 | 979 | templateUrl: 'modal-detalle-carga.html', |
| ... | ... | @@ -979,26 +983,26 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 979 | 983 | return { |
| 980 | 984 | hojasRutas: hojasRutas, |
| 981 | 985 | orden: $scope.hojaRuta.orden |
| 982 | - } | |
| 986 | + }; | |
| 983 | 987 | } |
| 984 | 988 | }, |
| 985 | 989 | size: 'lg', |
| 986 | 990 | backdrop: false |
| 987 | 991 | } |
| 988 | 992 | ); |
| 989 | - return modalInstance.result.then(function (res) { | |
| 990 | - res.cisternas.forEach( function (cisterna) { | |
| 991 | - $scope.cisternaCargas.push(cisterna.cisternaCarga); | |
| 992 | - }); | |
| 993 | - $scope.cisternaMovimientos = res.movimientos; | |
| 994 | - $scope.articulosRecibidos = res.articulos; | |
| 995 | - $scope.articulos = res.articulos; | |
| 996 | - $filter('filter')($scope.botonera, { | |
| 997 | - label: 'Detalle de Carga', | |
| 998 | - })[0].checked = true; | |
| 999 | - }, function () { | |
| 1000 | - //se ejecuta cuando se cancela el modal | |
| 1001 | - }); | |
| 993 | + return modalInstance.result | |
| 994 | + .then(function (res) { | |
| 995 | + res.cisternas.forEach(function (cisterna) { | |
| 996 | + $scope.cisternaCargas.push(cisterna.cisternaCarga); | |
| 997 | + }); | |
| 998 | + $scope.cisternaMovimientos = res.movimientos; | |
| 999 | + $scope.articulosRecibidos = res.articulos; | |
| 1000 | + $scope.articulos = res.articulos; | |
| 1001 | + $filter('filter')($scope.botonera, { | |
| 1002 | + label: 'Detalle de Carga', | |
| 1003 | + })[0].checked = true; | |
| 1004 | + }) | |
| 1005 | + .catch(function (e) { console.error(e); }); | |
| 1002 | 1006 | }; |
| 1003 | 1007 | |
| 1004 | 1008 | function elegirFecha() { |
| ... | ... | @@ -1112,7 +1116,7 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 1112 | 1116 | |
| 1113 | 1117 | focaCrearHojaRutaService |
| 1114 | 1118 | .getNumeroOrden(vehiculo.id, $scope.hojaRuta.fechaReparto) |
| 1115 | - .then(function(res) { | |
| 1119 | + .then(function (res) { | |
| 1116 | 1120 | $scope.hojaRuta.orden = res.data; |
| 1117 | 1121 | }); |
| 1118 | 1122 | |
| ... | ... | @@ -1247,7 +1251,7 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 1247 | 1251 | function getLSHojaRuta() { |
| 1248 | 1252 | if ($localStorage.data === undefined) return; |
| 1249 | 1253 | |
| 1250 | - var hojaRuta = (JSON.parse($localStorage.data))[0] || null; | |
| 1254 | + var hojaRuta = (JSON.parse($localStorage.data))[0] || null; | |
| 1251 | 1255 | if (hojaRuta) { |
| 1252 | 1256 | setearHojaRuta(hojaRuta); |
| 1253 | 1257 | delete $localStorage.data; |
| ... | ... | @@ -1273,7 +1277,8 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 1273 | 1277 | label: 'Precargados' |
| 1274 | 1278 | })[0].checked = $scope.precargado; |
| 1275 | 1279 | $scope.botonera = focaCrearHojaRutaService.getBotonFecha(); |
| 1276 | - Array.prototype.push.apply($scope.botonera,focaCrearHojaRutaService.getBotoneraPrecargado()); | |
| 1280 | + Array.prototype.push.apply($scope.botonera, | |
| 1281 | + focaCrearHojaRutaService.getBotoneraPrecargado()); | |
| 1277 | 1282 | } |
| 1278 | 1283 | if (cargaRemito) { |
| 1279 | 1284 | $scope.cargaRemito = cargaRemito; |
| ... | ... | @@ -1281,7 +1286,8 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 1281 | 1286 | label: 'Cargar Remitos' |
| 1282 | 1287 | })[0].checked = $scope.cargaRemito; |
| 1283 | 1288 | $scope.botonera = focaCrearHojaRutaService.getBotonFecha(); |
| 1284 | - Array.prototype.push.apply($scope.botonera,focaCrearHojaRutaService.getBotoneraCargarRemito()); | |
| 1289 | + Array.prototype.push.apply($scope.botonera, | |
| 1290 | + focaCrearHojaRutaService.getBotoneraCargarRemito()); | |
| 1285 | 1291 | } |
| 1286 | 1292 | } |
| 1287 | 1293 |