feat: Replace PDF retry with direct link and generate dialog

This commit is contained in:
mahdahar 2026-02-05 13:23:03 +07:00
parent 440f8b0362
commit 8b4c71d1a3
2 changed files with 5 additions and 23 deletions

View File

@ -232,15 +232,15 @@ class="dropdown-content menu bg-base-100 rounded-box z-[1] w-40 p-2 shadow-lg bo
</template>
<template x-if="<?= !in_array(session()->get('userroleid'), [1, 2]) ? 'true' : 'false' ?>">
<li>
<a :href="'<?=base_url('report/');?>' + req.SP_ACCESSNUMBER + '/pdf'" target="_blank">
<a :href="'http://glenlis/pdf/' + req.REQDATE.split(' ')[0].split('-').join('/') + '/' + req.SP_ACCESSNUMBER + '.pdf'" target="_blank">
<i class="fa fa-file-pdf mr-2"></i> PDF
</a>
</li>
</template>
<li>
<a @click="retryPdf(req.SP_ACCESSNUMBER)">
<i class="fa fa-sync-alt mr-2" :class="{ 'fa-spin': retryingPdf[req.SP_ACCESSNUMBER] }"></i>
<span x-text="retryingPdf[req.SP_ACCESSNUMBER] ? 'Retrying...' : 'Retry PDF'"></span>
<a @click="openGenerateDialog(req.SP_ACCESSNUMBER)">
<i class="fa fa-file-pdf mr-2"></i>
<span>Generate Result</span>
</a>
</li>
</div>

View File

@ -6,7 +6,7 @@ document.addEventListener('alpine:init', () => {
list: [],
isLoading: false,
counters: { Pend: 0, Coll: 0, Recv: 0, Inc: 0, Fin: 0, Total: 0 },
retryingPdf: {},
selectedPrinter: 'lab',
// PDF Generation Dialog
isGenerateDialogOpen: false,
@ -326,24 +326,6 @@ document.addEventListener('alpine:init', () => {
return this.getAllAuditEvents.filter(e => e.category === this.auditTab);
},
async retryPdf(accessnumber) {
if (this.retryingPdf[accessnumber]) return;
this.retryingPdf[accessnumber] = true;
try {
const res = await fetch(`${BASEURL}/report/${accessnumber}/pdf`);
const data = await res.json();
if (data.success) {
this.showToast('PDF queued for generation', 'success');
} else {
throw new Error(data.error || 'Unknown error');
}
} catch (e) {
this.showToast('PDF generation failed - try again', 'error');
} finally {
this.retryingPdf[accessnumber] = false;
}
},
/*
PDF Generation Dialog methods