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-02-21 11:48:34 +00:00
|
|
|
get entry() {
|
2020-04-30 10:48:52 +00:00
|
|
|
return this.entity;
|
2020-02-21 11:48:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
set entry(value) {
|
2020-04-30 10:48:52 +00:00
|
|
|
this.entity = value;
|
|
|
|
}
|
2020-02-21 11:48:34 +00:00
|
|
|
|
2020-04-30 10:48:52 +00:00
|
|
|
get travelFilter() {
|
2020-08-26 14:33:47 +00:00
|
|
|
let travelFilter;
|
|
|
|
const entryTravel = this.entry && this.entry.travel;
|
|
|
|
|
2022-07-13 12:36:03 +00:00
|
|
|
if (entryTravel && entryTravel.agencyModeFk) {
|
2020-08-26 14:33:47 +00:00
|
|
|
travelFilter = this.entry && JSON.stringify({
|
2022-07-13 12:36:03 +00:00
|
|
|
agencyModeFk: entryTravel.agencyModeFk
|
2020-08-26 14:33:47 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
return travelFilter;
|
2020-04-30 10:48:52 +00:00
|
|
|
}
|
2020-02-21 11:48:34 +00:00
|
|
|
|
2020-04-30 10:48:52 +00:00
|
|
|
get entryFilter() {
|
2020-08-26 14:33:47 +00:00
|
|
|
let entryTravel = this.entry && this.entry.travel;
|
|
|
|
|
|
|
|
if (!entryTravel || !entryTravel.landed) return null;
|
2020-05-06 12:38:09 +00:00
|
|
|
|
2020-08-26 14:33:47 +00:00
|
|
|
const date = new Date(entryTravel.landed);
|
2020-04-30 10:48:52 +00:00
|
|
|
date.setHours(0, 0, 0, 0);
|
2020-02-21 11:48:34 +00:00
|
|
|
|
2020-04-30 10:48:52 +00:00
|
|
|
const from = new Date(date.getTime());
|
2020-02-21 11:48:34 +00:00
|
|
|
from.setDate(from.getDate() - 10);
|
|
|
|
|
2020-04-30 10:48:52 +00:00
|
|
|
const to = new Date(date.getTime());
|
|
|
|
to.setDate(to.getDate() + 10);
|
2020-02-21 11:48:34 +00:00
|
|
|
|
2020-04-30 10:48:52 +00:00
|
|
|
return JSON.stringify({
|
2020-05-06 12:38:09 +00:00
|
|
|
supplierFk: this.entry.supplierFk,
|
2020-04-30 10:48:52 +00:00
|
|
|
from,
|
|
|
|
to
|
|
|
|
});
|
2020-02-21 11:48:34 +00:00
|
|
|
}
|
|
|
|
|
2020-08-26 14:33:47 +00:00
|
|
|
loadData() {
|
|
|
|
const filter = {
|
|
|
|
include: [
|
|
|
|
{
|
|
|
|
relation: 'travel',
|
|
|
|
scope: {
|
2022-07-13 12:36:03 +00:00
|
|
|
fields: ['id', 'landed', 'agencyModeFk', 'warehouseOutFk'],
|
2020-08-26 14:33:47 +00:00
|
|
|
include: [
|
|
|
|
{
|
|
|
|
relation: 'agency',
|
|
|
|
scope: {
|
|
|
|
fields: ['name']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
relation: 'warehouseOut',
|
|
|
|
scope: {
|
|
|
|
fields: ['name']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
relation: 'warehouseIn',
|
|
|
|
scope: {
|
|
|
|
fields: ['name']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
relation: 'supplier',
|
|
|
|
scope: {
|
|
|
|
fields: ['id', 'nickname']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
return this.getData(`Entries/${this.id}`, {filter})
|
|
|
|
.then(res => this.entity = res.data);
|
|
|
|
}
|
|
|
|
|
2020-02-24 11:20:53 +00:00
|
|
|
showEntryReport() {
|
2020-06-12 12:28:29 +00:00
|
|
|
this.vnReport.show('entry-order', {
|
2020-02-24 11:20:53 +00:00
|
|
|
entryId: this.entry.id
|
2020-04-30 10:48:52 +00:00
|
|
|
});
|
2020-02-24 11:20:53 +00:00
|
|
|
}
|
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
|
|
|
});
|