2018-11-13 06:44:03 +00:00
|
|
|
import ngModule from '../module';
|
2020-03-18 11:55:22 +00:00
|
|
|
import Section from 'salix/components/section';
|
2018-11-13 06:44:03 +00:00
|
|
|
|
2020-03-18 11:55:22 +00:00
|
|
|
export default class Controller extends Section {
|
2019-12-20 06:55:00 +00:00
|
|
|
getScopeDates(days) {
|
|
|
|
const today = new Date();
|
|
|
|
today.setHours(0, 0, 0, 0);
|
|
|
|
const daysOnward = new Date(today);
|
|
|
|
daysOnward.setDate(today.getDate() + days);
|
|
|
|
daysOnward.setHours(23, 59, 59, 999);
|
|
|
|
return {shippedFrom: today, shippedTo: daysOnward};
|
|
|
|
}
|
|
|
|
|
|
|
|
onSearch(params) {
|
|
|
|
if (params) {
|
|
|
|
let newParams = params;
|
|
|
|
if (params.scopeDays) {
|
|
|
|
const scopeDates = this.getScopeDates(params.scopeDays);
|
|
|
|
Object.assign(newParams, scopeDates);
|
|
|
|
} else if (Object.entries(params).length == 0)
|
|
|
|
newParams = this.getScopeDates(1);
|
|
|
|
|
|
|
|
this.$.model.applyFilter(null, newParams);
|
|
|
|
} else
|
|
|
|
this.$.model.clear();
|
|
|
|
}
|
2020-03-10 13:09:26 +00:00
|
|
|
|
|
|
|
stopEvent(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopImmediatePropagation();
|
|
|
|
}
|
|
|
|
|
|
|
|
cloneTravel(event, travel) {
|
|
|
|
this.stopEvent(event);
|
|
|
|
this.travelSelected = travel;
|
|
|
|
this.$.clone.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
onCloneAccept(response) {
|
|
|
|
if (!(response == 'accept' && this.travelSelected))
|
|
|
|
return;
|
|
|
|
if (this.travelSelected) {
|
|
|
|
const travel = {
|
|
|
|
ref: this.travelSelected.ref,
|
|
|
|
agencyModeFk: this.travelSelected.agencyFk,
|
|
|
|
shipped: this.travelSelected.shipped,
|
|
|
|
landed: this.travelSelected.landed,
|
|
|
|
warehouseInFk: this.travelSelected.warehouseInFk,
|
|
|
|
warehouseOutFk: this.travelSelected.warehouseOutFk
|
|
|
|
};
|
|
|
|
const queryParams = JSON.stringify(travel);
|
|
|
|
this.$state.go('travel.create', {q: queryParams});
|
|
|
|
}
|
|
|
|
|
|
|
|
this.travelSelected = null;
|
|
|
|
}
|
|
|
|
preview(event, travel) {
|
|
|
|
this.stopEvent(event);
|
|
|
|
this.travelSelected = travel;
|
|
|
|
this.$.summary.show();
|
|
|
|
}
|
2018-11-13 06:44:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ngModule.component('vnTravelIndex', {
|
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller
|
|
|
|
});
|