Merge remote-tracking branch 'origin/master'

This commit is contained in:
2026-02-14 19:57:41 +03:00
parent d0f20674ea
commit a2a756870d
4 changed files with 501 additions and 488 deletions

View File

@@ -1,15 +1,15 @@
// src/stores/downloadstpdfStore.js
// src/stores/downloadstpdfStore.js
import { defineStore } from 'pinia'
import { download } from 'src/services/api'
import { download, extractApiErrorDetail } from 'src/services/api'
export const useDownloadstpdfStore = defineStore('downloadstpdf', {
actions: {
/* ==========================================================
📄 PDF İNDİR / AÇ
📄 PDF İNDİR / AÇ
========================================================== */
async downloadPDF(accountCode, startDate, endDate, parislemler = []) {
try {
// 🔹 Query params
// 🔹 Query params
const params = {
accountcode: accountCode,
startdate: startDate,
@@ -22,28 +22,30 @@ export const useDownloadstpdfStore = defineStore('downloadstpdf', {
)
}
// 🔥 MERKEZİ API BLOB
// 🔥 MERKEZİ API — BLOB
const blob = await download('/export-pdf', params)
// 🔹 Blob URL
// 🔹 Blob → URL
const pdfUrl = window.URL.createObjectURL(
new Blob([blob], { type: 'application/pdf' })
)
// 🔹 Yeni sekmede aç
// 🔹 Yeni sekmede aç
window.open(pdfUrl, '_blank')
console.log(' PDF yeni sekmede açıldı')
return { ok: true, message: '📄 PDF hazırlandı' }
console.log('✅ PDF yeni sekmede açıldı')
return { ok: true, message: '📄 PDF hazırlandı' }
} catch (err) {
console.error('❌ PDF açma hatası:', err)
const detail = await extractApiErrorDetail(err)
const status = err?.status || err?.response?.status || '-'
console.error(`❌ PDF açma hatası [${status}] /export-pdf: ${detail}`)
return {
ok: false,
message:
err?.message ||
'PDF alınamadı'
detail ||
'PDF alınamadı'
}
}
}