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

78 lines
2.3 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: 'zone',
},
{
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: 'salesPersonUser',
scope: {
fields: ['id', 'name']
}
},
},
}, {
relation: 'ticketState',
scope: {
fields: ['stateFk'],
include: {
relation: 'state',
fields: ['id', 'name'],
}
},
},
],
};
return this.$http.get(`Tickets/${this.$params.id}`, {filter})
.then(res => this.onData(res.data));
}
onData(data) {
this.ticket = data;
return this.$http.get(`Clients/${data.client.id}/getDebt`)
.then(res => this.ticket.client.debt = res.data.debt);
}
}
ngModule.vnComponent('vnTicketCard', {
template: require('./index.html'),
controller: Controller
});