diff --git a/src/pages/Entry/EntryBuysTableDialog.vue b/src/pages/Entry/EntryBuysTableDialog.vue index 3975bff19..a2d8c9117 100644 --- a/src/pages/Entry/EntryBuysTableDialog.vue +++ b/src/pages/Entry/EntryBuysTableDialog.vue @@ -1,24 +1,24 @@ +function downloadCSV(rows) { + const headers = ['id', 'itemFk', 'name', 'stickers', 'packing', 'comment']; + + const csvRows = rows.map((row) => { + const buy = row; + const item = buy.item || {}; + + return [ + buy.id, + buy.itemFk, + item.name || '', + buy.stickers, + buy.packing, + item.comment || '', + ].join(','); + }); + + const csvContent = [headers.join(','), ...csvRows].join('\n'); + + const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' }); + const url = URL.createObjectURL(blob); + const link = document.createElement('a'); + link.href = url; + link.setAttribute('download', `${entityId.value}data.csv`); + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); +} +