forked from verdnatura/hedera-web
fix: refs #7498 Download invoice out error
This commit is contained in:
parent
961ff02053
commit
bcbbee411f
|
@ -3,30 +3,17 @@ import './style.scss';
|
|||
export default new Class({
|
||||
Extends: Hedera.Form,
|
||||
Template: require('./ui.xml'),
|
||||
|
||||
donwloadRenderer(column, invoice) {
|
||||
var invoiceId = invoice.$.id;
|
||||
|
||||
if (invoice.$.hasPdf && invoiceId) {
|
||||
var params = {
|
||||
srv: 'rest:dms/invoice',
|
||||
invoice: invoiceId,
|
||||
access_token: this.conn.token
|
||||
};
|
||||
onDownloadClick(column, value, row) {
|
||||
var model = this.$.invoices;
|
||||
var hasPdf = model.get(row, 'hasPdf');
|
||||
var id = model.get(row, 'id');
|
||||
|
||||
Object.assign(column, {
|
||||
tip: _('Download PDF'),
|
||||
disabled: false,
|
||||
icon: 'download',
|
||||
href: '?'+ Vn.Url.makeUri(params)
|
||||
});
|
||||
if (hasPdf && id) {
|
||||
let params = Vn.Url.makeUri({ access_token: this.conn.token });
|
||||
window.open(`/api/InvoiceOuts/${id}/download?${params}`);
|
||||
} else
|
||||
Object.assign(column, {
|
||||
tip: _('Request the invoice to your salesperson'),
|
||||
disabled: true,
|
||||
icon: 'warning',
|
||||
href: null
|
||||
});
|
||||
Htk.Toast.showWarning(_('Request the invoice to your salesperson'));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<htk-grid
|
||||
class="box vn-w-sm"
|
||||
show-header="false">
|
||||
<db-model property="model" id="tickets">
|
||||
<db-model property="model" id="invoices">
|
||||
SELECT id, ref, issued, amount, hasPdf
|
||||
FROM myInvoice
|
||||
ORDER BY issued DESC
|
||||
|
@ -16,8 +16,9 @@
|
|||
<htk-column-date title="_Date" column="issued" format="_%e %b %Y"/>
|
||||
<htk-column-spin title="_Import" column="amount" unit="€" digits="2"/>
|
||||
<htk-column-button
|
||||
renderer="donwloadRenderer"
|
||||
target="_blank"/>
|
||||
icon="download"
|
||||
tip="_Download PDF"
|
||||
on-clicked="onDownloadClick"/>
|
||||
</htk-grid>
|
||||
</div>
|
||||
</vn>
|
||||
|
|
Loading…
Reference in New Issue