Commit 59d5b6b83b2e63a7141bbb0f0ec28e376171ba79

Authored by Luigi
1 parent f7945bfaeb
Exists in master

cambio en precio y condicion

Showing 1 changed file with 46 additions and 38 deletions   Show diff stats
src/js/controller.js
... ... @@ -20,6 +20,8 @@ angular.module('focaModalPrecioCondicion')
20 20 activo: true
21 21 }
22 22 ];
  23 + $scope.remito = parametros.remito;
  24 + $scope.notaPedido = parametros.notaPedido;
23 25 $scope.openModalListaDePrecios = false;
24 26 $scope.associatedList = true;
25 27 $scope.listaDePreciosAlternativa = null;
... ... @@ -29,48 +31,57 @@ angular.module('focaModalPrecioCondicion')
29 31 function onInit() {
30 32 //Metodo para traer la lista de precio asociada al cliente
31 33 focaModalPrecioCondicionService.getListaPrecio(parametros.idListaPrecio)
32   - .then(function (res) {
33   - $scope.listaDePreciosAsociada = res.data[0];
34   - })
35   - .catch(function (e) { console.error(e) });
  34 + .then(function (res) {
  35 + $scope.listaDePreciosAsociada = res.data[0];
  36 + })
  37 + .catch(function (e) { console.error(e) });
36 38 focaModalPrecioCondicionService.getPlazosByIdCliente(parametros.idCliente)
37   - .then(function (res) {
38   - res.data.forEach(function (item) {
39   - $scope.plazos.push(item);
40   - });
41   - })
42   - .catch(function (e) { console.error(e) });
  39 + .then(function (res) {
  40 + res.data.forEach(function (item) {
  41 + $scope.plazos.push(item);
  42 + });
  43 + })
  44 + .catch(function (e) { console.error(e) });
43 45 }
44   -
  46 +
45 47 //#region Metodos para la lista de precios
46 48 $scope.openListaDePrecios = function () {
47 49 var datos = null;
48 50 focaModalPrecioCondicionService.getAllListaPrecio()
49   - .then(function (res) {
50   - datos = res.data;
51   - focaModalService.modal({
52   - titulo: 'Lista de precios',
53   - data: datos,
54   - size: 'md',
55   - columnas: [
56   - {
57   - propiedad: 'ID',
58   - nombre: 'Codigo'
59   - },
60   - {
61   - propiedad: 'DES',
62   - NOMBRE: 'Nombre'
63   - }
64   - ],
65   - }).then(function (res) {
66   - focaModalService.confirm('¿Desea cambiar la lista de precios?\n'+
67   - 'Se perderan los productos ingresados').then(function (data){
68   - if (data) {
69   - $scope.associatedList = false;
70   - $scope.listaDePreciosAlternativa = res;
  51 + .then(function (res) {
  52 + datos = res.data;
  53 + focaModalService.modal({
  54 + titulo: 'Lista de precios',
  55 + data: datos,
  56 + size: 'md',
  57 + columnas: [
  58 + {
  59 + propiedad: 'ID',
  60 + nombre: 'Codigo'
  61 + },
  62 + {
  63 + propiedad: 'DES',
  64 + NOMBRE: 'Nombre'
  65 + }
  66 + ],
  67 + }).then(function (res) {
  68 + focaModalService.confirm('¿Desea cambiar la lista de precios?\n'+
  69 + 'Se perderan los productos ingresados').then(function (data){
  70 + if (data) {
  71 + if ($scope.notaPedido) {
  72 + if ($scope.notaPedido.articulosNotaPedido.length > 0) {
  73 + $scope.notaPedido.articulosNotaPedido = [];
  74 + }
  75 + } else if ($scope.remito) {
  76 + if ($scope.remito.articulosRemito.length > 0) {
  77 + $scope.remito.articulosRemito = [];
  78 + }
71 79 }
72   - });
73   - }).catch(function (e) {
  80 + $scope.associatedList = false;
  81 + $scope.listaDePreciosAlternativa = res;
  82 + }
  83 + });
  84 + }).catch(function (e) {
74 85 console.error(e);
75 86 });
76 87 });
... ... @@ -135,8 +146,6 @@ angular.module('focaModalPrecioCondicion')
135 146 $uibModalInstance.dismiss('cancel');
136 147 };
137 148 $scope.guardarPrecioCondicion = function () {
138   - var mod = $scope.associatedList ? parseInt($scope.listaDePreciosAsociada.ID) : parseInt($scope.listaDePreciosAlternativa.ID);
139   - focaModalPrecioCondicionService.actualizarLista(parametros.idCliente, mod).then(function (){
140 149 $scope.plazos.shift();
141 150 focaModalPrecioCondicionService.createPlazo($scope.plazos)
142 151 .then(function () {
... ... @@ -147,7 +156,6 @@ angular.module('focaModalPrecioCondicion')
147 156 $uibModalInstance.close(precioCondicion);
148 157 })
149 158 .catch(function (e) { console.error(e) })
150   - });
151 159 };
152 160 }
153 161 ]);