fix: adds Excel export support for SEP list data
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user