Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -517,7 +517,7 @@ func ExportProductPriceListPDFHandler(pg *sql.DB) http.HandlerFunc {
|
|||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
w.Header().Set("Content-Type", "application/pdf")
|
w.Header().Set("Content-Type", "application/pdf")
|
||||||
w.Header().Set("Content-Disposition", fmt.Sprintf("inline; filename=%q", fmt.Sprintf("baggi_guncel_fiyat_listesi_%s.pdf", now.Format("20060102"))))
|
w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=%q", fmt.Sprintf("Fiyat_Listesi-%s.pdf", now.Format("20060102-1504"))))
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
_, _ = w.Write(buf.Bytes())
|
_, _ = w.Write(buf.Bytes())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1576,33 +1576,68 @@ function exportVisibleExcel () {
|
|||||||
void notifyExportTaken('excel')
|
void notifyExportTaken('excel')
|
||||||
}
|
}
|
||||||
|
|
||||||
function printVisibleRows () {
|
function exportFileStamp () {
|
||||||
const cols = visibleColumns.value
|
const d = new Date()
|
||||||
const body = filteredRows.value.map((row) => `<tr>${cols.map((c) => {
|
const pad = (n) => String(n).padStart(2, '0')
|
||||||
if (c.name === 'image' && row.imageUrl) return `<td><img src="${row.imageUrl}" class="thumb"></td>`
|
return `${d.getFullYear()}${pad(d.getMonth() + 1)}${pad(d.getDate())}-${pad(d.getHours())}${pad(d.getMinutes())}`
|
||||||
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>
|
function buildServerPriceListExportPayload () {
|
||||||
@page { size: A3 landscape; margin: 8mm; }
|
const filters = columnFilters.value || {}
|
||||||
body { font-family: Arial, sans-serif; font-size: 8px; }
|
return {
|
||||||
h1 { font-size: 16px; margin: 0 0 8px; }
|
in_stock_only: !!showInStockOnly.value,
|
||||||
table { border-collapse: collapse; width: 100%; }
|
include_meta: true,
|
||||||
th { background: #957116; color: #fff; }
|
include_cost: false,
|
||||||
th, td { border: 1px solid #ccc; padding: 3px; vertical-align: middle; }
|
include_base: false,
|
||||||
.num { text-align: right; }
|
price_fields: [...selectedPriceOptions.value],
|
||||||
.thumb { width: 100px; height: 100px; object-fit: cover; }
|
product_code: selectedProductCodes.value.length > 0 ? [...selectedProductCodes.value] : [],
|
||||||
</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>`
|
brand_group: Array.isArray(filters.brandGroupSelection) ? filters.brandGroupSelection : [],
|
||||||
const win = window.open('', '_blank')
|
marka: Array.isArray(filters.marka) ? filters.marka : [],
|
||||||
if (!win) return
|
askili_yan: Array.isArray(filters.askiliYan) ? filters.askiliYan : [],
|
||||||
win.document.open()
|
kategori: Array.isArray(filters.kategori) ? filters.kategori : [],
|
||||||
win.document.write(html)
|
urun_ilk_grubu: topUrunIlkGrubu.value ? [topUrunIlkGrubu.value] : (Array.isArray(filters.urunIlkGrubu) ? filters.urunIlkGrubu : []),
|
||||||
win.document.close()
|
urun_ana_grubu: topUrunAnaGrubu.value ? [topUrunAnaGrubu.value] : (Array.isArray(filters.urunAnaGrubu) ? filters.urunAnaGrubu : []),
|
||||||
void notifyExportTaken('pdf')
|
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) {
|
async function notifyExportTaken (format) {
|
||||||
try {
|
try {
|
||||||
await api.post('/order/price-list/export-notify', {
|
const payload = {
|
||||||
format,
|
format,
|
||||||
row_count: filteredRows.value.length,
|
row_count: filteredRows.value.length,
|
||||||
price_fields: [...selectedPriceOptions.value],
|
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')),
|
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_ilk_grubu: topUrunIlkGrubu.value || '',
|
||||||
urun_ana_grubu: topUrunAnaGrubu.value || ''
|
urun_ana_grubu: topUrunAnaGrubu.value || ''
|
||||||
}, { timeout: 30000 })
|
}
|
||||||
|
await api.post('/order/price-list/export-notify', payload, { timeout: 60000 })
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.warn('[order-price-list][ui] export notify failed', err?.response?.data || err?.message || 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));
|
height: calc(var(--pricing-table-height) - var(--top-scroll-height));
|
||||||
min-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));
|
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;
|
overflow: auto !important;
|
||||||
scrollbar-gutter: stable both-edges;
|
scrollbar-gutter: stable both-edges;
|
||||||
overscroll-behavior: contain;
|
overscroll-behavior: contain;
|
||||||
|
|||||||
Reference in New Issue
Block a user