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

75 lines
2.4 KiB
JavaScript

import ngModule from '../module';
import ModuleCard from 'salix/components/module-card';
class Controller extends ModuleCard {
reload() {
let filter = {
include: [
{relation: 'address'},
{relation: 'ship'},
{relation: 'stowaway'},
{
relation: 'warehouse',
scope: {fields: ['name']}
}, {
relation: 'invoiceOut',
scope: {fields: ['id']}
}, {
relation: 'agencyMode',
scope: {fields: ['name']}
}, {
relation: 'client',
scope: {
fields: [
'salesPersonFk',
'name',
'isActive',
'isFreezed',
'isTaxDataChecked',
'credit',
'email',
'phone',
'mobile'
],
include: {
relation: 'salesPerson',
scope: {
fields: ['userFk'],
include: {
relation: 'user',
scope: {
fields: ['nickname']
}
}
}
},
},
}, {
relation: 'state',
scope: {
fields: ['stateFk'],
include: {
relation: 'state',
fields: ['id', 'name'],
}
},
},
],
};
this.$http.get(`Tickets/${this.$params.id}`, {filter})
.then(res => this.onData(res.data));
}
onData(data) {
this.ticket = data;
this.$http.get(`Clients/${data.client.id}/getDebt`)
.then(res => this.ticket.client.debt = res.data.debt);
}
}
ngModule.component('vnTicketCard', {
template: require('./index.html'),
controller: Controller
});