import ngModule from '../module'; import Section from 'salix/components/section'; export default class Controller extends Section { get checked() { const rows = this.$.model.data || []; const checkedRows = []; for (let row of rows) { if (row.checked) checkedRows.push(row.id); } return checkedRows; } get totalChecked() { return this.checked.length; } preview(invoiceOut) { this.selectedInvoiceOut = invoiceOut; this.$.summary.show(); } openPdf() { const access_token = this.vnToken.tokenMultimedia; if (this.checked.length <= 1) { const [invoiceOutId] = this.checked; const url = `api/InvoiceOuts/${invoiceOutId}/download?access_token=${access_token}`; window.open(url, '_blank'); } else { const invoiceOutIds = this.checked; const invoicesIds = invoiceOutIds.join(','); const serializedParams = this.$httpParamSerializer({ access_token, ids: invoicesIds }); const url = `api/InvoiceOuts/downloadZip?${serializedParams}`; window.open(url, '_blank'); } } } ngModule.vnComponent('vnInvoiceOutIndex', { template: require('./index.html'), controller: Controller });