Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -1576,33 +1576,68 @@ function exportVisibleExcel () {
|
||||
void notifyExportTaken('excel')
|
||||
}
|
||||
|
||||
function printVisibleRows () {
|
||||
const cols = visibleColumns.value
|
||||
const body = filteredRows.value.map((row) => `<tr>${cols.map((c) => {
|
||||
if (c.name === 'image' && row.imageUrl) return `<td><img src="${row.imageUrl}" class="thumb"></td>`
|
||||
return `<td class="${isExcelNumericColumn(c) ? 'num' : ''}">${escapeHtml(exportCell(row, c))}</td>`
|
||||
}).join('')}</tr>`).join('')
|
||||
const html = `<!doctype html><html><head><meta charset="utf-8"><title>Fiyat Listesi</title><style>
|
||||
@page { size: A3 landscape; margin: 8mm; }
|
||||
body { font-family: Arial, sans-serif; font-size: 8px; }
|
||||
h1 { font-size: 16px; margin: 0 0 8px; }
|
||||
table { border-collapse: collapse; width: 100%; }
|
||||
th { background: #957116; color: #fff; }
|
||||
th, td { border: 1px solid #ccc; padding: 3px; vertical-align: middle; }
|
||||
.num { text-align: right; }
|
||||
.thumb { width: 100px; height: 100px; object-fit: cover; }
|
||||
</style></head><body><h1>Fiyat Listesi</h1><table><thead><tr>${cols.map((c) => `<th>${escapeHtml(c.label || 'Gorsel')}</th>`).join('')}</tr></thead><tbody>${body}</tbody></table><script>window.onload=function(){window.print()}<\/script></body></html>`
|
||||
const win = window.open('', '_blank')
|
||||
if (!win) return
|
||||
win.document.open()
|
||||
win.document.write(html)
|
||||
win.document.close()
|
||||
void notifyExportTaken('pdf')
|
||||
function exportFileStamp () {
|
||||
const d = new Date()
|
||||
const pad = (n) => String(n).padStart(2, '0')
|
||||
return `${d.getFullYear()}${pad(d.getMonth() + 1)}${pad(d.getDate())}-${pad(d.getHours())}${pad(d.getMinutes())}`
|
||||
}
|
||||
|
||||
function buildServerPriceListExportPayload () {
|
||||
const filters = columnFilters.value || {}
|
||||
return {
|
||||
in_stock_only: !!showInStockOnly.value,
|
||||
include_meta: true,
|
||||
include_cost: false,
|
||||
include_base: false,
|
||||
price_fields: [...selectedPriceOptions.value],
|
||||
product_code: selectedProductCodes.value.length > 0 ? [...selectedProductCodes.value] : [],
|
||||
brand_group: Array.isArray(filters.brandGroupSelection) ? filters.brandGroupSelection : [],
|
||||
marka: Array.isArray(filters.marka) ? filters.marka : [],
|
||||
askili_yan: Array.isArray(filters.askiliYan) ? filters.askiliYan : [],
|
||||
kategori: Array.isArray(filters.kategori) ? filters.kategori : [],
|
||||
urun_ilk_grubu: topUrunIlkGrubu.value ? [topUrunIlkGrubu.value] : (Array.isArray(filters.urunIlkGrubu) ? filters.urunIlkGrubu : []),
|
||||
urun_ana_grubu: topUrunAnaGrubu.value ? [topUrunAnaGrubu.value] : (Array.isArray(filters.urunAnaGrubu) ? filters.urunAnaGrubu : []),
|
||||
urun_alt_grubu: Array.isArray(filters.urunAltGrubu) ? filters.urunAltGrubu : [],
|
||||
icerik: Array.isArray(filters.icerik) ? filters.icerik : [],
|
||||
karisim: Array.isArray(filters.karisim) ? filters.karisim : []
|
||||
}
|
||||
}
|
||||
|
||||
function downloadBlob (blob, fileName) {
|
||||
const url = URL.createObjectURL(blob)
|
||||
const a = document.createElement('a')
|
||||
a.href = url
|
||||
a.download = fileName
|
||||
document.body.appendChild(a)
|
||||
a.click()
|
||||
a.remove()
|
||||
URL.revokeObjectURL(url)
|
||||
}
|
||||
|
||||
async function printVisibleRows () {
|
||||
try {
|
||||
const fileName = `Fiyat_Listesi-${exportFileStamp()}.pdf`
|
||||
const res = await api.request({
|
||||
method: 'POST',
|
||||
url: '/order/price-list/export-pdf',
|
||||
data: buildServerPriceListExportPayload(),
|
||||
responseType: 'blob',
|
||||
timeout: 0
|
||||
})
|
||||
const blob = res?.data instanceof Blob
|
||||
? res.data
|
||||
: new Blob([res?.data || ''], { type: 'application/pdf' })
|
||||
downloadBlob(blob, fileName)
|
||||
await notifyExportTaken('pdf')
|
||||
Notify.create({ type: 'positive', message: 'PDF indirildi.' })
|
||||
} catch (err) {
|
||||
Notify.create({ type: 'negative', message: err?.response?.data || err?.message || 'PDF olusturulamadi' })
|
||||
}
|
||||
}
|
||||
|
||||
async function notifyExportTaken (format) {
|
||||
try {
|
||||
await api.post('/order/price-list/export-notify', {
|
||||
const payload = {
|
||||
format,
|
||||
row_count: filteredRows.value.length,
|
||||
price_fields: [...selectedPriceOptions.value],
|
||||
@@ -1611,7 +1646,8 @@ async function notifyExportTaken (format) {
|
||||
first_groups: Array.from(new Set(filteredRows.value.map((row) => toText(row.urunIlkGrubu)).filter(Boolean))).sort((a, b) => a.localeCompare(b, 'tr')),
|
||||
urun_ilk_grubu: topUrunIlkGrubu.value || '',
|
||||
urun_ana_grubu: topUrunAnaGrubu.value || ''
|
||||
}, { timeout: 30000 })
|
||||
}
|
||||
await api.post('/order/price-list/export-notify', payload, { timeout: 60000 })
|
||||
} catch (err) {
|
||||
console.warn('[order-price-list][ui] export notify failed', err?.response?.data || err?.message || err)
|
||||
}
|
||||
@@ -1842,6 +1878,8 @@ onMounted(() => {
|
||||
height: calc(var(--pricing-table-height) - var(--top-scroll-height));
|
||||
min-height: calc(var(--pricing-table-height) - var(--top-scroll-height));
|
||||
max-height: calc(var(--pricing-table-height) - var(--top-scroll-height));
|
||||
padding-right: calc(var(--sticky-left-width, 0px) + 96px);
|
||||
box-sizing: border-box;
|
||||
overflow: auto !important;
|
||||
scrollbar-gutter: stable both-edges;
|
||||
overscroll-behavior: contain;
|
||||
|
||||
Reference in New Issue
Block a user