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

80 lines
2.4 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']}},
2019-04-26 06:52:43 +00:00
{relation: 'invoiceOut', scope: {fields: ['id']}},
{relation: 'address'},
2019-01-21 07:44:21 +00:00
{relation: 'ship'},
2018-04-10 09:14:33 +00:00
{relation: 'agencyMode', scope: {fields: ['name']}},
2019-01-21 07:44:21 +00:00
{relation: 'stowaway'},
2018-04-10 09:14:33 +00:00
{
relation: 'client',
scope: {
2019-01-16 14:38:50 +00:00
fields: ['salesPersonFk', 'name', 'isActive', 'isFreezed', 'isTaxDataChecked', 'credit'],
2018-04-10 09:14:33 +00:00
include: {
relation: 'salesPerson',
scope: {
fields: ['userFk'],
include: {
relation: 'user',
scope: {
fields: ['nickname']
}
}
}
},
},
2018-04-10 09:14:33 +00:00
},
{
relation: 'state',
2018-04-10 09:14:33 +00:00
scope: {
fields: ['stateFk'],
include: {
relation: 'state',
fields: ['id', 'name'],
}
},
},
],
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 => {
2019-01-16 14:38:50 +00:00
if (res.data) {
2018-05-31 12:48:10 +00:00
this.ticket = res.data;
2019-01-16 14:38:50 +00:00
this.getDebt(res.data.client.id);
}
2018-05-31 12:48:10 +00:00
});
2018-03-14 10:41:19 +00:00
}
2019-01-16 14:38:50 +00:00
getDebt(id) {
const query = `/ticket/api/Clients/${id}/getDebt`;
this.$http.get(query).then(res => {
if (res.data)
this.ticket.client.debt = res.data.debt;
});
}
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
});