2020-01-10 10:52:35 +00:00
|
|
|
import ngModule from '../module';
|
2020-04-25 09:50:04 +00:00
|
|
|
import Descriptor from 'salix/components/descriptor';
|
2020-01-10 10:52:35 +00:00
|
|
|
|
2020-04-25 09:50:04 +00:00
|
|
|
class Controller extends Descriptor {
|
2020-03-05 12:56:45 +00:00
|
|
|
constructor($element, $, $httpParamSerializer) {
|
2020-02-24 11:20:53 +00:00
|
|
|
super($element, $);
|
|
|
|
this.$httpParamSerializer = $httpParamSerializer;
|
2020-03-05 12:56:45 +00:00
|
|
|
|
2020-02-24 11:20:53 +00:00
|
|
|
this.moreOptions = [
|
|
|
|
{name: 'Show entry report', callback: this.showEntryReport}
|
|
|
|
];
|
2020-01-10 10:52:35 +00:00
|
|
|
}
|
2020-02-24 11:20:53 +00:00
|
|
|
|
|
|
|
onMoreChange(callback) {
|
|
|
|
callback.call(this);
|
|
|
|
}
|
|
|
|
|
2020-02-21 11:48:34 +00:00
|
|
|
get entry() {
|
|
|
|
return this._entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
set entry(value) {
|
|
|
|
this._entry = value;
|
|
|
|
if (!value) return;
|
|
|
|
|
|
|
|
const date = value.travel.landed;
|
|
|
|
let to = new Date(date);
|
|
|
|
let from = new Date(date);
|
|
|
|
to.setDate(to.getDate() + 10);
|
|
|
|
|
|
|
|
to.setHours(0, 0, 0, 0);
|
|
|
|
|
|
|
|
from.setDate(from.getDate() - 10);
|
|
|
|
from.setHours(0, 0, 0, 0);
|
|
|
|
|
|
|
|
let links = {
|
|
|
|
btnOne: {
|
|
|
|
icon: 'local_airport',
|
|
|
|
state: `travel.index({q: '{"agencyFk": ${value.travel.agencyFk}}'})`,
|
|
|
|
tooltip: 'All travels with current agency'
|
|
|
|
}};
|
|
|
|
|
|
|
|
links.btnTwo = {
|
|
|
|
icon: 'icon-entry',
|
|
|
|
state: `entry.index({q: '{"supplierFk": ${value.supplierFk}, "to": "${to}", "from": "${from}"}'})`,
|
|
|
|
tooltip: 'All entries with current supplier'
|
|
|
|
};
|
|
|
|
|
|
|
|
this._quicklinks = links;
|
|
|
|
}
|
|
|
|
|
2020-02-24 11:20:53 +00:00
|
|
|
showEntryReport() {
|
|
|
|
const params = {
|
2020-03-05 12:56:45 +00:00
|
|
|
authorization: this.vnToken.token,
|
2020-02-24 11:20:53 +00:00
|
|
|
clientId: this.vnConfig.storage.currentUserWorkerId,
|
|
|
|
entryId: this.entry.id
|
|
|
|
};
|
|
|
|
const serializedParams = this.$httpParamSerializer(params);
|
|
|
|
let url = `api/report/entry-order?${serializedParams}`;
|
|
|
|
window.open(url);
|
|
|
|
}
|
2020-01-10 10:52:35 +00:00
|
|
|
}
|
|
|
|
|
2020-03-05 12:56:45 +00:00
|
|
|
Controller.$inject = ['$element', '$scope', '$httpParamSerializer'];
|
2020-01-10 10:52:35 +00:00
|
|
|
|
2020-04-25 09:50:04 +00:00
|
|
|
ngModule.vnComponent('vnEntryDescriptor', {
|
2020-01-10 10:52:35 +00:00
|
|
|
template: require('./index.html'),
|
2020-04-25 09:50:04 +00:00
|
|
|
controller: Controller,
|
2020-01-10 10:52:35 +00:00
|
|
|
bindings: {
|
2020-04-25 09:50:04 +00:00
|
|
|
entry: '<'
|
2020-01-10 10:52:35 +00:00
|
|
|
},
|
|
|
|
require: {
|
|
|
|
card: '^?vnEntryCard'
|
2020-04-25 09:50:04 +00:00
|
|
|
}
|
2020-01-10 10:52:35 +00:00
|
|
|
});
|