Merge remote-tracking branch 'origin/master'

This commit is contained in:
M_Kececi
2026-06-19 23:47:43 +03:00
parent c0b6214ce6
commit 963b73e7b0

View File

@@ -1606,6 +1606,7 @@ async function printVisibleRows () {
const stamp = exportFileStamp()
const title = `Fiyat_Listesi-${stamp}`
const cols = visibleColumns.value
const pageSize = cols.length > 34 ? 'A0 landscape' : cols.length > 26 ? 'A1 landscape' : cols.length > 18 ? 'A2 landscape' : 'A3 landscape'
const generatedAt = new Date().toLocaleString('tr-TR')
const body = filteredRows.value.map((row) => `<tr>${cols.map((c) => {
if (c.name === 'image') {
@@ -1622,30 +1623,31 @@ async function printVisibleRows () {
return `<td class="${cls}">${escapeHtml(exportCell(row, c))}</td>`
}).join('')}</tr>`).join('')
const headerCols = cols.map((c) => `<th>${escapeHtml(c.label || 'Gorsel')}</th>`).join('')
const colgroup = cols.map((c) => `<col style="width:${printColumnWidthMm(c)}mm;min-width:${printColumnWidthMm(c)}mm;">`).join('')
const html = `<!doctype html><html><head><meta charset="utf-8"><title>${escapeHtml(title)}</title><style>
@page { size: A3 landscape; margin: 8mm; }
@page { size: ${pageSize}; margin: 8mm; }
* { box-sizing: border-box; }
body { font-family: Arial, sans-serif; color: #172033; font-size: 8px; margin: 0; }
table { border-collapse: collapse; width: 100%; table-layout: fixed; }
body { font-family: Arial, sans-serif; color: #172033; font-size: 10px; margin: 0; }
table { border-collapse: collapse; width: auto; min-width: 100%; table-layout: fixed; }
thead { display: table-header-group; }
tfoot { display: table-footer-group; }
tr { page-break-inside: avoid; break-inside: avoid; }
th, td { border: 1px solid #cfd6df; padding: 3px; vertical-align: middle; overflow-wrap: anywhere; }
th { background: #957116; color: #fff; text-align: center; font-weight: 700; line-height: 1.15; }
.report-title th { background: #fff; color: #172033; border: 0; padding: 0 0 5px; text-align: left; }
.title-main { font-size: 15px; font-weight: 800; color: #957116; }
.title-meta { font-size: 8px; color: #56616f; margin-top: 2px; }
td { background: #fff; line-height: 1.18; }
th, td { border: 1px solid #cfd6df; padding: 5px 4px; vertical-align: middle; overflow-wrap: anywhere; word-break: break-word; }
th { background: #957116; color: #fff; text-align: center; font-weight: 800; line-height: 1.18; font-size: 10px; }
.report-title th { background: #fff; color: #172033; border: 0; padding: 0 0 6px; text-align: left; }
.title-main { font-size: 18px; font-weight: 800; color: #957116; }
.title-meta { font-size: 10px; color: #56616f; margin-top: 3px; }
td { background: #fff; line-height: 1.22; min-height: 28px; }
.num, .price { text-align: right; font-weight: 700; white-space: nowrap; }
.campaign-price { background: #eef7ee; color: #0f6b2f; font-weight: 800; }
.wrap { white-space: normal; font-size: 7px; line-height: 1.1; }
.img-cell { width: 28mm; text-align: center; padding: 2px; }
.thumb { width: 24mm; height: 24mm; object-fit: contain; display: block; margin: 0 auto; }
.wrap { white-space: normal; font-size: 9px; line-height: 1.15; }
.img-cell { text-align: center; padding: 3px; }
.thumb { width: 28mm; height: 28mm; object-fit: contain; display: block; margin: 0 auto; }
.page-footer {
position: fixed;
right: 8mm;
bottom: 3mm;
font-size: 8px;
font-size: 9px;
color: #56616f;
}
.page-footer::after {
@@ -1657,6 +1659,7 @@ async function printVisibleRows () {
}
</style></head><body>
<table>
<colgroup>${colgroup}</colgroup>
<thead>
<tr class="report-title"><th colspan="${cols.length}">
<div class="title-main">Fiyat Listesi</div>
@@ -1667,7 +1670,22 @@ async function printVisibleRows () {
<tbody>${body}</tbody>
</table>
<div class="page-footer"></div>
<script>window.onload=function(){setTimeout(function(){window.print()},250)}<\/script>
<script>
window.onload=function(){
var imgs=Array.prototype.slice.call(document.images||[]);
var waits=imgs.map(function(img){
if(img.complete) return Promise.resolve();
return new Promise(function(resolve){
img.onload=resolve;
img.onerror=resolve;
});
});
Promise.race([
Promise.all(waits),
new Promise(function(resolve){ setTimeout(resolve,2500); })
]).then(function(){ setTimeout(function(){ window.print(); },150); });
}
<\/script>
</body></html>`
const win = window.open('', '_blank')
if (!win) {
@@ -1680,6 +1698,20 @@ async function printVisibleRows () {
await notifyExportTaken('pdf')
}
function printColumnWidthMm (col) {
if (!col) return 24
if (col.name === 'image') return 34
if (col.name === 'productCode') return 36
if (col.name === 'variantCodes') return 24
if (col.name === 'variantStocks') return 18
if (col.name === 'campaignLabel') return 34
if (col.name === 'campaignRate') return 18
if (col.name === 'icerik') return 34
if (col.name === 'karisim') return 40
if (priceColumnNames.includes(col.name)) return col.name.endsWith('Campaign') ? 27 : 24
return Math.max(20, Math.min(34, Math.round(extractWidth(col.style) * 0.28)))
}
async function notifyExportTaken (format) {
try {
const payload = {