Commit c0a784cff91ce13822c4139f9954cfa745bef820
1 parent
4accc8e91e
Exists in
master
and in
2 other branches
Agregada info para enviar al modal de detalle.
Showing
2 changed files
with
25 additions
and
21 deletions
Show diff stats
package.json
1 | { | 1 | { |
2 | "name": "foca-hoja-ruta", | 2 | "name": "foca-hoja-ruta", |
3 | "version": "0.0.1", | 3 | "version": "0.0.1", |
4 | "description": "foca-hoja-ruta", | 4 | "description": "foca-hoja-ruta", |
5 | "main": "index.js", | 5 | "main": "index.js", |
6 | "scripts": { | 6 | "scripts": { |
7 | "refresh" : "gulp uglify && cp tmp/foca-hoja-ruta.js ../wrapper-demo/node_modules/foca-hoja-ruta/dist/foca-hoja-ruta.min.js", | ||
7 | "test": "echo \"Error: no test specified\" && exit 1", | 8 | "test": "echo \"Error: no test specified\" && exit 1", |
8 | "compile": "gulp uglify", | 9 | "compile": "gulp uglify", |
9 | "gulp-pre-commit": "gulp pre-commit", | 10 | "gulp-pre-commit": "gulp pre-commit", |
10 | "postinstall": "npm run compile && gulp clean-post-install", | 11 | "postinstall": "npm run compile && gulp clean-post-install", |
11 | "install-dev": "npm install -D jasmine-core pre-commit angular angular-ladda ladda@1.0.6 angular-route bootstrap ui-bootstrap4 font-awesome gulp gulp-angular-templatecache gulp-connect gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-uglify jquery jshint pump git+http://git.focasoftware.com/npm/foca-directivas.git git+http://git.focasoftware.com/npm/foca-modal-remito.git" | 12 | "install-dev": "npm install -D jasmine-core pre-commit angular angular-ladda ladda@1.0.6 angular-route bootstrap ui-bootstrap4 font-awesome gulp gulp-angular-templatecache gulp-connect gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-uglify jquery jshint pump git+http://git.focasoftware.com/npm/foca-directivas.git git+http://git.focasoftware.com/npm/foca-modal-remito.git" |
12 | }, | 13 | }, |
13 | "pre-commit": [ | 14 | "pre-commit": [ |
14 | "gulp-pre-commit" | 15 | "gulp-pre-commit" |
15 | ], | 16 | ], |
16 | "repository": { | 17 | "repository": { |
17 | "type": "git", | 18 | "type": "git", |
18 | "url": "git+http://git.focasoftware.com/npm/foca-hoja-ruta.git" | 19 | "url": "git+http://git.focasoftware.com/npm/foca-hoja-ruta.git" |
19 | }, | 20 | }, |
20 | "author": "Foca Software", | 21 | "author": "Foca Software", |
21 | "license": "ISC", | 22 | "license": "ISC", |
22 | "devDependencies": { | 23 | "devDependencies": { |
23 | "angular": "^1.7.5", | 24 | "angular": "^1.7.5", |
24 | "angular-ladda": "^0.4.3", | 25 | "angular-ladda": "^0.4.3", |
25 | "angular-route": "^1.7.5", | 26 | "angular-route": "^1.7.5", |
26 | "bootstrap": "^4.1.3", | 27 | "bootstrap": "^4.1.3", |
27 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", | 28 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", |
28 | "foca-modal-remito": "git+http://git.focasoftware.com/npm/foca-modal-remito.git", | 29 | "foca-modal-remito": "git+http://git.focasoftware.com/npm/foca-modal-remito.git", |
29 | "font-awesome": "^4.7.0", | 30 | "font-awesome": "^4.7.0", |
30 | "gulp": "^3.9.1", | 31 | "gulp": "^3.9.1", |
31 | "gulp-angular-templatecache": "^2.2.5", | 32 | "gulp-angular-templatecache": "^2.2.5", |
32 | "gulp-clean": "^0.4.0", | 33 | "gulp-clean": "^0.4.0", |
33 | "gulp-concat": "^2.6.1", | 34 | "gulp-concat": "^2.6.1", |
34 | "gulp-connect": "^5.6.1", | 35 | "gulp-connect": "^5.6.1", |
35 | "gulp-htmlmin": "^5.0.1", | 36 | "gulp-htmlmin": "^5.0.1", |
36 | "gulp-jshint": "^2.1.0", | 37 | "gulp-jshint": "^2.1.0", |
37 | "gulp-rename": "^1.4.0", | 38 | "gulp-rename": "^1.4.0", |
38 | "gulp-replace": "^1.0.0", | 39 | "gulp-replace": "^1.0.0", |
39 | "gulp-sequence": "^1.0.0", | 40 | "gulp-sequence": "^1.0.0", |
40 | "gulp-uglify": "^3.0.1", | 41 | "gulp-uglify": "^3.0.1", |
41 | "gulp-uglify-es": "^1.0.4", | 42 | "gulp-uglify-es": "^1.0.4", |
42 | "jasmine-core": "^3.3.0", | 43 | "jasmine-core": "^3.3.0", |
43 | "jquery": "^3.3.1", | 44 | "jquery": "^3.3.1", |
44 | "jshint": "^2.9.6", | 45 | "jshint": "^2.9.6", |
45 | "ladda": "^1.0.6", | 46 | "ladda": "^1.0.6", |
46 | "pre-commit": "^1.2.2", | 47 | "pre-commit": "^1.2.2", |
47 | "pump": "^3.0.0", | 48 | "pump": "^3.0.0", |
48 | "ui-bootstrap4": "^3.0.5" | 49 | "ui-bootstrap4": "^3.0.5" |
49 | } | 50 | } |
50 | } | 51 | } |
51 | 52 |
src/js/controller.js
1 | angular.module('focaHojaRuta') | 1 | angular.module('focaHojaRuta') |
2 | .controller('listaHojaRutaCtrl', | 2 | .controller('listaHojaRutaCtrl', |
3 | [ | 3 | [ |
4 | '$scope', | 4 | '$scope', |
5 | '$location', | 5 | '$location', |
6 | '$filter', | 6 | '$filter', |
7 | '$uibModal', | 7 | '$uibModal', |
8 | 'hojaRutaService', | 8 | 'hojaRutaService', |
9 | 'focaLoginService', | 9 | 'focaLoginService', |
10 | 'focaModalService', | 10 | 'focaModalService', |
11 | '$rootScope', | 11 | '$rootScope', |
12 | '$localStorage', | 12 | '$localStorage', |
13 | function( | 13 | function ( |
14 | $scope, | 14 | $scope, |
15 | $location, | 15 | $location, |
16 | $filter, | 16 | $filter, |
17 | $uibModal, | 17 | $uibModal, |
18 | hojaRutaService, | 18 | hojaRutaService, |
19 | focaLoginService, | 19 | focaLoginService, |
20 | focaModalService, | 20 | focaModalService, |
21 | $rootScope, | 21 | $rootScope, |
22 | $localStorage | 22 | $localStorage |
23 | ) { | 23 | ) { |
24 | 24 | ||
25 | var loginData = focaLoginService.getLoginData(); | 25 | var loginData = focaLoginService.getLoginData(); |
26 | 26 | ||
27 | config(); | 27 | config(); |
28 | 28 | ||
29 | function config() { | 29 | function config() { |
30 | 30 | ||
31 | $scope.cabecera = []; | 31 | $scope.cabecera = []; |
32 | $scope.showCabecera = true; | 32 | $scope.showCabecera = true; |
33 | $scope.now = new Date(); | 33 | $scope.now = new Date(); |
34 | $scope.puntoVenta = '0000'; | 34 | $scope.puntoVenta = '0000'; |
35 | $scope.comprobante = '00000000'; | 35 | $scope.comprobante = '00000000'; |
36 | } | 36 | } |
37 | 37 | ||
38 | hojaRutaService.getHojaRuta(loginData.chofer).then(function(res) { | 38 | hojaRutaService.getHojaRuta(loginData.chofer).then(function (res) { |
39 | 39 | ||
40 | if (res.data) { | 40 | if (res.data) { |
41 | var hojaRuta = res.data; | 41 | var hojaRuta = res.data; |
42 | $scope.hojaRuta = hojaRuta; | 42 | $scope.hojaRuta = hojaRuta; |
43 | $scope.hojaRuta.abierta = true; | 43 | $scope.hojaRuta.abierta = true; |
44 | $scope.puntoVenta = hojaRuta.sucursal; | 44 | $scope.puntoVenta = hojaRuta.sucursal; |
45 | $scope.comprobante = hojaRuta.numeroHojaRuta; | 45 | $scope.comprobante = hojaRuta.numeroHojaRuta; |
46 | addCabecera('Transportista:', hojaRuta.transportista.NOM); | 46 | addCabecera('Transportista:', hojaRuta.transportista.NOM); |
47 | addCabecera('Chofer:', hojaRuta.chofer.nombre); | 47 | addCabecera('Chofer:', hojaRuta.chofer.nombre); |
48 | addCabecera('Vehículo:', hojaRuta.vehiculo.tractor); | 48 | addCabecera('Vehículo:', hojaRuta.vehiculo.tractor); |
49 | } else { | 49 | } else { |
50 | focaModalService.alert('Sin hoja de ruta asignada'); | 50 | focaModalService.alert('Sin hoja de ruta asignada'); |
51 | $location.path('/'); | 51 | $location.path('/'); |
52 | } | 52 | } |
53 | 53 | ||
54 | watch(); | 54 | watch(); |
55 | 55 | ||
56 | if (!$scope.esatadoRed) { | 56 | if (!$scope.esatadoRed) { |
57 | getLSHojaRuta(); | 57 | getLSHojaRuta(); |
58 | } | 58 | } |
59 | 59 | ||
60 | }); | 60 | }); |
61 | 61 | ||
62 | function watch() { | 62 | function watch() { |
63 | 63 | ||
64 | $scope.$watch('hojaRuta', function(nuevoValor) { | 64 | $scope.$watch('hojaRuta', function (nuevoValor) { |
65 | $localStorage.hojaRuta = JSON.stringify(nuevoValor); | 65 | $localStorage.hojaRuta = JSON.stringify(nuevoValor); |
66 | }, true); | 66 | }, true); |
67 | } | 67 | } |
68 | 68 | ||
69 | $scope.verDetalle = function(remito) { | 69 | $scope.verDetalle = function (remito) { |
70 | var modalInstance = $uibModal.open( | 70 | var modalInstance = $uibModal.open( |
71 | { | 71 | { |
72 | ariaLabelledBy: 'Detalle hoja ruta', | 72 | ariaLabelledBy: 'Detalle hoja ruta', |
73 | templateUrl: 'modal-detalle-hoja-ruta.html', | 73 | templateUrl: 'modal-detalle-hoja-ruta.html', |
74 | controller: 'focaModalDetalleHojaRutaController', | 74 | controller: 'focaModalDetalleHojaRutaController', |
75 | resolve: { | 75 | resolve: { |
76 | parametros: { | 76 | parametros: { |
77 | remito: remito, | 77 | remito: remito, |
78 | } | 78 | } |
79 | }, | 79 | }, |
80 | size: 'lg' | 80 | size: 'lg' |
81 | } | 81 | } |
82 | ); | 82 | ); |
83 | modalInstance.result.then(function() { | 83 | modalInstance.result.then(function () { |
84 | //funcion se ejecuta cuando se carga pantalla | 84 | //funcion se ejecuta cuando se carga pantalla |
85 | }); | 85 | }); |
86 | }; | 86 | }; |
87 | 87 | ||
88 | function addCabecera(label, valor) { | 88 | function addCabecera(label, valor) { |
89 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 89 | var propiedad = $filter('filter')($scope.cabecera, { label: label }, true); |
90 | if(propiedad.length === 1) { | 90 | if (propiedad.length === 1) { |
91 | propiedad[0].valor = valor; | 91 | propiedad[0].valor = valor; |
92 | } else { | 92 | } else { |
93 | $scope.cabecera.push({label: label, valor: valor}); | 93 | $scope.cabecera.push({ label: label, valor: valor }); |
94 | } | 94 | } |
95 | } | 95 | } |
96 | 96 | ||
97 | $scope.rellenar = function(relleno, longitud) { | 97 | $scope.rellenar = function (relleno, longitud) { |
98 | relleno = '' + relleno; | 98 | relleno = '' + relleno; |
99 | while (relleno.length < longitud) { | 99 | while (relleno.length < longitud) { |
100 | relleno = '0' + relleno; | 100 | relleno = '0' + relleno; |
101 | } | 101 | } |
102 | 102 | ||
103 | return relleno; | 103 | return relleno; |
104 | }; | 104 | }; |
105 | 105 | ||
106 | $scope.salir = function() { | 106 | $scope.salir = function () { |
107 | $location.path('/'); | 107 | $location.path('/'); |
108 | }; | 108 | }; |
109 | 109 | ||
110 | $scope.terminarHojaRuta = function() { | 110 | $scope.terminarHojaRuta = function () { |
111 | focaModalService | 111 | focaModalService |
112 | .confirm('¿Desea terminar la hoja de ruta? No podra realizar ninguna ' + | 112 | .confirm('¿Desea terminar la hoja de ruta? No podra realizar ninguna ' + |
113 | 'otra descarga ni modificación') | 113 | 'otra descarga ni modificación') |
114 | .then(function() {$scope.datosExtraCierre(terminar);}); | 114 | .then(function () { $scope.datosExtraCierre(terminar); }); |
115 | function terminar(datosExtraCierre) { | 115 | function terminar(datosExtraCierre) { |
116 | $scope.hojaRuta = angular.extend({}, $scope.hojaRuta, datosExtraCierre); | 116 | $scope.hojaRuta = angular.extend({}, $scope.hojaRuta, datosExtraCierre); |
117 | //limpio objeto para guardar | 117 | //limpio objeto para guardar |
118 | delete $scope.hojaRuta.chofer; | 118 | delete $scope.hojaRuta.chofer; |
119 | delete $scope.hojaRuta.remitos; | 119 | delete $scope.hojaRuta.remitos; |
120 | delete $scope.hojaRuta.transportista; | 120 | delete $scope.hojaRuta.transportista; |
121 | delete $scope.hojaRuta.vehiculo; | 121 | delete $scope.hojaRuta.vehiculo; |
122 | 122 | ||
123 | $scope.hojaRuta.fechaCreacion = | 123 | $scope.hojaRuta.fechaCreacion = |
124 | $scope.hojaRuta.fechaCreacion.slice(0, 19).replace('T', ' '); | 124 | $scope.hojaRuta.fechaCreacion.slice(0, 19).replace('T', ' '); |
125 | $scope.hojaRuta.fechaReparto = | 125 | $scope.hojaRuta.fechaReparto = |
126 | $scope.hojaRuta.fechaReparto.slice(0, 19).replace('T', ' '); | 126 | $scope.hojaRuta.fechaReparto.slice(0, 19).replace('T', ' '); |
127 | $scope.hojaRuta.estado = 2; | 127 | $scope.hojaRuta.estado = 2; |
128 | hojaRutaService.terminarHojaRuta($scope.hojaRuta).then( | 128 | hojaRutaService.terminarHojaRuta($scope.hojaRuta).then( |
129 | function() { | 129 | function () { |
130 | focaModalService.alert( | 130 | focaModalService.alert( |
131 | 'Hoja de ruta ' + | 131 | 'Hoja de ruta ' + |
132 | $filter('comprobante')([$scope.puntoVenta, | 132 | $filter('comprobante')([$scope.puntoVenta, |
133 | $scope.comprobante]) + ' cerrada con éxito'); | 133 | $scope.comprobante]) + ' cerrada con éxito'); |
134 | $location.path('/'); | 134 | $location.path('/'); |
135 | } | 135 | } |
136 | ); | 136 | ); |
137 | } | 137 | } |
138 | }; | 138 | }; |
139 | 139 | ||
140 | $scope.datosExtraCierre = function(terminar) { | 140 | $scope.datosExtraCierre = function (terminar) { |
141 | var modalInstance = $uibModal.open( | 141 | var modalInstance = $uibModal.open( |
142 | { | 142 | { |
143 | templateUrl: 'focaDatosExtra.html', | 143 | templateUrl: 'focaDatosExtra.html', |
144 | controller: 'focaModalDatosExtraCierre', | 144 | controller: 'focaModalDatosExtraCierre', |
145 | } | 145 | } |
146 | ); | 146 | ); |
147 | modalInstance.result.then(terminar); | 147 | modalInstance.result.then(terminar); |
148 | }; | 148 | }; |
149 | 149 | ||
150 | $scope.modalDescargas = function() { | 150 | $scope.modalDescargas = function () { |
151 | 151 | delete $scope.hojaRuta.remitos[0].cliente; | |
152 | var modalInstance = $uibModal.open( | 152 | var modalInstance = $uibModal.open( |
153 | { | 153 | { |
154 | templateUrl: 'foca-modal-descarga.html', | 154 | templateUrl: 'foca-modal-descarga.html', |
155 | controller: 'focaModalDescargaCtrl' | 155 | controller: 'focaModalDescargaCtrl', |
156 | resolve: { | ||
157 | remito: function () { return $scope.hojaRuta.remitos[0]; } | ||
158 | }, | ||
156 | } | 159 | } |
157 | ); | 160 | ); |
158 | 161 | ||
159 | modalInstance.result.then(function(data) { | 162 | modalInstance.result.then(function (data) { |
160 | 163 | ||
161 | console.log(data); | 164 | console.log(data); |
162 | }); | 165 | }); |
163 | }; | 166 | }; |
164 | 167 | ||
165 | $rootScope.$on('estadoRed', function(event, value) { | 168 | $rootScope.$on('estadoRed', function (event, value) { |
166 | $scope.esatadoRed = value; | 169 | $scope.esatadoRed = value; |
167 | }); | 170 | }); |
168 | 171 | ||
169 | function getLSHojaRuta() { | 172 | function getLSHojaRuta() { |
170 | 173 | ||
171 | var hojaRuta = JSON.parse($localStorage.hojaRuta || null); | 174 | var hojaRuta = JSON.parse($localStorage.hojaRuta || null); |
172 | 175 | ||
173 | if (hojaRuta) { | 176 | if (hojaRuta) { |
174 | $scope.hojaRuta = hojaRuta; | 177 | $scope.hojaRuta = hojaRuta; |
175 | delete $localStorage.hojaRuta; | 178 | delete $localStorage.hojaRuta; |
176 | } | 179 | } |
177 | } | 180 | } |
178 | 181 | ||
179 | } | 182 | } |
180 | ]); | 183 | ]); |
181 | 184 |