Commit 16ce5c4bfe32faca9bf61c708dcbba245e7624f0
1 parent
0671222b
Exists in
master
Redmine #4783 Alterando método de salvar materiais
Showing
1 changed file
with
23 additions
and
46 deletions
Show diff stats
cit-almoxarifado-web/src/main/webapp/assets/js/angular/custom/controller/EntradaAlmoxarifadoController.js
... | ... | @@ -292,61 +292,38 @@ citApp.controller('EntradaAlmoxarifadoController', ['$scope', '$filter', 'FileUp |
292 | 292 | |
293 | 293 | $scope.addEntradaItem = function(formDialogMateriais) { |
294 | 294 | formDialogMateriais.$submitted = true; |
295 | - $scope.validaAnexo = false; | |
296 | - | |
297 | - $scope.caracteristicas.forEach(function(bemAlmoxarifadoCaracteristica) { | |
298 | - if(bemAlmoxarifadoCaracteristica.materialCaracteristica.caracteristica.dominioTipoDado.nome == 'ARQUIVO'){ | |
299 | - if($scope.uploaderCaracteristica.queue && $scope.uploaderCaracteristica.queue.length > 0){ | |
300 | - bemAlmoxarifadoCaracteristica.uploadAnexo = $scope.uploaderCaracteristica.getNotUploadedItems(); | |
301 | - }else{ | |
302 | - $scope.validaAnexo = true; | |
303 | - } | |
304 | - } | |
305 | - }); | |
306 | 295 | |
307 | - if(formDialogMateriais.$valid && !$scope.validaAnexo){ | |
296 | + if(formDialogMateriais.$valid){ | |
308 | 297 | |
309 | 298 | if($scope.entradaItem.$quantidadeEntrada > 0){ |
299 | + | |
300 | + if($scope.entradaItem.$validarPrecoMedio){ | |
310 | 301 | |
311 | - if($scope.entradaItem.quantidadeDominioTipoUnidadeEntrada > 0){ | |
312 | - | |
313 | - if($scope.entradaItem.$validarPrecoMedio){ | |
314 | - | |
315 | - var idAlmoxarifado = $scope.entradaAlmoxarifado.almoxarifado ? $scope.entradaAlmoxarifado.almoxarifado.id : null; | |
316 | - | |
317 | - EntradaAlmoxarifadoItemRepository.validarPrecoMedio($scope.entradaItem.valorUnitario, $scope.entradaItem.material.id, idAlmoxarifado).then(function(result) {}); | |
318 | - | |
319 | - } | |
302 | + var idAlmoxarifado = $scope.entradaAlmoxarifado.almoxarifado ? $scope.entradaAlmoxarifado.almoxarifado.id : null; | |
320 | 303 | |
321 | - $scope.entradaItem.caracteristicas = $scope.caracteristicas; | |
322 | - | |
323 | - if(!$scope.entradaItem.uuid){ | |
324 | - $scope.entradaItem.uuid = getUuid(); | |
325 | - $scope.entradaAlmoxarifado.entradasIten.push($scope.entradaItem); | |
326 | - }else{ | |
327 | - var entradasItemTemp = []; | |
328 | - $scope.entradaAlmoxarifado.entradasIten.forEach(function (entradaItem, $index) { | |
329 | - if(entradaItem.uuid === $scope.entradaItem.uuid){ | |
330 | - entradasItemTemp.push($scope.entradaItem); | |
331 | - }else{ | |
332 | - entradasItemTemp.push(entradaItem); | |
333 | - } | |
334 | - }); | |
335 | - $scope.entradaAlmoxarifado.entradasIten = entradasItemTemp; | |
336 | - } | |
304 | + EntradaAlmoxarifadoItemRepository.validarPrecoMedio($scope.entradaItem.valorUnitario, $scope.entradaItem.material.id, idAlmoxarifado).then(function(result) {}); | |
337 | 305 | |
306 | + } | |
338 | 307 | |
339 | - $scope.calcularValorTotalMateriais(); | |
340 | - | |
341 | - if($scope.uploaderCaracteristica.queue > 0){ | |
308 | + if(!$scope.entradaItem.uuid){ | |
309 | + $scope.entradaItem.uuid = getUuid(); | |
310 | + $scope.entradaAlmoxarifado.entradasIten.push($scope.entradaItem); | |
311 | + }else{ | |
312 | + var entradasItemTemp = []; | |
313 | + $scope.entradaAlmoxarifado.entradasIten.forEach(function (entradaItem, $index) { | |
314 | + if(entradaItem.uuid === $scope.entradaItem.uuid){ | |
315 | + entradasItemTemp.push($scope.entradaItem); | |
316 | + }else{ | |
317 | + entradasItemTemp.push(entradaItem); | |
318 | + } | |
319 | + }); | |
320 | + $scope.entradaAlmoxarifado.entradasIten = entradasItemTemp; | |
321 | + } | |
342 | 322 | |
343 | - $scope.uploaderCaracteristica.clearQueue(); | |
344 | - } | |
323 | + $scope.calcularValorTotalMateriais(); | |
345 | 324 | |
346 | - $scope.$modalInstance.dismiss('cancel'); | |
347 | - } else{ | |
348 | - $scope.showAlert('error', $translate.instant('ALMOXARIFADO.VALIDACAO.UNIDADE_MAIOR_ZERO')); | |
349 | - } | |
325 | + $scope.$modalInstance.dismiss('cancel'); | |
326 | + | |
350 | 327 | }else{ |
351 | 328 | $scope.showAlert('error', $translate.instant('VALIDACAO.QUANTIDADE_MAIOR_ZERO')); |
352 | 329 | } | ... | ... |