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

69 lines
1.7 KiB
JavaScript
Raw Normal View History

import ngModule from '../../module';
import Component from 'core/lib/component';
import './style.scss';
class Controller extends Component {
set roadmap(value) {
this._roadmap = value;
this.$.summary = null;
if (!value) return;
this.loadData();
}
get roadmap() {
return this._roadmap;
}
loadData() {
const filter = {
include: [
{relation: 'supplier'},
{relation: 'worker'},
2024-05-20 11:19:01 +00:00
{relation: 'roadmapStop',
scope: {
include: [
{relation: 'warehouse'}
]
}}
]
};
this.$http.get(`Roadmaps/${this.roadmap.id}`, {filter})
.then(res => this.$.summary = res.data);
}
getETD() {
const eta = new Date(this.roadmap.etd);
eta.setDate(eta.getDate() + 1);
2024-05-16 08:20:08 +00:00
this.roadmapStop = {eta: eta};
}
onAddAccept() {
try {
const data = {
roadmapFk: this.roadmap.id,
2024-05-16 08:20:08 +00:00
warehouseFk: this.roadmapStop.warehouseFk,
eta: this.roadmapStop.eta,
description: this.roadmapStop.description
};
2024-05-20 11:19:01 +00:00
this.$http.post(`RoadmapStops`, data)
.then(() => {
this.loadData();
this.vnApp.showSuccess(this.$t('Data saved!'));
});
} catch (e) {
this.vnApp.showError(this.$t(e.message));
}
}
}
ngModule.component('vnRoadmapSummary', {
template: require('./index.html'),
controller: Controller,
bindings: {
roadmap: '<'
}
});