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
|
|
|
this.iSupplierAClient();
|
2020-10-20 07:44:44 +00:00
|
|
|
}
|
2020-10-22 07:35:11 +00:00
|
|
|
|
|
|
|
get entryFilter() {
|
|
|
|
if (!this.supplier) return null;
|
|
|
|
|
|
|
|
const date = new Date();
|
|
|
|
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({
|
|
|
|
supplierFk: this.supplier.id,
|
|
|
|
from,
|
|
|
|
to
|
|
|
|
});
|
|
|
|
}
|
|
|
|
iSupplierAClient() {
|
|
|
|
if (!this.supplier) return;
|
|
|
|
|
|
|
|
const filter = {
|
|
|
|
where: {fi: this.supplier.nif}
|
|
|
|
};
|
|
|
|
this.$http.get('Clients/findOne', {filter}).then(res => {
|
|
|
|
if (res.data)
|
|
|
|
this.isAClient = res.data;
|
|
|
|
}).catch(error => {
|
|
|
|
return this.isAClient = false;
|
|
|
|
});
|
|
|
|
// this.$http.get(`Suppliers/${this.supplier.nif}/isAClient`).then(res => {
|
|
|
|
// this.isAClient = res.data;
|
|
|
|
// });
|
|
|
|
}
|
|
|
|
|
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',
|
|
|
|
'isOfficial',
|
|
|
|
'account'
|
|
|
|
],
|
|
|
|
include: [
|
|
|
|
{
|
|
|
|
relation: 'payMethod',
|
|
|
|
scope: {
|
|
|
|
fields: ['id', 'name']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
relation: 'payDem',
|
|
|
|
scope: {
|
|
|
|
fields: ['id', 'payDem']
|
|
|
|
}
|
|
|
|
}
|
2020-10-20 07:44:44 +00:00
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
return this.getData(`Suppliers/${this.id}`, {filter})
|
|
|
|
.then(res => this.entity = res.data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ngModule.vnComponent('vnSupplierDescriptor', {
|
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller,
|
|
|
|
bindings: {
|
|
|
|
supplier: '<'
|
|
|
|
}
|
|
|
|
});
|