salix/client/ticket/src/card/ticket-card.js

60 lines
1.6 KiB
JavaScript
Raw Normal View History

2018-03-14 10:41:19 +00:00
import ngModule from '../module';
class TicketCard {
constructor($http, $state) {
2018-03-14 10:41:19 +00:00
this.$http = $http;
this.$state = $state;
this.ticket = null;
}
_getTicket() {
let filter = {
2018-04-10 09:14:33 +00:00
include: [
{relation: 'warehouse', scope: {fields: ['name']}},
{relation: 'agencyMode', scope: {fields: ['name']}},
{
relation: 'client',
scope: {
fields: ['salesPersonFk', 'name'],
include: {
relation: 'salesPerson',
fields: ['firstName', 'name']
}
}
},
{
relation: 'tracking',
2018-04-10 09:14:33 +00:00
scope: {
fields: ['stateFk'],
include: {
relation: 'state',
fields: ['name']
}
}
}
]
2018-03-14 10:41:19 +00:00
};
let json = encodeURIComponent(JSON.stringify(filter));
this.$http.get(`/ticket/api/Tickets/${this.$state.params.id}?filter=${json}`)
2018-03-14 10:41:19 +00:00
.then(res => {
if (res.data)
this.ticket = res.data;
2018-03-14 10:41:19 +00:00
}
);
}
$onInit() {
this._getTicket();
}
reload() {
this._getTicket();
}
2018-03-14 10:41:19 +00:00
}
TicketCard.$inject = ['$http', '$state'];
2018-03-14 10:41:19 +00:00
ngModule.component('vnTicketCard', {
template: require('./ticket-card.html'),
controller: TicketCard
});