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}); }); } }