2018-03-12 13:02:29 +00:00
|
|
|
import ngModule from '../module';
|
|
|
|
|
|
|
|
export default class Controller {
|
2018-04-10 05:48:04 +00:00
|
|
|
constructor($scope) {
|
2018-06-07 21:47:19 +00:00
|
|
|
this.$ = $scope;
|
2018-04-10 05:48:04 +00:00
|
|
|
this.ticketSelected = null;
|
2018-06-07 21:47:19 +00:00
|
|
|
|
|
|
|
this.filter = {
|
|
|
|
include: [
|
|
|
|
{
|
|
|
|
relation: 'address',
|
|
|
|
scope: {
|
|
|
|
fields: ['provinceFk'],
|
|
|
|
include: {
|
|
|
|
relation: 'province',
|
|
|
|
scope: {
|
|
|
|
fields: ['name']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
relation: 'warehouse',
|
|
|
|
scope: {
|
|
|
|
fields: ['name']
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
relation: 'agencyMode',
|
|
|
|
scope: {
|
|
|
|
fields: ['name']
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
relation: 'tracking',
|
|
|
|
scope: {
|
|
|
|
fields: ['stateFk'],
|
|
|
|
include: {
|
|
|
|
relation: 'state',
|
|
|
|
scope: {
|
|
|
|
fields: ['name']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
relation: 'client',
|
|
|
|
scope: {
|
|
|
|
fields: ['salesPersonFk'],
|
|
|
|
include: {
|
|
|
|
relation: 'salesPerson',
|
|
|
|
scope: {
|
|
|
|
fields: ['name']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
order: 'shipped DESC'
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
exprBuilder(param, value) {
|
|
|
|
switch (param) {
|
|
|
|
case 'search':
|
2018-07-03 15:41:41 +00:00
|
|
|
return /^\d+$/.test(value)
|
|
|
|
? {id: value}
|
|
|
|
: {nickname: {regexp: value}};
|
2018-06-07 21:47:19 +00:00
|
|
|
case 'from':
|
|
|
|
return {shipped: {gte: value}};
|
|
|
|
case 'to':
|
|
|
|
return {shipped: {lte: value}};
|
|
|
|
case 'nickname':
|
|
|
|
return {[param]: {regexp: value}};
|
|
|
|
case 'id':
|
|
|
|
case 'clientFk':
|
|
|
|
case 'agencyModeFk':
|
|
|
|
case 'warehouseFk':
|
|
|
|
return {[param]: value};
|
|
|
|
}
|
2018-04-10 05:48:04 +00:00
|
|
|
}
|
|
|
|
|
2018-04-19 12:56:05 +00:00
|
|
|
compareDate(date) {
|
|
|
|
let today = new Date();
|
|
|
|
today.setHours(0, 0, 0, 0);
|
|
|
|
let timeTicket = new Date(date);
|
|
|
|
timeTicket.setHours(0, 0, 0, 0);
|
|
|
|
|
|
|
|
let comparation = today - timeTicket;
|
|
|
|
|
|
|
|
if (comparation == 0)
|
|
|
|
return 'warning';
|
|
|
|
|
|
|
|
if (comparation < 0)
|
|
|
|
return 'success';
|
2018-03-12 13:02:29 +00:00
|
|
|
}
|
2018-04-10 05:48:04 +00:00
|
|
|
|
2018-04-19 12:56:05 +00:00
|
|
|
preview(event, ticket) {
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopImmediatePropagation();
|
2018-06-07 21:47:19 +00:00
|
|
|
this.$.dialogSummaryTicket.show();
|
2018-04-19 12:56:05 +00:00
|
|
|
this.ticketSelected = ticket;
|
|
|
|
}
|
2018-03-12 13:02:29 +00:00
|
|
|
}
|
2018-04-10 05:48:04 +00:00
|
|
|
|
|
|
|
Controller.$inject = ['$scope'];
|
2018-03-12 13:02:29 +00:00
|
|
|
|
2018-05-25 08:03:45 +00:00
|
|
|
ngModule.component('vnTicketIndex', {
|
|
|
|
template: require('./index.html'),
|
2018-03-12 13:02:29 +00:00
|
|
|
controller: Controller
|
|
|
|
});
|