salix/modules/route/front/index/index.js

55 lines
1.3 KiB
JavaScript

import ngModule from '../module';
export default class Controller {
constructor($scope, vnToken, vnConfig) {
this.accessToken = vnToken.token;
this.$ = $scope;
this.vnConfig = vnConfig;
this.setDefaultFilter();
}
setDefaultFilter() {
let to = new Date();
to.setDate(to.getDate() + 1);
to.setHours(0, 0, 0, 0);
let from = new Date();
from.setHours(0, 0, 0, 0);
this.filter = {from, to, warehouseFk: this.vnConfig.warehouseFk};
}
showWorkerDescriptor(event, workerFk) {
if (event.defaultPrevented) return;
event.preventDefault();
event.stopImmediatePropagation();
this.selectedWorker = workerFk;
this.$.workerDescriptor.parent = event.target;
this.$.workerDescriptor.show();
}
preview(event, route) {
this.routeSelected = route;
this.$.summary.show();
event.preventDefault();
event.stopImmediatePropagation();
}
onSearch(params) {
if (params)
this.$.model.applyFilter(null, params);
else
this.$.model.clear();
}
}
Controller.$inject = ['$scope', 'vnToken', 'vnConfig'];
ngModule.component('vnRouteIndex', {
template: require('./index.html'),
controller: Controller
});