salix/modules/invoiceIn/front/index/index.js

59 lines
1.4 KiB
JavaScript

import ngModule from '../module';
import Section from 'salix/components/section';
export default class Controller extends Section {
constructor($element, $, vnFile) {
super($element, $, vnFile);
this.vnFile = vnFile;
}
exprBuilder(param, value) {
switch (param) {
case 'issued':
return {'ii.issued': {
between: this.dateRange(value)}
};
case 'id':
case 'supplierFk':
case 'supplierRef':
case 'serialNumber':
case 'serial':
case 'created':
case 'isBooked':
return {[`ii.${param}`]: value};
case 'account':
case 'fi':
return {[`s.${param}`]: value};
case 'awbCode':
return {'awb.code': value};
default:
return {[param]: value};
}
}
dateRange(value) {
const minHour = new Date(value);
minHour.setHours(0, 0, 0, 0);
const maxHour = new Date(value);
maxHour.setHours(23, 59, 59, 59);
return [minHour, maxHour];
}
preview(invoiceIn) {
this.selectedInvoiceIn = invoiceIn;
this.$.summary.show();
}
downloadFile(dmsId) {
this.vnFile.download(`api/dms/${dmsId}/downloadFile`);
}
}
Controller.$inject = ['$element', '$scope', 'vnFile'];
ngModule.vnComponent('vnInvoiceInIndex', {
template: require('./index.html'),
controller: Controller
});