salix/client/order/src/card/index.js

61 lines
1.6 KiB
JavaScript
Raw Normal View History

2018-07-18 12:21:58 +00:00
import ngModule from '../module';
class Controller {
constructor($http, $state) {
this.$http = $http;
this.$state = $state;
2018-07-24 09:28:20 +00:00
this.order = {};
this.filter = {
2018-07-18 12:21:58 +00:00
include: [
{relation: 'agencyMode', scope: {fields: ['name']}},
{relation: 'address', scope: {fields: ['nickname']}},
{relation: 'rows', scope: {fields: ['id']}},
{
relation: 'client',
scope: {
fields: ['salesPersonFk', 'name', 'isActive', 'isFreezed', 'isTaxDataChecked'],
include: {
relation: 'salesPerson',
fields: ['firstName', 'name']
}
}
}
]
};
}
2018-07-18 12:21:58 +00:00
getOrder() {
let json = encodeURIComponent(JSON.stringify(this.filter));
2018-07-18 12:21:58 +00:00
let query = `/order/api/Orders/${this.$state.params.id}?filter=${json}`;
this.$http.get(query).then(res => {
if (res.data) {
2018-07-18 12:21:58 +00:00
this.order = res.data;
this.getTotal();
}
2018-07-18 12:21:58 +00:00
});
2018-07-24 10:55:10 +00:00
}
2018-07-20 14:32:34 +00:00
2018-07-24 10:55:10 +00:00
getTotal() {
let query = `/order/api/Orders/${this.$state.params.id}/getTotal`;
2018-07-20 14:32:34 +00:00
this.$http.get(query).then(res => {
if (res.data) {
this.order.total = res.data.total;
}
});
2018-07-18 12:21:58 +00:00
}
$onInit() {
this.getOrder();
}
reload() {
this.getOrder();
}
}
Controller.$inject = ['$http', '$state'];
ngModule.component('vnOrderCard', {
template: require('./index.html'),
controller: Controller
});