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

82 lines
2.5 KiB
JavaScript
Raw Permalink Normal View History

2018-03-14 10:41:19 +00:00
import ngModule from '../module';
2019-11-10 10:08:44 +00:00
import ModuleCard from 'salix/components/module-card';
2024-06-04 07:10:47 +00:00
import UserError from 'core/lib/user-error';
2018-03-14 10:41:19 +00:00
2019-11-10 10:08:44 +00:00
class Controller extends ModuleCard {
reload() {
let filter = {
2018-04-10 09:14:33 +00:00
include: [
{
relation: 'address'
},
{
relation: 'zone'
},
2018-04-10 09:14:33 +00:00
{
2019-11-10 10:08:44 +00:00
relation: 'warehouse',
scope: {fields: ['name']}
},
{
2019-11-10 10:08:44 +00:00
relation: 'invoiceOut',
scope: {fields: ['id']}
},
{
2019-11-10 10:08:44 +00:00
relation: 'agencyMode',
scope: {fields: ['name']}
},
{
2018-04-10 09:14:33 +00:00
relation: 'client',
scope: {
fields: [
'salesPersonFk',
'name',
'isActive',
'isFreezed',
'isTaxDataChecked',
'credit',
2020-02-21 07:37:37 +00:00
'email',
'phone',
'mobile',
2022-11-23 07:55:44 +00:00
'hasElectronicInvoice',
],
2018-04-10 09:14:33 +00:00
include: {
relation: 'salesPersonUser',
scope: {
fields: ['id', 'name']
}
},
},
},
{
2020-06-23 11:40:49 +00:00
relation: 'ticketState',
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-05-31 12:48:10 +00:00
2024-06-04 07:10:47 +00:00
if (!this.$params.id) {
this.$state.go('ticket.index');
throw new UserError(`You must select a ticket`);
}
2020-03-30 15:30:03 +00:00
return this.$http.get(`Tickets/${this.$params.id}`, {filter})
2019-11-10 10:08:44 +00:00
.then(res => this.onData(res.data));
2018-10-03 06:00:19 +00:00
}
2019-11-10 10:08:44 +00:00
onData(data) {
this.ticket = data;
2020-03-30 15:30:03 +00:00
return this.$http.get(`Clients/${data.client.id}/getDebt`)
2019-11-10 10:08:44 +00:00
.then(res => this.ticket.client.debt = res.data.debt);
}
2018-03-14 10:41:19 +00:00
}
ngModule.vnComponent('vnTicketCard', {
template: require('./index.html'),
controller: Controller
2018-03-14 10:41:19 +00:00
});