From 7ada4b7f142d312d0600ae99c654ac7a202fd7f0 Mon Sep 17 00:00:00 2001 From: Gerard Date: Thu, 22 Nov 2018 13:56:35 +0100 Subject: [PATCH] =?UTF-8?q?#853=20order.new=20deber=C3=ADa=20rellenar=20el?= =?UTF-8?q?=20consignatario=20por=20defecto=20del=20cliente?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/order/src/create/card.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/client/order/src/create/card.js b/client/order/src/create/card.js index 6a477f59e..b6caf707d 100644 --- a/client/order/src/create/card.js +++ b/client/order/src/create/card.js @@ -10,9 +10,8 @@ class Controller { } set order(value) { - if (value) { + if (value) this._order = value; - } } get order() { @@ -21,7 +20,16 @@ class Controller { set clientFk(value) { this.order.clientFk = value; - this.addressFk = null; + + if (value) { + let filter = {where: {clientFk: value, isDefaultAddress: true}}; + filter = encodeURIComponent(JSON.stringify(filter)); + let query = `/api/Addresses?filter=${filter}`; + this.$http.get(query).then(res => { + this.addressFk = res.data[0].id; + }); + } else + this.addressFk = null; } get clientFk() { @@ -74,7 +82,7 @@ class Controller { }; this.$http.post(`order/api/Orders/new`, params).then(res => { this.vnApp.showSuccess(this.translate.instant('Data saved!')); - this.$state.go("order.card.catalog", {id: res.data}); + this.$state.go('order.card.catalog', {id: res.data}); }); } }