salix/modules/order/front/card/index.js

83 lines
2.3 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']
}
},
2018-07-18 12:21:58 +00:00
{
relation: 'client',
scope: {
fields: ['salesPersonFk', 'name', 'isActive', 'isFreezed', 'isTaxDataChecked'],
include: {
relation: 'salesPerson',
scope: {
fields: ['userFk'],
include: {
relation: 'user',
scope: {
fields: ['nickname']
}
}
}
2018-07-18 12:21:58 +00:00
}
}
}
]
};
}
2018-07-18 12:21:58 +00:00
2018-10-03 06:00:19 +00:00
$onInit() {
this.getCard();
}
getCard() {
let json = encodeURIComponent(JSON.stringify(this.filter));
let query = `Orders/${this.$state.params.id}?filter=${json}`;
2018-07-18 12:21:58 +00:00
this.$http.get(query).then(res => {
2018-12-10 07:43:57 +00:00
if (res.data && res.data.rows) {
2018-11-30 10:45:17 +00:00
if (res.data.rows.length == 0)
delete res.data.rows;
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-10-03 06:00:19 +00:00
reload() {
this.getCard();
}
2018-07-24 10:55:10 +00:00
getTotal() {
let query = `Orders/${this.$state.params.id}/getTotal`;
2018-07-20 14:32:34 +00:00
this.$http.get(query).then(res => {
2018-11-30 10:45:17 +00:00
if (res.data)
2018-10-10 10:55:04 +00:00
this.order.total = res.data;
2018-07-20 14:32:34 +00:00
});
2018-07-18 12:21:58 +00:00
}
}
Controller.$inject = ['$http', '$state'];
ngModule.component('vnOrderCard', {
template: require('./index.html'),
controller: Controller
});