From 761e2779b55f174af3e665876d7635533763b07b Mon Sep 17 00:00:00 2001 From: Benjamin Date: Fri, 4 Oct 2019 15:43:37 -0300 Subject: [PATCH] hojaruta --- src/js/controller.js | 138 ++++++++++++++++++++++++++++----------------- src/js/service.js | 8 ++- src/views/orden-carga.html | 28 ++------- 3 files changed, 98 insertions(+), 76 deletions(-) diff --git a/src/js/controller.js b/src/js/controller.js index f42bab2..ad7e918 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -26,7 +26,6 @@ angular.module('focaOrdenCarga') maxDate: new Date(), minDate: new Date(2010, 0, 1) }; - $scope.ordenCarga = { id: 0, cliente: {}, @@ -60,28 +59,6 @@ angular.module('focaOrdenCarga') focaBotoneraLateralService.addCustomButton('Salir', salir); }); - function seleccionarTransportista() { - var parametrosModal = { - titulo: 'Búsqueda de Transportista', - query: '/transportista', - columnas: [ - { - nombre: 'Código', - propiedad: 'COD' - }, - { - nombre: 'Nombre', - propiedad: 'NOM' - }, - { - nombre: 'CUIT', - propiedad: 'CUIT' - } - ] - }; - return focaModalService.modal(parametrosModal); - }; - $scope.seleccionarVehiculo = function () { seleccionarTransportista().then( @@ -129,25 +106,26 @@ angular.module('focaOrdenCarga') }); }; - $scope.seleccionarVerCisternas = function () { - if (!$scope.hojaRuta.vehiculo.cisternas.length) { - focaModalService.alert('Primero seleccione un vehículo con cisternas'); - return; - } - console.log($scope.hojaRuta.vehiculo); - $uibModal.open( - { - ariaLabelledBy: 'Grafico de cisternas', - templateUrl: 'modal-grafico-cisternas.html', - controller: 'focaModalGraficoCisternasController', - size: 'md', - resolve: { - filters: { - cisternas: $scope.hojaRuta.vehiculo.cisternas - } + function seleccionarTransportista() { + var parametrosModal = { + titulo: 'Búsqueda de Transportista', + query: '/transportista', + columnas: [ + { + nombre: 'Código', + propiedad: 'COD' + }, + { + nombre: 'Nombre', + propiedad: 'NOM' + }, + { + nombre: 'CUIT', + propiedad: 'CUIT' } - } - ); + ] + }; + return focaModalService.modal(parametrosModal); }; $scope.seleccionarFechaDeReparto = function () { @@ -163,6 +141,34 @@ angular.module('focaOrdenCarga') }); }; + $scope.seleccionarHojasDeRuta = function () { + if (!$scope.hojaRuta.vehiculo.cisternas.length) { + focaModalService.alert('Primero seleccione un vehículo con cisternas'); + return; + } + $uibModal.open( + { + ariaLabelledBy: 'Hojas de Ruta', + templateUrl: 'modal-hojas-ruta.html', + controller: 'focaOrdenCargaController', + size: 'md', + resolve: { + filters: { + cisternas: $scope.hojaRuta.vehiculo.id + } + } + } + ); + var idVehiculo = $scope.hojaRuta.vehiculo.id + focaOrdenCargaService.getHojasRuta(idVehiculo) + .then(function (res) { + console.log(res); + }) + .catch(function (err) { + console.error(err) + }) + } + $scope.seleccionarRemitoAbierto = function () { if ($scope.hojaRuta.vehiculo.capacidad === 0) { focaModalService.alert('Debe ingresar vehiculo'); @@ -216,16 +222,25 @@ angular.module('focaOrdenCarga') ); }; - function getEstadosCisternas(cisternas) { - cisternas.forEach(function (cisterna) { - focaOrdenCargaService - .getEstadoCisterna(cisterna.id, $scope.fecha) - .then(function (res) { - cisterna.estado = res.data; - }) - .catch(function (err) { console.error(err) }); - }); - } + $scope.seleccionarGraficar = function () { + if (!$scope.hojaRuta.vehiculo.cisternas.length) { + focaModalService.alert('Primero seleccione un vehículo con cisternas'); + return; + } + $uibModal.open( + { + ariaLabelledBy: 'Grafico de cisternas', + templateUrl: 'modal-grafico-cisternas.html', + controller: 'focaModalGraficoCisternasController', + size: 'md', + resolve: { + filters: { + cisternas: $scope.hojaRuta.vehiculo.cisternas + } + } + } + ); + }; function elegirTransportista(transportista) { var codigo = ('00000' + transportista.COD).slice(-5); @@ -237,6 +252,17 @@ angular.module('focaOrdenCarga') }); } + function getEstadosCisternas(cisternas) { + cisternas.forEach(function (cisterna) { + focaOrdenCargaService + .getEstadoCisterna(cisterna.id, $scope.fecha) + .then(function (res) { + cisterna.estado = res.data; + }) + .catch(function (err) { console.error(err) }); + }); + } + function mostrarDetalle(hojasRutas) { var modalInstance = $uibModal.open( { @@ -271,9 +297,17 @@ angular.module('focaOrdenCarga') }; function crearOrdenCarga() { + if (!$scope.hojaRuta.vehiculo) { + focaModalService.alert('Ingrese Vehículo'); + return; + } else if (!$scope.hojaRuta.chofer) { + focaBotoneraLateralService.alert('Ingrese Chofer'); + return; + } focaBotoneraLateralService.startGuardar(); $scope.saveLoading = true; + } $scope.$watch('ordenCarga', function (newValue) { @@ -317,4 +351,4 @@ angular.module('focaOrdenCarga') $location.path('/'); } } - }]); + }]); diff --git a/src/js/service.js b/src/js/service.js index 3f72b05..4eb59a6 100644 --- a/src/js/service.js +++ b/src/js/service.js @@ -27,6 +27,9 @@ angular.module('focaOrdenCarga') return $http.post(API_ENDPOINT.URL + '/cisterna/stock', { idCisterna: id, fecha: fecha }); }, + getHojasRuta: function (idVehiculo) { + return $http.get(API_ENDPOINT.URL + '/orden-carga/hoja-ruta/' + idVehiculo); + }, getBotonera: function () { var result = [ { @@ -50,11 +53,12 @@ angular.module('focaOrdenCarga') image: 'chofer_secundario.png' }, { - label: 'Ver Cisternas', - image: 'verCisterna.png' + label: 'Graficar', + image: 'graficar.png' } ]; return result; }, + }; }]); diff --git a/src/views/orden-carga.html b/src/views/orden-carga.html index b143e82..855a10a 100644 --- a/src/views/orden-carga.html +++ b/src/views/orden-carga.html @@ -23,30 +23,14 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + producto + + + {{cisterna.capacidad - cisterna.cantidadDescargada}} - \ No newline at end of file -- 1.9.1