Commit 89b9bfdb5f893a226f7b8b60f88e2aa5fc59ef96
Exists in
master
Merge branch 'master' into 'master'
Master(mpuebla) See merge request !9
Showing
3 changed files
Show diff stats
src/js/controller.js
... | ... | @@ -20,17 +20,18 @@ angular.module('focaModalDescarga') |
20 | 20 | $scope.remito = remito; |
21 | 21 | $scope.nroRecibo = 0; |
22 | 22 | $scope.cisternas = remito.cisternas; |
23 | - $scope.nroSucursal = "00" + remito.sucursal; | |
23 | + $scope.nroSucursal; | |
24 | 24 | $scope.nroRemito; |
25 | 25 | $scope.articulos = []; |
26 | + $scope.hasErrorSucursalRemito = false; | |
26 | 27 | //#endregion |
27 | 28 | |
28 | - function init () { | |
29 | + function init() { | |
29 | 30 | crearRemitoService.getNumeroRemito().then( |
30 | 31 | function (res) { |
31 | - | |
32 | - $scope.nroRemito = rellenar(res.data.sucursal, 4) + '-' + | |
33 | - rellenar(res.data.numeroRemito, 8); | |
32 | + $scope.nroSucursal = res.data.sucursal; | |
33 | + $scope.nroRemito = res.data.numeroRemito; | |
34 | + $scope.validateSucursalRemito($scope.nroSucursal, $scope.nroRemito); | |
34 | 35 | }, |
35 | 36 | function (err) { |
36 | 37 | focaModalService.alert('La terminal no esta configurada correctamente'); |
... | ... | @@ -62,15 +63,15 @@ angular.module('focaModalDescarga') |
62 | 63 | idProveedor: $scope.remito.proveedor.COD, |
63 | 64 | idDomicilio: 0, |
64 | 65 | idCotizacion: $scope.remito.cotizacion.ID, |
65 | - idListaPrecio: $scope.remito.cliente.mod, | |
66 | + idListaPrecio: parseInt($scope.remito.cliente.mod), | |
66 | 67 | flete: $scope.remito.flete, |
67 | 68 | fob: $scope.remito.fob, |
68 | 69 | bomba: $scope.remito.bomba, |
69 | 70 | kilometros: $scope.remito.kilometros, |
70 | 71 | domicilioStamp: $scope.remito.cliente.DOM, |
71 | 72 | observaciones: $scope.remito.observaciones, |
72 | - numeroRemito: parseInt($scope.comprobante), | |
73 | - sucursal: parseInt($scope.puntoVenta), | |
73 | + numeroRemito: parseInt($scope.nroRemito), | |
74 | + sucursal: parseInt($scope.nroSucursal), | |
74 | 75 | responsabilidadIvaCliente: $scope.remito.cliente.iva, |
75 | 76 | descuento: 0,//TODO, |
76 | 77 | importeNeto: getImporte('netoUnitario'), |
... | ... | @@ -214,17 +215,31 @@ angular.module('focaModalDescarga') |
214 | 215 | //funcion ejecutada al cancelar modal |
215 | 216 | }); |
216 | 217 | }; |
218 | + $scope.validateSucursalRemito = function (sucursal, remito) { | |
219 | + if (!sucursal || !remito) { | |
220 | + $scope.hasErrorSucursalRemito = false; | |
221 | + return; | |
222 | + } | |
223 | + | |
224 | + focaModalDescargasService.validarSucursalRemito(sucursal, remito) | |
225 | + .then(function (res) { | |
226 | + if (res.data.data === 1) { | |
227 | + $scope.hasErrorSucursalRemito = true; | |
228 | + } else { | |
229 | + $scope.hasErrorSucursalRemito = false; | |
230 | + } | |
231 | + }) | |
232 | + .catch(function (e) { console.error(e); }); | |
233 | + }; | |
217 | 234 | $scope.cancelar = function () { |
218 | 235 | $uibModalInstance.dismiss(); |
219 | - } | |
220 | - | |
221 | - | |
236 | + }; | |
222 | 237 | function rellenar(relleno, longitud) { |
223 | 238 | relleno = '' + relleno; |
224 | 239 | while (relleno.length < longitud) { |
225 | 240 | relleno = '0' + relleno; |
226 | 241 | } |
227 | 242 | return relleno; |
228 | - } | |
243 | + }; | |
229 | 244 | } |
230 | 245 | ]); |
src/js/service.js
... | ... | @@ -4,13 +4,17 @@ angular.module('focaModalDescarga') |
4 | 4 | var route = API_ENDPOINT.URL; |
5 | 5 | return { |
6 | 6 | crearRemito: function (remito) { |
7 | - return $http.post(route + '/remito', remito); | |
7 | + return $http.post('http://10.231.45.197:9900' + '/remito/mobile', remito); | |
8 | + }, | |
9 | + validarSucursalRemito: function (sucursal, remito) { | |
10 | + return $http.get('http://10.231.45.197:9900' + '/remito/validar/' + | |
11 | + sucursal + '/' + remito); | |
8 | 12 | }, |
9 | 13 | addArticulos: function (articulosRemito, articulosBase, idRemito, cotizacion) { |
10 | 14 | |
11 | 15 | for (var i = 0; i < articulosRemito.length; i++) { |
12 | 16 | |
13 | - var articuloReferencia = articulosBase.filter(function(articulo) { | |
17 | + var articuloReferencia = articulosBase.filter(function (articulo) { | |
14 | 18 | return articulosRemito[i].idArticulo == articulo.id; |
15 | 19 | })[0]; |
16 | 20 |
src/views/foca-modal-descarga.html
... | ... | @@ -40,13 +40,22 @@ |
40 | 40 | </div> |
41 | 41 | <div class="col-3 pr-0 mt-1"> |
42 | 42 | <input |
43 | - type="text" class="text-center form-control form-control-sm" | |
44 | - ng-model="nroSucursal" readonly> | |
43 | + type="number" class="text-center form-control form-control-sm" | |
44 | + ng-focus="$event.target.select();" | |
45 | + ng-model="nroSucursal" | |
46 | + ng-change="validateSucursalRemito(nroSucursal, nroRemito)"> | |
45 | 47 | </div> |
46 | 48 | <div class="col-6 mt-1"> |
47 | 49 | <input |
48 | 50 | type="number" class="text-center form-control form-control-sm" |
49 | - ng-model="remito.numeroRemito"> | |
51 | + ng-focus="$event.target.select();" | |
52 | + ng-model="nroRemito" | |
53 | + ng-change="validateSucursalRemito(nroSucursal, nroRemito)"> | |
54 | + </div> | |
55 | + <div | |
56 | + class="col-12 mt-1 alert alert-danger text-center" role="alert" | |
57 | + ng-show="hasErrorSucursalRemito"> | |
58 | + Error numero de remito existente!<br>Ingrese otro número | |
50 | 59 | </div> |
51 | 60 | <div class="col-12 mt-3 p-0"> |
52 | 61 | <table class="table"> |
... | ... | @@ -69,7 +78,8 @@ |
69 | 78 | ng-init="cisterna.cisternaCarga.descargar = |
70 | 79 | cisterna.cisternaCarga.cantidad" |
71 | 80 | ng-model="cisterna.cisternaCarga.descargar" |
72 | - type="number" class="text-center form-control col-12"> | |
81 | + ng-focus="$event.target.select();" | |
82 | + class="text-center form-control col-12"> | |
73 | 83 | </td> |
74 | 84 | </tr> |
75 | 85 | </tbody> |
... | ... | @@ -81,6 +91,7 @@ |
81 | 91 | <div class="col-9"> |
82 | 92 | <input |
83 | 93 | ng-model="nroRecibo" class="form-control" |
94 | + ng-focus="$event.target.select();" | |
84 | 95 | type="number" placeholder="Nº de recibo"> |
85 | 96 | </div> |
86 | 97 | </div> |
... | ... | @@ -96,6 +107,7 @@ |
96 | 107 | ladda="cargando" |
97 | 108 | type="button" |
98 | 109 | ng-click="crearRemito()" |
99 | - ng-disabled="tieneArticulosPendientes() || idRemito === -1" | |
110 | + ng-disabled="tieneArticulosPendientes() || | |
111 | + idRemito === -1 || hasErrorSucursalRemito || !nroSucursal || !nroRemito" | |
100 | 112 | foca-focus="!tieneArticulosPendientes() && idRemito !== -1">Descargar</button> |
101 | 113 | </div> |