feat: create xls export in daftar gangguan dialihkan ke posko lain
This commit is contained in:
parent
39c75a6af8
commit
ae5bd2366e
@ -375,6 +375,24 @@ const dataDetail = ref<any>()
|
||||
const showDetail = ref(false)
|
||||
const closeDetail = () => (showDetail.value = false)
|
||||
|
||||
const setHeaderStyle = (
|
||||
worksheet: any,
|
||||
row: number,
|
||||
column: number,
|
||||
value: string,
|
||||
horizontalAlignment: boolean = false
|
||||
) => {
|
||||
const cell = worksheet.getRow(row).getCell(column)
|
||||
|
||||
cell.value = value
|
||||
cell.alignment = { vertical: 'middle' }
|
||||
cell.font = { bold: true }
|
||||
|
||||
if (horizontalAlignment) {
|
||||
cell.alignment.horizontal = 'center'
|
||||
}
|
||||
}
|
||||
|
||||
const onExporting = (e: any) => {
|
||||
const periode = reportMeta.value.periode ? reportMeta.value.periode.split(' s/d ') : ''
|
||||
|
||||
@ -401,7 +419,6 @@ const onExporting = (e: any) => {
|
||||
const doc = new jsPDF({
|
||||
orientation: 'landscape'
|
||||
})
|
||||
|
||||
autoTable(doc, {
|
||||
head: [
|
||||
['PT. PLN(Persero)', '', ''],
|
||||
@ -436,7 +453,6 @@ const onExporting = (e: any) => {
|
||||
theme: 'plain',
|
||||
startY: 10
|
||||
})
|
||||
|
||||
autoTable(doc, {
|
||||
head: [
|
||||
['DAFTAR GANGGUAN DIALIHKAN KE POSKO LAIN'],
|
||||
@ -452,7 +468,6 @@ const onExporting = (e: any) => {
|
||||
theme: 'plain',
|
||||
startY: 18
|
||||
})
|
||||
|
||||
autoTable(doc, {
|
||||
head: [
|
||||
[
|
||||
@ -525,7 +540,6 @@ const onExporting = (e: any) => {
|
||||
},
|
||||
startY: 23
|
||||
})
|
||||
|
||||
autoTable(doc, {
|
||||
head: [
|
||||
[`${dayTo}, ${dateToFormat}`],
|
||||
@ -547,7 +561,6 @@ const onExporting = (e: any) => {
|
||||
tableWidth: 50,
|
||||
margin: { left: 230 }
|
||||
})
|
||||
|
||||
doc
|
||||
.save('Laporan Daftar Gangguan Dialihkan Ke Posko Lain.pdf', { returnPromise: true })
|
||||
.then(() => {
|
||||
@ -557,15 +570,64 @@ const onExporting = (e: any) => {
|
||||
const workbook = new Workbook()
|
||||
const worksheet = workbook.addWorksheet('Daftar Gangguan Dialihkan Ke Posko Lain')
|
||||
|
||||
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,
|
||||
`POSKO : ${
|
||||
reportMeta.value.posko
|
||||
? reportMeta.value.posko.name.toUpperCase()
|
||||
: 'Semua Posko'.toUpperCase()
|
||||
}`
|
||||
)
|
||||
|
||||
setHeaderStyle(worksheet, 7, 8, `DAFTAR GANGGUAN DIALIHKAN KE POSKO LAIN`, true)
|
||||
setHeaderStyle(
|
||||
worksheet,
|
||||
8,
|
||||
8,
|
||||
`PERIODE TANGGAL : ${dateFromFormat} SD TGL ${dateToFormat}`,
|
||||
true
|
||||
)
|
||||
|
||||
worksheet.mergeCells('A1:F1')
|
||||
worksheet.mergeCells('A2:F2')
|
||||
worksheet.mergeCells('A3:F3')
|
||||
worksheet.mergeCells('A4:F4')
|
||||
worksheet.mergeCells('H7:I7')
|
||||
worksheet.mergeCells('H8:I8')
|
||||
|
||||
exportToExcel({
|
||||
component: e.component,
|
||||
worksheet,
|
||||
autoFilterEnabled: true
|
||||
autoFilterEnabled: true,
|
||||
topLeftCell: { row: 10, column: 1 }
|
||||
}).then(() => {
|
||||
workbook.xlsx.writeBuffer().then((buffer: any) => {
|
||||
saveAs(
|
||||
new Blob([buffer], { type: 'application/octet-stream' }),
|
||||
'Daftar Gangguan Dialihkan Ke Posko Lain.xlsx'
|
||||
'Laporan Daftar Gangguan Dialihkan Ke Posko Lain.xlsx'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
@ -1026,6 +1026,7 @@ import DetailDialog from '@/components/Dialogs/DetailDialog.vue'
|
||||
import InputText from '@/components/InputText.vue'
|
||||
import { apolloClient } from '@/utils/api/api.graphql'
|
||||
import { provideApolloClient } from '@vue/apollo-composable'
|
||||
import autoTable from 'jspdf-autotable'
|
||||
|
||||
const client = apolloClient()
|
||||
provideApolloClient(client)
|
||||
@ -1129,14 +1130,118 @@ const showDialogDataSelected = () => {
|
||||
|
||||
const onExporting = (e: any) => {
|
||||
if (e.format === 'pdf') {
|
||||
const doc = new jsPDF()
|
||||
const doc = new jsPDF({
|
||||
orientation: 'landscape'
|
||||
})
|
||||
|
||||
exportToPdf({
|
||||
jsPDFDocument: doc,
|
||||
component: e.component,
|
||||
indent: 5
|
||||
}).then(() => {
|
||||
doc.save(`.pdf`)
|
||||
autoTable(doc, {
|
||||
head: [
|
||||
// [
|
||||
// 'No',
|
||||
// 'No Laporan',
|
||||
// 'Nama Pelapor',
|
||||
// 'Alamat Pelapor',
|
||||
// 'No Telp Pelapor',
|
||||
// 'Keterangan Pelapor',
|
||||
// 'Status',
|
||||
// 'Tgl Lapor',
|
||||
// 'Tgl Response',
|
||||
// 'Tgl Recovery',
|
||||
// 'Durasi Response Time',
|
||||
// 'Durasi Recovery Time',
|
||||
// 'Sumber Lapor',
|
||||
// 'Tgl Media',
|
||||
// 'Keterangan Media'
|
||||
// ],
|
||||
// ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15']
|
||||
[
|
||||
{
|
||||
content: 'Nama Unit',
|
||||
rowSpan: 2
|
||||
},
|
||||
{
|
||||
content: 'Total',
|
||||
rowSpan: 2
|
||||
},
|
||||
{
|
||||
content: 'Selesai',
|
||||
rowSpan: 2
|
||||
},
|
||||
{
|
||||
content: '%',
|
||||
rowSpan: 2
|
||||
},
|
||||
{
|
||||
content: 'In Proses',
|
||||
rowSpan: 2
|
||||
},
|
||||
{
|
||||
content: '%',
|
||||
rowSpan: 2
|
||||
},
|
||||
{
|
||||
content: 'Dispatching Time',
|
||||
colSpan: 5
|
||||
},
|
||||
{
|
||||
content: 'Response Time',
|
||||
colSpan: 5
|
||||
},
|
||||
{
|
||||
content: 'Recovery Time',
|
||||
colSpan: 5
|
||||
}
|
||||
],
|
||||
['Rata-Rata', 'Max', 'Min', '>SLA', '<SLA']
|
||||
],
|
||||
// body: data.value.map((item, i) => [
|
||||
// { content: ++i, styles: { halign: 'right' } },
|
||||
// item.no_laporan,
|
||||
// item.nama_pelapor,
|
||||
// item.alamat_pelapor,
|
||||
// item.no_telp_pelapor,
|
||||
// item.keterangan_pelapor,
|
||||
// item.status_akhir,
|
||||
// item.waktu_lapor,
|
||||
// item.waktu_response,
|
||||
// item.waktu_recovery,
|
||||
// parseInt(item.durasi_response_time) ? formatWaktu(item.durasi_response_time) : '-',
|
||||
// parseInt(item.durasi_recovery_time) ? formatWaktu(item.durasi_recovery_time) : '-',
|
||||
// item.nama_posko,
|
||||
// item.waktu_media,
|
||||
// item.keterangan_media
|
||||
// ]),
|
||||
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',
|
||||
valign: 'middle'
|
||||
},
|
||||
bodyStyles: {
|
||||
textColor: [0, 0, 0]
|
||||
},
|
||||
didParseCell: function (data) {
|
||||
if (data.row.section === 'head') {
|
||||
data.cell.text = data.cell.text.map(function (word: any) {
|
||||
return word.toUpperCase()
|
||||
})
|
||||
}
|
||||
},
|
||||
startY: 23
|
||||
})
|
||||
|
||||
doc.save('Laporan Rekapitulasi Gangguan All.pdf', { returnPromise: true }).then(() => {
|
||||
console.log('pdf berhasil disimpan')
|
||||
})
|
||||
} else {
|
||||
const workbook = new Workbook()
|
||||
|
Loading…
x
Reference in New Issue
Block a user