fix: adds Excel export support for SEP list data

This commit is contained in:
riefive
2025-11-18 16:08:57 +07:00
parent 97b6d8fccd
commit 34d4b85e16
4 changed files with 172 additions and 19 deletions
+15 -4
View File
@@ -26,7 +26,7 @@ import type { VclaimSepData } from '~/models/vclaim'
// Libraries
import { getFormatDateId } from '~/lib/date'
import { downloadCsv } from '~/lib/download'
import { downloadCsv, downloadXls } from '~/lib/download'
// Constants
import { serviceTypes } from '~/lib/constants.vclaim'
@@ -184,9 +184,20 @@ function exportCsv() {
downloadCsv(headers, data.value, filename)
}
function exportExcel() {
console.log('Ekspor Excel dipilih')
// tambahkan logic untuk generate Excel
async function exportExcel() {
if (!data.value || data.value.length === 0) {
toast({ title: 'Kosong', description: 'Tidak ada data untuk diekspor', variant: 'destructive' })
return
}
try {
const headers = Object.keys(data.value[0] || {})
const filename = `file-sep-${getFormatDateId(today)}.xlsx`
await downloadXls(headers, data.value, filename, 'SEP Data')
} catch (err: any) {
console.error('exportExcel error', err)
toast({ title: 'Gagal', description: err?.message || 'Gagal mengekspor data ke Excel', variant: 'destructive' })
}
}
async function handleRemove() {