feat: create export pdf in detail rekapitulasi gangguan per posko
This commit is contained in:
parent
7c063897e6
commit
790f2f3012
@ -873,7 +873,11 @@ import DetailDialog from '@/components/Dialogs/DetailDialog.vue'
|
|||||||
import InputText from '@/components/InputText.vue'
|
import InputText from '@/components/InputText.vue'
|
||||||
import { apolloClient } from '@/utils/api/api.graphql'
|
import { apolloClient } from '@/utils/api/api.graphql'
|
||||||
import { provideApolloClient } from '@vue/apollo-composable'
|
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()
|
const client = apolloClient()
|
||||||
provideApolloClient(client)
|
provideApolloClient(client)
|
||||||
@ -959,7 +963,7 @@ const onExporting = (e: any) => {
|
|||||||
|
|
||||||
const onExportingDetail = (e: any) => {
|
const onExportingDetail = (e: any) => {
|
||||||
if (e.format === 'pdf') {
|
if (e.format === 'pdf') {
|
||||||
// exportToPDF(reportMeta.value, data.value)
|
exportDetailToPDF(reportMeta.value, dataSub.value)
|
||||||
} else if (e.format === 'xlsx') {
|
} else if (e.format === 'xlsx') {
|
||||||
// exportToXLSX(reportMeta.value, e)
|
// exportToXLSX(reportMeta.value, e)
|
||||||
} else {
|
} else {
|
||||||
|
@ -21,6 +21,8 @@ import { setHeaderStyle } from '@/report/utils/xlsx'
|
|||||||
import { formatNumber, formatPercentage } from '@/utils/numbers'
|
import { formatNumber, formatPercentage } from '@/utils/numbers'
|
||||||
|
|
||||||
const reportName = 'Rekapitulasi Gangguan Per Posko'
|
const reportName = 'Rekapitulasi Gangguan Per Posko'
|
||||||
|
const fontSize = 5
|
||||||
|
const detailFontSize = 3
|
||||||
|
|
||||||
const groupingData = (data: any) => {
|
const groupingData = (data: any) => {
|
||||||
const groupedData: any = {}
|
const groupedData: any = {}
|
||||||
@ -237,7 +239,6 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) =>
|
|||||||
const doc = new jsPDF({
|
const doc = new jsPDF({
|
||||||
orientation: 'landscape'
|
orientation: 'landscape'
|
||||||
})
|
})
|
||||||
const fontSize = 5
|
|
||||||
|
|
||||||
autoTable(doc, {
|
autoTable(doc, {
|
||||||
head: [
|
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 exportToXLSX = (reportMeta: any, e: any) => {
|
||||||
const meta = formatMetaData(reportMeta)
|
const meta = formatMetaData(reportMeta)
|
||||||
const workbook = new Workbook()
|
const workbook = new Workbook()
|
||||||
@ -487,4 +622,4 @@ const exportToXLSX = (reportMeta: any, e: any) => {
|
|||||||
e.cancel = true
|
e.cancel = true
|
||||||
}
|
}
|
||||||
|
|
||||||
export { exportToPDF, exportToXLSX }
|
export { exportToPDF, exportToXLSX, exportDetailToPDF }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user