Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -1606,6 +1606,7 @@ async function printVisibleRows () {
|
|||||||
const stamp = exportFileStamp()
|
const stamp = exportFileStamp()
|
||||||
const title = `Fiyat_Listesi-${stamp}`
|
const title = `Fiyat_Listesi-${stamp}`
|
||||||
const cols = visibleColumns.value
|
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 generatedAt = new Date().toLocaleString('tr-TR')
|
||||||
const body = filteredRows.value.map((row) => `<tr>${cols.map((c) => {
|
const body = filteredRows.value.map((row) => `<tr>${cols.map((c) => {
|
||||||
if (c.name === 'image') {
|
if (c.name === 'image') {
|
||||||
@@ -1622,30 +1623,31 @@ async function printVisibleRows () {
|
|||||||
return `<td class="${cls}">${escapeHtml(exportCell(row, c))}</td>`
|
return `<td class="${cls}">${escapeHtml(exportCell(row, c))}</td>`
|
||||||
}).join('')}</tr>`).join('')
|
}).join('')}</tr>`).join('')
|
||||||
const headerCols = cols.map((c) => `<th>${escapeHtml(c.label || 'Gorsel')}</th>`).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>
|
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; }
|
* { box-sizing: border-box; }
|
||||||
body { font-family: Arial, sans-serif; color: #172033; font-size: 8px; margin: 0; }
|
body { font-family: Arial, sans-serif; color: #172033; font-size: 10px; margin: 0; }
|
||||||
table { border-collapse: collapse; width: 100%; table-layout: fixed; }
|
table { border-collapse: collapse; width: auto; min-width: 100%; table-layout: fixed; }
|
||||||
thead { display: table-header-group; }
|
thead { display: table-header-group; }
|
||||||
tfoot { display: table-footer-group; }
|
tfoot { display: table-footer-group; }
|
||||||
tr { page-break-inside: avoid; break-inside: avoid; }
|
tr { page-break-inside: avoid; break-inside: avoid; }
|
||||||
th, td { border: 1px solid #cfd6df; padding: 3px; vertical-align: middle; overflow-wrap: anywhere; }
|
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: 700; line-height: 1.15; }
|
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 5px; text-align: left; }
|
.report-title th { background: #fff; color: #172033; border: 0; padding: 0 0 6px; text-align: left; }
|
||||||
.title-main { font-size: 15px; font-weight: 800; color: #957116; }
|
.title-main { font-size: 18px; font-weight: 800; color: #957116; }
|
||||||
.title-meta { font-size: 8px; color: #56616f; margin-top: 2px; }
|
.title-meta { font-size: 10px; color: #56616f; margin-top: 3px; }
|
||||||
td { background: #fff; line-height: 1.18; }
|
td { background: #fff; line-height: 1.22; min-height: 28px; }
|
||||||
.num, .price { text-align: right; font-weight: 700; white-space: nowrap; }
|
.num, .price { text-align: right; font-weight: 700; white-space: nowrap; }
|
||||||
.campaign-price { background: #eef7ee; color: #0f6b2f; font-weight: 800; }
|
.campaign-price { background: #eef7ee; color: #0f6b2f; font-weight: 800; }
|
||||||
.wrap { white-space: normal; font-size: 7px; line-height: 1.1; }
|
.wrap { white-space: normal; font-size: 9px; line-height: 1.15; }
|
||||||
.img-cell { width: 28mm; text-align: center; padding: 2px; }
|
.img-cell { text-align: center; padding: 3px; }
|
||||||
.thumb { width: 24mm; height: 24mm; object-fit: contain; display: block; margin: 0 auto; }
|
.thumb { width: 28mm; height: 28mm; object-fit: contain; display: block; margin: 0 auto; }
|
||||||
.page-footer {
|
.page-footer {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
right: 8mm;
|
right: 8mm;
|
||||||
bottom: 3mm;
|
bottom: 3mm;
|
||||||
font-size: 8px;
|
font-size: 9px;
|
||||||
color: #56616f;
|
color: #56616f;
|
||||||
}
|
}
|
||||||
.page-footer::after {
|
.page-footer::after {
|
||||||
@@ -1657,6 +1659,7 @@ async function printVisibleRows () {
|
|||||||
}
|
}
|
||||||
</style></head><body>
|
</style></head><body>
|
||||||
<table>
|
<table>
|
||||||
|
<colgroup>${colgroup}</colgroup>
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="report-title"><th colspan="${cols.length}">
|
<tr class="report-title"><th colspan="${cols.length}">
|
||||||
<div class="title-main">Fiyat Listesi</div>
|
<div class="title-main">Fiyat Listesi</div>
|
||||||
@@ -1667,7 +1670,22 @@ async function printVisibleRows () {
|
|||||||
<tbody>${body}</tbody>
|
<tbody>${body}</tbody>
|
||||||
</table>
|
</table>
|
||||||
<div class="page-footer"></div>
|
<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>`
|
</body></html>`
|
||||||
const win = window.open('', '_blank')
|
const win = window.open('', '_blank')
|
||||||
if (!win) {
|
if (!win) {
|
||||||
@@ -1680,6 +1698,20 @@ async function printVisibleRows () {
|
|||||||
await notifyExportTaken('pdf')
|
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) {
|
async function notifyExportTaken (format) {
|
||||||
try {
|
try {
|
||||||
const payload = {
|
const payload = {
|
||||||
|
|||||||
Reference in New Issue
Block a user