salix/modules/invoiceOut/front/index/index.js

77 lines
1.9 KiB
JavaScript

import ngModule from '../module';
export default class Controller {
constructor($scope, vnToken) {
this.accessToken = vnToken.token;
this.$ = $scope;
this.ticketSelected = null;
this.filter = {
include: [
{
relation: 'client',
scope: {
fields: ['name']
}
},
{
relation: 'company',
scope: {
fields: ['code']
}
}
]
};
}
exprBuilder(param, value) {
switch (param) {
case 'search':
return {ref: {like: `%${value}%`}};
case 'min':
return {amount: {gte: value}};
case 'max':
return {amount: {lte: value}};
case 'hasPdf':
case 'amount':
case 'clientFk':
case 'companyFk':
case 'issued':
case 'created':
case 'dued':
return {[param]: value};
}
}
showClientDescriptor(event, clientFk) {
this.$.clientDescriptor.clientFk = clientFk;
this.$.clientDescriptor.parent = event.target;
this.$.clientDescriptor.show();
event.preventDefault();
event.stopImmediatePropagation();
}
preview(event, claim) {
this.claimSelected = claim;
this.$.dialogSummaryClaim.show();
event.preventDefault();
event.stopImmediatePropagation();
}
onDescriptorLoad() {
this.$.popover.relocate();
}
openPdf(id) {
let url = `api/InvoiceOuts/${id}/download?access_token=${this.accessToken}`;
window.open(url, '_blank');
}
}
Controller.$inject = ['$scope', 'vnToken'];
ngModule.component('vnInvoiceOutIndex', {
template: require('./index.html'),
controller: Controller
});