From 2b643a9dc166fcee63f17fbfea6ac2feeffe736a Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 3 Jan 2025 12:16:24 +0100 Subject: [PATCH 1/2] feat: refs #8348 add CSV download functionality and update print label icon --- src/pages/Entry/EntryBuysTableDialog.vue | 83 +++++++++++++++--------- src/pages/Entry/MyEntries.vue | 2 +- src/pages/Entry/locale/en.yml | 1 + src/pages/Entry/locale/es.yml | 1 + 4 files changed, 57 insertions(+), 30 deletions(-) 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); +} +