2020-10-20 07:44:44 +00:00
|
|
|
import ngModule from '../module';
|
|
|
|
import Descriptor from 'salix/components/descriptor';
|
|
|
|
|
|
|
|
class Controller extends Descriptor {
|
|
|
|
get supplier() {
|
|
|
|
return this.entity;
|
|
|
|
}
|
|
|
|
|
|
|
|
set supplier(value) {
|
|
|
|
this.entity = value;
|
|
|
|
}
|
2020-10-22 07:35:11 +00:00
|
|
|
|
|
|
|
get entryFilter() {
|
|
|
|
if (!this.supplier) return null;
|
|
|
|
|
2023-01-16 14:18:24 +00:00
|
|
|
const date = Date.vnNew();
|
2020-10-22 07:35:11 +00:00
|
|
|
date.setHours(0, 0, 0, 0);
|
|
|
|
|
|
|
|
const from = new Date(date.getTime());
|
|
|
|
from.setDate(from.getDate() - 10);
|
|
|
|
|
|
|
|
const to = new Date(date.getTime());
|
|
|
|
to.setDate(to.getDate() + 10);
|
|
|
|
|
|
|
|
return JSON.stringify({
|
2021-02-10 14:03:11 +00:00
|
|
|
supplierFk: this.id,
|
2020-10-22 07:35:11 +00:00
|
|
|
from,
|
|
|
|
to
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-10-20 07:44:44 +00:00
|
|
|
loadData() {
|
|
|
|
const filter = {
|
|
|
|
fields: [
|
|
|
|
'id',
|
|
|
|
'name',
|
|
|
|
'nickname',
|
2020-10-22 07:35:11 +00:00
|
|
|
'nif',
|
|
|
|
'payMethodFk',
|
|
|
|
'payDemFk',
|
|
|
|
'payDay',
|
|
|
|
'isActive',
|
2020-11-18 10:47:23 +00:00
|
|
|
'isSerious',
|
2022-10-26 08:03:13 +00:00
|
|
|
'isTrucker',
|
2020-10-22 07:35:11 +00:00
|
|
|
'account'
|
|
|
|
],
|
|
|
|
include: [
|
|
|
|
{
|
|
|
|
relation: 'payMethod',
|
|
|
|
scope: {
|
|
|
|
fields: ['id', 'name']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
relation: 'payDem',
|
|
|
|
scope: {
|
|
|
|
fields: ['id', 'payDem']
|
|
|
|
}
|
2020-10-22 11:00:11 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
relation: 'client',
|
|
|
|
scope: {
|
|
|
|
fields: ['id', 'fi']
|
|
|
|
}
|
2020-10-22 07:35:11 +00:00
|
|
|
}
|
2020-10-20 07:44:44 +00:00
|
|
|
]
|
|
|
|
};
|
|
|
|
|
2021-02-10 14:03:11 +00:00
|
|
|
return this.getData(`Suppliers/${this.id}`, {filter})
|
2020-10-26 07:38:43 +00:00
|
|
|
.then(res => this.supplier = res.data);
|
2020-10-20 07:44:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ngModule.vnComponent('vnSupplierDescriptor', {
|
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller,
|
|
|
|
bindings: {
|
|
|
|
supplier: '<'
|
|
|
|
}
|
|
|
|
});
|