2018-03-14 10:41:19 +00:00
|
|
|
import ngModule from '../module';
|
|
|
|
|
2018-05-25 08:03:45 +00:00
|
|
|
class Controller {
|
2018-05-08 07:30:55 +00:00
|
|
|
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-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',
|
2019-01-31 13:14:39 +00:00
|
|
|
scope: {
|
|
|
|
fields: ['userFk'],
|
|
|
|
include: {
|
|
|
|
relation: 'user',
|
|
|
|
scope: {
|
|
|
|
fields: ['nickname']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-10-29 07:33:53 +00:00
|
|
|
},
|
|
|
|
},
|
2018-04-10 09:14:33 +00:00
|
|
|
},
|
|
|
|
{
|
2018-11-14 13:33:25 +00:00
|
|
|
relation: 'state',
|
2018-04-10 09:14:33 +00:00
|
|
|
scope: {
|
|
|
|
fields: ['stateFk'],
|
|
|
|
include: {
|
|
|
|
relation: 'state',
|
2018-11-14 13:33:25 +00:00
|
|
|
fields: ['id', 'name'],
|
|
|
|
}
|
2018-10-29 07:33:53 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
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() {
|
2018-10-29 07:33:53 +00:00
|
|
|
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;
|
|
|
|
});
|
|
|
|
}
|
2018-05-08 07:30:55 +00:00
|
|
|
reload() {
|
2018-10-03 06:00:19 +00:00
|
|
|
this.getCard();
|
2018-05-08 07:30:55 +00:00
|
|
|
}
|
2018-03-14 10:41:19 +00:00
|
|
|
}
|
2018-05-25 08:03:45 +00:00
|
|
|
|
|
|
|
Controller.$inject = ['$http', '$state'];
|
2018-03-14 10:41:19 +00:00
|
|
|
|
|
|
|
ngModule.component('vnTicketCard', {
|
2018-05-25 08:03:45 +00:00
|
|
|
template: require('./index.html'),
|
2018-11-14 13:33:25 +00:00
|
|
|
controller: Controller
|
2018-03-14 10:41:19 +00:00
|
|
|
});
|