Commit d065c2ca79cb140c9493a58ba07ca6e2aa8646a0
1 parent
c46beb1187
Exists in
master
Unificar tabla vehiculo - cisterna
Showing
2 changed files
with
76 additions
and
63 deletions
Show diff stats
src/js/controller.js
... | ... | @@ -6,6 +6,7 @@ angular.module('focaAbmVehiculo') |
6 | 6 | $uibModal, focaBotoneraLateralService, $timeout, $localStorage) { |
7 | 7 | |
8 | 8 | $scope.now = new Date(); |
9 | + $scope.tipo = ''; | |
9 | 10 | $scope.botonera = [{ |
10 | 11 | label: 'Transportista', |
11 | 12 | image: 'cliente.png' |
... | ... | @@ -101,6 +102,7 @@ angular.module('focaAbmVehiculo') |
101 | 102 | $scope.nuevoCisterna = ($routeParams.idx > -1) ? false : true; |
102 | 103 | $scope.now = new Date(); |
103 | 104 | $scope.focused = 1; |
105 | + $scope.tipo = ''; | |
104 | 106 | $scope.creando = false; |
105 | 107 | $scope.crear = false; |
106 | 108 | $scope.transportistaStamp = ''; |
... | ... | @@ -115,6 +117,7 @@ angular.module('focaAbmVehiculo') |
115 | 117 | }); |
116 | 118 | |
117 | 119 | if ($scope.nuevo) { |
120 | + $scope.tipo = 'Crear Vehiculo'; | |
118 | 121 | focaAbmVehiculoService |
119 | 122 | .getTransportistaPorId($routeParams.idTransportista) |
120 | 123 | .then(function (res) { |
... | ... | @@ -125,12 +128,17 @@ angular.module('focaAbmVehiculo') |
125 | 128 | label: 'Transportista:', |
126 | 129 | valor: codigo + ' - ' + res.data[0].ALI |
127 | 130 | }); |
131 | + $scope.$broadcast('addCabecera', { | |
132 | + label: 'Unidad:', | |
133 | + valor: 'NUEVO' | |
134 | + }); | |
128 | 135 | }); |
136 | + } else { | |
137 | + $scope.tipo = 'Editar Vehiculo'; | |
129 | 138 | } |
130 | 139 | $scope.vehiculo = {}; |
131 | 140 | |
132 | 141 | focaAbmVehiculoService.getVehiculo($routeParams.idVehiculo).then(function (res) { |
133 | - | |
134 | 142 | if (res.data) { |
135 | 143 | var vehiculoSeteado = getLSVehiculo(); |
136 | 144 | if (vehiculoSeteado === false) { |
... | ... | @@ -257,23 +265,26 @@ angular.module('focaAbmVehiculo') |
257 | 265 | return; |
258 | 266 | } |
259 | 267 | |
260 | - validaCodigoUnidad().then(function () { | |
261 | - delete $scope.vehiculo.transportista; | |
262 | - delete $scope.vehiculo.cisternas; | |
263 | - focaAbmVehiculoService.guardarVehiculo($scope.vehiculo) | |
264 | - .then(function (res) { | |
265 | - if ($scope.nuevo) { | |
266 | - $location.path('/vehiculo/' + res.data.id + | |
267 | - '/' + res.data.idTransportista); | |
268 | - } else { | |
268 | + if ($scope.nuevo) { | |
269 | + validaCodigoUnidad().then(function () { | |
270 | + delete $scope.vehiculo.transportista; | |
271 | + focaAbmVehiculoService.guardarVehiculo($scope.vehiculo) | |
272 | + .then(function (res) { | |
273 | + $routeParams.idVehiculo = res.data.id; | |
269 | 274 | guardarCisternas($scope.cisternas).then(function () { |
270 | - $location.path('/vehiculo'); | |
275 | + angular.element('#guardar').addClass('guardado'); | |
276 | + $timeout(function () {$location.path('/vehiculo');},300); | |
271 | 277 | }); |
272 | - } | |
273 | - }); | |
274 | - }, function () { | |
275 | - focaModalService.alert('Cรณdigo de unidad existente'); | |
276 | - }); | |
278 | + }); | |
279 | + }, function () { | |
280 | + focaModalService.alert('Cรณdigo de unidad existente'); | |
281 | + }); | |
282 | + } else { | |
283 | + guardarCisternas($scope.cisternas).then(function () { | |
284 | + angular.element('#guardar').addClass('guardado'); | |
285 | + $timeout(function () {$location.path('/vehiculo');},500); | |
286 | + }); | |
287 | + } | |
277 | 288 | } |
278 | 289 | }; |
279 | 290 | //Agregar propiedades de cisterna |
... | ... | @@ -349,6 +360,7 @@ angular.module('focaAbmVehiculo') |
349 | 360 | return $scope.vehiculo.capacidad >= total; |
350 | 361 | } |
351 | 362 | function guardarCisternas() { |
363 | + | |
352 | 364 | var cisternas = $scope.cisternas.map(function (cisterna) { |
353 | 365 | return { |
354 | 366 | id: cisterna.id, |
... | ... | @@ -420,6 +432,6 @@ angular.module('focaAbmVehiculo') |
420 | 432 | $scope.crear = false; |
421 | 433 | }); |
422 | 434 | }); |
423 | - } | |
435 | + } | |
424 | 436 | } |
425 | 437 | ]); |
src/views/foca-abm-vehiculos-item.html
1 | 1 | <div class="row"> |
2 | 2 | <foca-cabecera-facturador |
3 | - titulo="'Vehรญculo'" | |
3 | + titulo="'Vehiculo / ' + tipo" | |
4 | 4 | fecha="now" |
5 | 5 | class="mb-0 col-lg-12" |
6 | 6 | ></foca-cabecera-facturador> |
... | ... | @@ -60,19 +60,20 @@ |
60 | 60 | <div class="input-group col-md-8 pl-0"> |
61 | 61 | <input |
62 | 62 | class="form-control" |
63 | - type="text" | |
63 | + foca-tipo-input | |
64 | + solo-positivos | |
64 | 65 | teclado-virtual |
65 | 66 | ng-model="vehiculo.capacidad" |
66 | 67 | ng-required="true" |
67 | 68 | foca-focus="focused == 4" |
68 | 69 | ng-focus="focused = 4" |
69 | - ng-keypress="guardar($event.keyCode)" | |
70 | + ng-disabled="!nuevo" | |
70 | 71 | /> |
71 | 72 | </div> |
72 | 73 | </div> |
73 | 74 | </div> |
74 | 75 | </form> |
75 | - <div ng-show="!nuevo"> | |
76 | + <div> | |
76 | 77 | <h5 class="pl-4 table-title">Cisternas</h5> |
77 | 78 | <table class="table table-default table-hover table-sm table-abm table-striped mb-0" > |
78 | 79 | <thead> |
... | ... | @@ -109,6 +110,7 @@ |
109 | 110 | class="form-control text-uppercase foca-input ng-not-empty ng-valid ng-valid-required ng-touched" |
110 | 111 | teclado-virtual |
111 | 112 | foca-tipo-input |
113 | + solo-positivos | |
112 | 114 | ng-model="cisterna.capacidad" |
113 | 115 | ng-required="true" |
114 | 116 | ng-keypress="next($event.keyCode)" |
... | ... | @@ -149,52 +151,53 @@ |
149 | 151 | <tr ng-repeat="(key, cisterna) in cisternas | filter:filtros" ng-hide="cisterna.desactivado"> |
150 | 152 | <td ng-bind="cisterna.codigo" class="text-center" ng-hide="cisterna.editando"></td> |
151 | 153 | <td align="center" ng-show="cisterna.editando"> |
152 | - <input | |
153 | - class="form-control text-uppercase foca-input ng-not-empty ng-valid ng-valid-required ng-touched" | |
154 | - ng-model="cisterna.codigo" | |
155 | - ng-keypress="next($event.keyCode)" | |
156 | - foca-focus="focused == 1" | |
157 | - ng-focus="focused = 1" | |
158 | - teclado-virtual | |
159 | - esc-key="volver(cisterna, key)" | |
160 | - > | |
154 | + <input | |
155 | + class="form-control text-uppercase foca-input ng-not-empty ng-valid ng-valid-required ng-touched" | |
156 | + ng-model="cisterna.codigo" | |
157 | + ng-keypress="next($event.keyCode)" | |
158 | + foca-focus="focused == 1" | |
159 | + ng-focus="focused = 1" | |
160 | + teclado-virtual | |
161 | + esc-key="volver(cisterna, key)" | |
162 | + > | |
161 | 163 | </td> |
162 | 164 | <td ng-bind="cisterna.capacidad" class="text-center" ng-hide="cisterna.editando"></td> |
163 | 165 | <td align="center" ng-show="cisterna.editando" > |
164 | - <input | |
165 | - class="form-control text-uppercase foca-input ng-not-empty ng-valid ng-valid-required ng-touched" | |
166 | - teclado-virtual | |
167 | - foca-tipo-input | |
168 | - ng-model="cisterna.capacidad" | |
169 | - ng-required="true" | |
170 | - ng-keypress="next($event.keyCode)" | |
171 | - foca-focus="focused == 2" | |
172 | - ng-focus="focused = 2" | |
173 | - esc-key="volver(cisterna, key)" | |
174 | - > | |
175 | - </td> | |
166 | + <input | |
167 | + class="form-control text-uppercase foca-input ng-not-empty ng-valid ng-valid-required ng-touched" | |
168 | + teclado-virtual | |
169 | + foca-tipo-input | |
170 | + solo-positivos | |
171 | + ng-model="cisterna.capacidad" | |
172 | + ng-required="true" | |
173 | + ng-keypress="next($event.keyCode)" | |
174 | + foca-focus="focused == 2" | |
175 | + ng-focus="focused = 2" | |
176 | + esc-key="volver(cisterna, key)" | |
177 | + > | |
178 | + </td> | |
176 | 179 | <td ng-bind="cisterna.unidadMedida.NOM" class="text-center" ng-hide="cisterna.editando"></td> |
177 | 180 | <td align="center" ng-show="cisterna.editando"> |
178 | - <div class="input-group"> | |
179 | - <input | |
180 | - ng-model="cisterna.unidadMedida.NOM" | |
181 | - class="form-control" | |
182 | - readonly | |
183 | - esc-key="volver(cisterna, key)" | |
184 | - /> | |
185 | - <div class="input-group-append"> | |
186 | - <button | |
187 | - ladda="searchLoading" | |
188 | - class="btn btn-outline-secondary form-control" | |
189 | - type="button" | |
190 | - ng-click="seleccionarUnidadMedida(cisterna)" | |
191 | - foca-focus="focused == 3" | |
192 | - > | |
193 | - <i class="fa fa-search" aria-hidden="true"></i> | |
194 | - </button> | |
195 | - </div> | |
181 | + <div class="input-group"> | |
182 | + <input | |
183 | + ng-model="cisterna.unidadMedida.NOM" | |
184 | + class="form-control" | |
185 | + readonly | |
186 | + esc-key="volver(cisterna, key)" | |
187 | + /> | |
188 | + <div class="input-group-append"> | |
189 | + <button | |
190 | + ladda="searchLoading" | |
191 | + class="btn btn-outline-secondary form-control" | |
192 | + type="button" | |
193 | + ng-click="seleccionarUnidadMedida(cisterna)" | |
194 | + foca-focus="focused == 3" | |
195 | + > | |
196 | + <i class="fa fa-search" aria-hidden="true"></i> | |
197 | + </button> | |
196 | 198 | </div> |
197 | - </td> | |
199 | + </div> | |
200 | + </td> | |
198 | 201 | <td class="text-center" ng-hide="cisterna.editando"> |
199 | 202 | <button |
200 | 203 | class="btn btn-outline-dark boton-accion" |
... | ... | @@ -226,10 +229,8 @@ |
226 | 229 | </button> |
227 | 230 | </td> |
228 | 231 | </tr> |
229 | - | |
230 | 232 | <tr ng-repeat="(key, cisterna) in cisternas" ng-show="false"> |
231 | 233 | </tr> |
232 | - | |
233 | 234 | </body> |
234 | 235 | </table> |
235 | 236 | </div> |