fix: report in monalisa gangguan
This commit is contained in:
@ -1,17 +1,4 @@
|
|||||||
import { exportDataGrid as exportToExcel } from 'devextreme/excel_exporter'
|
import { exportDataGrid as exportToExcel } from 'devextreme/excel_exporter'
|
||||||
import {
|
|
||||||
Document,
|
|
||||||
AlignmentType,
|
|
||||||
Packer,
|
|
||||||
Paragraph,
|
|
||||||
Table,
|
|
||||||
TableCell,
|
|
||||||
TableRow,
|
|
||||||
VerticalAlign,
|
|
||||||
TextRun,
|
|
||||||
WidthType,
|
|
||||||
PageOrientation
|
|
||||||
} from 'docx'
|
|
||||||
import { saveAs } from 'file-saver'
|
import { saveAs } from 'file-saver'
|
||||||
import { jsPDF } from 'jspdf'
|
import { jsPDF } from 'jspdf'
|
||||||
import autoTable from 'jspdf-autotable'
|
import autoTable from 'jspdf-autotable'
|
||||||
@ -26,9 +13,46 @@ const reportName = 'Dispacthing Time (DT) Gangguan'
|
|||||||
const fontSize = 5
|
const fontSize = 5
|
||||||
const detailFontSize = 3
|
const detailFontSize = 3
|
||||||
|
|
||||||
const groupingData = (data: any) => {
|
const getGroupParent = (reportMeta: any) => {
|
||||||
|
if (reportMeta.ulp.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.ulp.name,
|
||||||
|
summaryName: reportMeta.ulp.name,
|
||||||
|
summaryKey: 'nama_ulp'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reportMeta.up3.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.up3.name,
|
||||||
|
summaryName: reportMeta.up3.name,
|
||||||
|
summaryKey: 'nama_up3'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reportMeta.uid.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.uid.name,
|
||||||
|
summaryName: reportMeta.uid.name,
|
||||||
|
summaryKey: 'nama_uid'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reportMeta.regional.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.regional.name,
|
||||||
|
summaryName: reportMeta.regional.name,
|
||||||
|
summaryKey: 'nama_regional'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
|
const groupingData = (data: any, reportMeta: any) => {
|
||||||
const groupedData: any = {}
|
const groupedData: any = {}
|
||||||
|
|
||||||
|
if (reportMeta.regional.id == 0) {
|
||||||
data.forEach((item: any) => {
|
data.forEach((item: any) => {
|
||||||
const { nama_regional } = item
|
const { nama_regional } = item
|
||||||
|
|
||||||
@ -64,10 +88,36 @@ const groupingData = (data: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return groupedData
|
return groupedData
|
||||||
|
} else {
|
||||||
|
const groupParent = getGroupParent(reportMeta)
|
||||||
|
|
||||||
|
if (groupParent === '') {
|
||||||
|
return {
|
||||||
|
data,
|
||||||
|
parent: '',
|
||||||
|
summaryName: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data.forEach((item: any) => {
|
||||||
|
const group = item[groupParent.summaryKey]
|
||||||
|
|
||||||
|
if (!groupedData[group]) {
|
||||||
|
groupedData[group] = []
|
||||||
|
}
|
||||||
|
|
||||||
|
groupedData[group].push(item)
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: groupedData,
|
||||||
|
parent: groupParent.parent,
|
||||||
|
summaryName: groupParent.summaryName
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const formatData = (rawData: any) => {
|
const formatData = (rawData: any, reportMeta: any) => {
|
||||||
const data = groupingData(rawData)
|
|
||||||
const formattedData: any = []
|
const formattedData: any = []
|
||||||
|
|
||||||
const total: any = {
|
const total: any = {
|
||||||
@ -77,6 +127,10 @@ const formatData = (rawData: any) => {
|
|||||||
yoy_tahun_ini: []
|
yoy_tahun_ini: []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (reportMeta.regional.id == 0) {
|
||||||
|
const data = groupingData(rawData, reportMeta)
|
||||||
|
const formattedData: any = []
|
||||||
|
|
||||||
formattedData.push([{ content: 'NASIONAL', colSpan: 7, styles: { fontStyle: 'bold' } }])
|
formattedData.push([{ content: 'NASIONAL', colSpan: 7, styles: { fontStyle: 'bold' } }])
|
||||||
|
|
||||||
let no = 1
|
let no = 1
|
||||||
@ -91,14 +145,16 @@ const formatData = (rawData: any) => {
|
|||||||
formatPercentage(
|
formatPercentage(
|
||||||
!summary.mom_bulan_ini || !summary.mom_bulan_kemarin
|
!summary.mom_bulan_ini || !summary.mom_bulan_kemarin
|
||||||
? '0%'
|
? '0%'
|
||||||
: ((summary.mom_bulan_kemarin - summary.mom_bulan_ini) / summary.mom_bulan_kemarin) * 100
|
: ((summary.mom_bulan_kemarin - summary.mom_bulan_ini) / summary.mom_bulan_kemarin) *
|
||||||
|
100
|
||||||
),
|
),
|
||||||
formatNumber(summary.yoy_tahun_kemarin),
|
formatNumber(summary.yoy_tahun_kemarin),
|
||||||
formatNumber(summary.yoy_tahun_ini),
|
formatNumber(summary.yoy_tahun_ini),
|
||||||
formatPercentage(
|
formatPercentage(
|
||||||
!summary.yoy_tahun_ini || !summary.yoy_tahun_kemarin
|
!summary.yoy_tahun_ini || !summary.yoy_tahun_kemarin
|
||||||
? '0%'
|
? '0%'
|
||||||
: ((summary.yoy_tahun_kemarin - summary.yoy_tahun_ini) / summary.yoy_tahun_kemarin) * 100
|
: ((summary.yoy_tahun_kemarin - summary.yoy_tahun_ini) / summary.yoy_tahun_kemarin) *
|
||||||
|
100
|
||||||
)
|
)
|
||||||
])
|
])
|
||||||
|
|
||||||
@ -138,6 +194,59 @@ const formatData = (rawData: any) => {
|
|||||||
])
|
])
|
||||||
|
|
||||||
return formattedData
|
return formattedData
|
||||||
|
} else {
|
||||||
|
const tempData = groupingData(rawData, reportMeta)
|
||||||
|
const data = tempData.data[tempData.summaryName] || tempData.data
|
||||||
|
const formattedData: any = []
|
||||||
|
|
||||||
|
let parentName = tempData.parent
|
||||||
|
let summaryName = tempData.summaryName ? tempData.summaryName : 'Seluruh Unit'
|
||||||
|
|
||||||
|
data.forEach((item: any) => {
|
||||||
|
total.mom_bulan_kemarin.push(item.mom_bulan_kemarin)
|
||||||
|
total.mom_bulan_ini.push(item.mom_bulan_ini)
|
||||||
|
total.yoy_tahun_kemarin.push(item.yoy_tahun_kemarin)
|
||||||
|
total.yoy_tahun_ini.push(item.yoy_tahun_ini)
|
||||||
|
})
|
||||||
|
|
||||||
|
const totalMoMBulanKemarin =
|
||||||
|
total.mom_bulan_kemarin.reduce((a: number, b: number) => a + b, 0) /
|
||||||
|
total.mom_bulan_kemarin.length
|
||||||
|
const totalMoMBulanIni =
|
||||||
|
total.mom_bulan_ini.reduce((a: number, b: number) => a + b, 0) / total.mom_bulan_ini.length
|
||||||
|
const totalYoYTahunKemarin =
|
||||||
|
total.yoy_tahun_kemarin.reduce((a: number, b: number) => a + b, 0) /
|
||||||
|
total.yoy_tahun_kemarin.length
|
||||||
|
const totalYoYTahunIni =
|
||||||
|
total.yoy_tahun_ini.reduce((a: number, b: number) => a + b, 0) / total.yoy_tahun_ini.length
|
||||||
|
|
||||||
|
formattedData.push([{ content: parentName, colSpan: 7, styles: { fontStyle: 'bold' } }])
|
||||||
|
|
||||||
|
const result = [
|
||||||
|
formatNumber(totalMoMBulanKemarin),
|
||||||
|
formatNumber(totalMoMBulanIni),
|
||||||
|
formatPercentage(
|
||||||
|
!totalMoMBulanIni || !totalMoMBulanKemarin
|
||||||
|
? '0%'
|
||||||
|
: ((totalMoMBulanKemarin - totalMoMBulanIni) / totalMoMBulanKemarin) * 100
|
||||||
|
),
|
||||||
|
formatNumber(totalYoYTahunKemarin),
|
||||||
|
formatNumber(totalYoYTahunIni),
|
||||||
|
formatPercentage(
|
||||||
|
!totalYoYTahunIni || !totalYoYTahunKemarin
|
||||||
|
? '0%'
|
||||||
|
: ((totalYoYTahunKemarin - totalYoYTahunIni) / totalYoYTahunKemarin) * 100
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
|
formattedData.push([{ content: '1', styles: { halign: 'right' } }, summaryName, ...result])
|
||||||
|
formattedData.push([
|
||||||
|
{ content: 'TOTAL RATA-RATA', colSpan: 2, styles: { fontStyle: 'bold' } },
|
||||||
|
...result
|
||||||
|
])
|
||||||
|
|
||||||
|
return formattedData
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) => {
|
const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) => {
|
||||||
@ -145,7 +254,7 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) =>
|
|||||||
const date = new Date().getDate()
|
const date = new Date().getDate()
|
||||||
const month = new Date().toLocaleString('id-ID', { month: 'long' })
|
const month = new Date().toLocaleString('id-ID', { month: 'long' })
|
||||||
const year = new Date().getFullYear()
|
const year = new Date().getFullYear()
|
||||||
const data = formatData(rawData)
|
const data = formatData(rawData, reportMeta)
|
||||||
const doc = new jsPDF({
|
const doc = new jsPDF({
|
||||||
orientation: 'landscape'
|
orientation: 'landscape'
|
||||||
})
|
})
|
||||||
@ -466,7 +575,8 @@ const exportToXLSX = (reportMeta: any, e: any) => {
|
|||||||
worksheet,
|
worksheet,
|
||||||
2,
|
2,
|
||||||
1,
|
1,
|
||||||
`UNIT INDUK : ${reportMeta.uid
|
`UNIT INDUK : ${
|
||||||
|
reportMeta.uid
|
||||||
? reportMeta.uid.name.toUpperCase()
|
? reportMeta.uid.name.toUpperCase()
|
||||||
: 'Semua Unit Induk Distribusi/Wilayah'.toUpperCase()
|
: 'Semua Unit Induk Distribusi/Wilayah'.toUpperCase()
|
||||||
}`
|
}`
|
||||||
@ -475,7 +585,8 @@ const exportToXLSX = (reportMeta: any, e: any) => {
|
|||||||
worksheet,
|
worksheet,
|
||||||
3,
|
3,
|
||||||
1,
|
1,
|
||||||
`UNIT PELAKSANA PELAYANAN PELANGGAN : ${reportMeta.up3
|
`UNIT PELAKSANA PELAYANAN PELANGGAN : ${
|
||||||
|
reportMeta.up3
|
||||||
? reportMeta.up3.name.toUpperCase()
|
? reportMeta.up3.name.toUpperCase()
|
||||||
: 'Semua Unit Pelaksanaan Pelayanan Pelanggan'.toUpperCase()
|
: 'Semua Unit Pelaksanaan Pelayanan Pelanggan'.toUpperCase()
|
||||||
}`
|
}`
|
||||||
@ -484,7 +595,8 @@ const exportToXLSX = (reportMeta: any, e: any) => {
|
|||||||
worksheet,
|
worksheet,
|
||||||
4,
|
4,
|
||||||
1,
|
1,
|
||||||
`UNIT LAYANAN PELANGGAN : ${reportMeta.ulp
|
`UNIT LAYANAN PELANGGAN : ${
|
||||||
|
reportMeta.ulp
|
||||||
? reportMeta.ulp.name.toUpperCase()
|
? reportMeta.ulp.name.toUpperCase()
|
||||||
: 'Semua Unit Layanan Pelanggan'.toUpperCase()
|
: 'Semua Unit Layanan Pelanggan'.toUpperCase()
|
||||||
}`
|
}`
|
||||||
@ -493,7 +605,8 @@ const exportToXLSX = (reportMeta: any, e: any) => {
|
|||||||
worksheet,
|
worksheet,
|
||||||
5,
|
5,
|
||||||
1,
|
1,
|
||||||
`REGIONAL : ${reportMeta.regional ? reportMeta.regional.name.toUpperCase() : 'Semua Regional'.toUpperCase()
|
`REGIONAL : ${
|
||||||
|
reportMeta.regional ? reportMeta.regional.name.toUpperCase() : 'Semua Regional'.toUpperCase()
|
||||||
}`
|
}`
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -558,9 +671,16 @@ const exportDetailToXLSX = (reportMeta: any, e: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const exportToDOCX = (reportMeta: any, rawData: any) => {
|
const exportToDOCX = (reportMeta: any, rawData: any) => {
|
||||||
exportToWord(reportMeta, formatData(rawData), `Laporan ${reportName}`, null)
|
exportToWord(reportMeta, formatData(rawData, reportMeta), `Laporan ${reportName}`, null)
|
||||||
}
|
}
|
||||||
const exportDetailToDOCX = (reportMeta: any, rawData: any) => {
|
const exportDetailToDOCX = (reportMeta: any, rawData: any) => {
|
||||||
exportDetailToWord(reportMeta, rawData, `Laporan Detail ${reportName}`, null)
|
exportDetailToWord(reportMeta, rawData, `Laporan Detail ${reportName}`, null)
|
||||||
}
|
}
|
||||||
export { exportToPDF, exportDetailToPDF, exportToXLSX, exportDetailToXLSX, exportToDOCX, exportDetailToDOCX }
|
export {
|
||||||
|
exportToPDF,
|
||||||
|
exportDetailToPDF,
|
||||||
|
exportToXLSX,
|
||||||
|
exportDetailToXLSX,
|
||||||
|
exportToDOCX,
|
||||||
|
exportDetailToDOCX
|
||||||
|
}
|
||||||
|
@ -1,17 +1,4 @@
|
|||||||
import { exportDataGrid as exportToExcel } from 'devextreme/excel_exporter'
|
import { exportDataGrid as exportToExcel } from 'devextreme/excel_exporter'
|
||||||
import {
|
|
||||||
Document,
|
|
||||||
AlignmentType,
|
|
||||||
Packer,
|
|
||||||
Paragraph,
|
|
||||||
Table,
|
|
||||||
TableCell,
|
|
||||||
TableRow,
|
|
||||||
VerticalAlign,
|
|
||||||
TextRun,
|
|
||||||
WidthType,
|
|
||||||
PageOrientation
|
|
||||||
} from 'docx'
|
|
||||||
import { saveAs } from 'file-saver'
|
import { saveAs } from 'file-saver'
|
||||||
import { jsPDF } from 'jspdf'
|
import { jsPDF } from 'jspdf'
|
||||||
import autoTable from 'jspdf-autotable'
|
import autoTable from 'jspdf-autotable'
|
||||||
@ -24,9 +11,46 @@ import { exportToWord } from './doc/MonalisaGR_ENSGangguan_DOC'
|
|||||||
const reportName = 'Rekapitulasi ENS Gangguan'
|
const reportName = 'Rekapitulasi ENS Gangguan'
|
||||||
const fontSize = 5
|
const fontSize = 5
|
||||||
|
|
||||||
const groupingData = (data: any) => {
|
const getGroupParent = (reportMeta: any) => {
|
||||||
|
if (reportMeta.ulp.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.ulp.name,
|
||||||
|
summaryName: reportMeta.ulp.name,
|
||||||
|
summaryKey: 'nama_ulp'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reportMeta.up3.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.up3.name,
|
||||||
|
summaryName: reportMeta.up3.name,
|
||||||
|
summaryKey: 'nama_up3'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reportMeta.uid.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.uid.name,
|
||||||
|
summaryName: reportMeta.uid.name,
|
||||||
|
summaryKey: 'nama_uid'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reportMeta.regional.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.regional.name,
|
||||||
|
summaryName: reportMeta.regional.name,
|
||||||
|
summaryKey: 'nama_regional'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
|
const groupingData = (data: any, reportMeta: any) => {
|
||||||
const groupedData: any = {}
|
const groupedData: any = {}
|
||||||
|
|
||||||
|
if (reportMeta.regional.id == 0) {
|
||||||
data.forEach((item: any) => {
|
data.forEach((item: any) => {
|
||||||
const { nama_regional } = item
|
const { nama_regional } = item
|
||||||
|
|
||||||
@ -62,10 +86,36 @@ const groupingData = (data: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return groupedData
|
return groupedData
|
||||||
|
} else {
|
||||||
|
const groupParent = getGroupParent(reportMeta)
|
||||||
|
|
||||||
|
if (groupParent === '') {
|
||||||
|
return {
|
||||||
|
data,
|
||||||
|
parent: '',
|
||||||
|
summaryName: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data.forEach((item: any) => {
|
||||||
|
const group = item[groupParent.summaryKey]
|
||||||
|
|
||||||
|
if (!groupedData[group]) {
|
||||||
|
groupedData[group] = []
|
||||||
|
}
|
||||||
|
|
||||||
|
groupedData[group].push(item)
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: groupedData,
|
||||||
|
parent: groupParent.parent,
|
||||||
|
summaryName: groupParent.summaryName
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const formatData = (rawData: any) => {
|
const formatData = (rawData: any, reportMeta: any) => {
|
||||||
const data = groupingData(rawData)
|
|
||||||
const formattedData: any = []
|
const formattedData: any = []
|
||||||
|
|
||||||
const total: any = {
|
const total: any = {
|
||||||
@ -75,6 +125,9 @@ const formatData = (rawData: any) => {
|
|||||||
yoy_tahun_ini: 0
|
yoy_tahun_ini: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (reportMeta.regional.id == 0) {
|
||||||
|
const data = groupingData(rawData, reportMeta)
|
||||||
|
|
||||||
formattedData.push([{ content: 'NASIONAL', colSpan: 7, styles: { fontStyle: 'bold' } }])
|
formattedData.push([{ content: 'NASIONAL', colSpan: 7, styles: { fontStyle: 'bold' } }])
|
||||||
|
|
||||||
let no = 1
|
let no = 1
|
||||||
@ -89,14 +142,16 @@ const formatData = (rawData: any) => {
|
|||||||
formatPercentage(
|
formatPercentage(
|
||||||
!summary.mom_bulan_ini || !summary.mom_bulan_kemarin
|
!summary.mom_bulan_ini || !summary.mom_bulan_kemarin
|
||||||
? '0%'
|
? '0%'
|
||||||
: ((summary.mom_bulan_kemarin - summary.mom_bulan_ini) / summary.mom_bulan_kemarin) * 100
|
: ((summary.mom_bulan_kemarin - summary.mom_bulan_ini) / summary.mom_bulan_kemarin) *
|
||||||
|
100
|
||||||
),
|
),
|
||||||
formatNumber(summary.yoy_tahun_kemarin),
|
formatNumber(summary.yoy_tahun_kemarin),
|
||||||
formatNumber(summary.yoy_tahun_ini),
|
formatNumber(summary.yoy_tahun_ini),
|
||||||
formatPercentage(
|
formatPercentage(
|
||||||
!summary.yoy_tahun_ini || !summary.yoy_tahun_kemarin
|
!summary.yoy_tahun_ini || !summary.yoy_tahun_kemarin
|
||||||
? '0%'
|
? '0%'
|
||||||
: ((summary.yoy_tahun_kemarin - summary.yoy_tahun_ini) / summary.yoy_tahun_kemarin) * 100
|
: ((summary.yoy_tahun_kemarin - summary.yoy_tahun_ini) / summary.yoy_tahun_kemarin) *
|
||||||
|
100
|
||||||
)
|
)
|
||||||
])
|
])
|
||||||
|
|
||||||
@ -125,6 +180,45 @@ const formatData = (rawData: any) => {
|
|||||||
])
|
])
|
||||||
|
|
||||||
return formattedData
|
return formattedData
|
||||||
|
} else {
|
||||||
|
const tempData = groupingData(rawData, reportMeta)
|
||||||
|
const data = tempData.data[tempData.summaryName] || tempData.data
|
||||||
|
const formattedData: any = []
|
||||||
|
|
||||||
|
let parentName = tempData.parent
|
||||||
|
let summaryName = tempData.summaryName ? tempData.summaryName : 'Seluruh Unit'
|
||||||
|
|
||||||
|
data.forEach((item: any) => {
|
||||||
|
total.mom_bulan_kemarin += item.mom_bulan_kemarin
|
||||||
|
total.mom_bulan_ini += item.mom_bulan_ini
|
||||||
|
total.yoy_tahun_kemarin += item.yoy_tahun_kemarin
|
||||||
|
total.yoy_tahun_ini += item.yoy_tahun_ini
|
||||||
|
})
|
||||||
|
|
||||||
|
formattedData.push([{ content: parentName, colSpan: 7, styles: { fontStyle: 'bold' } }])
|
||||||
|
|
||||||
|
const result = [
|
||||||
|
formatNumber(total.mom_bulan_kemarin),
|
||||||
|
formatNumber(total.mom_bulan_ini),
|
||||||
|
formatPercentage(
|
||||||
|
!total.mom_bulan_ini || !total.mom_bulan_kemarin
|
||||||
|
? '0%'
|
||||||
|
: ((total.mom_bulan_kemarin - total.mom_bulan_ini) / total.mom_bulan_kemarin) * 100
|
||||||
|
),
|
||||||
|
formatNumber(total.yoy_tahun_kemarin),
|
||||||
|
formatNumber(total.yoy_tahun_ini),
|
||||||
|
formatPercentage(
|
||||||
|
!total.yoy_tahun_ini || !total.yoy_tahun_kemarin
|
||||||
|
? '0%'
|
||||||
|
: ((total.yoy_tahun_kemarin - total.yoy_tahun_ini) / total.yoy_tahun_kemarin) * 100
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
|
formattedData.push([{ content: '1', styles: { halign: 'right' } }, summaryName, ...result])
|
||||||
|
formattedData.push([{ content: 'TOTAL', colSpan: 2, styles: { fontStyle: 'bold' } }, ...result])
|
||||||
|
|
||||||
|
return formattedData
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) => {
|
const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) => {
|
||||||
@ -132,7 +226,7 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) =>
|
|||||||
const date = new Date().getDate()
|
const date = new Date().getDate()
|
||||||
const month = new Date().toLocaleString('id-ID', { month: 'long' })
|
const month = new Date().toLocaleString('id-ID', { month: 'long' })
|
||||||
const year = new Date().getFullYear()
|
const year = new Date().getFullYear()
|
||||||
const data = formatData(rawData)
|
const data = formatData(rawData, reportMeta)
|
||||||
const doc = new jsPDF({
|
const doc = new jsPDF({
|
||||||
orientation: 'landscape'
|
orientation: 'landscape'
|
||||||
})
|
})
|
||||||
@ -370,6 +464,6 @@ const exportToXLSX = (reportMeta: any, e: any) => {
|
|||||||
e.cancel = true
|
e.cancel = true
|
||||||
}
|
}
|
||||||
const exportToDOCX = (reportMeta: any, rawData: any) => {
|
const exportToDOCX = (reportMeta: any, rawData: any) => {
|
||||||
exportToWord(reportMeta, formatData(rawData), `Laporan ${reportName}`, null)
|
exportToWord(reportMeta, formatData(rawData, reportMeta), `Laporan ${reportName}`, null)
|
||||||
}
|
}
|
||||||
export { exportToPDF, exportToXLSX , exportToDOCX}
|
export { exportToPDF, exportToXLSX, exportToDOCX }
|
||||||
|
@ -1,17 +1,4 @@
|
|||||||
import { exportDataGrid as exportToExcel } from 'devextreme/excel_exporter'
|
import { exportDataGrid as exportToExcel } from 'devextreme/excel_exporter'
|
||||||
import {
|
|
||||||
Document,
|
|
||||||
AlignmentType,
|
|
||||||
Packer,
|
|
||||||
Paragraph,
|
|
||||||
Table,
|
|
||||||
TableCell,
|
|
||||||
TableRow,
|
|
||||||
VerticalAlign,
|
|
||||||
TextRun,
|
|
||||||
WidthType,
|
|
||||||
PageOrientation
|
|
||||||
} from 'docx'
|
|
||||||
import { saveAs } from 'file-saver'
|
import { saveAs } from 'file-saver'
|
||||||
import { jsPDF } from 'jspdf'
|
import { jsPDF } from 'jspdf'
|
||||||
import autoTable from 'jspdf-autotable'
|
import autoTable from 'jspdf-autotable'
|
||||||
@ -25,9 +12,46 @@ const reportName = 'Rekapitulasi Gangguan Belum Selesai'
|
|||||||
const fontSize = 5
|
const fontSize = 5
|
||||||
const detailFontSize = 3
|
const detailFontSize = 3
|
||||||
|
|
||||||
const groupingData = (data: any) => {
|
const getGroupParent = (reportMeta: any) => {
|
||||||
|
if (reportMeta.ulp.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.ulp.name,
|
||||||
|
summaryName: reportMeta.ulp.name,
|
||||||
|
summaryKey: 'nama_ulp'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reportMeta.up3.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.up3.name,
|
||||||
|
summaryName: reportMeta.up3.name,
|
||||||
|
summaryKey: 'nama_up3'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reportMeta.uid.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.uid.name,
|
||||||
|
summaryName: reportMeta.uid.name,
|
||||||
|
summaryKey: 'nama_uid'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reportMeta.regional.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.regional.name,
|
||||||
|
summaryName: reportMeta.regional.name,
|
||||||
|
summaryKey: 'nama_regional'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
|
const groupingData = (data: any, reportMeta: any) => {
|
||||||
const groupedData: any = {}
|
const groupedData: any = {}
|
||||||
|
|
||||||
|
if (reportMeta.regional.id == 0) {
|
||||||
data.forEach((item: any) => {
|
data.forEach((item: any) => {
|
||||||
const { nama_regional } = item
|
const { nama_regional } = item
|
||||||
|
|
||||||
@ -57,10 +81,36 @@ const groupingData = (data: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return groupedData
|
return groupedData
|
||||||
|
} else {
|
||||||
|
const groupParent = getGroupParent(reportMeta)
|
||||||
|
|
||||||
|
if (groupParent === '') {
|
||||||
|
return {
|
||||||
|
data,
|
||||||
|
parent: '',
|
||||||
|
summaryName: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data.forEach((item: any) => {
|
||||||
|
const group = item[groupParent.summaryKey]
|
||||||
|
|
||||||
|
if (!groupedData[group]) {
|
||||||
|
groupedData[group] = []
|
||||||
|
}
|
||||||
|
|
||||||
|
groupedData[group].push(item)
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: groupedData,
|
||||||
|
parent: groupParent.parent,
|
||||||
|
summaryName: groupParent.summaryName
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const formatData = (rawData: any) => {
|
const formatData = (rawData: any, reportMeta: any) => {
|
||||||
const data = groupingData(rawData)
|
|
||||||
const formattedData: any = []
|
const formattedData: any = []
|
||||||
|
|
||||||
const total: any = {
|
const total: any = {
|
||||||
@ -69,6 +119,15 @@ const formatData = (rawData: any) => {
|
|||||||
total: 0
|
total: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (reportMeta.regional.id == 0) {
|
||||||
|
const data = groupingData(rawData, reportMeta)
|
||||||
|
|
||||||
|
const total: any = {
|
||||||
|
jumlah_gangguan: 0,
|
||||||
|
jumlah_informasi: 0,
|
||||||
|
total: 0
|
||||||
|
}
|
||||||
|
|
||||||
formattedData.push([{ content: 'NASIONAL', colSpan: 5, styles: { fontStyle: 'bold' } }])
|
formattedData.push([{ content: 'NASIONAL', colSpan: 5, styles: { fontStyle: 'bold' } }])
|
||||||
|
|
||||||
let no = 1
|
let no = 1
|
||||||
@ -96,6 +155,33 @@ const formatData = (rawData: any) => {
|
|||||||
])
|
])
|
||||||
|
|
||||||
return formattedData
|
return formattedData
|
||||||
|
} else {
|
||||||
|
const tempData = groupingData(rawData, reportMeta)
|
||||||
|
const data = tempData.data[tempData.summaryName] || tempData.data
|
||||||
|
const formattedData: any = []
|
||||||
|
|
||||||
|
let parentName = tempData.parent
|
||||||
|
let summaryName = tempData.summaryName ? tempData.summaryName : 'Seluruh Unit'
|
||||||
|
|
||||||
|
data.forEach((item: any) => {
|
||||||
|
total.jumlah_gangguan += item.jumlah_gangguan
|
||||||
|
total.jumlah_informasi += item.jumlah_informasi
|
||||||
|
total.total += item.total
|
||||||
|
})
|
||||||
|
|
||||||
|
formattedData.push([{ content: parentName, colSpan: 5, styles: { fontStyle: 'bold' } }])
|
||||||
|
|
||||||
|
const result = [
|
||||||
|
formatNumber(total.jumlah_gangguan),
|
||||||
|
formatNumber(total.jumlah_informasi),
|
||||||
|
formatNumber(total.total)
|
||||||
|
]
|
||||||
|
|
||||||
|
formattedData.push([{ content: '1', styles: { halign: 'right' } }, summaryName, ...result])
|
||||||
|
formattedData.push([{ content: 'TOTAL', colSpan: 2, styles: { fontStyle: 'bold' } }, ...result])
|
||||||
|
|
||||||
|
return formattedData
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) => {
|
const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) => {
|
||||||
@ -103,7 +189,7 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) =>
|
|||||||
const date = new Date().getDate()
|
const date = new Date().getDate()
|
||||||
const month = new Date().toLocaleString('id-ID', { month: 'long' })
|
const month = new Date().toLocaleString('id-ID', { month: 'long' })
|
||||||
const year = new Date().getFullYear()
|
const year = new Date().getFullYear()
|
||||||
const data = formatData(rawData)
|
const data = formatData(rawData, reportMeta)
|
||||||
const doc = new jsPDF({
|
const doc = new jsPDF({
|
||||||
orientation: 'landscape'
|
orientation: 'landscape'
|
||||||
})
|
})
|
||||||
@ -392,7 +478,8 @@ const exportToXLSX = (reportMeta: any, e: any) => {
|
|||||||
worksheet,
|
worksheet,
|
||||||
2,
|
2,
|
||||||
1,
|
1,
|
||||||
`UNIT INDUK : ${reportMeta.uid
|
`UNIT INDUK : ${
|
||||||
|
reportMeta.uid
|
||||||
? reportMeta.uid.name.toUpperCase()
|
? reportMeta.uid.name.toUpperCase()
|
||||||
: 'Semua Unit Induk Distribusi/Wilayah'.toUpperCase()
|
: 'Semua Unit Induk Distribusi/Wilayah'.toUpperCase()
|
||||||
}`
|
}`
|
||||||
@ -401,7 +488,8 @@ const exportToXLSX = (reportMeta: any, e: any) => {
|
|||||||
worksheet,
|
worksheet,
|
||||||
3,
|
3,
|
||||||
1,
|
1,
|
||||||
`UNIT PELAKSANA PELAYANAN PELANGGAN : ${reportMeta.up3
|
`UNIT PELAKSANA PELAYANAN PELANGGAN : ${
|
||||||
|
reportMeta.up3
|
||||||
? reportMeta.up3.name.toUpperCase()
|
? reportMeta.up3.name.toUpperCase()
|
||||||
: 'Semua Unit Pelaksanaan Pelayanan Pelanggan'.toUpperCase()
|
: 'Semua Unit Pelaksanaan Pelayanan Pelanggan'.toUpperCase()
|
||||||
}`
|
}`
|
||||||
@ -410,7 +498,8 @@ const exportToXLSX = (reportMeta: any, e: any) => {
|
|||||||
worksheet,
|
worksheet,
|
||||||
4,
|
4,
|
||||||
1,
|
1,
|
||||||
`UNIT LAYANAN PELANGGAN : ${reportMeta.ulp
|
`UNIT LAYANAN PELANGGAN : ${
|
||||||
|
reportMeta.ulp
|
||||||
? reportMeta.ulp.name.toUpperCase()
|
? reportMeta.ulp.name.toUpperCase()
|
||||||
: 'Semua Unit Layanan Pelanggan'.toUpperCase()
|
: 'Semua Unit Layanan Pelanggan'.toUpperCase()
|
||||||
}`
|
}`
|
||||||
@ -419,7 +508,8 @@ const exportToXLSX = (reportMeta: any, e: any) => {
|
|||||||
worksheet,
|
worksheet,
|
||||||
5,
|
5,
|
||||||
1,
|
1,
|
||||||
`REGIONAL : ${reportMeta.regional ? reportMeta.regional.name.toUpperCase() : 'Semua Regional'.toUpperCase()
|
`REGIONAL : ${
|
||||||
|
reportMeta.regional ? reportMeta.regional.name.toUpperCase() : 'Semua Regional'.toUpperCase()
|
||||||
}`
|
}`
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -488,9 +578,16 @@ const exportDetailToXLSX = (reportMeta: any, e: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const exportToDOCX = (reportMeta: any, rawData: any) => {
|
const exportToDOCX = (reportMeta: any, rawData: any) => {
|
||||||
exportToWord(reportMeta, formatData(rawData), `Laporan ${reportName}`, null)
|
exportToWord(reportMeta, formatData(rawData, reportMeta), `Laporan ${reportName}`, null)
|
||||||
}
|
}
|
||||||
const exportDetailToDOCX = (reportMeta: any, rawData: any) => {
|
const exportDetailToDOCX = (reportMeta: any, rawData: any) => {
|
||||||
exportDetailToWord(reportMeta, rawData, `Laporan Detail ${reportName}`, null)
|
exportDetailToWord(reportMeta, rawData, `Laporan Detail ${reportName}`, null)
|
||||||
}
|
}
|
||||||
export { exportToPDF, exportDetailToPDF, exportToXLSX, exportDetailToXLSX, exportToDOCX, exportDetailToDOCX }
|
export {
|
||||||
|
exportToPDF,
|
||||||
|
exportDetailToPDF,
|
||||||
|
exportToXLSX,
|
||||||
|
exportDetailToXLSX,
|
||||||
|
exportToDOCX,
|
||||||
|
exportDetailToDOCX
|
||||||
|
}
|
||||||
|
@ -1,17 +1,4 @@
|
|||||||
import { exportDataGrid as exportToExcel } from 'devextreme/excel_exporter'
|
import { exportDataGrid as exportToExcel } from 'devextreme/excel_exporter'
|
||||||
import {
|
|
||||||
Document,
|
|
||||||
AlignmentType,
|
|
||||||
Packer,
|
|
||||||
Paragraph,
|
|
||||||
Table,
|
|
||||||
TableCell,
|
|
||||||
TableRow,
|
|
||||||
VerticalAlign,
|
|
||||||
TextRun,
|
|
||||||
WidthType,
|
|
||||||
PageOrientation
|
|
||||||
} from 'docx'
|
|
||||||
import { saveAs } from 'file-saver'
|
import { saveAs } from 'file-saver'
|
||||||
import { jsPDF } from 'jspdf'
|
import { jsPDF } from 'jspdf'
|
||||||
import autoTable from 'jspdf-autotable'
|
import autoTable from 'jspdf-autotable'
|
||||||
@ -287,4 +274,4 @@ const exportToXLSX = (reportMeta: any, e: any) => {
|
|||||||
const exportToDOCX = (reportMeta: any, rawData: any) => {
|
const exportToDOCX = (reportMeta: any, rawData: any) => {
|
||||||
exportToWord(reportMeta, formatData(rawData), `Laporan ${reportName}`, null)
|
exportToWord(reportMeta, formatData(rawData), `Laporan ${reportName}`, null)
|
||||||
}
|
}
|
||||||
export { exportToPDF, exportToXLSX , exportToDOCX}
|
export { exportToPDF, exportToXLSX, exportToDOCX }
|
||||||
|
@ -1,17 +1,4 @@
|
|||||||
import { exportDataGrid as exportToExcel } from 'devextreme/excel_exporter'
|
import { exportDataGrid as exportToExcel } from 'devextreme/excel_exporter'
|
||||||
import {
|
|
||||||
Document,
|
|
||||||
AlignmentType,
|
|
||||||
Packer,
|
|
||||||
Paragraph,
|
|
||||||
Table,
|
|
||||||
TableCell,
|
|
||||||
TableRow,
|
|
||||||
VerticalAlign,
|
|
||||||
TextRun,
|
|
||||||
WidthType,
|
|
||||||
PageOrientation
|
|
||||||
} from 'docx'
|
|
||||||
import { saveAs } from 'file-saver'
|
import { saveAs } from 'file-saver'
|
||||||
import { jsPDF } from 'jspdf'
|
import { jsPDF } from 'jspdf'
|
||||||
import autoTable from 'jspdf-autotable'
|
import autoTable from 'jspdf-autotable'
|
||||||
@ -24,7 +11,72 @@ import { exportToWord } from './doc/MonalisaGR_JumlahDDRPTRCTGangguan_DOC'
|
|||||||
const reportName = 'Jumlah dan Durasi RPT RCT Gangguan'
|
const reportName = 'Jumlah dan Durasi RPT RCT Gangguan'
|
||||||
const fontSize = 5
|
const fontSize = 5
|
||||||
|
|
||||||
const formatData = (rawData: any) => {
|
const getGroupParent = (reportMeta: any) => {
|
||||||
|
if (reportMeta.ulp.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.ulp.name,
|
||||||
|
summaryName: reportMeta.ulp.name,
|
||||||
|
summaryKey: 'nama_ulp'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reportMeta.up3.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.up3.name,
|
||||||
|
summaryName: reportMeta.up3.name,
|
||||||
|
summaryKey: 'nama_up3'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reportMeta.uid.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.uid.name,
|
||||||
|
summaryName: reportMeta.uid.name,
|
||||||
|
summaryKey: 'nama_uid'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reportMeta.regional.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.regional.name,
|
||||||
|
summaryName: reportMeta.regional.name,
|
||||||
|
summaryKey: 'nama_regional'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
|
const groupingData = (data: any, reportMeta: any) => {
|
||||||
|
const groupedData: any = {}
|
||||||
|
const groupParent = getGroupParent(reportMeta)
|
||||||
|
|
||||||
|
if (groupParent === '') {
|
||||||
|
return {
|
||||||
|
data,
|
||||||
|
parent: '',
|
||||||
|
summaryName: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data.forEach((item: any) => {
|
||||||
|
const group = item[groupParent.summaryKey]
|
||||||
|
|
||||||
|
if (!groupedData[group]) {
|
||||||
|
groupedData[group] = []
|
||||||
|
}
|
||||||
|
|
||||||
|
groupedData[group].push(item)
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: groupedData,
|
||||||
|
parent: groupParent.parent,
|
||||||
|
summaryName: groupParent.summaryName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const formatData = (rawData: any, reportMeta: any) => {
|
||||||
const formattedData: any = []
|
const formattedData: any = []
|
||||||
|
|
||||||
const total: any = {
|
const total: any = {
|
||||||
@ -38,6 +90,7 @@ const formatData = (rawData: any) => {
|
|||||||
count_durasi_recovery_time_tahun_ini: 0
|
count_durasi_recovery_time_tahun_ini: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (reportMeta.regional.id == 0) {
|
||||||
rawData.forEach((data: any) => {
|
rawData.forEach((data: any) => {
|
||||||
total.total_durasi_response_time_bulan_ini += data.total_durasi_response_time_bulan_ini
|
total.total_durasi_response_time_bulan_ini += data.total_durasi_response_time_bulan_ini
|
||||||
total.count_durasi_response_time_bulan_ini += data.count_durasi_response_time_bulan_ini
|
total.count_durasi_response_time_bulan_ini += data.count_durasi_response_time_bulan_ini
|
||||||
@ -74,6 +127,51 @@ const formatData = (rawData: any) => {
|
|||||||
])
|
])
|
||||||
|
|
||||||
return formattedData
|
return formattedData
|
||||||
|
} else {
|
||||||
|
const tempData = groupingData(rawData, reportMeta)
|
||||||
|
const data = tempData.data[tempData.summaryName] || tempData.data
|
||||||
|
const formattedData: any = []
|
||||||
|
|
||||||
|
let parentName = tempData.parent
|
||||||
|
let summaryName = tempData.summaryName ? tempData.summaryName : 'Seluruh Unit'
|
||||||
|
|
||||||
|
data.forEach((item: any) => {
|
||||||
|
total.total_durasi_response_time_bulan_ini += item.total_durasi_response_time_bulan_ini
|
||||||
|
total.count_durasi_response_time_bulan_ini += item.count_durasi_response_time_bulan_ini
|
||||||
|
total.total_durasi_recovery_time_bulan_ini += item.total_durasi_recovery_time_bulan_ini
|
||||||
|
total.count_durasi_recovery_time_bulan_ini += item.count_durasi_recovery_time_bulan_ini
|
||||||
|
total.total_durasi_response_time_tahun_ini += item.total_durasi_response_time_tahun_ini
|
||||||
|
total.count_durasi_response_time_tahun_ini += item.count_durasi_response_time_tahun_ini
|
||||||
|
total.total_durasi_recovery_time_tahun_ini += item.total_durasi_recovery_time_tahun_ini
|
||||||
|
total.count_durasi_recovery_time_tahun_ini += item.count_durasi_recovery_time_tahun_ini
|
||||||
|
})
|
||||||
|
|
||||||
|
formattedData.push([
|
||||||
|
summaryName,
|
||||||
|
formatNumber(total.total_durasi_response_time_bulan_ini),
|
||||||
|
formatNumber(total.count_durasi_response_time_bulan_ini),
|
||||||
|
formatNumber(
|
||||||
|
total.total_durasi_response_time_bulan_ini / total.count_durasi_response_time_bulan_ini
|
||||||
|
),
|
||||||
|
formatNumber(total.total_durasi_recovery_time_bulan_ini),
|
||||||
|
formatNumber(total.count_durasi_recovery_time_bulan_ini),
|
||||||
|
formatPercentage(
|
||||||
|
total.total_durasi_recovery_time_bulan_ini / total.count_durasi_recovery_time_bulan_ini
|
||||||
|
),
|
||||||
|
formatNumber(total.total_durasi_response_time_tahun_ini),
|
||||||
|
formatNumber(total.count_durasi_response_time_tahun_ini),
|
||||||
|
formatPercentage(
|
||||||
|
total.total_durasi_response_time_tahun_ini / total.count_durasi_response_time_tahun_ini
|
||||||
|
),
|
||||||
|
formatNumber(total.total_durasi_recovery_time_tahun_ini),
|
||||||
|
formatNumber(total.count_durasi_recovery_time_tahun_ini),
|
||||||
|
formatPercentage(
|
||||||
|
total.total_durasi_recovery_time_tahun_ini / total.count_durasi_recovery_time_tahun_ini
|
||||||
|
)
|
||||||
|
])
|
||||||
|
|
||||||
|
return formattedData
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) => {
|
const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) => {
|
||||||
@ -81,7 +179,7 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) =>
|
|||||||
const date = new Date().getDate()
|
const date = new Date().getDate()
|
||||||
const month = new Date().toLocaleString('id-ID', { month: 'long' })
|
const month = new Date().toLocaleString('id-ID', { month: 'long' })
|
||||||
const year = new Date().getFullYear()
|
const year = new Date().getFullYear()
|
||||||
const data = formatData(rawData)
|
const data = formatData(rawData, reportMeta)
|
||||||
const doc = new jsPDF({
|
const doc = new jsPDF({
|
||||||
orientation: 'landscape'
|
orientation: 'landscape'
|
||||||
})
|
})
|
||||||
@ -324,6 +422,6 @@ const exportToXLSX = (reportMeta: any, e: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const exportToDOCX = (reportMeta: any, rawData: any) => {
|
const exportToDOCX = (reportMeta: any, rawData: any) => {
|
||||||
exportToWord(reportMeta, formatData(rawData), `Laporan ${reportName}`, null)
|
exportToWord(reportMeta, formatData(rawData, reportMeta), `Laporan ${reportName}`, null)
|
||||||
}
|
}
|
||||||
export { exportToPDF, exportToXLSX , exportToDOCX}
|
export { exportToPDF, exportToXLSX, exportToDOCX }
|
||||||
|
@ -1,22 +1,8 @@
|
|||||||
import { exportDataGrid as exportToExcel } from 'devextreme/excel_exporter'
|
import { exportDataGrid as exportToExcel } from 'devextreme/excel_exporter'
|
||||||
import {
|
|
||||||
Document,
|
|
||||||
AlignmentType,
|
|
||||||
Packer,
|
|
||||||
Paragraph,
|
|
||||||
Table,
|
|
||||||
TableCell,
|
|
||||||
TableRow,
|
|
||||||
VerticalAlign,
|
|
||||||
TextRun,
|
|
||||||
WidthType,
|
|
||||||
PageOrientation
|
|
||||||
} from 'docx'
|
|
||||||
import { saveAs } from 'file-saver'
|
import { saveAs } from 'file-saver'
|
||||||
import { jsPDF } from 'jspdf'
|
import { jsPDF } from 'jspdf'
|
||||||
import autoTable from 'jspdf-autotable'
|
import autoTable from 'jspdf-autotable'
|
||||||
import { Workbook } from 'exceljs'
|
import { Workbook } from 'exceljs'
|
||||||
import { formatWaktu } from '@/components/Form/FiltersType/reference'
|
|
||||||
import { setHeaderStyle } from '@/report/utils/xlsx'
|
import { setHeaderStyle } from '@/report/utils/xlsx'
|
||||||
import { formatNumber, formatPercentage } from '@/utils/numbers'
|
import { formatNumber, formatPercentage } from '@/utils/numbers'
|
||||||
import { getMonthName } from '@/utils/texts'
|
import { getMonthName } from '@/utils/texts'
|
||||||
@ -24,11 +10,47 @@ import { exportToWord } from './doc/MonalisaGR_JumlahKaliGangguan_DOC'
|
|||||||
|
|
||||||
const reportName = 'Jumlah Kali Gangguan'
|
const reportName = 'Jumlah Kali Gangguan'
|
||||||
const fontSize = 5
|
const fontSize = 5
|
||||||
const detailFontSize = 3
|
|
||||||
|
|
||||||
const groupingData = (data: any) => {
|
const getGroupParent = (reportMeta: any) => {
|
||||||
|
if (reportMeta.ulp.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.ulp.name,
|
||||||
|
summaryName: reportMeta.ulp.name,
|
||||||
|
summaryKey: 'nama_ulp'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reportMeta.up3.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.up3.name,
|
||||||
|
summaryName: reportMeta.up3.name,
|
||||||
|
summaryKey: 'nama_up3'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reportMeta.uid.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.uid.name,
|
||||||
|
summaryName: reportMeta.uid.name,
|
||||||
|
summaryKey: 'nama_uid'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reportMeta.regional.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.regional.name,
|
||||||
|
summaryName: reportMeta.regional.name,
|
||||||
|
summaryKey: 'nama_regional'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
|
const groupingData = (data: any, reportMeta: any) => {
|
||||||
const groupedData: any = {}
|
const groupedData: any = {}
|
||||||
|
|
||||||
|
if (reportMeta.regional.id == 0) {
|
||||||
data.forEach((item: any) => {
|
data.forEach((item: any) => {
|
||||||
const { nama_regional } = item
|
const { nama_regional } = item
|
||||||
|
|
||||||
@ -64,10 +86,36 @@ const groupingData = (data: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return groupedData
|
return groupedData
|
||||||
|
} else {
|
||||||
|
const groupParent = getGroupParent(reportMeta)
|
||||||
|
|
||||||
|
if (groupParent === '') {
|
||||||
|
return {
|
||||||
|
data,
|
||||||
|
parent: '',
|
||||||
|
summaryName: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data.forEach((item: any) => {
|
||||||
|
const group = item[groupParent.summaryKey]
|
||||||
|
|
||||||
|
if (!groupedData[group]) {
|
||||||
|
groupedData[group] = []
|
||||||
|
}
|
||||||
|
|
||||||
|
groupedData[group].push(item)
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: groupedData,
|
||||||
|
parent: groupParent.parent,
|
||||||
|
summaryName: groupParent.summaryName
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const formatData = (rawData: any) => {
|
const formatData = (rawData: any, reportMeta: any) => {
|
||||||
const data = groupingData(rawData)
|
|
||||||
const formattedData: any = []
|
const formattedData: any = []
|
||||||
|
|
||||||
const total: any = {
|
const total: any = {
|
||||||
@ -77,6 +125,9 @@ const formatData = (rawData: any) => {
|
|||||||
yoy_tahun_ini: 0
|
yoy_tahun_ini: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (reportMeta.regional.id == 0) {
|
||||||
|
const data = groupingData(rawData, reportMeta)
|
||||||
|
|
||||||
formattedData.push([{ content: 'NASIONAL', colSpan: 7, styles: { fontStyle: 'bold' } }])
|
formattedData.push([{ content: 'NASIONAL', colSpan: 7, styles: { fontStyle: 'bold' } }])
|
||||||
|
|
||||||
let no = 1
|
let no = 1
|
||||||
@ -91,14 +142,16 @@ const formatData = (rawData: any) => {
|
|||||||
formatPercentage(
|
formatPercentage(
|
||||||
!summary.mom_bulan_ini || !summary.mom_bulan_kemarin
|
!summary.mom_bulan_ini || !summary.mom_bulan_kemarin
|
||||||
? '0%'
|
? '0%'
|
||||||
: ((summary.mom_bulan_kemarin - summary.mom_bulan_ini) / summary.mom_bulan_kemarin) * 100
|
: ((summary.mom_bulan_kemarin - summary.mom_bulan_ini) / summary.mom_bulan_kemarin) *
|
||||||
|
100
|
||||||
),
|
),
|
||||||
formatNumber(summary.yoy_tahun_kemarin),
|
formatNumber(summary.yoy_tahun_kemarin),
|
||||||
formatNumber(summary.yoy_tahun_ini),
|
formatNumber(summary.yoy_tahun_ini),
|
||||||
formatPercentage(
|
formatPercentage(
|
||||||
!summary.yoy_tahun_ini || !summary.yoy_tahun_kemarin
|
!summary.yoy_tahun_ini || !summary.yoy_tahun_kemarin
|
||||||
? '0%'
|
? '0%'
|
||||||
: ((summary.yoy_tahun_kemarin - summary.yoy_tahun_ini) / summary.yoy_tahun_kemarin) * 100
|
: ((summary.yoy_tahun_kemarin - summary.yoy_tahun_ini) / summary.yoy_tahun_kemarin) *
|
||||||
|
100
|
||||||
)
|
)
|
||||||
])
|
])
|
||||||
|
|
||||||
@ -127,6 +180,45 @@ const formatData = (rawData: any) => {
|
|||||||
])
|
])
|
||||||
|
|
||||||
return formattedData
|
return formattedData
|
||||||
|
} else {
|
||||||
|
const tempData = groupingData(rawData, reportMeta)
|
||||||
|
const data = tempData.data[tempData.summaryName] || tempData.data
|
||||||
|
const formattedData: any = []
|
||||||
|
|
||||||
|
let parentName = tempData.parent
|
||||||
|
let summaryName = tempData.summaryName ? tempData.summaryName : 'Seluruh Unit'
|
||||||
|
|
||||||
|
data.forEach((item: any) => {
|
||||||
|
total.mom_bulan_kemarin += item.mom_bulan_kemarin
|
||||||
|
total.mom_bulan_ini += item.mom_bulan_ini
|
||||||
|
total.yoy_tahun_kemarin += item.yoy_tahun_kemarin
|
||||||
|
total.yoy_tahun_ini += item.yoy_tahun_ini
|
||||||
|
})
|
||||||
|
|
||||||
|
formattedData.push([{ content: parentName, colSpan: 7, styles: { fontStyle: 'bold' } }])
|
||||||
|
|
||||||
|
const result = [
|
||||||
|
formatNumber(total.mom_bulan_kemarin),
|
||||||
|
formatNumber(total.mom_bulan_ini),
|
||||||
|
formatPercentage(
|
||||||
|
!total.mom_bulan_ini || !total.mom_bulan_kemarin
|
||||||
|
? '0%'
|
||||||
|
: ((total.mom_bulan_kemarin - total.mom_bulan_ini) / total.mom_bulan_kemarin) * 100
|
||||||
|
),
|
||||||
|
formatNumber(total.yoy_tahun_kemarin),
|
||||||
|
formatNumber(total.yoy_tahun_ini),
|
||||||
|
formatPercentage(
|
||||||
|
!total.yoy_tahun_ini || !total.yoy_tahun_kemarin
|
||||||
|
? '0%'
|
||||||
|
: ((total.yoy_tahun_kemarin - total.yoy_tahun_ini) / total.yoy_tahun_kemarin) * 100
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
|
formattedData.push([{ content: '1', styles: { halign: 'right' } }, summaryName, ...result])
|
||||||
|
formattedData.push([{ content: 'TOTAL', colSpan: 2, styles: { fontStyle: 'bold' } }, ...result])
|
||||||
|
|
||||||
|
return formattedData
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) => {
|
const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) => {
|
||||||
@ -134,7 +226,7 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) =>
|
|||||||
const date = new Date().getDate()
|
const date = new Date().getDate()
|
||||||
const month = new Date().toLocaleString('id-ID', { month: 'long' })
|
const month = new Date().toLocaleString('id-ID', { month: 'long' })
|
||||||
const year = new Date().getFullYear()
|
const year = new Date().getFullYear()
|
||||||
const data = formatData(rawData)
|
const data = formatData(rawData, reportMeta)
|
||||||
const doc = new jsPDF({
|
const doc = new jsPDF({
|
||||||
orientation: 'landscape'
|
orientation: 'landscape'
|
||||||
})
|
})
|
||||||
@ -309,7 +401,8 @@ const exportToXLSX = (reportMeta: any, e: any) => {
|
|||||||
worksheet,
|
worksheet,
|
||||||
2,
|
2,
|
||||||
1,
|
1,
|
||||||
`UNIT INDUK : ${reportMeta.uid
|
`UNIT INDUK : ${
|
||||||
|
reportMeta.uid
|
||||||
? reportMeta.uid.name.toUpperCase()
|
? reportMeta.uid.name.toUpperCase()
|
||||||
: 'Semua Unit Induk Distribusi/Wilayah'.toUpperCase()
|
: 'Semua Unit Induk Distribusi/Wilayah'.toUpperCase()
|
||||||
}`
|
}`
|
||||||
@ -318,7 +411,8 @@ const exportToXLSX = (reportMeta: any, e: any) => {
|
|||||||
worksheet,
|
worksheet,
|
||||||
3,
|
3,
|
||||||
1,
|
1,
|
||||||
`UNIT PELAKSANA PELAYANAN PELANGGAN : ${reportMeta.up3
|
`UNIT PELAKSANA PELAYANAN PELANGGAN : ${
|
||||||
|
reportMeta.up3
|
||||||
? reportMeta.up3.name.toUpperCase()
|
? reportMeta.up3.name.toUpperCase()
|
||||||
: 'Semua Unit Pelaksanaan Pelayanan Pelanggan'.toUpperCase()
|
: 'Semua Unit Pelaksanaan Pelayanan Pelanggan'.toUpperCase()
|
||||||
}`
|
}`
|
||||||
@ -327,7 +421,8 @@ const exportToXLSX = (reportMeta: any, e: any) => {
|
|||||||
worksheet,
|
worksheet,
|
||||||
4,
|
4,
|
||||||
1,
|
1,
|
||||||
`UNIT LAYANAN PELANGGAN : ${reportMeta.ulp
|
`UNIT LAYANAN PELANGGAN : ${
|
||||||
|
reportMeta.ulp
|
||||||
? reportMeta.ulp.name.toUpperCase()
|
? reportMeta.ulp.name.toUpperCase()
|
||||||
: 'Semua Unit Layanan Pelanggan'.toUpperCase()
|
: 'Semua Unit Layanan Pelanggan'.toUpperCase()
|
||||||
}`
|
}`
|
||||||
@ -336,7 +431,8 @@ const exportToXLSX = (reportMeta: any, e: any) => {
|
|||||||
worksheet,
|
worksheet,
|
||||||
5,
|
5,
|
||||||
1,
|
1,
|
||||||
`REGIONAL : ${reportMeta.regional ? reportMeta.regional.name.toUpperCase() : 'Semua Regional'.toUpperCase()
|
`REGIONAL : ${
|
||||||
|
reportMeta.regional ? reportMeta.regional.name.toUpperCase() : 'Semua Regional'.toUpperCase()
|
||||||
}`
|
}`
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -370,6 +466,6 @@ const exportToXLSX = (reportMeta: any, e: any) => {
|
|||||||
|
|
||||||
const exportToDOCX = (reportMeta: any, rawData: any) => {
|
const exportToDOCX = (reportMeta: any, rawData: any) => {
|
||||||
console.log(reportMeta, rawData)
|
console.log(reportMeta, rawData)
|
||||||
exportToWord(reportMeta, formatData(rawData), `Laporan ${reportName}`, null)
|
exportToWord(reportMeta, formatData(rawData, reportMeta), `Laporan ${reportName}`, null)
|
||||||
}
|
}
|
||||||
export { exportToPDF, exportToXLSX, exportToDOCX }
|
export { exportToPDF, exportToXLSX, exportToDOCX }
|
@ -1,17 +1,4 @@
|
|||||||
import { exportDataGrid as exportToExcel } from 'devextreme/excel_exporter'
|
import { exportDataGrid as exportToExcel } from 'devextreme/excel_exporter'
|
||||||
import {
|
|
||||||
Document,
|
|
||||||
AlignmentType,
|
|
||||||
Packer,
|
|
||||||
Paragraph,
|
|
||||||
Table,
|
|
||||||
TableCell,
|
|
||||||
TableRow,
|
|
||||||
VerticalAlign,
|
|
||||||
TextRun,
|
|
||||||
WidthType,
|
|
||||||
PageOrientation
|
|
||||||
} from 'docx'
|
|
||||||
import { saveAs } from 'file-saver'
|
import { saveAs } from 'file-saver'
|
||||||
import { jsPDF } from 'jspdf'
|
import { jsPDF } from 'jspdf'
|
||||||
import autoTable from 'jspdf-autotable'
|
import autoTable from 'jspdf-autotable'
|
||||||
@ -24,9 +11,46 @@ import { exportToWord } from './doc/MonalisaGR_LaporUlang_DOC'
|
|||||||
const reportName = 'Rekapitulasi Lapor Ulang Gangguan'
|
const reportName = 'Rekapitulasi Lapor Ulang Gangguan'
|
||||||
const fontSize = 5
|
const fontSize = 5
|
||||||
|
|
||||||
const groupingData = (data: any) => {
|
const getGroupParent = (reportMeta: any) => {
|
||||||
|
if (reportMeta.ulp.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.ulp.name,
|
||||||
|
summaryName: reportMeta.ulp.name,
|
||||||
|
summaryKey: 'nama_ulp'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reportMeta.up3.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.up3.name,
|
||||||
|
summaryName: reportMeta.up3.name,
|
||||||
|
summaryKey: 'nama_up3'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reportMeta.uid.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.uid.name,
|
||||||
|
summaryName: reportMeta.uid.name,
|
||||||
|
summaryKey: 'nama_uid'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reportMeta.regional.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.regional.name,
|
||||||
|
summaryName: reportMeta.regional.name,
|
||||||
|
summaryKey: 'nama_regional'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
|
const groupingData = (data: any, reportMeta: any) => {
|
||||||
const groupedData: any = {}
|
const groupedData: any = {}
|
||||||
|
|
||||||
|
if (reportMeta.regional.id == 0) {
|
||||||
data.forEach((item: any) => {
|
data.forEach((item: any) => {
|
||||||
const { nama_regional } = item
|
const { nama_regional } = item
|
||||||
|
|
||||||
@ -62,10 +86,36 @@ const groupingData = (data: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return groupedData
|
return groupedData
|
||||||
|
} else {
|
||||||
|
const groupParent = getGroupParent(reportMeta)
|
||||||
|
|
||||||
|
if (groupParent === '') {
|
||||||
|
return {
|
||||||
|
data,
|
||||||
|
parent: '',
|
||||||
|
summaryName: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data.forEach((item: any) => {
|
||||||
|
const group = item[groupParent.summaryKey]
|
||||||
|
|
||||||
|
if (!groupedData[group]) {
|
||||||
|
groupedData[group] = []
|
||||||
|
}
|
||||||
|
|
||||||
|
groupedData[group].push(item)
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: groupedData,
|
||||||
|
parent: groupParent.parent,
|
||||||
|
summaryName: groupParent.summaryName
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const formatData = (rawData: any) => {
|
const formatData = (rawData: any, reportMeta: any) => {
|
||||||
const data = groupingData(rawData)
|
|
||||||
const formattedData: any = []
|
const formattedData: any = []
|
||||||
|
|
||||||
const total: any = {
|
const total: any = {
|
||||||
@ -75,6 +125,9 @@ const formatData = (rawData: any) => {
|
|||||||
yoy_tahun_ini: 0
|
yoy_tahun_ini: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (reportMeta.regional.id == 0) {
|
||||||
|
const data = groupingData(rawData, reportMeta)
|
||||||
|
|
||||||
formattedData.push([{ content: 'NASIONAL', colSpan: 7, styles: { fontStyle: 'bold' } }])
|
formattedData.push([{ content: 'NASIONAL', colSpan: 7, styles: { fontStyle: 'bold' } }])
|
||||||
|
|
||||||
let no = 1
|
let no = 1
|
||||||
@ -89,14 +142,16 @@ const formatData = (rawData: any) => {
|
|||||||
formatPercentage(
|
formatPercentage(
|
||||||
!summary.mom_bulan_ini || !summary.mom_bulan_kemarin
|
!summary.mom_bulan_ini || !summary.mom_bulan_kemarin
|
||||||
? '0%'
|
? '0%'
|
||||||
: ((summary.mom_bulan_kemarin - summary.mom_bulan_ini) / summary.mom_bulan_kemarin) * 100
|
: ((summary.mom_bulan_kemarin - summary.mom_bulan_ini) / summary.mom_bulan_kemarin) *
|
||||||
|
100
|
||||||
),
|
),
|
||||||
formatNumber(summary.yoy_tahun_kemarin),
|
formatNumber(summary.yoy_tahun_kemarin),
|
||||||
formatNumber(summary.yoy_tahun_ini),
|
formatNumber(summary.yoy_tahun_ini),
|
||||||
formatPercentage(
|
formatPercentage(
|
||||||
!summary.yoy_tahun_ini || !summary.yoy_tahun_kemarin
|
!summary.yoy_tahun_ini || !summary.yoy_tahun_kemarin
|
||||||
? '0%'
|
? '0%'
|
||||||
: ((summary.yoy_tahun_kemarin - summary.yoy_tahun_ini) / summary.yoy_tahun_kemarin) * 100
|
: ((summary.yoy_tahun_kemarin - summary.yoy_tahun_ini) / summary.yoy_tahun_kemarin) *
|
||||||
|
100
|
||||||
)
|
)
|
||||||
])
|
])
|
||||||
|
|
||||||
@ -125,6 +180,45 @@ const formatData = (rawData: any) => {
|
|||||||
])
|
])
|
||||||
|
|
||||||
return formattedData
|
return formattedData
|
||||||
|
} else {
|
||||||
|
const tempData = groupingData(rawData, reportMeta)
|
||||||
|
const data = tempData.data[tempData.summaryName] || tempData.data
|
||||||
|
const formattedData: any = []
|
||||||
|
|
||||||
|
let parentName = tempData.parent
|
||||||
|
let summaryName = tempData.summaryName ? tempData.summaryName : 'Seluruh Unit'
|
||||||
|
|
||||||
|
data.forEach((item: any) => {
|
||||||
|
total.mom_bulan_kemarin += item.mom_bulan_kemarin
|
||||||
|
total.mom_bulan_ini += item.mom_bulan_ini
|
||||||
|
total.yoy_tahun_kemarin += item.yoy_tahun_kemarin
|
||||||
|
total.yoy_tahun_ini += item.yoy_tahun_ini
|
||||||
|
})
|
||||||
|
|
||||||
|
formattedData.push([{ content: parentName, colSpan: 7, styles: { fontStyle: 'bold' } }])
|
||||||
|
|
||||||
|
const result = [
|
||||||
|
formatNumber(total.mom_bulan_kemarin),
|
||||||
|
formatNumber(total.mom_bulan_ini),
|
||||||
|
formatPercentage(
|
||||||
|
!total.mom_bulan_ini || !total.mom_bulan_kemarin
|
||||||
|
? '0%'
|
||||||
|
: ((total.mom_bulan_kemarin - total.mom_bulan_ini) / total.mom_bulan_kemarin) * 100
|
||||||
|
),
|
||||||
|
formatNumber(total.yoy_tahun_kemarin),
|
||||||
|
formatNumber(total.yoy_tahun_ini),
|
||||||
|
formatPercentage(
|
||||||
|
!total.yoy_tahun_ini || !total.yoy_tahun_kemarin
|
||||||
|
? '0%'
|
||||||
|
: ((total.yoy_tahun_kemarin - total.yoy_tahun_ini) / total.yoy_tahun_kemarin) * 100
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
|
formattedData.push([{ content: '1', styles: { halign: 'right' } }, summaryName, ...result])
|
||||||
|
formattedData.push([{ content: 'TOTAL', colSpan: 2, styles: { fontStyle: 'bold' } }, ...result])
|
||||||
|
|
||||||
|
return formattedData
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) => {
|
const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) => {
|
||||||
@ -132,7 +226,7 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) =>
|
|||||||
const date = new Date().getDate()
|
const date = new Date().getDate()
|
||||||
const month = new Date().toLocaleString('id-ID', { month: 'long' })
|
const month = new Date().toLocaleString('id-ID', { month: 'long' })
|
||||||
const year = new Date().getFullYear()
|
const year = new Date().getFullYear()
|
||||||
const data = formatData(rawData)
|
const data = formatData(rawData, reportMeta)
|
||||||
const doc = new jsPDF({
|
const doc = new jsPDF({
|
||||||
orientation: 'landscape'
|
orientation: 'landscape'
|
||||||
})
|
})
|
||||||
@ -371,6 +465,6 @@ const exportToXLSX = (reportMeta: any, e: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const exportToDOCX = (reportMeta: any, rawData: any) => {
|
const exportToDOCX = (reportMeta: any, rawData: any) => {
|
||||||
exportToWord(reportMeta, formatData(rawData), `Laporan ${reportName}`, null)
|
exportToWord(reportMeta, formatData(rawData, reportMeta), `Laporan ${reportName}`, null)
|
||||||
}
|
}
|
||||||
export { exportToPDF, exportToXLSX , exportToDOCX}
|
export { exportToPDF, exportToXLSX, exportToDOCX }
|
||||||
|
@ -1,22 +1,8 @@
|
|||||||
import { exportDataGrid as exportToExcel } from 'devextreme/excel_exporter'
|
import { exportDataGrid as exportToExcel } from 'devextreme/excel_exporter'
|
||||||
import {
|
|
||||||
Document,
|
|
||||||
AlignmentType,
|
|
||||||
Packer,
|
|
||||||
Paragraph,
|
|
||||||
Table,
|
|
||||||
TableCell,
|
|
||||||
TableRow,
|
|
||||||
VerticalAlign,
|
|
||||||
TextRun,
|
|
||||||
WidthType,
|
|
||||||
PageOrientation
|
|
||||||
} from 'docx'
|
|
||||||
import { saveAs } from 'file-saver'
|
import { saveAs } from 'file-saver'
|
||||||
import { jsPDF } from 'jspdf'
|
import { jsPDF } from 'jspdf'
|
||||||
import autoTable from 'jspdf-autotable'
|
import autoTable from 'jspdf-autotable'
|
||||||
import { Workbook } from 'exceljs'
|
import { Workbook } from 'exceljs'
|
||||||
import { formatWaktu } from '@/components/Form/FiltersType/reference'
|
|
||||||
import { setHeaderStyle } from '@/report/utils/xlsx'
|
import { setHeaderStyle } from '@/report/utils/xlsx'
|
||||||
import { formatNumber, formatPercentage } from '@/utils/numbers'
|
import { formatNumber, formatPercentage } from '@/utils/numbers'
|
||||||
import { getMonthName } from '@/utils/texts'
|
import { getMonthName } from '@/utils/texts'
|
||||||
@ -25,9 +11,46 @@ import { exportToWord } from './doc/MonalisaGR_RecoveryTimeGangguan_DOC'
|
|||||||
const reportName = 'Recovery Time (RCT) Gangguan'
|
const reportName = 'Recovery Time (RCT) Gangguan'
|
||||||
const fontSize = 5
|
const fontSize = 5
|
||||||
|
|
||||||
const groupingData = (data: any) => {
|
const getGroupParent = (reportMeta: any) => {
|
||||||
|
if (reportMeta.ulp.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.ulp.name,
|
||||||
|
summaryName: reportMeta.ulp.name,
|
||||||
|
summaryKey: 'nama_ulp'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reportMeta.up3.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.up3.name,
|
||||||
|
summaryName: reportMeta.up3.name,
|
||||||
|
summaryKey: 'nama_up3'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reportMeta.uid.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.uid.name,
|
||||||
|
summaryName: reportMeta.uid.name,
|
||||||
|
summaryKey: 'nama_uid'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reportMeta.regional.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.regional.name,
|
||||||
|
summaryName: reportMeta.regional.name,
|
||||||
|
summaryKey: 'nama_regional'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
|
const groupingData = (data: any, reportMeta: any) => {
|
||||||
const groupedData: any = {}
|
const groupedData: any = {}
|
||||||
|
|
||||||
|
if (reportMeta.regional.id == 0) {
|
||||||
data.forEach((item: any) => {
|
data.forEach((item: any) => {
|
||||||
const { nama_regional } = item
|
const { nama_regional } = item
|
||||||
|
|
||||||
@ -63,10 +86,36 @@ const groupingData = (data: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return groupedData
|
return groupedData
|
||||||
|
} else {
|
||||||
|
const groupParent = getGroupParent(reportMeta)
|
||||||
|
|
||||||
|
if (groupParent === '') {
|
||||||
|
return {
|
||||||
|
data,
|
||||||
|
parent: '',
|
||||||
|
summaryName: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data.forEach((item: any) => {
|
||||||
|
const group = item[groupParent.summaryKey]
|
||||||
|
|
||||||
|
if (!groupedData[group]) {
|
||||||
|
groupedData[group] = []
|
||||||
|
}
|
||||||
|
|
||||||
|
groupedData[group].push(item)
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: groupedData,
|
||||||
|
parent: groupParent.parent,
|
||||||
|
summaryName: groupParent.summaryName
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const formatData = (rawData: any) => {
|
const formatData = (rawData: any, reportMeta: any) => {
|
||||||
const data = groupingData(rawData)
|
|
||||||
const formattedData: any = []
|
const formattedData: any = []
|
||||||
|
|
||||||
const total: any = {
|
const total: any = {
|
||||||
@ -76,6 +125,9 @@ const formatData = (rawData: any) => {
|
|||||||
yoy_tahun_ini: []
|
yoy_tahun_ini: []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (reportMeta.regional.id == 0) {
|
||||||
|
const data = groupingData(rawData, reportMeta)
|
||||||
|
|
||||||
formattedData.push([{ content: 'NASIONAL', colSpan: 7, styles: { fontStyle: 'bold' } }])
|
formattedData.push([{ content: 'NASIONAL', colSpan: 7, styles: { fontStyle: 'bold' } }])
|
||||||
|
|
||||||
let no = 1
|
let no = 1
|
||||||
@ -90,14 +142,16 @@ const formatData = (rawData: any) => {
|
|||||||
formatPercentage(
|
formatPercentage(
|
||||||
!summary.mom_bulan_ini || !summary.mom_bulan_kemarin
|
!summary.mom_bulan_ini || !summary.mom_bulan_kemarin
|
||||||
? '0%'
|
? '0%'
|
||||||
: ((summary.mom_bulan_kemarin - summary.mom_bulan_ini) / summary.mom_bulan_kemarin) * 100
|
: ((summary.mom_bulan_kemarin - summary.mom_bulan_ini) / summary.mom_bulan_kemarin) *
|
||||||
|
100
|
||||||
),
|
),
|
||||||
formatNumber(summary.yoy_tahun_kemarin),
|
formatNumber(summary.yoy_tahun_kemarin),
|
||||||
formatNumber(summary.yoy_tahun_ini),
|
formatNumber(summary.yoy_tahun_ini),
|
||||||
formatPercentage(
|
formatPercentage(
|
||||||
!summary.yoy_tahun_ini || !summary.yoy_tahun_kemarin
|
!summary.yoy_tahun_ini || !summary.yoy_tahun_kemarin
|
||||||
? '0%'
|
? '0%'
|
||||||
: ((summary.yoy_tahun_kemarin - summary.yoy_tahun_ini) / summary.yoy_tahun_kemarin) * 100
|
: ((summary.yoy_tahun_kemarin - summary.yoy_tahun_ini) / summary.yoy_tahun_kemarin) *
|
||||||
|
100
|
||||||
)
|
)
|
||||||
])
|
])
|
||||||
|
|
||||||
@ -137,6 +191,59 @@ const formatData = (rawData: any) => {
|
|||||||
])
|
])
|
||||||
|
|
||||||
return formattedData
|
return formattedData
|
||||||
|
} else {
|
||||||
|
const tempData = groupingData(rawData, reportMeta)
|
||||||
|
const data = tempData.data[tempData.summaryName] || tempData.data
|
||||||
|
const formattedData: any = []
|
||||||
|
|
||||||
|
let parentName = tempData.parent
|
||||||
|
let summaryName = tempData.summaryName ? tempData.summaryName : 'Seluruh Unit'
|
||||||
|
|
||||||
|
data.forEach((item: any) => {
|
||||||
|
total.mom_bulan_kemarin.push(item.mom_bulan_kemarin)
|
||||||
|
total.mom_bulan_ini.push(item.mom_bulan_ini)
|
||||||
|
total.yoy_tahun_kemarin.push(item.yoy_tahun_kemarin)
|
||||||
|
total.yoy_tahun_ini.push(item.yoy_tahun_ini)
|
||||||
|
})
|
||||||
|
|
||||||
|
const totalMoMBulanKemarin =
|
||||||
|
total.mom_bulan_kemarin.reduce((a: number, b: number) => a + b, 0) /
|
||||||
|
total.mom_bulan_kemarin.length
|
||||||
|
const totalMoMBulanIni =
|
||||||
|
total.mom_bulan_ini.reduce((a: number, b: number) => a + b, 0) / total.mom_bulan_ini.length
|
||||||
|
const totalYoYTahunKemarin =
|
||||||
|
total.yoy_tahun_kemarin.reduce((a: number, b: number) => a + b, 0) /
|
||||||
|
total.yoy_tahun_kemarin.length
|
||||||
|
const totalYoYTahunIni =
|
||||||
|
total.yoy_tahun_ini.reduce((a: number, b: number) => a + b, 0) / total.yoy_tahun_ini.length
|
||||||
|
|
||||||
|
formattedData.push([{ content: parentName, colSpan: 7, styles: { fontStyle: 'bold' } }])
|
||||||
|
|
||||||
|
const result = [
|
||||||
|
formatNumber(totalMoMBulanKemarin),
|
||||||
|
formatNumber(totalMoMBulanIni),
|
||||||
|
formatPercentage(
|
||||||
|
!totalMoMBulanIni || !totalMoMBulanKemarin
|
||||||
|
? '0%'
|
||||||
|
: ((totalMoMBulanKemarin - totalMoMBulanIni) / totalMoMBulanKemarin) * 100
|
||||||
|
),
|
||||||
|
formatNumber(totalYoYTahunKemarin),
|
||||||
|
formatNumber(totalYoYTahunIni),
|
||||||
|
formatPercentage(
|
||||||
|
!totalYoYTahunIni || !totalYoYTahunKemarin
|
||||||
|
? '0%'
|
||||||
|
: ((totalYoYTahunKemarin - totalYoYTahunIni) / totalYoYTahunKemarin) * 100
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
|
formattedData.push([{ content: '1', styles: { halign: 'right' } }, summaryName, ...result])
|
||||||
|
formattedData.push([
|
||||||
|
{ content: 'RATA-RATA', colSpan: 2, styles: { fontStyle: 'bold' } },
|
||||||
|
...result
|
||||||
|
])
|
||||||
|
|
||||||
|
return formattedData
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) => {
|
const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) => {
|
||||||
@ -144,7 +251,7 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) =>
|
|||||||
const date = new Date().getDate()
|
const date = new Date().getDate()
|
||||||
const month = new Date().toLocaleString('id-ID', { month: 'long' })
|
const month = new Date().toLocaleString('id-ID', { month: 'long' })
|
||||||
const year = new Date().getFullYear()
|
const year = new Date().getFullYear()
|
||||||
const data = formatData(rawData)
|
const data = formatData(rawData, reportMeta)
|
||||||
const doc = new jsPDF({
|
const doc = new jsPDF({
|
||||||
orientation: 'landscape'
|
orientation: 'landscape'
|
||||||
})
|
})
|
||||||
@ -383,6 +490,6 @@ const exportToXLSX = (reportMeta: any, e: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const exportToDOCX = (reportMeta: any, rawData: any) => {
|
const exportToDOCX = (reportMeta: any, rawData: any) => {
|
||||||
exportToWord(reportMeta, formatData(rawData), `Laporan ${reportName}`, null)
|
exportToWord(reportMeta, formatData(rawData, reportMeta), `Laporan ${reportName}`, null)
|
||||||
}
|
}
|
||||||
export { exportToPDF, exportToXLSX , exportToDOCX}
|
export { exportToPDF, exportToXLSX, exportToDOCX }
|
||||||
|
@ -1,22 +1,8 @@
|
|||||||
import { exportDataGrid as exportToExcel } from 'devextreme/excel_exporter'
|
import { exportDataGrid as exportToExcel } from 'devextreme/excel_exporter'
|
||||||
import {
|
|
||||||
Document,
|
|
||||||
AlignmentType,
|
|
||||||
Packer,
|
|
||||||
Paragraph,
|
|
||||||
Table,
|
|
||||||
TableCell,
|
|
||||||
TableRow,
|
|
||||||
VerticalAlign,
|
|
||||||
TextRun,
|
|
||||||
WidthType,
|
|
||||||
PageOrientation
|
|
||||||
} from 'docx'
|
|
||||||
import { saveAs } from 'file-saver'
|
import { saveAs } from 'file-saver'
|
||||||
import { jsPDF } from 'jspdf'
|
import { jsPDF } from 'jspdf'
|
||||||
import autoTable from 'jspdf-autotable'
|
import autoTable from 'jspdf-autotable'
|
||||||
import { Workbook } from 'exceljs'
|
import { Workbook } from 'exceljs'
|
||||||
import { formatWaktu } from '@/components/Form/FiltersType/reference'
|
|
||||||
import { setHeaderStyle } from '@/report/utils/xlsx'
|
import { setHeaderStyle } from '@/report/utils/xlsx'
|
||||||
import { formatNumber, formatPercentage } from '@/utils/numbers'
|
import { formatNumber, formatPercentage } from '@/utils/numbers'
|
||||||
import { getMonthName } from '@/utils/texts'
|
import { getMonthName } from '@/utils/texts'
|
||||||
@ -25,9 +11,46 @@ import { exportToWord } from './doc/MonalisaGR_ResponseTimeGangguan_DOC'
|
|||||||
const reportName = 'Response Time (RPT) Gangguan'
|
const reportName = 'Response Time (RPT) Gangguan'
|
||||||
const fontSize = 5
|
const fontSize = 5
|
||||||
|
|
||||||
const groupingData = (data: any) => {
|
const getGroupParent = (reportMeta: any) => {
|
||||||
|
if (reportMeta.ulp.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.ulp.name,
|
||||||
|
summaryName: reportMeta.ulp.name,
|
||||||
|
summaryKey: 'nama_ulp'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reportMeta.up3.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.up3.name,
|
||||||
|
summaryName: reportMeta.up3.name,
|
||||||
|
summaryKey: 'nama_up3'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reportMeta.uid.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.uid.name,
|
||||||
|
summaryName: reportMeta.uid.name,
|
||||||
|
summaryKey: 'nama_uid'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reportMeta.regional.id != 0) {
|
||||||
|
return {
|
||||||
|
parent: reportMeta.regional.name,
|
||||||
|
summaryName: reportMeta.regional.name,
|
||||||
|
summaryKey: 'nama_regional'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
|
const groupingData = (data: any, reportMeta: any) => {
|
||||||
const groupedData: any = {}
|
const groupedData: any = {}
|
||||||
|
|
||||||
|
if (reportMeta.regional.id == 0) {
|
||||||
data.forEach((item: any) => {
|
data.forEach((item: any) => {
|
||||||
const { nama_regional } = item
|
const { nama_regional } = item
|
||||||
|
|
||||||
@ -63,10 +86,36 @@ const groupingData = (data: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return groupedData
|
return groupedData
|
||||||
|
} else {
|
||||||
|
const groupParent = getGroupParent(reportMeta)
|
||||||
|
|
||||||
|
if (groupParent === '') {
|
||||||
|
return {
|
||||||
|
data,
|
||||||
|
parent: '',
|
||||||
|
summaryName: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data.forEach((item: any) => {
|
||||||
|
const group = item[groupParent.summaryKey]
|
||||||
|
|
||||||
|
if (!groupedData[group]) {
|
||||||
|
groupedData[group] = []
|
||||||
|
}
|
||||||
|
|
||||||
|
groupedData[group].push(item)
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: groupedData,
|
||||||
|
parent: groupParent.parent,
|
||||||
|
summaryName: groupParent.summaryName
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const formatData = (rawData: any) => {
|
const formatData = (rawData: any, reportMeta: any) => {
|
||||||
const data = groupingData(rawData)
|
|
||||||
const formattedData: any = []
|
const formattedData: any = []
|
||||||
|
|
||||||
const total: any = {
|
const total: any = {
|
||||||
@ -76,6 +125,9 @@ const formatData = (rawData: any) => {
|
|||||||
yoy_tahun_ini: []
|
yoy_tahun_ini: []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (reportMeta.regional.id == 0) {
|
||||||
|
const data = groupingData(rawData, reportMeta)
|
||||||
|
|
||||||
formattedData.push([{ content: 'NASIONAL', colSpan: 7, styles: { fontStyle: 'bold' } }])
|
formattedData.push([{ content: 'NASIONAL', colSpan: 7, styles: { fontStyle: 'bold' } }])
|
||||||
|
|
||||||
let no = 1
|
let no = 1
|
||||||
@ -90,14 +142,16 @@ const formatData = (rawData: any) => {
|
|||||||
formatPercentage(
|
formatPercentage(
|
||||||
!summary.mom_bulan_ini || !summary.mom_bulan_kemarin
|
!summary.mom_bulan_ini || !summary.mom_bulan_kemarin
|
||||||
? '0%'
|
? '0%'
|
||||||
: ((summary.mom_bulan_kemarin - summary.mom_bulan_ini) / summary.mom_bulan_kemarin) * 100
|
: ((summary.mom_bulan_kemarin - summary.mom_bulan_ini) / summary.mom_bulan_kemarin) *
|
||||||
|
100
|
||||||
),
|
),
|
||||||
formatNumber(summary.yoy_tahun_kemarin),
|
formatNumber(summary.yoy_tahun_kemarin),
|
||||||
formatNumber(summary.yoy_tahun_ini),
|
formatNumber(summary.yoy_tahun_ini),
|
||||||
formatPercentage(
|
formatPercentage(
|
||||||
!summary.yoy_tahun_ini || !summary.yoy_tahun_kemarin
|
!summary.yoy_tahun_ini || !summary.yoy_tahun_kemarin
|
||||||
? '0%'
|
? '0%'
|
||||||
: ((summary.yoy_tahun_kemarin - summary.yoy_tahun_ini) / summary.yoy_tahun_kemarin) * 100
|
: ((summary.yoy_tahun_kemarin - summary.yoy_tahun_ini) / summary.yoy_tahun_kemarin) *
|
||||||
|
100
|
||||||
)
|
)
|
||||||
])
|
])
|
||||||
|
|
||||||
@ -137,6 +191,59 @@ const formatData = (rawData: any) => {
|
|||||||
])
|
])
|
||||||
|
|
||||||
return formattedData
|
return formattedData
|
||||||
|
} else {
|
||||||
|
const tempData = groupingData(rawData, reportMeta)
|
||||||
|
const data = tempData.data[tempData.summaryName] || tempData.data
|
||||||
|
const formattedData: any = []
|
||||||
|
|
||||||
|
let parentName = tempData.parent
|
||||||
|
let summaryName = tempData.summaryName ? tempData.summaryName : 'Seluruh Unit'
|
||||||
|
|
||||||
|
data.forEach((item: any) => {
|
||||||
|
total.mom_bulan_kemarin.push(item.mom_bulan_kemarin)
|
||||||
|
total.mom_bulan_ini.push(item.mom_bulan_ini)
|
||||||
|
total.yoy_tahun_kemarin.push(item.yoy_tahun_kemarin)
|
||||||
|
total.yoy_tahun_ini.push(item.yoy_tahun_ini)
|
||||||
|
})
|
||||||
|
|
||||||
|
const totalMoMBulanKemarin =
|
||||||
|
total.mom_bulan_kemarin.reduce((a: number, b: number) => a + b, 0) /
|
||||||
|
total.mom_bulan_kemarin.length
|
||||||
|
const totalMoMBulanIni =
|
||||||
|
total.mom_bulan_ini.reduce((a: number, b: number) => a + b, 0) / total.mom_bulan_ini.length
|
||||||
|
const totalYoYTahunKemarin =
|
||||||
|
total.yoy_tahun_kemarin.reduce((a: number, b: number) => a + b, 0) /
|
||||||
|
total.yoy_tahun_kemarin.length
|
||||||
|
const totalYoYTahunIni =
|
||||||
|
total.yoy_tahun_ini.reduce((a: number, b: number) => a + b, 0) / total.yoy_tahun_ini.length
|
||||||
|
|
||||||
|
formattedData.push([{ content: parentName, colSpan: 7, styles: { fontStyle: 'bold' } }])
|
||||||
|
|
||||||
|
const result = [
|
||||||
|
formatNumber(totalMoMBulanKemarin),
|
||||||
|
formatNumber(totalMoMBulanIni),
|
||||||
|
formatPercentage(
|
||||||
|
!totalMoMBulanIni || !totalMoMBulanKemarin
|
||||||
|
? '0%'
|
||||||
|
: ((totalMoMBulanKemarin - totalMoMBulanIni) / totalMoMBulanKemarin) * 100
|
||||||
|
),
|
||||||
|
formatNumber(totalYoYTahunKemarin),
|
||||||
|
formatNumber(totalYoYTahunIni),
|
||||||
|
formatPercentage(
|
||||||
|
!totalYoYTahunIni || !totalYoYTahunKemarin
|
||||||
|
? '0%'
|
||||||
|
: ((totalYoYTahunKemarin - totalYoYTahunIni) / totalYoYTahunKemarin) * 100
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
|
formattedData.push([{ content: '1', styles: { halign: 'right' } }, summaryName, ...result])
|
||||||
|
formattedData.push([
|
||||||
|
{ content: 'RATA-RATA', colSpan: 2, styles: { fontStyle: 'bold' } },
|
||||||
|
...result
|
||||||
|
])
|
||||||
|
|
||||||
|
return formattedData
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) => {
|
const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) => {
|
||||||
@ -144,7 +251,7 @@ const exportToPDF = (reportMeta: any, rawData: any, preview: boolean = false) =>
|
|||||||
const date = new Date().getDate()
|
const date = new Date().getDate()
|
||||||
const month = new Date().toLocaleString('id-ID', { month: 'long' })
|
const month = new Date().toLocaleString('id-ID', { month: 'long' })
|
||||||
const year = new Date().getFullYear()
|
const year = new Date().getFullYear()
|
||||||
const data = formatData(rawData)
|
const data = formatData(rawData, reportMeta)
|
||||||
const doc = new jsPDF({
|
const doc = new jsPDF({
|
||||||
orientation: 'landscape'
|
orientation: 'landscape'
|
||||||
})
|
})
|
||||||
@ -383,6 +490,6 @@ const exportToXLSX = (reportMeta: any, e: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const exportToDOCX = (reportMeta: any, rawData: any) => {
|
const exportToDOCX = (reportMeta: any, rawData: any) => {
|
||||||
exportToWord(reportMeta, formatData(rawData), `Laporan ${reportName}`, null)
|
exportToWord(reportMeta, formatData(rawData, reportMeta), `Laporan ${reportName}`, null)
|
||||||
}
|
}
|
||||||
export { exportToPDF, exportToXLSX , exportToDOCX}
|
export { exportToPDF, exportToXLSX, exportToDOCX }
|
||||||
|
Reference in New Issue
Block a user