fix(tahesab): open invoice PDF window synchronously on click
Awaiting settings before window.open left a blank tab; open about:blank on click then fill via blob URL.
This commit is contained in:
@@ -411,15 +411,35 @@ async function exportAsnadPdf(g: {
|
||||
rows: Record<string, unknown>[];
|
||||
}) {
|
||||
error.value = '';
|
||||
// باز کردن همزمان با کلیک — وگرنه بعد از await پاپآپ بلاک/خالی میشود
|
||||
const preview = window.open('about:blank', '_blank');
|
||||
if (preview) {
|
||||
try {
|
||||
preview.document.write(
|
||||
'<!DOCTYPE html><html lang="fa" dir="rtl"><head><meta charset="utf-8" /><title>فاکتور</title></head><body style="font-family:Tahoma,sans-serif;padding:24px">در حال آمادهسازی فاکتور…</body></html>',
|
||||
);
|
||||
preview.document.close();
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
|
||||
if (!invoiceSettings.value) {
|
||||
await loadInvoiceSettings();
|
||||
}
|
||||
printTahesabInvoicePdf({
|
||||
|
||||
const okPrint = printTahesabInvoicePdf({
|
||||
group: g,
|
||||
settings: invoiceSettings.value,
|
||||
customerName: props.personName?.trim() || 'مشتری',
|
||||
moshtariCode: currentLink.value?.moshtariCode ?? null,
|
||||
targetWindow: preview,
|
||||
});
|
||||
if (!okPrint) {
|
||||
error.value =
|
||||
'خروجی فاکتور باز نشد. پاپآپ مرورگر را برای این سایت مجاز کنید و دوباره بزنید.';
|
||||
preview?.close();
|
||||
}
|
||||
}
|
||||
|
||||
async function loadAsnad() {
|
||||
|
||||
Reference in New Issue
Block a user