fix : tre {tre1 and trre2} displaying
This commit is contained in:
parent
7fd671e3ab
commit
7143b72407
@ -1103,9 +1103,14 @@ printTicket() {
|
|||||||
|
|
||||||
|
|
||||||
//----------------------------------------WINLABELS START HERE ------------------------------------------------------
|
//----------------------------------------WINLABELS START HERE ------------------------------------------------------
|
||||||
|
|
||||||
const winLabels = allRows.map(row => {
|
const winLabels = allRows.map(row => {
|
||||||
let displayNumbers = row.numbers;
|
let displayNumbers = row.numbers;
|
||||||
|
let displayLabel = row.label; // Use row.label by default
|
||||||
|
|
||||||
|
// Override label for TRE to use currentPool (trb1 or trb2)
|
||||||
|
if (row.label === 'TRE' && this.currentPool) {
|
||||||
|
displayLabel = this.currentPool; // Use trb1 or trb2
|
||||||
|
}
|
||||||
|
|
||||||
// --- Multi-leg pools: Expand 'F' for each leg ---
|
// --- Multi-leg pools: Expand 'F' for each leg ---
|
||||||
if (['TRE', 'MJP', 'JKP'].includes(row.label)) {
|
if (['TRE', 'MJP', 'JKP'].includes(row.label)) {
|
||||||
@ -1123,7 +1128,7 @@ const winLabels = allRows.map(row => {
|
|||||||
if (currentLeg.length) legs.push(currentLeg);
|
if (currentLeg.length) legs.push(currentLeg);
|
||||||
|
|
||||||
// For each leg, expand 'F' to correct horse numbers for that leg
|
// For each leg, expand 'F' to correct horse numbers for that leg
|
||||||
const poolName = row.label === 'MJP' ? 'mjp1' : row.label === 'JKP' ? 'jkp1' : row.label === 'TRE' ? 'trb1' : row.label;
|
const poolName = row.label === 'MJP' ? 'mjp1' : row.label === 'JKP' ? 'jkp1' : this.currentPool || 'trb1';
|
||||||
const raceCardData = JSON.parse(localStorage.getItem('raceCardData') || '{}');
|
const raceCardData = JSON.parse(localStorage.getItem('raceCardData') || '{}');
|
||||||
const poolRaces = raceCardData?.raceVenueRaces?.pools?.[poolName] || [];
|
const poolRaces = raceCardData?.raceVenueRaces?.pools?.[poolName] || [];
|
||||||
// Fallback to hardcoded mapping if needed
|
// Fallback to hardcoded mapping if needed
|
||||||
@ -1146,18 +1151,17 @@ const winLabels = allRows.map(row => {
|
|||||||
// : [n]
|
// : [n]
|
||||||
// );
|
// );
|
||||||
let expanded = leg.flatMap((n, idx) => {
|
let expanded = leg.flatMap((n, idx) => {
|
||||||
if (n === 'F') {
|
if (n === 'F') {
|
||||||
const horses = this.getHorseNumbersForRaceIdx(raceIdx).map(num => num.toString()).join(',');
|
const horses = this.getHorseNumbersForRaceIdx(raceIdx).map(num => num.toString()).join(',');
|
||||||
const isFirst = idx === 0;
|
const isFirst = idx === 0;
|
||||||
const isLast = idx === leg.length - 1;
|
const isLast = idx === leg.length - 1;
|
||||||
if (isFirst && !isLast) return [`${horses}-`];
|
if (isFirst && !isLast) return [`${horses}-`];
|
||||||
if (!isFirst && isLast) return [`-${horses}`];
|
if (!isFirst && isLast) return [`-${horses}`];
|
||||||
if (isFirst && isLast) return [horses]; // only F in the leg
|
if (isFirst && isLast) return [horses]; // only F in the leg
|
||||||
return [`-${horses}-`];
|
return [`-${horses}-`];
|
||||||
}
|
}
|
||||||
return [n];
|
return [n];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Remove '-' and '#' for display
|
// Remove '-' and '#' for display
|
||||||
return expanded.filter(n => n !== '-' && n !== '#').join(',');
|
return expanded.filter(n => n !== '-' && n !== '#').join(',');
|
||||||
@ -1166,7 +1170,7 @@ const winLabels = allRows.map(row => {
|
|||||||
// Join legs with '/'
|
// Join legs with '/'
|
||||||
let numbersStr = expandedLegs.join(' / ');
|
let numbersStr = expandedLegs.join(' / ');
|
||||||
|
|
||||||
const label = row.label.padEnd(10);
|
const label = displayLabel.padEnd(10);
|
||||||
const numbers = numbersStr.padEnd(15);
|
const numbers = numbersStr.padEnd(15);
|
||||||
const value = (`*${row.value || 0}`).padEnd(8);
|
const value = (`*${row.value || 0}`).padEnd(8);
|
||||||
return `${label}${numbers} ${value}`;
|
return `${label}${numbers} ${value}`;
|
||||||
@ -1207,14 +1211,13 @@ const winLabels = allRows.map(row => {
|
|||||||
numbersStr = displayNumbers.filter(n => n !== '#' && n !== '-').join(',');
|
numbersStr = displayNumbers.filter(n => n !== '#' && n !== '-').join(',');
|
||||||
}
|
}
|
||||||
|
|
||||||
const label = row.label.padEnd(10);
|
const label = displayLabel.padEnd(10);
|
||||||
const numbers = numbersStr.padEnd(15);
|
const numbers = numbersStr.padEnd(15);
|
||||||
const value = (`*${row.value || 0}`).padEnd(8);
|
const value = (`*${row.value || 0}`).padEnd(8);
|
||||||
const total = `Rs ${row.total || 0}`.padStart(8);
|
const total = `Rs ${row.total || 0}`.padStart(8);
|
||||||
return `${label}${numbers} ${value} ${total}`;
|
return `${label}${numbers} ${value} ${total}`;
|
||||||
}).join('\n');
|
}).join('\n');
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------WIN LABELS ENDS HERE --------------------------------
|
//------------------------------------WIN LABELS ENDS HERE --------------------------------
|
||||||
|
|
||||||
// ✅ Print preview
|
// ✅ Print preview
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user