fix(receipt): use div layout instead of table for receipt items
Table elements can have rendering issues in print popup windows. Switched to div-based flex layout for item rows to ensure products appear correctly in printed receipts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -101,8 +101,6 @@ public class ReceiptPrintService
|
||||
sb.Append($"body {{ font-family: 'Courier New', monospace; font-size: {fontSize}; width: {contentW}mm; margin: 0 auto; color: #000; }}");
|
||||
sb.Append(".c { text-align: center; } .b { font-weight: bold; }");
|
||||
sb.Append(".d { border-top: 1px dashed #000; margin: 6px 0; }");
|
||||
sb.Append("table { width: 100%; border-collapse: collapse; }");
|
||||
sb.Append("th { text-align: left; border-bottom: 1px solid #000; padding: 2px 0; }");
|
||||
sb.Append(".r { display: flex; justify-content: space-between; padding: 2px 0; }");
|
||||
sb.Append(".f { text-align: center; margin-top: 8px; color: #555; }");
|
||||
sb.Append("</style></head><body>");
|
||||
@@ -134,16 +132,16 @@ public class ReceiptPrintService
|
||||
sb.Append("<div class='d'></div>");
|
||||
|
||||
// ── ITEMS ──
|
||||
if (t.ShowItemList)
|
||||
if (t.ShowItemList && d.Items.Count > 0)
|
||||
{
|
||||
sb.Append("<table><tr><th>Sản phẩm</th><th style='text-align:center;'>SL</th><th style='text-align:right;'>Tiền</th></tr>");
|
||||
sb.Append("<div style='border-bottom:1px solid #000;padding:2px 0;display:flex;justify-content:space-between;font-weight:bold;'>");
|
||||
sb.Append("<span>Sản phẩm</span><span>Tiền</span></div>");
|
||||
foreach (var item in d.Items)
|
||||
{
|
||||
sb.Append($"<tr><td style='padding:2px 0;'>{Enc(item.Name)}</td>");
|
||||
sb.Append($"<td style='text-align:center;'>x{item.Qty}</td>");
|
||||
sb.Append($"<td style='text-align:right;'>{item.Qty * item.Price:N0}</td></tr>");
|
||||
sb.Append($"<div style='display:flex;justify-content:space-between;padding:2px 0;'>");
|
||||
sb.Append($"<span>{Enc(item.Name)} x{item.Qty}</span>");
|
||||
sb.Append($"<span>{item.Qty * item.Price:N0}</span></div>");
|
||||
}
|
||||
sb.Append("</table>");
|
||||
sb.Append("<div class='d'></div>");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user