2019-10-24 10:49:18 +00:00
|
|
|
import ngModule from '../module';
|
2020-03-18 11:55:22 +00:00
|
|
|
import Section from 'salix/components/section';
|
2019-10-24 10:49:18 +00:00
|
|
|
import './style.scss';
|
|
|
|
|
2020-03-18 11:55:22 +00:00
|
|
|
class Controller extends Section {
|
|
|
|
$onInit() {
|
2020-01-08 12:52:04 +00:00
|
|
|
this.entries = [];
|
2019-10-24 10:49:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get travel() {
|
|
|
|
return this._travel;
|
|
|
|
}
|
|
|
|
|
|
|
|
set travel(value) {
|
|
|
|
this._travel = value;
|
|
|
|
|
|
|
|
if (value && value.id) {
|
|
|
|
this.getTravel();
|
|
|
|
this.getEntries();
|
2020-01-13 10:53:10 +00:00
|
|
|
this.getThermographs();
|
2019-10-24 10:49:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
getTravel() {
|
2020-04-25 09:50:04 +00:00
|
|
|
return this.$http.get(`Travels/${this.travel.id}/getTravel`)
|
|
|
|
.then(res => this.travelData = res.data);
|
2019-10-24 10:49:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
getEntries() {
|
2020-04-25 09:50:04 +00:00
|
|
|
return this.$http.get(`Travels/${this.travel.id}/getEntries`)
|
|
|
|
.then(res => this.entries = res.data);
|
2019-10-24 10:49:18 +00:00
|
|
|
}
|
2020-01-08 12:52:04 +00:00
|
|
|
|
2020-01-13 10:53:10 +00:00
|
|
|
getThermographs() {
|
2020-04-25 09:50:04 +00:00
|
|
|
const filter = {
|
|
|
|
include: {
|
|
|
|
relation: 'warehouse',
|
|
|
|
scope: {
|
|
|
|
fields: ['id', 'name']
|
2020-01-13 10:53:10 +00:00
|
|
|
}
|
2020-04-25 09:50:04 +00:00
|
|
|
},
|
|
|
|
where: {
|
|
|
|
travelFk: this.travel.id
|
2020-01-13 10:53:10 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-04-25 09:50:04 +00:00
|
|
|
return this.$http.get(`TravelThermographs`, {filter})
|
|
|
|
.then(res => this.travelThermographs = res.data);
|
2020-01-13 10:53:10 +00:00
|
|
|
}
|
|
|
|
|
2020-01-08 12:52:04 +00:00
|
|
|
total(field) {
|
|
|
|
let total = 0;
|
|
|
|
|
|
|
|
for (let entry of this.entries)
|
|
|
|
total += entry[field];
|
|
|
|
|
|
|
|
return total;
|
|
|
|
}
|
2019-10-24 10:49:18 +00:00
|
|
|
}
|
|
|
|
|
2020-07-24 12:22:30 +00:00
|
|
|
ngModule.vnComponent('vnTravelSummary', {
|
2019-10-24 10:49:18 +00:00
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller,
|
|
|
|
bindings: {
|
|
|
|
travel: '<'
|
|
|
|
}
|
|
|
|
});
|