Enhance PDF generation by adding column exclusion functionality in PDFGenerator

Updated PDFGenerator.js to allow exclusion of specified columns when generating tables in PDFs. Modified ScheduleView.vue to determine which columns to exclude based on the selected league, improving the flexibility and usability of the PDF generation feature.
This commit is contained in:
Torsten Schulz (local)
2025-10-20 23:40:05 +02:00
parent 4ff021a85c
commit b69684ad03
2 changed files with 27 additions and 2 deletions

View File

@@ -241,7 +241,7 @@ class PDFGenerator {
}
}
addTable(tableId, highlightName = '') {
addTable(tableId, highlightName = '', excludeColumns = []) {
this.pdf.setFontSize(11);
autoTable(this.pdf, {
html: `#${tableId}`,
@@ -251,6 +251,12 @@ class PDFGenerator {
headStyles: { fillColor: [220, 220, 220], textColor: 0, halign: 'left' },
theme: 'grid',
didParseCell: (data) => {
// Spalten ausschließen
if (excludeColumns.includes(data.column.index)) {
data.cell.styles.display = 'none';
return;
}
const cellText = Array.isArray(data.cell.text)
? data.cell.text.join(' ')
: String(data.cell.text);
@@ -260,6 +266,12 @@ class PDFGenerator {
},
didDrawPage: (data) => {
this.cursorY = data.cursor.y + 10;
},
// Spalten aus dem Header entfernen
willDrawCell: (data) => {
if (excludeColumns.includes(data.column.index)) {
return false;
}
}
});
}

View File

@@ -630,7 +630,20 @@ export default {
if (element) {
const pdfGen = new PDFGenerator();
pdfGen.addTitle(`Spiele für ${highlightName} in ${this.selectedLeague}`);
pdfGen.addTable('schedule-table', highlightName);
// Bestimme die auszuschließenden Spalten
// Spaltenstruktur: Datum, Uhrzeit, Heimmannschaft, Gastmannschaft, Ergebnis, [Altersklasse], Code, Heim-PIN, Gast-PIN
const hasAgeClass = this.selectedLeague === 'Gesamtspielplan' || this.selectedLeague === 'Spielplan Erwachsene';
let excludeColumns;
if (hasAgeClass) {
// Mit Altersklasse: Ergebnis=4, Code=6, Heim-PIN=7, Gast-PIN=8
excludeColumns = [4, 6, 7, 8];
} else {
// Ohne Altersklasse: Ergebnis=4, Code=5, Heim-PIN=6, Gast-PIN=7
excludeColumns = [4, 5, 6, 7];
}
pdfGen.addTable('schedule-table', highlightName, excludeColumns);
pdfGen.addNewPage();
const uniqueLocations = this.getUniqueLocations();
uniqueLocations.forEach((addressLines, clubName) => {