2023-07-04 12:42:51 +00:00
|
|
|
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',
|
2023-07-04 12:42:51 +00:00
|
|
|
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};
|
2023-07-04 12:42:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2023-07-04 12:42:51 +00:00
|
|
|
};
|
|
|
|
|
2024-05-20 11:19:01 +00:00
|
|
|
this.$http.post(`RoadmapStops`, data)
|
2023-07-04 12:42:51 +00:00
|
|
|
.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: '<'
|
|
|
|
}
|
|
|
|
});
|