feat: create export pdf, xlsx and docx in daftar keluhan selesai di cc
This commit is contained in:
parent
7b0afb4982
commit
d4dd36bd00
@ -322,15 +322,9 @@ import {
|
||||
DxSearchPanel,
|
||||
DxSelection
|
||||
} from 'devextreme-vue/data-grid'
|
||||
import { jsPDF } from 'jspdf'
|
||||
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'
|
||||
import autoTable from 'jspdf-autotable'
|
||||
import { exportToPDF, exportToXLSX, exportToDOCX } from '@/report/Keluhan/Daftar/DKeluhan_SelesaiCC'
|
||||
|
||||
const position = { of: '#data' }
|
||||
const showIndicator = ref(true)
|
||||
@ -361,197 +355,12 @@ const onSelectionChanged = ({ selectedRowsData }: any) => {
|
||||
}
|
||||
|
||||
const onExporting = (e: any) => {
|
||||
const periode = reportMeta.value.periode ? reportMeta.value.periode.split(' s/d ') : ''
|
||||
|
||||
let dateFromFormat = ''
|
||||
let dateToFormat = ''
|
||||
let dayTo = ''
|
||||
|
||||
if (periode != '') {
|
||||
const dateFrom = new Date(periode[0].split('-').reverse().join('-'))
|
||||
const dateTo = new Date(periode[1].split('-').reverse().join('-'))
|
||||
|
||||
dateFromFormat = `${dateFrom.getDate()}-${dateFrom.toLocaleString('default', {
|
||||
month: 'long'
|
||||
})}-${dateFrom.getFullYear()}`
|
||||
|
||||
dateToFormat = `${dateTo.getDate()}-${dateTo.toLocaleString('default', {
|
||||
month: 'long'
|
||||
})}-${dateTo.getFullYear()}`
|
||||
|
||||
dayTo = dateTo.toLocaleString('default', { weekday: 'long' })
|
||||
}
|
||||
|
||||
if (e.format === 'pdf') {
|
||||
const doc = new jsPDF({
|
||||
orientation: 'landscape'
|
||||
})
|
||||
|
||||
autoTable(doc, {
|
||||
head: [
|
||||
['PT. PLN(Persero)', '', ''],
|
||||
[
|
||||
{ content: 'UNIT INDUK', styles: { cellWidth: 25 } },
|
||||
{ content: ':', styles: { cellWidth: 1 } },
|
||||
reportMeta.value.uid
|
||||
? reportMeta.value.uid.name.toUpperCase()
|
||||
: 'Semua Unit Induk Distribusi/Wilayah'.toUpperCase()
|
||||
],
|
||||
[
|
||||
'UNIT PELAKSANA PELAYANAN PELANGGAN',
|
||||
':',
|
||||
reportMeta.value.up3
|
||||
? reportMeta.value.up3.name.toUpperCase()
|
||||
: 'Semua Unit Pelaksanaan Pelayanan Pelanggan'.toUpperCase()
|
||||
],
|
||||
[
|
||||
'UNIT LAYANAN PELANGGAN',
|
||||
':',
|
||||
reportMeta.value.ulp
|
||||
? reportMeta.value.ulp.name.toUpperCase()
|
||||
: 'Semua Unit Layanan Pelanggan'.toUpperCase()
|
||||
]
|
||||
],
|
||||
styles: {
|
||||
fontSize: 3,
|
||||
cellPadding: 0.1,
|
||||
textColor: [0, 0, 0],
|
||||
fontStyle: 'bold'
|
||||
},
|
||||
theme: 'plain',
|
||||
startY: 10
|
||||
})
|
||||
|
||||
autoTable(doc, {
|
||||
head: [
|
||||
['Daftar Keluhan Selesai di Contact Center'.toUpperCase()],
|
||||
[`PERIODE TANGGAL : ${dateFromFormat} SD TGL ${dateToFormat}`]
|
||||
],
|
||||
styles: {
|
||||
fontSize: 3,
|
||||
cellPadding: 0.1,
|
||||
textColor: [0, 0, 0],
|
||||
fontStyle: 'bold',
|
||||
halign: 'center'
|
||||
},
|
||||
theme: 'plain',
|
||||
startY: 18
|
||||
})
|
||||
|
||||
autoTable(doc, {
|
||||
head: [
|
||||
[
|
||||
'No',
|
||||
'No Laporan',
|
||||
'Contact Center',
|
||||
'UI Dist.',
|
||||
'ULP',
|
||||
'IDPEL/NO METER',
|
||||
'Nama Pelapor',
|
||||
'Alamat Pelapor',
|
||||
'No Tlp Pelapor',
|
||||
'Keterangan Pelapor',
|
||||
'APKT Status',
|
||||
'Created By',
|
||||
'Tgl Penyelesaian',
|
||||
'Lapor Ulang',
|
||||
'Sumber Lapor',
|
||||
'Issue Type',
|
||||
'Sub Issue Type'
|
||||
]
|
||||
],
|
||||
body: data.value.map((item: any, i: any) => [
|
||||
{ content: ++i, styles: { halign: 'right' } },
|
||||
item.no_laporan,
|
||||
item.nama_ulp,
|
||||
item.nama_uid,
|
||||
item.nama_ulp,
|
||||
item.idpel_nometer,
|
||||
item.nama_pelapor,
|
||||
item.alamat_pelapor,
|
||||
item.no_telp_pelapor,
|
||||
item.keterangan_pelapor,
|
||||
item.status_akhir,
|
||||
item.nama_pelapor,
|
||||
item.waktu_recovery,
|
||||
item.jumlah_lapor,
|
||||
item.media,
|
||||
item.nama_issuetype,
|
||||
item.nama_subissuetype
|
||||
]),
|
||||
styles: {
|
||||
fontSize: 3,
|
||||
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'
|
||||
},
|
||||
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: 23
|
||||
})
|
||||
|
||||
autoTable(doc, {
|
||||
head: [
|
||||
[`${dayTo}, ${dateToFormat}`],
|
||||
[
|
||||
{
|
||||
content: '(.........................................)',
|
||||
styles: { minCellHeight: 8, valign: 'bottom' }
|
||||
}
|
||||
]
|
||||
],
|
||||
styles: {
|
||||
fontSize: 3,
|
||||
cellPadding: 0.1,
|
||||
textColor: [0, 0, 0],
|
||||
fontStyle: 'bold',
|
||||
halign: 'center'
|
||||
},
|
||||
theme: 'plain',
|
||||
tableWidth: 50,
|
||||
margin: { left: 230 }
|
||||
})
|
||||
|
||||
doc
|
||||
.save('Laporan Daftar Keluhan Selesai di Contact Center.pdf', { returnPromise: true })
|
||||
.then(() => {
|
||||
console.log('pdf berhasil disimpan')
|
||||
})
|
||||
exportToPDF(reportMeta, data)
|
||||
} else if (e.format === 'xlsx') {
|
||||
exportToXLSX(reportMeta, e)
|
||||
} else {
|
||||
const workbook = new Workbook()
|
||||
const worksheet = workbook.addWorksheet('Daftar Keluhan Selesai di Contact Center')
|
||||
|
||||
exportToExcel({
|
||||
component: e.component,
|
||||
worksheet,
|
||||
autoFilterEnabled: true
|
||||
}).then(() => {
|
||||
workbook.xlsx.writeBuffer().then((buffer: any) => {
|
||||
saveAs(
|
||||
new Blob([buffer], { type: 'application/octet-stream' }),
|
||||
'Daftar Keluhan Selesai di Contact Center.xlsx'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
e.cancel = true
|
||||
exportToDOCX(reportMeta, data)
|
||||
}
|
||||
}
|
||||
|
||||
|
510
src/report/Keluhan/Daftar/DKeluhan_SelesaiCC.ts
Normal file
510
src/report/Keluhan/Daftar/DKeluhan_SelesaiCC.ts
Normal file
@ -0,0 +1,510 @@
|
||||
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 { 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'
|
||||
|
||||
const reportName = 'Daftar Keluhan Selesai di Contact Center'
|
||||
const fontSize = 4
|
||||
const docxFontSize = 6
|
||||
|
||||
const formatMetaData = (reportMeta: any) => {
|
||||
const periode = reportMeta.value.periode ? reportMeta.value.periode.split(' s/d ') : ''
|
||||
|
||||
let dateFromFormat = ''
|
||||
let dateToFormat = ''
|
||||
let dayTo = ''
|
||||
|
||||
if (periode != '') {
|
||||
const dateFrom = new Date(periode[0].split('-').reverse().join('-'))
|
||||
const dateTo = new Date(periode[1].split('-').reverse().join('-'))
|
||||
|
||||
dateFromFormat = `${dateFrom.getDate()}-${dateFrom.toLocaleString('default', {
|
||||
month: 'long'
|
||||
})}-${dateFrom.getFullYear()}`
|
||||
|
||||
dateToFormat = `${dateTo.getDate()}-${dateTo.toLocaleString('default', {
|
||||
month: 'long'
|
||||
})}-${dateTo.getFullYear()}`
|
||||
|
||||
dayTo = dateTo.toLocaleString('default', { weekday: 'long' })
|
||||
}
|
||||
|
||||
return { dateFromFormat, dateToFormat, dayTo }
|
||||
}
|
||||
|
||||
const exportToPDF = (reportMeta: any, data: any) => {
|
||||
const meta = formatMetaData(reportMeta)
|
||||
const doc = new jsPDF({
|
||||
orientation: 'landscape'
|
||||
})
|
||||
|
||||
autoTable(doc, {
|
||||
head: [
|
||||
['PT. PLN(Persero)', '', ''],
|
||||
[
|
||||
{ content: 'UNIT INDUK', styles: { cellWidth: 35 } },
|
||||
{ content: ':', styles: { cellWidth: 1 } },
|
||||
reportMeta.value.uid
|
||||
? reportMeta.value.uid.name.toUpperCase()
|
||||
: 'Semua Unit Induk Distribusi/Wilayah'.toUpperCase()
|
||||
],
|
||||
[
|
||||
'UNIT PELAKSANA PELAYANAN PELANGGAN',
|
||||
':',
|
||||
reportMeta.value.up3
|
||||
? reportMeta.value.up3.name.toUpperCase()
|
||||
: 'Semua Unit Pelaksanaan Pelayanan Pelanggan'.toUpperCase()
|
||||
],
|
||||
[
|
||||
'UNIT LAYANAN PELANGGAN',
|
||||
':',
|
||||
reportMeta.value.ulp
|
||||
? reportMeta.value.ulp.name.toUpperCase()
|
||||
: 'Semua Unit Layanan Pelanggan'.toUpperCase()
|
||||
]
|
||||
],
|
||||
styles: {
|
||||
fontSize,
|
||||
cellPadding: 0.1,
|
||||
textColor: [0, 0, 0],
|
||||
fontStyle: 'bold'
|
||||
},
|
||||
theme: 'plain',
|
||||
startY: 10
|
||||
})
|
||||
|
||||
autoTable(doc, {
|
||||
head: [
|
||||
[`${reportName}`.toUpperCase()],
|
||||
[`PERIODE TANGGAL : ${meta.dateFromFormat} SD TGL ${meta.dateToFormat}`]
|
||||
],
|
||||
styles: {
|
||||
fontSize,
|
||||
cellPadding: 0.1,
|
||||
textColor: [0, 0, 0],
|
||||
fontStyle: 'bold',
|
||||
halign: 'center'
|
||||
},
|
||||
theme: 'plain',
|
||||
startY: 25
|
||||
})
|
||||
|
||||
autoTable(doc, {
|
||||
head: [
|
||||
[
|
||||
'No',
|
||||
'No Laporan',
|
||||
'Contact Center',
|
||||
'UI Dist.',
|
||||
'ULP',
|
||||
'IDPEL/NO METER',
|
||||
'Nama Pelapor',
|
||||
'Alamat Pelapor',
|
||||
'No Tlp Pelapor',
|
||||
'Keterangan Pelapor',
|
||||
'APKT Status',
|
||||
'Created By',
|
||||
'Tgl Penyelesaian',
|
||||
'Lapor Ulang',
|
||||
'Sumber Lapor',
|
||||
'Issue Type',
|
||||
'Sub Issue Type'
|
||||
]
|
||||
],
|
||||
body: data.value.map((item: any, i: any) => [
|
||||
{ content: ++i, styles: { halign: 'right' } },
|
||||
item.no_laporan,
|
||||
item.nama_ulp,
|
||||
item.nama_uid,
|
||||
item.nama_ulp,
|
||||
item.idpel_nometer,
|
||||
item.nama_pelapor,
|
||||
item.alamat_pelapor,
|
||||
item.no_telp_pelapor,
|
||||
item.keterangan_pelapor,
|
||||
item.status_akhir,
|
||||
item.nama_pelapor,
|
||||
item.waktu_recovery,
|
||||
item.jumlah_lapor,
|
||||
item.media,
|
||||
item.nama_issuetype,
|
||||
item.nama_subissuetype
|
||||
]),
|
||||
styles: {
|
||||
fontSize,
|
||||
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'
|
||||
},
|
||||
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: 35
|
||||
})
|
||||
|
||||
autoTable(doc, {
|
||||
head: [
|
||||
[`${meta.dayTo}, ${meta.dateToFormat}`],
|
||||
[
|
||||
{
|
||||
content: '(.........................................)',
|
||||
styles: { minCellHeight: 8, valign: 'bottom' }
|
||||
}
|
||||
]
|
||||
],
|
||||
styles: {
|
||||
fontSize,
|
||||
cellPadding: 0.1,
|
||||
textColor: [0, 0, 0],
|
||||
fontStyle: 'bold',
|
||||
halign: 'center'
|
||||
},
|
||||
theme: 'plain',
|
||||
tableWidth: 50,
|
||||
margin: { left: 230 }
|
||||
})
|
||||
|
||||
doc.save(`Laporan ${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.value.uid
|
||||
? reportMeta.value.uid.name.toUpperCase()
|
||||
: 'Semua Unit Induk Distribusi/Wilayah'.toUpperCase()
|
||||
}`
|
||||
)
|
||||
setHeaderStyle(
|
||||
worksheet,
|
||||
3,
|
||||
1,
|
||||
`UNIT PELAKSANA PELAYANAN PELANGGAN : ${
|
||||
reportMeta.value.up3
|
||||
? reportMeta.value.up3.name.toUpperCase()
|
||||
: 'Semua Unit Pelaksanaan Pelayanan Pelanggan'.toUpperCase()
|
||||
}`
|
||||
)
|
||||
setHeaderStyle(
|
||||
worksheet,
|
||||
4,
|
||||
1,
|
||||
`UNIT LAYANAN PELANGGAN : ${
|
||||
reportMeta.value.posko
|
||||
? reportMeta.value.posko.name.toUpperCase()
|
||||
: 'Semua Unit Layanan Pelanggan'.toUpperCase()
|
||||
}`
|
||||
)
|
||||
|
||||
setHeaderStyle(worksheet, 6, 1, `${reportName}`.toUpperCase(), true)
|
||||
setHeaderStyle(
|
||||
worksheet,
|
||||
7,
|
||||
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('A6:Q6')
|
||||
worksheet.mergeCells('A7:Q7')
|
||||
|
||||
exportToExcel({
|
||||
component: e.component,
|
||||
worksheet,
|
||||
autoFilterEnabled: true,
|
||||
topLeftCell: { row: 9, column: 1 }
|
||||
}).then(() => {
|
||||
workbook.xlsx.writeBuffer().then((buffer: any) => {
|
||||
saveAs(new Blob([buffer], { type: 'application/octet-stream' }), `Laporan ${reportName}.xlsx`)
|
||||
})
|
||||
})
|
||||
|
||||
e.cancel = true
|
||||
}
|
||||
|
||||
const exportToDOCX = (reportMeta: any, data: any) => {
|
||||
const meta = formatMetaData(reportMeta)
|
||||
|
||||
const generateRows = () => {
|
||||
return data.value.map((item: any, i: any) => {
|
||||
return new TableRow({
|
||||
children: [
|
||||
{ text: `${++i}`, field: 'no' },
|
||||
{ text: item.no_laporan, field: 'no_laporan' },
|
||||
{ text: item.nama_ulp, field: 'nama_ulp' },
|
||||
{ text: item.nama_uid, field: 'nama_uid' },
|
||||
{ text: item.nama_ulp, field: 'nama_ulp' },
|
||||
{ text: item.idpel_nometer, field: 'idpel_nometer' },
|
||||
{ text: item.nama_pelapor, field: 'nama_pelapor' },
|
||||
{ text: item.alamat_pelapor, field: 'alamat_pelapor' },
|
||||
{ text: item.no_telp_pelapor, field: 'no_telp_pelapor' },
|
||||
{ text: item.keterangan_pelapor, field: 'keterangan_pelapor' },
|
||||
{ text: item.status_akhir, field: 'status_akhir' },
|
||||
{ text: item.nama_pelapor, field: 'nama_pelapor' },
|
||||
{ text: formatWaktu(item.waktu_recovery), field: 'waktu_recovery' },
|
||||
{ text: item.jumlah_lapor, field: 'jumlah_lapor' },
|
||||
{ text: item.media, field: 'media' },
|
||||
{ text: item.nama_issuetype, field: 'nama_issuetype' },
|
||||
{ text: item.nama_subissuetype, field: 'nama_subissuetype' }
|
||||
].map(
|
||||
(cell) =>
|
||||
new TableCell({
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun({
|
||||
text: cell.text,
|
||||
size: docxFontSize
|
||||
})
|
||||
]
|
||||
})
|
||||
],
|
||||
verticalAlign: VerticalAlign.CENTER,
|
||||
margins: { top: 0, bottom: 0, right: 0, left: 30 }
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
{
|
||||
properties: {
|
||||
page: {
|
||||
size: {
|
||||
orientation: PageOrientation.LANDSCAPE
|
||||
}
|
||||
}
|
||||
},
|
||||
children: [
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun({
|
||||
text: 'PT. PLN(Persero)',
|
||||
bold: true,
|
||||
size: docxFontSize
|
||||
})
|
||||
]
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun({
|
||||
text: `UNIT INDUK : ${
|
||||
reportMeta.value.uid
|
||||
? reportMeta.value.uid.name.toUpperCase()
|
||||
: 'Semua Unit Induk Distribusi/Wilayah'.toUpperCase()
|
||||
}`,
|
||||
bold: true,
|
||||
size: docxFontSize
|
||||
})
|
||||
]
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun({
|
||||
text: `UNIT PELAKSANA PELAYANAN PELANGGAN : ${
|
||||
reportMeta.value.up3
|
||||
? reportMeta.value.up3.name.toUpperCase()
|
||||
: 'Semua Unit Pelaksanaan Pelayanan Pelanggan'.toUpperCase()
|
||||
}`,
|
||||
bold: true,
|
||||
size: docxFontSize
|
||||
})
|
||||
]
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun({
|
||||
text: `UNIT LAYANAN PELANGGAN : ${
|
||||
reportMeta.value.ulp
|
||||
? reportMeta.value.ulp.name.toUpperCase()
|
||||
: 'Semua Unit Layanan Pelanggan'.toUpperCase()
|
||||
}`,
|
||||
bold: true,
|
||||
size: docxFontSize
|
||||
})
|
||||
]
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun({
|
||||
text: '',
|
||||
bold: true,
|
||||
size: docxFontSize
|
||||
})
|
||||
]
|
||||
}),
|
||||
new Paragraph({
|
||||
alignment: AlignmentType.CENTER,
|
||||
children: [
|
||||
new TextRun({
|
||||
text: `${reportName}`.toUpperCase(),
|
||||
bold: true,
|
||||
size: docxFontSize
|
||||
})
|
||||
]
|
||||
}),
|
||||
new Paragraph({
|
||||
alignment: AlignmentType.CENTER,
|
||||
children: [
|
||||
new TextRun({
|
||||
text: `PERIODE TANGGAL : ${meta.dateFromFormat} SD TGL ${meta.dateToFormat}`,
|
||||
bold: true,
|
||||
size: docxFontSize
|
||||
})
|
||||
]
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun({
|
||||
text: '',
|
||||
bold: true,
|
||||
size: docxFontSize
|
||||
})
|
||||
]
|
||||
}),
|
||||
new Table({
|
||||
width: {
|
||||
size: 13950,
|
||||
type: WidthType.DXA
|
||||
},
|
||||
rows: [
|
||||
new TableRow({
|
||||
children: [
|
||||
{ text: 'No', field: 'no' },
|
||||
{ text: 'No Laporan', field: 'no_laporan' },
|
||||
{ text: 'Contact Center', field: 'nama_ulp' },
|
||||
{ text: 'UI Dist.', field: 'nama_uid' },
|
||||
{ text: 'ULP', field: 'nama_ulp' },
|
||||
{ text: 'IDPEL/NO METER', field: 'idpel_nometer' },
|
||||
{ text: 'Nama Pelapor', field: 'nama_pelapor' },
|
||||
{ text: 'Alamat Pelapor', field: 'alamat_pelapor' },
|
||||
{ text: 'No Tlp Pelapor', field: 'no_telp_pelapor' },
|
||||
{ text: 'Keterangan Pelapor', field: 'keterangan_pelapor' },
|
||||
{ text: 'APKT Status', field: 'status_akhir' },
|
||||
{ text: 'Created By', field: 'nama_pelapor' },
|
||||
{ text: 'Tgl Penyelesaian', field: 'waktu_recovery' },
|
||||
{ text: 'Lapor Ulang', field: 'jumlah_lapor' },
|
||||
{ text: 'Sumber Lapor', field: 'media' },
|
||||
{ text: 'Issue Type', field: 'nama_issuetype' },
|
||||
{ text: 'Sub Issue Type', field: 'nama_subissuetype' }
|
||||
].map(
|
||||
(header) =>
|
||||
new TableCell({
|
||||
children: [
|
||||
new Paragraph({
|
||||
alignment: AlignmentType.CENTER,
|
||||
children: [
|
||||
new TextRun({
|
||||
text: header.text,
|
||||
bold: true,
|
||||
size: docxFontSize,
|
||||
allCaps: true
|
||||
})
|
||||
]
|
||||
})
|
||||
],
|
||||
verticalAlign: VerticalAlign.CENTER
|
||||
})
|
||||
)
|
||||
}),
|
||||
...generateRows()
|
||||
]
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun({
|
||||
text: '',
|
||||
bold: true,
|
||||
size: docxFontSize
|
||||
})
|
||||
]
|
||||
}),
|
||||
new Paragraph({
|
||||
alignment: AlignmentType.RIGHT,
|
||||
children: [
|
||||
new TextRun({
|
||||
text: `${meta.dayTo}, ${meta.dateToFormat}`,
|
||||
bold: true,
|
||||
size: docxFontSize
|
||||
})
|
||||
]
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun({
|
||||
text: '',
|
||||
bold: true,
|
||||
size: docxFontSize
|
||||
})
|
||||
]
|
||||
}),
|
||||
new Paragraph({
|
||||
alignment: AlignmentType.RIGHT,
|
||||
children: [
|
||||
new TextRun({
|
||||
text: '(.........................................)',
|
||||
bold: true,
|
||||
size: docxFontSize
|
||||
})
|
||||
]
|
||||
})
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
Packer.toBlob(doc).then((blob) => {
|
||||
saveAs(blob, `Laporan ${reportName}.docx`)
|
||||
console.log('Document created successfully')
|
||||
})
|
||||
}
|
||||
|
||||
export { exportToPDF, exportToXLSX, exportToDOCX }
|
Loading…
x
Reference in New Issue
Block a user