Merge remote-tracking branch 'origin/master'

This commit is contained in:
M_Kececi
2026-06-04 14:33:10 +03:00
parent 00626152c2
commit 7b1588d69d
11 changed files with 2065 additions and 78 deletions

View File

@@ -1,52 +1,59 @@
// src/stores/downloadstpdfStore.js
import { defineStore } from 'pinia'
import { download, extractApiErrorDetail } from 'src/services/api'
import api, { download, extractApiErrorDetail } from 'src/services/api'
export const useDownloadstpdfStore = defineStore('downloadstpdf', {
actions: {
/* ==========================================================
📄 PDF İNDİR / AÇ
========================================================== */
async downloadPDF(accountCode, startDate, endDate, parislemler = [], langcode = 'TR') {
async downloadPDF(accountCode, startDate, endDate, parislemler = [], langcode = 'TR', rows = []) {
try {
// 🔹 Query params
const params = {
accountcode: accountCode,
startdate: startDate,
enddate: endDate,
langcode: langcode || 'TR'
let pdfBlob
if (Array.isArray(rows) && rows.length > 0) {
const response = await api.request({
method: 'POST',
url: '/export-pdf',
data: {
account_code: accountCode,
start_date: startDate,
end_date: endDate,
lang_code: langcode || 'TR',
rows
},
responseType: 'blob',
timeout: 180000
})
pdfBlob = response.data
} else {
const params = {
accountcode: accountCode,
startdate: startDate,
enddate: endDate,
langcode: langcode || 'TR'
}
if (Array.isArray(parislemler) && parislemler.length > 0) {
params.parislemler = parislemler.filter(
p => p !== undefined && p !== null && p !== ''
)
}
pdfBlob = await download('/export-pdf', params)
}
if (Array.isArray(parislemler) && parislemler.length > 0) {
params.parislemler = parislemler.filter(
p => p !== undefined && p !== null && p !== ''
)
}
// 🔥 MERKEZİ API — BLOB
const blob = await download('/export-pdf', params)
// 🔹 Blob → URL
const pdfUrl = window.URL.createObjectURL(
new Blob([blob], { type: 'application/pdf' })
new Blob([pdfBlob], { type: 'application/pdf' })
)
// 🔹 Yeni sekmede aç
window.open(pdfUrl, '_blank')
console.log('✅ PDF yeni sekmede açıldı')
return { ok: true, message: '📄 PDF hazırlandı' }
return { ok: true, message: 'PDF hazirlandi' }
} catch (err) {
const detail = await extractApiErrorDetail(err)
const status = err?.status || err?.response?.status || '-'
console.error(`? PDF a<EFBFBD>ma hatas<EFBFBD> [${status}] /export-pdf: ${detail}`)
console.error(`PDF acma hatasi [${status}] /export-pdf: ${detail}`)
return {
ok: false,
message:
detail ||
'PDF al<61>namad<61>'
message: detail || 'PDF alinamadi'
}
}
}