2018-11-13 06:44:03 +00:00
|
|
|
import ngModule from '../module';
|
2020-03-16 17:54:22 +00:00
|
|
|
import Section from 'salix/components/section';
|
2018-11-13 06:44:03 +00:00
|
|
|
|
2020-03-16 17:54:22 +00:00
|
|
|
export default class Controller extends Section {
|
2020-04-25 09:50:04 +00:00
|
|
|
preview(travel) {
|
2019-10-24 10:49:18 +00:00
|
|
|
this.travelSelected = travel;
|
|
|
|
this.$.summary.show();
|
2019-12-20 06:55:00 +00:00
|
|
|
}
|
|
|
|
|
2020-03-16 17:33:39 +00:00
|
|
|
onCloneAccept(travel) {
|
|
|
|
const params = JSON.stringify({
|
|
|
|
ref: travel.ref,
|
|
|
|
agencyModeFk: travel.agencyFk,
|
|
|
|
shipped: travel.shipped,
|
|
|
|
landed: travel.landed,
|
|
|
|
warehouseInFk: travel.warehouseInFk,
|
|
|
|
warehouseOutFk: travel.warehouseOutFk
|
|
|
|
});
|
|
|
|
this.$state.go('travel.create', {q: params});
|
2019-12-20 06:55:00 +00:00
|
|
|
}
|
2020-11-13 12:04:22 +00:00
|
|
|
|
|
|
|
compareDate(date) {
|
|
|
|
let today = new Date();
|
|
|
|
today.setHours(0, 0, 0, 0);
|
|
|
|
|
|
|
|
date = new Date(date);
|
|
|
|
date.setHours(0, 0, 0, 0);
|
|
|
|
|
|
|
|
const timeDifference = today - date;
|
|
|
|
if (timeDifference == 0) return 'warning';
|
|
|
|
if (timeDifference < 0) return 'success';
|
|
|
|
}
|
|
|
|
|
|
|
|
exprBuilder(param, value) {
|
|
|
|
switch (param) {
|
|
|
|
case 'search':
|
|
|
|
return /^\d+$/.test(value)
|
|
|
|
? {'t.id': value}
|
|
|
|
: {'t.ref': {like: `%${value}%`}};
|
|
|
|
case 'ref':
|
|
|
|
return {'t.ref': {like: `%${value}%`}};
|
|
|
|
case 'shipped':
|
|
|
|
return {'t.shipped': {between: this.dateRange(value)}};
|
|
|
|
case 'landed':
|
|
|
|
return {'t.landed': {between: this.dateRange(value)}};
|
|
|
|
case 'id':
|
|
|
|
case 'agencyFk':
|
|
|
|
case 'warehouseOutFk':
|
|
|
|
case 'warehouseInFk':
|
|
|
|
case 'totalEntries':
|
|
|
|
param = `t.${param}`;
|
|
|
|
return {[param]: value};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dateRange(value) {
|
|
|
|
const minHour = new Date(value);
|
|
|
|
minHour.setHours(0, 0, 0, 0);
|
|
|
|
const maxHour = new Date(value);
|
|
|
|
maxHour.setHours(23, 59, 59, 59);
|
|
|
|
|
|
|
|
return [minHour, maxHour];
|
|
|
|
}
|
2018-11-13 06:44:03 +00:00
|
|
|
}
|
|
|
|
|
2020-07-24 12:22:30 +00:00
|
|
|
ngModule.vnComponent('vnTravelIndex', {
|
2018-11-13 06:44:03 +00:00
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller
|
|
|
|
});
|