Commit 41ed1c3751d571efea6648f2b15e188be6d260e9
1 parent
bf8877f3f8
Exists in
master
agregar nuevos puntos de descarga
Showing
3 changed files
with
62 additions
and
14 deletions
Show diff stats
src/js/controller.js
| ... | ... | @@ -156,8 +156,8 @@ angular.module('focaModalDetalleHojaRuta') |
| 156 | 156 | templateUrl: 'modal-actualizar-punto-descarga.html', |
| 157 | 157 | controller: 'focaModalActualizarPuntoDescargaController', |
| 158 | 158 | resolve: { |
| 159 | - puntosDescarga: function() { | |
| 160 | - return $scope.remito.notaPedido.notaPedidoPuntoDescarga; | |
| 159 | + notaPedido: function() { | |
| 160 | + return $scope.remito.notaPedido; | |
| 161 | 161 | } |
| 162 | 162 | }, |
| 163 | 163 | size: 'lg' |
| ... | ... | @@ -207,33 +207,59 @@ angular.module('focaModalDetalleHojaRuta') |
| 207 | 207 | '$uibModalInstance', |
| 208 | 208 | 'focaSeguimientoService', |
| 209 | 209 | 'focaModalService', |
| 210 | - 'puntosDescarga', | |
| 210 | + 'notaPedido', | |
| 211 | 211 | 'focaModalDetalleHojaRutaService', |
| 212 | 212 | function($scope, $uibModalInstance, focaSeguimientoService, |
| 213 | - focaModalService, puntosDescarga, focaModalDetalleHojaRutaService) | |
| 213 | + focaModalService, notaPedido, focaModalDetalleHojaRutaService) | |
| 214 | 214 | { |
| 215 | - $scope.puntosDescarga = puntosDescarga; | |
| 215 | + $scope.notaPedido = notaPedido; | |
| 216 | + $scope.descripcion = ''; | |
| 216 | 217 | focaSeguimientoService.obtenerPosicion(function(res) { |
| 217 | 218 | $scope.posicion = res.coords; |
| 218 | 219 | }); |
| 219 | 220 | |
| 220 | 221 | $scope.cancel = function() { |
| 221 | - $uibModalInstance.dismiss(); | |
| 222 | + if ($scope.ingreso) { | |
| 223 | + $scope.ingreso = false; | |
| 224 | + } else { | |
| 225 | + $uibModalInstance.dismiss(); | |
| 226 | + } | |
| 222 | 227 | }; |
| 223 | 228 | |
| 224 | 229 | $scope.select = function(puntoDescarga) { |
| 225 | - if(!$scope.posicion){ | |
| 226 | - focaModalService.alert('No se pudo obtener la ubicacion'); | |
| 230 | + if (!$scope.posicion) { | |
| 231 | + focaModalService.alert('No se pudo obtener la ubicación'); | |
| 227 | 232 | return; |
| 228 | 233 | } |
| 229 | 234 | puntoDescarga.latitud = $scope.posicion.latitude; |
| 230 | 235 | puntoDescarga.longitud = $scope.posicion.longitude; |
| 231 | 236 | focaModalDetalleHojaRutaService |
| 232 | - .updatePuntoDescarga(puntoDescarga) | |
| 237 | + .guardarPuntoDescarga(puntoDescarga) | |
| 238 | + .then(function(res) { | |
| 239 | + $uibModalInstance.close(res.data); | |
| 240 | + }); | |
| 241 | + }; | |
| 242 | + | |
| 243 | + $scope.guardar = function() { | |
| 244 | + if (!$scope.posicion) { | |
| 245 | + focaModalService.alert('No se pudo obtener la ubicación'); | |
| 246 | + return; | |
| 247 | + } | |
| 248 | + focaModalDetalleHojaRutaService | |
| 249 | + .guardarPuntoDescarga({ | |
| 250 | + id: 0, | |
| 251 | + id_cliente: $scope.notaPedido.idCliente, | |
| 252 | + id_da_config_0: $scope.notaPedido.idDomicilio, | |
| 253 | + descripcion: $scope.descripcion, | |
| 254 | + latitud: $scope.posicion.latitude, | |
| 255 | + longitud: $scope.posicion.longitude | |
| 256 | + }) | |
| 233 | 257 | .then(function(res) { |
| 234 | 258 | $uibModalInstance.close(res.data); |
| 235 | 259 | }); |
| 260 | + | |
| 236 | 261 | }; |
| 262 | + | |
| 237 | 263 | } |
| 238 | 264 | ] |
| 239 | 265 | ); |
src/js/service.js
| ... | ... | @@ -19,7 +19,7 @@ angular.module('focaModalDetalleHojaRuta') |
| 19 | 19 | rechazarRemito: function(remito) { |
| 20 | 20 | return $http.post(API_ENDPOINT.URL + '/remito/update', {remito: remito}); |
| 21 | 21 | }, |
| 22 | - updatePuntoDescarga: function(puntoDescarga) { | |
| 22 | + guardarPuntoDescarga: function(puntoDescarga) { | |
| 23 | 23 | return $http.post(API_ENDPOINT.URL + '/punto-descarga', |
| 24 | 24 | {puntoDescarga: puntoDescarga}); |
| 25 | 25 | } |
src/views/modal-actualizar-punto-descarga.html
| 1 | -<div class="modal-header py-1"> | |
| 2 | - <h5 class="modal-title">Actualizar posición punto de descarga</h5> | |
| 1 | +<div class="modal-header py-1 d-flex"> | |
| 2 | + <h5 class="modal-title" ng-hide="ingreso">Actualizar posición punto de descarga</h5> | |
| 3 | + <h5 class="modal-title" ng-show="ingreso">Crear nuevo punto de descarga</h5> | |
| 4 | + <button | |
| 5 | + class="btn btn-primary" | |
| 6 | + title="Nuevo" | |
| 7 | + ng-click="ingreso = true" | |
| 8 | + ng-hide="ingreso"> | |
| 9 | + <i class="fa fa-plus" aria-hidden="true"></i> | |
| 10 | + </button> | |
| 3 | 11 | </div> |
| 4 | 12 | <div class="modal-body" id="modal-body"> |
| 5 | - <table | |
| 13 | + <table | |
| 6 | 14 | class="table table-striped table-sm col-12" |
| 7 | - ng-hide="ingreso || cargaArticulos"> | |
| 15 | + ng-hide="ingreso"> | |
| 8 | 16 | <thead> |
| 9 | 17 | <tr> |
| 10 | 18 | <th>Código</th> |
| ... | ... | @@ -47,11 +55,25 @@ |
| 47 | 55 | </tr> |
| 48 | 56 | </tbody> |
| 49 | 57 | </table> |
| 58 | + <div ng-show="ingreso"> | |
| 59 | + <form> | |
| 60 | + <label>Descripción</label> | |
| 61 | + <input | |
| 62 | + ng-model="descripcion" | |
| 63 | + type="text" | |
| 64 | + class="form-control"> | |
| 65 | + </form> | |
| 66 | + </div> | |
| 50 | 67 | </div> |
| 51 | 68 | <div class="modal-footer py-2"> |
| 52 | 69 | <button |
| 53 | 70 | class="btn btn-secondary btn-sm" |
| 54 | 71 | type="button" |
| 72 | + ng-click="guardar()" | |
| 73 | + >Guardar</button> | |
| 74 | + <button | |
| 75 | + class="btn btn-secondary btn-sm" | |
| 76 | + type="button" | |
| 55 | 77 | ng-click="cancel()" |
| 56 | 78 | >Cancelar</button> |
| 57 | 79 | </div> |