diff --git a/src/components/Pages/Gangguan/Rekap/RGangguan_PerPosko.vue b/src/components/Pages/Gangguan/Rekap/RGangguan_PerPosko.vue index b0d2b42..567c07c 100755 --- a/src/components/Pages/Gangguan/Rekap/RGangguan_PerPosko.vue +++ b/src/components/Pages/Gangguan/Rekap/RGangguan_PerPosko.vue @@ -873,7 +873,11 @@ import DetailDialog from '@/components/Dialogs/DetailDialog.vue' import InputText from '@/components/InputText.vue' import { apolloClient } from '@/utils/api/api.graphql' import { provideApolloClient } from '@vue/apollo-composable' -import { exportToPDF, exportToXLSX } from '@/report/Gangguan/Rekap/RGangguan_PerPosko' +import { + exportToPDF, + exportToXLSX, + exportDetailToPDF +} from '@/report/Gangguan/Rekap/RGangguan_PerPosko' const client = apolloClient() provideApolloClient(client) @@ -959,7 +963,7 @@ const onExporting = (e: any) => { const onExportingDetail = (e: any) => { if (e.format === 'pdf') { - // exportToPDF(reportMeta.value, data.value) + exportDetailToPDF(reportMeta.value, dataSub.value) } else if (e.format === 'xlsx') { // exportToXLSX(reportMeta.value, e) } else { diff --git a/src/report/Gangguan/Rekap/RGangguan_PerPosko.ts b/src/report/Gangguan/Rekap/RGangguan_PerPosko.ts index 1dd31a9..9a368a3 100644 --- a/src/report/Gangguan/Rekap/RGangguan_PerPosko.ts +++ b/src/report/Gangguan/Rekap/RGangguan_PerPosko.ts @@ -21,6 +21,8 @@ import { setHeaderStyle } from '@/report/utils/xlsx' import { formatNumber, formatPercentage } from '@/utils/numbers' const reportName = 'Rekapitulasi Gangguan Per Posko' +const fontSize = 5 +const detailFontSize = 3 const groupingData = (data: any) => { const groupedData: any = {} @@ -237,7 +239,6 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) => const doc = new jsPDF({ orientation: 'landscape' }) - const fontSize = 5 autoTable(doc, { head: [ @@ -431,6 +432,140 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) => } } +const exportDetailToPDF = (reportMeta: any, rawData: any) => { + const meta = formatMetaData(reportMeta) + const doc = new jsPDF({ + orientation: 'landscape' + }) + + autoTable(doc, { + head: [['PT. PLN(Persero)']], + styles: { + fontSize: detailFontSize, + cellPadding: 0.1, + textColor: [0, 0, 0], + fontStyle: 'bold' + }, + theme: 'plain', + startY: 10, + margin: 5 + }) + + autoTable(doc, { + head: [ + [`Daftar Detail ${reportName}`.toUpperCase()], + [`PERIODE TANGGAL : ${meta.dateFromFormat} SD TGL ${meta.dateToFormat}`] + ], + styles: { + fontSize: detailFontSize, + cellPadding: 0.1, + textColor: [0, 0, 0], + fontStyle: 'bold', + halign: 'center' + }, + theme: 'plain', + startY: 18, + margin: 5 + }) + + autoTable(doc, { + head: [ + [ + 'No', + 'No Laporan', + 'Tgl Lapor', + 'Tgl Datang', + 'Tgl Nyala', + 'Durasi Response Time', + 'Durasi Recovery Time', + 'Status', + 'Referensi Marking', + 'IDPEL/NO METER', + 'Nama Pelapor', + 'Alamat Pelapor', + 'No Telp Pelapor', + 'Keterangan Pelapor', + 'Posko', + 'Tindakan', + 'Penyebab' + ] + ], + body: rawData.map((item: any, i: any) => [ + { content: i + 1, styles: { halign: 'right' } }, + item.no_laporan, + item.waktu_lapor, + item.waktu_response, + item.waktu_recovery, + item.durasi_response_time, + item.durasi_recovery_time, + item.status_akhir, + item.referensi_marking, + item.idpel_nometer, + item.nama_pelapor, + item.alamat_pelapor, + item.no_telp_pelapor, + item.keterangan_pelapor, + item.nama_posko, + item.tindakan, + item.penyebab + ]), + styles: { + fontSize: detailFontSize, + cellPadding: 1, + lineColor: [0, 0, 0], + lineWidth: 0.1, + cellWidth: 'auto' + }, + rowPageBreak: 'auto', + headStyles: { + fillColor: [192, 192, 192], + textColor: [0, 0, 0], + fontStyle: 'bold', + cellWidth: 'wrap', + halign: 'center', + valign: 'middle' + }, + bodyStyles: { + textColor: [0, 0, 0] + }, + didParseCell: function (data) { + if (data.row.section === 'head') { + data.cell.text = data.cell.text.map(function (word: any) { + return word.toUpperCase() + }) + } + }, + startY: 24, + margin: 5 + }) + + autoTable(doc, { + head: [ + [`${meta.dayTo}, ${meta.dateToFormat}`], + [ + { + content: '(.........................................)', + styles: { minCellHeight: 8, valign: 'bottom' } + } + ] + ], + styles: { + fontSize: detailFontSize, + cellPadding: 0.1, + textColor: [0, 0, 0], + fontStyle: 'bold', + halign: 'center' + }, + theme: 'plain', + tableWidth: 50, + margin: { left: 230 } + }) + + doc.save(`Laporan Detail ${reportName}.pdf`, { returnPromise: true }).then(() => { + console.log('pdf berhasil disimpan') + }) +} + const exportToXLSX = (reportMeta: any, e: any) => { const meta = formatMetaData(reportMeta) const workbook = new Workbook() @@ -487,4 +622,4 @@ const exportToXLSX = (reportMeta: any, e: any) => { e.cancel = true } -export { exportToPDF, exportToXLSX } +export { exportToPDF, exportToXLSX, exportDetailToPDF }