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

60 lines
1.7 KiB
JavaScript
Raw Normal View History

2018-03-14 10:41:19 +00:00
import ngModule from '../module';
class Controller {
constructor($http, $state) {
2018-03-14 10:41:19 +00:00
this.$http = $http;
this.$state = $state;
2018-10-03 06:00:19 +00:00
this.filter = {
2018-04-10 09:14:33 +00:00
include: [
{relation: 'warehouse', scope: {fields: ['name']}},
{relation: 'agencyMode', scope: {fields: ['name']}},
{
relation: 'client',
scope: {
2018-05-31 06:57:25 +00:00
fields: ['salesPersonFk', 'name', 'isActive', 'isFreezed', 'isTaxDataChecked'],
2018-04-10 09:14:33 +00:00
include: {
relation: 'salesPerson',
fields: ['firstName', 'name'],
},
},
2018-04-10 09:14:33 +00:00
},
{
relation: 'tracking',
2018-04-10 09:14:33 +00:00
scope: {
fields: ['stateFk'],
include: {
relation: 'state',
fields: ['name'],
},
2018-11-12 11:06:18 +00:00
order: 'created DESC'
},
},
],
2018-03-14 10:41:19 +00:00
};
2018-10-03 06:00:19 +00:00
}
2018-05-31 12:48:10 +00:00
2018-10-03 06:00:19 +00:00
$onInit() {
this.getCard();
}
getCard() {
const json = encodeURIComponent(JSON.stringify(this.filter));
const query = `/ticket/api/Tickets/${this.$state.params.id}?filter=${json}`;
2018-11-12 11:06:18 +00:00
this.$http.get(query).then(res => {
if (res.data)
2018-05-31 12:48:10 +00:00
this.ticket = res.data;
});
2018-03-14 10:41:19 +00:00
}
reload() {
2018-10-03 06:00:19 +00:00
this.getCard();
}
2018-03-14 10:41:19 +00:00
}
Controller.$inject = ['$http', '$state'];
2018-03-14 10:41:19 +00:00
ngModule.component('vnTicketCard', {
template: require('./index.html'),
controller: Controller,
2018-03-14 10:41:19 +00:00
});