Merge branch 'dev-bagus' of https://github.com/defuj/eis into dev-defuj

This commit is contained in:
Dede Fuji Abdul 2024-03-30 15:34:25 +07:00
commit 877ef5f944
19 changed files with 1538 additions and 164 deletions

View File

@ -160,7 +160,7 @@
:hover-state-enabled="true"
@selection-changed="onDataSubSelectionChanged"
:column-width="100"
@exporting="onExporting"
@exporting="onExportingDetail"
:allow-column-resizing="true"
column-resizing-mode="widget"
>
@ -502,12 +502,6 @@ import {
DxPager,
DxGrouping
} from 'devextreme-vue/data-grid'
import { jsPDF } from 'jspdf'
import { exportDataGrid as exportToPdf } from 'devextreme/pdf_exporter'
import { exportDataGrid as exportToExcel } from 'devextreme/excel_exporter'
import { saveAs } from 'file-saver'
import { Workbook } from 'exceljs'
import { useQuery } from '@vue/apollo-composable'
import { queries, requestGraphQl } from '@/utils/api/api.graphql'
import { formatNumber, formatPercentage, isNumber } from '@/utils/numbers'
import InputText from '@/components/InputText.vue'
@ -515,7 +509,12 @@ import { formatWaktu } from '@/components/Form/FiltersType/reference'
import DetailDialog from '@/components/Dialogs/DetailDialog.vue'
import { apolloClient } from '@/utils/api/api.graphql'
import { provideApolloClient } from '@vue/apollo-composable'
import { exportToPDF } from '@/report/Gangguan/Rekap/RGangguan_AlihPosko'
import {
exportToPDF,
exportToXLSX,
exportDetailToXLSX,
exportDetailToPDF
} from '@/report/Gangguan/Rekap/RGangguan_AlihPosko'
const client = apolloClient()
provideApolloClient(client)
@ -590,21 +589,18 @@ const closeDialog = () => {
const onExporting = (e: any) => {
if (e.format === 'pdf') {
exportToPDF(reportMeta.value, data.value)
} else if (e.format === 'xlsx') {
exportToXLSX(reportMeta.value, e)
} else {
const workbook = new Workbook()
const worksheet = workbook.addWorksheet('Employees')
}
}
exportToExcel({
component: e.component,
worksheet,
autoFilterEnabled: true
}).then(() => {
workbook.xlsx.writeBuffer().then((buffer: any) => {
saveAs(new Blob([buffer], { type: 'application/octet-stream' }), 'DataGrid.xlsx')
})
})
e.cancel = true
const onExportingDetail = (e: any) => {
if (e.format === 'pdf') {
exportDetailToPDF(reportMeta.value, dataSub.value)
} else if (e.format === 'xlsx') {
exportDetailToXLSX(reportMeta.value, e)
} else {
}
}

View File

@ -441,7 +441,7 @@
:hover-state-enabled="true"
@selection-changed="onDataSubSelectionChanged"
:column-width="100"
@exporting="onExporting"
@exporting="onExportingDetail"
:allow-column-resizing="true"
column-resizing-mode="widget"
>
@ -758,7 +758,7 @@
<script setup lang="ts">
import Filters from '@/components/Form/Filters.vue'
import Type1 from '@/components/Form/FiltersType/Type1.vue'
import { onMounted, ref, watch } from 'vue'
import { onMounted, ref } from 'vue'
import { DxDataGrid } from 'devextreme-vue'
import {
DxColumn,
@ -773,12 +773,6 @@ import {
DxSummary,
DxTotalItem
} from 'devextreme-vue/data-grid'
import { jsPDF } from 'jspdf'
import { exportDataGrid as exportToPdf } from 'devextreme/pdf_exporter'
import { exportDataGrid as exportToExcel } from 'devextreme/excel_exporter'
import { saveAs } from 'file-saver'
import { Workbook } from 'exceljs'
import { useQuery } from '@vue/apollo-composable'
import { queries, requestGraphQl } from '@/utils/api/api.graphql'
import { formatNumber, formatPercentage, isNumber } from '@/utils/numbers'
import { formatWaktu } from '@/components/Form/FiltersType/reference'
@ -786,7 +780,12 @@ import InputText from '@/components/InputText.vue'
import DetailDialog from '@/components/Dialogs/DetailDialog.vue'
import { apolloClient } from '@/utils/api/api.graphql'
import { provideApolloClient } from '@vue/apollo-composable'
import { exportToPDF } from '@/report/Gangguan/Rekap/RGangguan_DMAPKT'
import {
exportToPDF,
exportToXLSX,
exportDetailToPDF,
exportDetailToXLSX
} from '@/report/Gangguan/Rekap/RGangguan_DMAPKT'
const client = apolloClient()
provideApolloClient(client)
@ -863,21 +862,18 @@ const closeDialog = () => {
const onExporting = (e: any) => {
if (e.format === 'pdf') {
exportToPDF(reportMeta.value, data.value)
} else if (e.format === 'xlsx') {
exportToXLSX(reportMeta.value, e)
} else {
const workbook = new Workbook()
const worksheet = workbook.addWorksheet('Employees')
}
}
exportToExcel({
component: e.component,
worksheet,
autoFilterEnabled: true
}).then(() => {
workbook.xlsx.writeBuffer().then((buffer: any) => {
saveAs(new Blob([buffer], { type: 'application/octet-stream' }), 'DataGrid.xlsx')
})
})
e.cancel = true
const onExportingDetail = (e: any) => {
if (e.format === 'pdf') {
exportDetailToPDF(reportMeta.value, dataSub.value)
} else if (e.format === 'xlsx') {
exportDetailToXLSX(reportMeta.value, e)
} else {
}
}

View File

@ -330,7 +330,7 @@
:hover-state-enabled="true"
@selection-changed="onDataSubSelectionChanged"
:column-width="100"
@exporting="onExporting"
@exporting="onExportingDetail"
:allow-column-resizing="true"
column-resizing-mode="widget"
>
@ -1119,10 +1119,6 @@ import {
DxSelection,
DxSummary
} from 'devextreme-vue/data-grid'
import { exportDataGrid as exportToExcel } from 'devextreme/excel_exporter'
import { saveAs } from 'file-saver'
import { Workbook } from 'exceljs'
import { useQuery } from '@vue/apollo-composable'
import { queries, requestGraphQl } from '@/utils/api/api.graphql'
import { formatNumber, formatPercentage, isNumber } from '@/utils/numbers'
import { formatWaktu } from '@/components/Form/FiltersType/reference'
@ -1130,7 +1126,12 @@ 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 } from '@/report/Gangguan/Rekap/RGangguan_KTI'
import {
exportToPDF,
exportToXLSX,
exportDetailToPDF,
exportDetailToXLSX
} from '@/report/Gangguan/Rekap/RGangguan_KTI'
const client = apolloClient()
provideApolloClient(client)
@ -1207,21 +1208,18 @@ const closeDialog = () => {
const onExporting = (e: any) => {
if (e.format === 'pdf') {
exportToPDF(reportMeta.value, data.value)
} else if (e.format === 'xlsx') {
exportToXLSX(reportMeta.value, e)
} else {
const workbook = new Workbook()
const worksheet = workbook.addWorksheet('Employees')
}
}
exportToExcel({
component: e.component,
worksheet,
autoFilterEnabled: true
}).then(() => {
workbook.xlsx.writeBuffer().then((buffer: any) => {
saveAs(new Blob([buffer], { type: 'application/octet-stream' }), 'DataGrid.xlsx')
})
})
e.cancel = true
const onExportingDetail = (e: any) => {
if (e.format === 'pdf') {
exportDetailToPDF(reportMeta.value, dataSub.value)
} else if (e.format === 'xlsx') {
exportDetailToXLSX(reportMeta.value, e)
} else {
}
}

View File

@ -259,7 +259,7 @@
:hover-state-enabled="true"
@selection-changed="onDataSubSelectionChanged"
:column-width="100"
@exporting="onExporting"
@exporting="onExportingDetail"
:allow-column-resizing="true"
column-resizing-mode="widget"
>
@ -625,13 +625,7 @@ import {
DxSearchPanel,
DxSelection
} from 'devextreme-vue/data-grid'
import { onMounted, ref, watch } from 'vue'
import { jsPDF } from 'jspdf'
import { exportDataGrid as exportToPdf } from 'devextreme/pdf_exporter'
import { exportDataGrid as exportToExcel } from 'devextreme/excel_exporter'
import { saveAs } from 'file-saver'
import { Workbook } from 'exceljs'
import { useQuery } from '@vue/apollo-composable'
import { onMounted, ref } from 'vue'
import { queries, requestGraphQl } from '@/utils/api/api.graphql'
import { formatNumber, formatPercentage, isNumber } from '@/utils/numbers'
import { formatWaktu } from '@/components/Form/FiltersType/reference'
@ -640,7 +634,12 @@ import InputText from '@/components/InputText.vue'
import vue3starRatings from 'vue3-star-ratings'
import { apolloClient } from '@/utils/api/api.graphql'
import { provideApolloClient } from '@vue/apollo-composable'
import { exportToPDF } from '@/report/Gangguan/Rekap/RGangguan_RatingPerPosko'
import {
exportToPDF,
exportToXLSX,
exportDetailToPDF,
exportDetailToXLSX
} from '@/report/Gangguan/Rekap/RGangguan_RatingPerPosko'
const client = apolloClient()
provideApolloClient(client)
@ -721,21 +720,18 @@ const closeDialog = () => {
const onExporting = (e: any) => {
if (e.format === 'pdf') {
exportToPDF(reportMeta.value, data.value)
} else if (e.format === 'xlsx') {
exportToXLSX(reportMeta.value, e)
} else {
const workbook = new Workbook()
const worksheet = workbook.addWorksheet('Employees')
}
}
exportToExcel({
component: e.component,
worksheet,
autoFilterEnabled: true
}).then(() => {
workbook.xlsx.writeBuffer().then((buffer: any) => {
saveAs(new Blob([buffer], { type: 'application/octet-stream' }), 'DataGrid.xlsx')
})
})
e.cancel = true
const onExportingDetail = (e: any) => {
if (e.format === 'pdf') {
exportDetailToPDF(reportMeta.value, dataSub.value)
} else if (e.format === 'xlsx') {
exportDetailToXLSX(reportMeta.value, e)
} else {
}
}

View File

@ -249,7 +249,7 @@
:hover-state-enabled="true"
@selection-changed="onDataSubSelectionChanged"
:column-width="100"
@exporting="onExporting"
@exporting="onExportingDetail"
:allow-column-resizing="true"
column-resizing-mode="widget"
>
@ -615,10 +615,6 @@ import {
DxSearchPanel,
DxSelection
} from 'devextreme-vue/data-grid'
import { exportDataGrid as exportToExcel } from 'devextreme/excel_exporter'
import { saveAs } from 'file-saver'
import { Workbook } from 'exceljs'
import { useQuery } from '@vue/apollo-composable'
import { queries, requestGraphQl } from '@/utils/api/api.graphql'
import { formatNumber, formatPercentage, isNumber } from '@/utils/numbers'
import { formatWaktu } from '@/components/Form/FiltersType/reference'
@ -627,7 +623,12 @@ 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 } from '@/report/Gangguan/Rekap/RGangguan_RatingPerRegu'
import {
exportToPDF,
exportDetailToPDF,
exportToXLSX,
exportDetailToXLSX
} from '@/report/Gangguan/Rekap/RGangguan_RatingPerRegu'
const client = apolloClient()
provideApolloClient(client)
@ -713,21 +714,18 @@ const closeDialog = () => {
const onExporting = (e: any) => {
if (e.format === 'pdf') {
exportToPDF(reportMeta.value, data.value)
} else if (e.format === 'xlsx') {
exportToXLSX(reportMeta.value, e)
} else {
const workbook = new Workbook()
const worksheet = workbook.addWorksheet('Employees')
}
}
exportToExcel({
component: e.component,
worksheet,
autoFilterEnabled: true
}).then(() => {
workbook.xlsx.writeBuffer().then((buffer: any) => {
saveAs(new Blob([buffer], { type: 'application/octet-stream' }), 'DataGrid.xlsx')
})
})
e.cancel = true
const onExportingDetail = (e: any) => {
if (e.format === 'pdf') {
exportDetailToPDF(reportMeta.value, dataSub.value)
} else if (e.format === 'xlsx') {
exportDetailToXLSX(reportMeta.value, e)
} else {
}
}

View File

@ -173,7 +173,11 @@ const formatData = (rawData: any) => {
? formatPercentage((summary.total_selesai / summary.total) * 100)
: '100%',
formatNumber(summary.total_inproses),
formatPercentage((summary.total_inproses / summary.total) * 100),
formatPercentage(
!summary.total_inproses || !summary.total
? '0%'
: (summary.total_inproses / summary.total) * 100
),
formatNumber(avgDurasiDispatch),
formatWaktu(summary.max_durasi_dispatch),
formatWaktu(summary.min_durasi_dispatch),
@ -221,9 +225,13 @@ const formatData = (rawData: any) => {
{ content: 'TOTAL', colSpan: 2, styles: { fontStyle: 'bold' } },
formatNumber(total.total),
formatNumber(total.total_selesai),
formatPercentage((total.total_selesai / total.total) * 100),
formatPercentage(
!total.total_selesai || !total.total ? '0%' : (total.total_selesai / total.total) * 100
),
formatNumber(total.total_inproses),
formatPercentage((total.total_inproses / total.total) * 100),
formatPercentage(
!total.total_inproses || !total.total ? '0%' : (total.total_inproses / total.total) * 100
),
formatNumber(
total.avg_durasi_dispatch.length
? total.avg_durasi_dispatch.reduce((a: any, b: any) => a + b) /
@ -463,6 +471,9 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) =>
})
if (preview) {
doc.setProperties({
title: `${reportName}`
})
window.open(doc.output('bloburl'))
} else {
doc.save(`Laporan ${reportName}.pdf`, { returnPromise: true }).then(() => {
@ -689,7 +700,7 @@ const exportToXLSX = (reportMeta: any, e: any) => {
const exportDetailToXLSX = (reportMeta: any, e: any) => {
const meta = formatMetaData(reportMeta)
const workbook = new Workbook()
const worksheet = workbook.addWorksheet(`${reportName}`)
const worksheet = workbook.addWorksheet(`Detail ${reportName}`)
setHeaderStyle(worksheet, 1, 1, 'PT. PLN(Persero)')
setHeaderStyle(worksheet, 3, 8, `Daftar Detail ${reportName}`.toUpperCase(), true)

View File

@ -21,6 +21,8 @@ import { setHeaderStyle } from '@/report/utils/xlsx'
import { formatNumber } from '@/utils/numbers'
const reportName = 'Rekapitulasi Gangguan Alih Posko'
const fontSize = 5
const detailFontSize = 3
const groupingData = (data: any) => {
const groupedData: any = {}
@ -119,7 +121,6 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) =>
const doc = new jsPDF({
orientation: 'landscape'
})
const fontSize = 5
autoTable(doc, {
head: [
@ -239,6 +240,9 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) =>
})
if (preview) {
doc.setProperties({
title: `${reportName}`
})
window.open(doc.output('bloburl'))
} else {
doc.save(`Laporan ${reportName}.pdf`, { returnPromise: true }).then(() => {
@ -247,4 +251,238 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) =>
}
}
export { exportToPDF }
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',
'IDPEL/NO METER',
'Nama Pelapor',
'Alamat Pelapor',
'No Telp Pelapor',
'Keterangan Pelapor',
'Posko',
'Sumber Lapor',
'Nama Petugas',
'Posko Awal',
'Posko Tujuan'
]
],
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.idpel_nometer,
item.nama_pelapor,
item.alamat_pelapor,
item.no_telp_pelapor,
item.keterangan_pelapor,
item.nama_posko,
item.media,
'',
'',
''
]),
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()
const worksheet = workbook.addWorksheet(`${reportName}`)
setHeaderStyle(worksheet, 1, 1, 'PT. PLN(Persero)')
setHeaderStyle(
worksheet,
2,
1,
`UNIT INDUK : ${
reportMeta.uid
? reportMeta.uid.name.toUpperCase()
: 'Semua Unit Induk Distribusi/Wilayah'.toUpperCase()
}`
)
setHeaderStyle(
worksheet,
3,
1,
`UNIT PELAKSANA PELAYANAN PELANGGAN : ${
reportMeta.up3
? reportMeta.up3.name.toUpperCase()
: 'Semua Unit Pelaksanaan Pelayanan Pelanggan'.toUpperCase()
}`
)
setHeaderStyle(
worksheet,
4,
1,
`POSKO : ${
reportMeta.posko ? reportMeta.posko.name.toUpperCase() : 'Semua Posko'.toUpperCase()
}`
)
setHeaderStyle(worksheet, 7, 3, `${reportName}`.toUpperCase(), true)
setHeaderStyle(
worksheet,
8,
3,
`PERIODE TANGGAL : ${meta.dateFromFormat} SD TGL ${meta.dateToFormat}`,
true
)
worksheet.mergeCells('A1:F1')
worksheet.mergeCells('A2:F2')
worksheet.mergeCells('A3:F3')
worksheet.mergeCells('A4:F4')
exportToExcel({
component: e.component,
worksheet,
autoFilterEnabled: true,
topLeftCell: { row: 10, column: 1 }
}).then(() => {
workbook.xlsx.writeBuffer().then((buffer: any) => {
saveAs(new Blob([buffer], { type: 'application/octet-stream' }), `Laporan ${reportName}.xlsx`)
})
})
e.cancel = true
}
const exportDetailToXLSX = (reportMeta: any, e: any) => {
const meta = formatMetaData(reportMeta)
const workbook = new Workbook()
const worksheet = workbook.addWorksheet(`Detail ${reportName}`)
setHeaderStyle(worksheet, 1, 1, 'PT. PLN(Persero)')
setHeaderStyle(worksheet, 3, 8, `Daftar Detail ${reportName}`.toUpperCase(), true)
setHeaderStyle(
worksheet,
4,
8,
`PERIODE TANGGAL : ${meta.dateFromFormat} SD TGL ${meta.dateToFormat}`,
true
)
worksheet.mergeCells('H3:J3')
worksheet.mergeCells('H4:J4')
exportToExcel({
component: e.component,
worksheet,
autoFilterEnabled: true,
topLeftCell: { row: 6, column: 1 }
}).then(() => {
workbook.xlsx.writeBuffer().then((buffer: any) => {
saveAs(
new Blob([buffer], { type: 'application/octet-stream' }),
`Laporan Detail ${reportName}.xlsx`
)
})
})
e.cancel = true
}
export { exportToPDF, exportDetailToPDF, exportToXLSX, exportDetailToXLSX }

View File

@ -16,9 +16,8 @@ import { saveAs } from 'file-saver'
import { jsPDF } from 'jspdf'
import autoTable from 'jspdf-autotable'
import { Workbook } from 'exceljs'
import { formatWaktu } from '@/components/Form/FiltersType/reference'
import { setHeaderStyle } from '@/report/utils/xlsx'
import { formatNumber, formatPercentage } from '@/utils/numbers'
import { formatNumber } from '@/utils/numbers'
const reportName = 'Rekapitulasi Gangguan Berdasarkan Media'
const fontSize = 5
@ -245,6 +244,9 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) =>
})
if (preview) {
doc.setProperties({
title: `${reportName}`
})
window.open(doc.output('bloburl'))
} else {
doc.save(`Laporan ${reportName}.pdf`, { returnPromise: true }).then(() => {
@ -455,7 +457,7 @@ const exportToXLSX = (reportMeta: any, e: any) => {
const exportDetailToXLSX = (reportMeta: any, e: any) => {
const meta = formatMetaData(reportMeta)
const workbook = new Workbook()
const worksheet = workbook.addWorksheet(`${reportName}`)
const worksheet = workbook.addWorksheet(`Detail ${reportName}`)
setHeaderStyle(worksheet, 1, 1, 'PT. PLN(Persero)')
setHeaderStyle(worksheet, 3, 8, `Daftar Detail ${reportName}`.toUpperCase(), true)

View File

@ -267,6 +267,9 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) =>
})
if (preview) {
doc.setProperties({
title: `${reportName}`
})
window.open(doc.output('bloburl'))
} else {
doc.save(`Laporan ${reportName}.pdf`, { returnPromise: true }).then(() => {

View File

@ -16,11 +16,12 @@ import { saveAs } from 'file-saver'
import { jsPDF } from 'jspdf'
import autoTable from 'jspdf-autotable'
import { Workbook } from 'exceljs'
import { formatWaktu } from '@/components/Form/FiltersType/reference'
import { setHeaderStyle } from '@/report/utils/xlsx'
import { formatNumber, formatPercentage } from '@/utils/numbers'
const reportName = 'Rekapitulasi Gangguan Diselesaikan Mobile APKT'
const fontSize = 4
const detailFontSize = 3
const formatData = (rawData: any) => {
const formattedData: any = []
@ -128,7 +129,6 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) =>
const doc = new jsPDF({
orientation: 'landscape'
})
const fontSize = 4
autoTable(doc, {
head: [
@ -402,6 +402,9 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) =>
})
if (preview) {
doc.setProperties({
title: `${reportName}`
})
window.open(doc.output('bloburl'))
} else {
doc.save(`Laporan ${reportName}.pdf`, { returnPromise: true }).then(() => {
@ -410,4 +413,238 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) =>
}
}
export { exportToPDF }
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()
const worksheet = workbook.addWorksheet(`${reportName}`)
setHeaderStyle(worksheet, 1, 1, 'PT. PLN(Persero)')
setHeaderStyle(
worksheet,
2,
1,
`UNIT INDUK : ${
reportMeta.uid
? reportMeta.uid.name.toUpperCase()
: 'Semua Unit Induk Distribusi/Wilayah'.toUpperCase()
}`
)
setHeaderStyle(
worksheet,
3,
1,
`UNIT PELAKSANA PELAYANAN PELANGGAN : ${
reportMeta.up3
? reportMeta.up3.name.toUpperCase()
: 'Semua Unit Pelaksanaan Pelayanan Pelanggan'.toUpperCase()
}`
)
setHeaderStyle(
worksheet,
4,
1,
`POSKO : ${
reportMeta.posko ? reportMeta.posko.name.toUpperCase() : 'Semua Posko'.toUpperCase()
}`
)
setHeaderStyle(worksheet, 7, 1, `${reportName}`.toUpperCase(), true)
setHeaderStyle(
worksheet,
8,
1,
`PERIODE TANGGAL : ${meta.dateFromFormat} SD TGL ${meta.dateToFormat}`,
true
)
worksheet.mergeCells('A1:X1')
worksheet.mergeCells('A2:X2')
worksheet.mergeCells('A3:X3')
worksheet.mergeCells('A4:X4')
worksheet.mergeCells('A7:X7')
worksheet.mergeCells('A8:X8')
exportToExcel({
component: e.component,
worksheet,
autoFilterEnabled: true,
topLeftCell: { row: 10, column: 1 }
}).then(() => {
workbook.xlsx.writeBuffer().then((buffer: any) => {
saveAs(new Blob([buffer], { type: 'application/octet-stream' }), `Laporan ${reportName}.xlsx`)
})
})
e.cancel = true
}
const exportDetailToXLSX = (reportMeta: any, e: any) => {
const meta = formatMetaData(reportMeta)
const workbook = new Workbook()
const worksheet = workbook.addWorksheet(`Detail ${reportName}`)
setHeaderStyle(worksheet, 1, 1, 'PT. PLN(Persero)')
setHeaderStyle(worksheet, 3, 1, `Daftar Detail ${reportName}`.toUpperCase(), true)
setHeaderStyle(
worksheet,
4,
1,
`PERIODE TANGGAL : ${meta.dateFromFormat} SD TGL ${meta.dateToFormat}`,
true
)
worksheet.mergeCells('A3:Q3')
worksheet.mergeCells('A4:Q4')
exportToExcel({
component: e.component,
worksheet,
autoFilterEnabled: true,
topLeftCell: { row: 6, column: 1 }
}).then(() => {
workbook.xlsx.writeBuffer().then((buffer: any) => {
saveAs(
new Blob([buffer], { type: 'application/octet-stream' }),
`Laporan Detail ${reportName}.xlsx`
)
})
})
e.cancel = true
}
export { exportToPDF, exportToXLSX, exportDetailToPDF, exportDetailToXLSX }

View File

@ -59,7 +59,7 @@ const formatData = (rawData: any) => {
total_recovery_time_kurang_sla: 0
}
for (const sub_kelompok in data) {
for (const sub_kelompok of data) {
const total: any = {
total_laporan: 0,
total_laporan_sudah_selesai: 0,
@ -78,7 +78,13 @@ const formatData = (rawData: any) => {
total_recovery_time_kurang_sla: 0
}
formattedData.push([{ content: sub_kelompok, colSpan: 20, styles: { fontStyle: 'bold' } }])
formattedData.push([
{
content: `${sub_kelompok} (${data[sub_kelompok][0].nama_sub_kelompok})`,
colSpan: 20,
styles: { fontStyle: 'bold' }
}
])
for (let i = 0; i < data[sub_kelompok].length; i++) {
formattedData.push([
@ -88,13 +94,19 @@ const formatData = (rawData: any) => {
formatNumber(data[sub_kelompok][i].laporan.total),
formatNumber(data[sub_kelompok][i].laporan.sudahSelesai.jml),
formatPercentage(
(data[sub_kelompok][i].laporan.sudahSelesai.jml / data[sub_kelompok][i].laporan.total) *
100
!data[sub_kelompok][i].laporan.sudahSelesai.jml || !data[sub_kelompok][i].laporan.total
? '0%'
: (data[sub_kelompok][i].laporan.sudahSelesai.jml /
data[sub_kelompok][i].laporan.total) *
100
),
formatNumber(data[sub_kelompok][i].laporan.belumSelesai.jml),
formatPercentage(
(data[sub_kelompok][i].laporan.belumSelesai.jml / data[sub_kelompok][i].laporan.total) *
100
!data[sub_kelompok][i].laporan.belumSelesai.jml || !data[sub_kelompok][i].laporan.total
? '0%'
: (data[sub_kelompok][i].laporan.belumSelesai.jml /
data[sub_kelompok][i].laporan.total) *
100
),
formatNumber(data[sub_kelompok][i].responseTime.menit.total),
formatNumber(data[sub_kelompok][i].responseTime.menit.rataRata),
@ -155,9 +167,17 @@ const formatData = (rawData: any) => {
{ content: 'TOTAL', colSpan: 3, styles: { fontStyle: 'bold' } },
formatNumber(total.total_laporan),
formatNumber(total.total_laporan_sudah_selesai),
formatPercentage((total.total_laporan_sudah_selesai / total.total_laporan) * 100),
formatPercentage(
!total.total_laporan_sudah_selesai || !total.total_laporan
? '0%'
: (total.total_laporan_sudah_selesai / total.total_laporan) * 100
),
formatNumber(total.total_laporan_belum_selesai),
formatPercentage((total.total_laporan_belum_selesai / total.total_laporan) * 100),
formatPercentage(
!total.total_laporan_belum_selesai || !total.total_laporan
? '0%'
: (total.total_laporan_belum_selesai / total.total_laporan) * 100
),
formatNumber(total.total_response_time_total),
formatNumber(
total.total_response_time_rata_rata.length
@ -187,9 +207,17 @@ const formatData = (rawData: any) => {
{ content: 'GRAND TOTAL', colSpan: 3, styles: { fontStyle: 'bold' } },
formatNumber(grandTotal.total_laporan),
formatNumber(grandTotal.total_laporan_sudah_selesai),
formatPercentage((grandTotal.total_laporan_sudah_selesai / grandTotal.total_laporan) * 100),
formatPercentage(
!grandTotal.total_laporan_sudah_selesai || !grandTotal.total_laporan
? '0%'
: (grandTotal.total_laporan_sudah_selesai / grandTotal.total_laporan) * 100
),
formatNumber(grandTotal.total_laporan_belum_selesai),
formatPercentage((grandTotal.total_laporan_belum_selesai / grandTotal.total_laporan) * 100),
formatPercentage(
!grandTotal.total_laporan_belum_selesai || !grandTotal.total_laporan
? '0%'
: (grandTotal.total_laporan_belum_selesai / grandTotal.total_laporan) * 100
),
formatNumber(grandTotal.total_response_time_total),
formatNumber(
grandTotal.total_response_time_rata_rata.length
@ -244,6 +272,7 @@ const formatMetaData = (reportMeta: any) => {
const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) => {
const data = formatData(rawData)
console.log(data)
const meta = formatMetaData(reportMeta)
const doc = new jsPDF({
orientation: 'landscape'
@ -443,6 +472,9 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) =>
})
if (preview) {
doc.setProperties({
title: `${reportName}`
})
window.open(doc.output('bloburl'))
} else {
doc.save(`Laporan ${reportName}.pdf`, { returnPromise: true }).then(() => {

View File

@ -89,10 +89,14 @@ const formatData = (rawData: any) => {
data[id_fasilitas][i].sub_kelompok,
formatNumber(data[id_fasilitas][i].total),
formatNumber(data[id_fasilitas][i].total_selesai),
formatPercentage((data[id_fasilitas][i].total_selesai / data[id_fasilitas][i].total) * 100),
formatPercentage(
!data[id_fasilitas][i].total_selesai || !data[id_fasilitas][i].total
? '0%'
: (data[id_fasilitas][i].total_selesai / data[id_fasilitas][i].total) * 100
),
formatNumber(data[id_fasilitas][i].total_inproses),
formatPercentage(
data[id_fasilitas][i].total_inproses == null || data[id_fasilitas][i].total == null
!data[id_fasilitas][i].total_inproses || !data[id_fasilitas][i].total
? '0%'
: (data[id_fasilitas][i].total_inproses / data[id_fasilitas][i].total) * 100
),
@ -147,9 +151,17 @@ const formatData = (rawData: any) => {
{ content: 'TOTAL', colSpan: 3, styles: { fontStyle: 'bold' } },
formatNumber(total.total_laporan),
formatNumber(total.total_laporan_sudah_selesai),
formatPercentage((total.total_laporan_sudah_selesai / total.total_laporan) * 100),
formatPercentage(
!total.total_laporan_sudah_selesai || !total.total_laporan
? '0%'
: (total.total_laporan_sudah_selesai / total.total_laporan) * 100
),
formatNumber(total.total_laporan_belum_selesai),
formatPercentage((total.total_laporan_belum_selesai / total.total_laporan) * 100),
formatPercentage(
!total.total_laporan_belum_selesai || !total.total_laporan
? '0%'
: (total.total_laporan_belum_selesai / total.total_laporan) * 100
),
formatNumber(total.total_response_time_total),
formatNumber(
total.total_response_time_rata_rata.length
@ -179,9 +191,17 @@ const formatData = (rawData: any) => {
{ content: 'GRAND TOTAL', colSpan: 3, styles: { fontStyle: 'bold' } },
formatNumber(grandTotal.total_laporan),
formatNumber(grandTotal.total_laporan_sudah_selesai),
formatPercentage((grandTotal.total_laporan_sudah_selesai / grandTotal.total_laporan) * 100),
formatPercentage(
!grandTotal.total_laporan_sudah_selesai || !grandTotal.total_laporan
? '0%'
: (grandTotal.total_laporan_sudah_selesai / grandTotal.total_laporan) * 100
),
formatNumber(grandTotal.total_laporan_belum_selesai),
formatPercentage((grandTotal.total_laporan_belum_selesai / grandTotal.total_laporan) * 100),
formatPercentage(
!grandTotal.total_laporan_belum_selesai || !grandTotal.total_laporan
? '0%'
: (grandTotal.total_laporan_belum_selesai / grandTotal.total_laporan) * 100
),
formatNumber(grandTotal.total_response_time_total),
formatNumber(
grandTotal.total_response_time_rata_rata.length
@ -435,6 +455,9 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) =>
})
if (preview) {
doc.setProperties({
title: `${reportName}`
})
window.open(doc.output('bloburl'))
} else {
doc.save(`Laporan ${reportName}.pdf`, { returnPromise: true }).then(() => {

View File

@ -21,6 +21,8 @@ import { setHeaderStyle } from '@/report/utils/xlsx'
import { formatNumber } from '@/utils/numbers'
const reportName = 'Rekapitulasi Koreksi Transaksi Individual'
const fontSize = 5
const detailFontSize = 3
const formatData = (rawData: any) => {
const formattedData: any = []
@ -125,7 +127,6 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) =>
const doc = new jsPDF({
orientation: 'landscape'
})
const fontSize = 5
autoTable(doc, {
head: [
@ -267,6 +268,9 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) =>
})
if (preview) {
doc.setProperties({
title: `${reportName}`
})
window.open(doc.output('bloburl'))
} else {
doc.save(`Laporan ${reportName}.pdf`, { returnPromise: true }).then(() => {
@ -275,4 +279,291 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) =>
}
}
export { exportToPDF }
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 Lapor Sebelum',
'Tgl Lapor Koreksi',
'Tgl Penugasan Sebelum',
'Tgl Penugasan Koreksi',
'Tgl Perjalanan Sebelum',
'Tgl Perjalanan Koreksi',
'Tgl Pengerjaan Sebelum',
'Tgl Pengerjaan Koreksi',
'Tgl Nyala Sebelum',
'Tgl Nyala Koreksi',
'Tgl Selesai Sebelum',
'Tgl Selesai Koreksi',
'Durasi Response Time Sebelum',
'Durasi Response Time Koreksi',
'Durasi Recovery Time Koreksi',
'Kelompok ID Sebelum',
'Kelompok ID Koreksi',
'Sub Kelompok ID Sebelum',
'Sub Kelompok ID Koreksi',
'Fasilitas ID Sebelum',
'Fasilitas ID Koreksi',
'Sub Fasilitas ID Sebelum',
'Sub Fasilitas ID Koreksi',
'Equipment ID Sebelum',
'Equipment ID Koreksi',
'Event Damage ID Sebelum',
'Event Damage ID Koreksi',
'Cause ID Sebelum',
'Cause ID Koreksi',
'Cause Group ID Sebelum',
'Cause Group ID Koreksi',
'Weather ID Sebelum',
'Weather ID Koreksi',
'Group Koreksi',
'ALASAN',
'IDPEL/NO METER',
'Keterangan Pelapor',
'Posko',
'Tindakan',
'Penyebab'
]
],
body: rawData.map((item: any, i: any) => [
{ content: i + 1, styles: { halign: 'right' } },
item.no_laporan,
item.tgl_lapor,
item.tgl_lapor_sblm,
item.tgl_lapor_sdh,
item.tgl_penugasan_sblm,
item.tgl_penugasan_sdh,
item.tgl_perjalanan_sblm,
item.tgl_perjalanan_sdh,
item.tgl_pengerjaan_sblm,
item.tgl_pengerjaan_sdh,
item.tgl_nyala_sementara_sblm,
item.tgl_nyala_sementara_sdh,
item.tgl_nyala_sblm,
item.tgl_nyala_sdh,
item.tgl_selesai_sblm,
item.tgl_selesai_sdh,
item.durasi_response_time_sblm,
item.durasi_response_time_sdh,
item.durasi_recovery_time_sdh,
item.kelompok_sblm,
item.kelompok_sdh,
item.sub_kelompok_sblm,
item.sub_kelompok_sdh,
item.fasilitas_id_sblm,
item.fasilitas_id_sdh,
item.sub_fasilitas_id_sblm,
item.sub_fasilitas_id_sdh,
item.equipment_id_sblm,
item.equipment_id_sdh,
item.event_damage_sblm,
item.event_damage_sdh,
item.cause_id_sblm,
item.cause_id_sdh,
item.cause_group_id_sblm,
item.cause_group_id_sdh,
item.weather_id_sblm,
item.weather_id_sdh,
item.group_koreksi,
item.alasan,
item.idpel_no_meter,
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',
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()
const worksheet = workbook.addWorksheet(`${reportName}`)
setHeaderStyle(worksheet, 1, 1, 'PT. PLN(Persero)')
setHeaderStyle(
worksheet,
2,
1,
`UNIT INDUK : ${
reportMeta.uid
? reportMeta.uid.name.toUpperCase()
: 'Semua Unit Induk Distribusi/Wilayah'.toUpperCase()
}`
)
setHeaderStyle(
worksheet,
3,
1,
`UNIT PELAKSANA PELAYANAN PELANGGAN : ${
reportMeta.up3
? reportMeta.up3.name.toUpperCase()
: 'Semua Unit Pelaksanaan Pelayanan Pelanggan'.toUpperCase()
}`
)
setHeaderStyle(
worksheet,
4,
1,
`POSKO : ${
reportMeta.posko ? reportMeta.posko.name.toUpperCase() : 'Semua Posko'.toUpperCase()
}`
)
setHeaderStyle(worksheet, 7, 1, `${reportName}`.toUpperCase(), true)
setHeaderStyle(
worksheet,
8,
1,
`PERIODE TANGGAL : ${meta.dateFromFormat} SD TGL ${meta.dateToFormat}`,
true
)
worksheet.mergeCells('A1:M1')
worksheet.mergeCells('A2:M2')
worksheet.mergeCells('A3:M3')
worksheet.mergeCells('A4:M4')
worksheet.mergeCells('A7:M7')
worksheet.mergeCells('A8:M8')
exportToExcel({
component: e.component,
worksheet,
autoFilterEnabled: true,
topLeftCell: { row: 10, column: 1 }
}).then(() => {
workbook.xlsx.writeBuffer().then((buffer: any) => {
saveAs(new Blob([buffer], { type: 'application/octet-stream' }), `Laporan ${reportName}.xlsx`)
})
})
e.cancel = true
}
const exportDetailToXLSX = (reportMeta: any, e: any) => {
const meta = formatMetaData(reportMeta)
const workbook = new Workbook()
const worksheet = workbook.addWorksheet(`Detail ${reportName}`)
setHeaderStyle(worksheet, 1, 1, 'PT. PLN(Persero)')
setHeaderStyle(worksheet, 3, 8, `Daftar Detail ${reportName}`.toUpperCase(), true)
setHeaderStyle(
worksheet,
4,
8,
`PERIODE TANGGAL : ${meta.dateFromFormat} SD TGL ${meta.dateToFormat}`,
true
)
worksheet.mergeCells('H3:J3')
worksheet.mergeCells('H4:J4')
exportToExcel({
component: e.component,
worksheet,
autoFilterEnabled: true,
topLeftCell: { row: 6, column: 1 }
}).then(() => {
workbook.xlsx.writeBuffer().then((buffer: any) => {
saveAs(
new Blob([buffer], { type: 'application/octet-stream' }),
`Laporan Detail ${reportName}.xlsx`
)
})
})
e.cancel = true
}
export { exportToPDF, exportToXLSX, exportDetailToPDF, exportDetailToXLSX }

View File

@ -88,10 +88,14 @@ const formatData = (rawData: any) => {
data[nama_up3][i].nama_posko,
formatNumber(data[nama_up3][i].total),
formatNumber(data[nama_up3][i].total_selesai),
formatPercentage((data[nama_up3][i].total_selesai / data[nama_up3][i].total) * 100),
formatPercentage(
!data[nama_up3][i].total_selesai || !data[nama_up3][i].total
? '0%'
: (data[nama_up3][i].total_selesai / data[nama_up3][i].total) * 100
),
formatNumber(data[nama_up3][i].total_inproses),
formatPercentage(
data[nama_up3][i].total_inproses == null || data[nama_up3][i].total == null
!data[nama_up3][i].total_inproses || !data[nama_up3][i].total
? '0%'
: (data[nama_up3][i].total_inproses / data[nama_up3][i].total) * 100
),
@ -146,9 +150,17 @@ const formatData = (rawData: any) => {
{ content: 'TOTAL', colSpan: 2, styles: { fontStyle: 'bold' } },
formatNumber(total.total_laporan),
formatNumber(total.total_laporan_sudah_selesai),
formatPercentage((total.total_laporan_sudah_selesai / total.total_laporan) * 100),
formatPercentage(
!total.total_laporan_sudah_selesai || !total.total_laporan
? '0%'
: (total.total_laporan_sudah_selesai / total.total_laporan) * 100
),
formatNumber(total.total_laporan_belum_selesai),
formatPercentage((total.total_laporan_belum_selesai / total.total_laporan) * 100),
formatPercentage(
!total.total_laporan_belum_selesai || !total.total_laporan
? '0%'
: (total.total_laporan_belum_selesai / total.total_laporan) * 100
),
formatNumber(total.total_response_time_total),
formatNumber(
total.total_response_time_rata_rata.length
@ -178,9 +190,17 @@ const formatData = (rawData: any) => {
{ content: 'GRAND TOTAL', colSpan: 2, styles: { fontStyle: 'bold' } },
formatNumber(grandTotal.total_laporan),
formatNumber(grandTotal.total_laporan_sudah_selesai),
formatPercentage((grandTotal.total_laporan_sudah_selesai / grandTotal.total_laporan) * 100),
formatPercentage(
!grandTotal.total_laporan_sudah_selesai || !grandTotal.total_laporan
? '0%'
: (grandTotal.total_laporan_sudah_selesai / grandTotal.total_laporan) * 100
),
formatNumber(grandTotal.total_laporan_belum_selesai),
formatPercentage((grandTotal.total_laporan_belum_selesai / grandTotal.total_laporan) * 100),
formatPercentage(
!grandTotal.total_laporan_belum_selesai || !grandTotal.total_laporan
? '0%'
: (grandTotal.total_laporan_belum_selesai / grandTotal.total_laporan) * 100
),
formatNumber(grandTotal.total_response_time_total),
formatNumber(
grandTotal.total_response_time_rata_rata.length
@ -424,6 +444,9 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) =>
})
if (preview) {
doc.setProperties({
title: `${reportName}`
})
window.open(doc.output('bloburl'))
} else {
doc.save(`Laporan ${reportName}.pdf`, { returnPromise: true }).then(() => {
@ -625,7 +648,7 @@ const exportToXLSX = (reportMeta: any, e: any) => {
const exportDetailToXLSX = (reportMeta: any, e: any) => {
const meta = formatMetaData(reportMeta)
const workbook = new Workbook()
const worksheet = workbook.addWorksheet(`${reportName}`)
const worksheet = workbook.addWorksheet(`Detail ${reportName}`)
setHeaderStyle(worksheet, 1, 1, 'PT. PLN(Persero)')
setHeaderStyle(worksheet, 3, 8, `Daftar Detail ${reportName}`.toUpperCase(), true)

View File

@ -91,10 +91,14 @@ const formatData = (rawData: any, groupBy: boolean) => {
data[nama_uid][i].nama_regu,
formatNumber(data[nama_uid][i].total),
formatNumber(data[nama_uid][i].total_selesai),
formatPercentage((data[nama_uid][i].total_selesai / data[nama_uid][i].total) * 100),
formatPercentage(
!data[nama_uid][i].total || !data[nama_uid][i].total_selesai
? '0%'
: (data[nama_uid][i].total_selesai / data[nama_uid][i].total) * 100
),
formatNumber(data[nama_uid][i].total_inproses),
formatPercentage(
data[nama_uid][i].total_inproses == null || data[nama_uid][i].total == null
!data[nama_uid][i].total_inproses || !data[nama_uid][i].total
? '0%'
: (data[nama_uid][i].total_inproses / data[nama_uid][i].total) * 100
),
@ -149,9 +153,17 @@ const formatData = (rawData: any, groupBy: boolean) => {
{ content: 'TOTAL', colSpan: 3, styles: { fontStyle: 'bold' } },
formatNumber(total.total_laporan),
formatNumber(total.total_laporan_sudah_selesai),
formatPercentage((total.total_laporan_sudah_selesai / total.total_laporan) * 100),
formatPercentage(
!total.total_laporan || !total.total_laporan_sudah_selesai
? '0%'
: (total.total_laporan_sudah_selesai / total.total_laporan) * 100
),
formatNumber(total.total_laporan_belum_selesai),
formatPercentage((total.total_laporan_belum_selesai / total.total_laporan) * 100),
formatPercentage(
!total.total_laporan || !total.total_laporan_belum_selesai
? '0%'
: (total.total_laporan_belum_selesai / total.total_laporan) * 100
),
formatNumber(total.total_response_time_total),
formatNumber(
total.total_response_time_rata_rata.length
@ -184,10 +196,14 @@ const formatData = (rawData: any, groupBy: boolean) => {
rawData[i].nama_regu,
formatNumber(rawData[i].total),
formatNumber(rawData[i].total_selesai),
formatPercentage((rawData[i].total_selesai / rawData[i].total) * 100),
formatPercentage(
!rawData[i].total || !rawData[i].total_selesai
? '0%'
: (rawData[i].total_selesai / rawData[i].total) * 100
),
formatNumber(rawData[i].total_inproses),
formatPercentage(
rawData[i].total_inproses == null || rawData[i].total == null
!rawData[i].total_inproses || !rawData[i].total
? '0%'
: (rawData[i].total_inproses / rawData[i].total) * 100
),
@ -227,9 +243,17 @@ const formatData = (rawData: any, groupBy: boolean) => {
{ content: 'GRAND TOTAL', colSpan: 3, styles: { fontStyle: 'bold' } },
formatNumber(grandTotal.total_laporan),
formatNumber(grandTotal.total_laporan_sudah_selesai),
formatPercentage((grandTotal.total_laporan_sudah_selesai / grandTotal.total_laporan) * 100),
formatPercentage(
!grandTotal.total_laporan || !grandTotal.total_laporan_sudah_selesai
? '0%'
: (grandTotal.total_laporan_sudah_selesai / grandTotal.total_laporan) * 100
),
formatNumber(grandTotal.total_laporan_belum_selesai),
formatPercentage((grandTotal.total_laporan_belum_selesai / grandTotal.total_laporan) * 100),
formatPercentage(
!grandTotal.total_laporan || !grandTotal.total_laporan_belum_selesai
? '0%'
: (grandTotal.total_laporan_belum_selesai / grandTotal.total_laporan) * 100
),
formatNumber(grandTotal.total_response_time_total),
formatNumber(
grandTotal.total_response_time_rata_rata.length
@ -482,6 +506,9 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) =>
})
if (preview) {
doc.setProperties({
title: `${reportName}`
})
window.open(doc.output('bloburl'))
} else {
doc.save(`Laporan ${reportName}.pdf`, { returnPromise: true }).then(() => {
@ -692,7 +719,7 @@ const exportToXLSX = (reportMeta: any, e: any) => {
const exportDetailToXLSX = (reportMeta: any, e: any) => {
const meta = formatMetaData(reportMeta)
const workbook = new Workbook()
const worksheet = workbook.addWorksheet(`${reportName}`)
const worksheet = workbook.addWorksheet(`Detail ${reportName}`)
setHeaderStyle(worksheet, 1, 1, 'PT. PLN(Persero)')
setHeaderStyle(worksheet, 3, 8, `Daftar Detail ${reportName}`.toUpperCase(), true)

View File

@ -90,10 +90,14 @@ const formatData = (rawData: any, groupBy: boolean) => {
data[nama_uid][i].tanggal,
formatNumber(data[nama_uid][i].total),
formatNumber(data[nama_uid][i].total_selesai),
formatPercentage((data[nama_uid][i].total_selesai / data[nama_uid][i].total) * 100),
formatPercentage(
!data[nama_uid][i].total || !data[nama_uid][i].total_selesai
? '0%'
: (data[nama_uid][i].total_selesai / data[nama_uid][i].total) * 100
),
formatNumber(data[nama_uid][i].total_inproses),
formatPercentage(
data[nama_uid][i].total_inproses == null || data[nama_uid][i].total == null
!data[nama_uid][i].total_inproses || !data[nama_uid][i].total
? '0%'
: (data[nama_uid][i].total_inproses / data[nama_uid][i].total) * 100
),
@ -148,9 +152,17 @@ const formatData = (rawData: any, groupBy: boolean) => {
{ content: 'TOTAL', colSpan: 2, styles: { fontStyle: 'bold' } },
formatNumber(total.total_laporan),
formatNumber(total.total_laporan_sudah_selesai),
formatPercentage((total.total_laporan_sudah_selesai / total.total_laporan) * 100),
formatPercentage(
!total.total_laporan || !total.total_laporan_sudah_selesai
? '0%'
: (total.total_laporan_sudah_selesai / total.total_laporan) * 100
),
formatNumber(total.total_laporan_belum_selesai),
formatPercentage((total.total_laporan_belum_selesai / total.total_laporan) * 100),
formatPercentage(
!total.total_laporan_belum_selesai || !total.total_laporan
? '0%'
: (total.total_laporan_belum_selesai / total.total_laporan) * 100
),
formatNumber(total.total_response_time_total),
formatNumber(
total.total_response_time_rata_rata.length
@ -182,10 +194,14 @@ const formatData = (rawData: any, groupBy: boolean) => {
rawData[i].tanggal,
formatNumber(rawData[i].total),
formatNumber(rawData[i].total_selesai),
formatPercentage((rawData[i].total_selesai / rawData[i].total) * 100),
formatPercentage(
!rawData[i].total || !rawData[i].total_selesai
? '0%'
: (rawData[i].total_selesai / rawData[i].total) * 100
),
formatNumber(rawData[i].total_inproses),
formatPercentage(
rawData[i].total_inproses == null || rawData[i].total == null
!rawData[i].total_inproses || !rawData[i].total
? '0%'
: (rawData[i].total_inproses / rawData[i].total) * 100
),
@ -225,9 +241,17 @@ const formatData = (rawData: any, groupBy: boolean) => {
{ content: 'GRAND TOTAL', colSpan: 2, styles: { fontStyle: 'bold' } },
formatNumber(grandTotal.total_laporan),
formatNumber(grandTotal.total_laporan_sudah_selesai),
formatPercentage((grandTotal.total_laporan_sudah_selesai / grandTotal.total_laporan) * 100),
formatPercentage(
!grandTotal.total_laporan || !grandTotal.total_laporan_sudah_selesai
? '0%'
: (grandTotal.total_laporan_sudah_selesai / grandTotal.total_laporan) * 100
),
formatNumber(grandTotal.total_laporan_belum_selesai),
formatPercentage((grandTotal.total_laporan_belum_selesai / grandTotal.total_laporan) * 100),
formatPercentage(
!grandTotal.total_laporan_belum_selesai || !grandTotal.total_laporan
? '0%'
: (grandTotal.total_laporan_belum_selesai / grandTotal.total_laporan) * 100
),
formatNumber(grandTotal.total_response_time_total),
formatNumber(
grandTotal.total_response_time_rata_rata.length
@ -476,6 +500,9 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) =>
})
if (preview) {
doc.setProperties({
title: `${reportName}`
})
window.open(doc.output('bloburl'))
} else {
doc.save(`Laporan ${reportName}.pdf`, { returnPromise: true }).then(() => {
@ -686,7 +713,7 @@ const exportToXLSX = (reportMeta: any, e: any) => {
const exportDetailToXLSX = (reportMeta: any, e: any) => {
const meta = formatMetaData(reportMeta)
const workbook = new Workbook()
const worksheet = workbook.addWorksheet(`${reportName}`)
const worksheet = workbook.addWorksheet(`Detail ${reportName}`)
setHeaderStyle(worksheet, 1, 1, 'PT. PLN(Persero)')
setHeaderStyle(worksheet, 3, 8, `Daftar Detail ${reportName}`.toUpperCase(), true)

View File

@ -16,11 +16,13 @@ import { saveAs } from 'file-saver'
import { jsPDF } from 'jspdf'
import autoTable from 'jspdf-autotable'
import { Workbook } from 'exceljs'
import { formatWaktu } from '@/components/Form/FiltersType/reference'
import { setHeaderStyle } from '@/report/utils/xlsx'
import { formatNumber, formatPercentage } from '@/utils/numbers'
import { numberToStars } from '@/report/utils/rating'
const reportName = 'Rekapitulasi Rating Per Posko'
const fontSize = 5
const detailFontSize = 3
const groupingData = (data: any) => {
const groupedData: any = {}
@ -102,7 +104,6 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) =>
const doc = new jsPDF({
orientation: 'landscape'
})
const fontSize = 5
autoTable(doc, {
head: [
@ -257,6 +258,9 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) =>
})
if (preview) {
doc.setProperties({
title: `${reportName}`
})
window.open(doc.output('bloburl'))
} else {
doc.save(`Laporan ${reportName}.pdf`, { returnPromise: true }).then(() => {
@ -265,4 +269,231 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) =>
}
}
export { exportToPDF }
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',
'Rating',
'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,
numberToStars(item.nilai_rating),
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()
const worksheet = workbook.addWorksheet(`${reportName}`)
setHeaderStyle(worksheet, 1, 1, 'PT. PLN(Persero)')
setHeaderStyle(
worksheet,
2,
1,
`UNIT INDUK : ${
reportMeta.uid
? reportMeta.uid.name.toUpperCase()
: 'Semua Unit Induk Distribusi/Wilayah'.toUpperCase()
}`
)
setHeaderStyle(
worksheet,
3,
1,
`UNIT PELAKSANA PELAYANAN PELANGGAN : ${
reportMeta.up3
? reportMeta.up3.name.toUpperCase()
: 'Semua Unit Pelaksanaan Pelayanan Pelanggan'.toUpperCase()
}`
)
setHeaderStyle(worksheet, 5, 1, `${reportName}`.toUpperCase(), true)
setHeaderStyle(
worksheet,
6,
1,
`PERIODE TANGGAL : ${meta.dateFromFormat} SD TGL ${meta.dateToFormat}`,
true
)
worksheet.mergeCells('A1:Q1')
worksheet.mergeCells('A2:Q2')
worksheet.mergeCells('A3:Q3')
worksheet.mergeCells('A5:Q5')
worksheet.mergeCells('A6:Q6')
exportToExcel({
component: e.component,
worksheet,
autoFilterEnabled: true,
topLeftCell: { row: 8, column: 1 }
}).then(() => {
workbook.xlsx.writeBuffer().then((buffer: any) => {
saveAs(new Blob([buffer], { type: 'application/octet-stream' }), `Laporan ${reportName}.xlsx`)
})
})
e.cancel = true
}
const exportDetailToXLSX = (reportMeta: any, e: any) => {
const meta = formatMetaData(reportMeta)
const workbook = new Workbook()
const worksheet = workbook.addWorksheet(`Detail ${reportName}`)
setHeaderStyle(worksheet, 1, 1, 'PT. PLN(Persero)')
setHeaderStyle(worksheet, 3, 1, `Daftar Detail ${reportName}`.toUpperCase(), true)
setHeaderStyle(
worksheet,
4,
1,
`PERIODE TANGGAL : ${meta.dateFromFormat} SD TGL ${meta.dateToFormat}`,
true
)
worksheet.mergeCells('A3:R3')
worksheet.mergeCells('A4:R4')
exportToExcel({
component: e.component,
worksheet,
autoFilterEnabled: true,
topLeftCell: { row: 6, column: 1 }
}).then(() => {
workbook.xlsx.writeBuffer().then((buffer: any) => {
saveAs(
new Blob([buffer], { type: 'application/octet-stream' }),
`Laporan Detail ${reportName}.xlsx`
)
})
})
e.cancel = true
}
export { exportToPDF, exportToXLSX, exportDetailToPDF, exportDetailToXLSX }

View File

@ -16,11 +16,13 @@ import { saveAs } from 'file-saver'
import { jsPDF } from 'jspdf'
import autoTable from 'jspdf-autotable'
import { Workbook } from 'exceljs'
import { formatWaktu } from '@/components/Form/FiltersType/reference'
import { setHeaderStyle } from '@/report/utils/xlsx'
import { formatNumber, formatPercentage } from '@/utils/numbers'
import { numberToStars } from '@/report/utils/rating'
const reportName = 'Rekapitulasi Rating Per Regu'
const fontSize = 5
const detailFontSize = 3
const formatData = (rawData: any) => {
return rawData.map((item: any, i: any) => {
@ -77,7 +79,6 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) =>
const doc = new jsPDF({
orientation: 'landscape'
})
const fontSize = 5
autoTable(doc, {
head: [
@ -237,6 +238,9 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) =>
})
if (preview) {
doc.setProperties({
title: `${reportName}`
})
window.open(doc.output('bloburl'))
} else {
doc.save(`Laporan ${reportName}.pdf`, { returnPromise: true }).then(() => {
@ -245,4 +249,240 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) =>
}
}
export { exportToPDF }
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',
'Rating',
'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,
numberToStars(item.nilai_rating),
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()
const worksheet = workbook.addWorksheet(`${reportName}`)
setHeaderStyle(worksheet, 1, 1, 'PT. PLN(Persero)')
setHeaderStyle(
worksheet,
2,
1,
`UNIT INDUK : ${
reportMeta.uid
? reportMeta.uid.name.toUpperCase()
: 'Semua Unit Induk Distribusi/Wilayah'.toUpperCase()
}`
)
setHeaderStyle(
worksheet,
3,
1,
`UNIT PELAKSANA PELAYANAN PELANGGAN : ${
reportMeta.up3
? reportMeta.up3.name.toUpperCase()
: 'Semua Unit Pelaksanaan Pelayanan Pelanggan'.toUpperCase()
}`
)
setHeaderStyle(
worksheet,
4,
1,
`POSKO : ${
reportMeta.posko ? reportMeta.posko.name.toUpperCase() : 'Semua Posko'.toUpperCase()
}`
)
setHeaderStyle(worksheet, 7, 1, `${reportName}`.toUpperCase(), true)
setHeaderStyle(
worksheet,
8,
1,
`PERIODE TANGGAL : ${meta.dateFromFormat} SD TGL ${meta.dateToFormat}`,
true
)
worksheet.mergeCells('A1:Q1')
worksheet.mergeCells('A2:Q2')
worksheet.mergeCells('A3:Q3')
worksheet.mergeCells('A4:Q4')
worksheet.mergeCells('A7:Q7')
worksheet.mergeCells('A8:Q8')
exportToExcel({
component: e.component,
worksheet,
autoFilterEnabled: true,
topLeftCell: { row: 10, column: 1 }
}).then(() => {
workbook.xlsx.writeBuffer().then((buffer: any) => {
saveAs(new Blob([buffer], { type: 'application/octet-stream' }), `Laporan ${reportName}.xlsx`)
})
})
e.cancel = true
}
const exportDetailToXLSX = (reportMeta: any, e: any) => {
const meta = formatMetaData(reportMeta)
const workbook = new Workbook()
const worksheet = workbook.addWorksheet(`Detail ${reportName}`)
setHeaderStyle(worksheet, 1, 1, 'PT. PLN(Persero)')
setHeaderStyle(worksheet, 3, 1, `Daftar Detail ${reportName}`.toUpperCase(), true)
setHeaderStyle(
worksheet,
4,
1,
`PERIODE TANGGAL : ${meta.dateFromFormat} SD TGL ${meta.dateToFormat}`,
true
)
worksheet.mergeCells('A3:R3')
worksheet.mergeCells('A4:R4')
exportToExcel({
component: e.component,
worksheet,
autoFilterEnabled: true,
topLeftCell: { row: 6, column: 1 }
}).then(() => {
workbook.xlsx.writeBuffer().then((buffer: any) => {
saveAs(
new Blob([buffer], { type: 'application/octet-stream' }),
`Laporan Detail ${reportName}.xlsx`
)
})
})
e.cancel = true
}
export { exportToPDF, exportToXLSX, exportDetailToPDF, exportDetailToXLSX }

View File

@ -0,0 +1,5 @@
export const numberToStars = (rating: number) => {
const stars = rating ? Math.round(rating) : 0
return stars ? '*'.repeat(stars) : 'Tidak ada'
}