fix: pdf style daftar gangguan diselesaikan mobile apkt
This commit is contained in:
parent
4906a99724
commit
56eba5fe0d
@ -242,20 +242,45 @@ const filterData = (params: any) => {
|
||||
idUid: uid ? uid.id : 0,
|
||||
idUp3: up3?.id ? up3.id : 0
|
||||
})
|
||||
|
||||
onResult((queryResult) => {
|
||||
if (queryResult.data != undefined) {
|
||||
data.value = queryResult.data.daftarGangguanDiselesaikanMobileAPKT
|
||||
}
|
||||
|
||||
reportMeta.value = filters.value
|
||||
console.log(queryResult.data)
|
||||
console.log(queryResult.loading)
|
||||
console.log(queryResult.networkStatus)
|
||||
})
|
||||
|
||||
onError((error) => {
|
||||
console.log(error)
|
||||
})
|
||||
}
|
||||
|
||||
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'
|
||||
@ -263,7 +288,59 @@ const onExporting = (e: any) => {
|
||||
|
||||
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()
|
||||
],
|
||||
[
|
||||
'POSKO',
|
||||
':',
|
||||
reportMeta.value.posko
|
||||
? reportMeta.value.posko.name.toUpperCase()
|
||||
: 'Semua Posko'.toUpperCase()
|
||||
]
|
||||
],
|
||||
styles: {
|
||||
fontSize: 3,
|
||||
cellPadding: 0.1,
|
||||
textColor: [0, 0, 0],
|
||||
fontStyle: 'bold'
|
||||
},
|
||||
theme: 'plain',
|
||||
startY: 10
|
||||
})
|
||||
|
||||
autoTable(doc, {
|
||||
head: [
|
||||
['Daftar Gangguan Diselesaikan Mobile APKT'.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',
|
||||
'Tgl Lapor',
|
||||
'Tgl Response',
|
||||
@ -280,7 +357,8 @@ const onExporting = (e: any) => {
|
||||
'Posko'
|
||||
]
|
||||
],
|
||||
body: data.value.map((item) => [
|
||||
body: data.value.map((item, i) => [
|
||||
{ content: ++i, styles: { halign: 'right' } },
|
||||
item.no_laporan,
|
||||
item.waktu_lapor,
|
||||
item.waktu_response,
|
||||
@ -297,11 +375,60 @@ const onExporting = (e: any) => {
|
||||
item.nama_posko
|
||||
]),
|
||||
styles: {
|
||||
fontSize: 4
|
||||
}
|
||||
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
|
||||
})
|
||||
|
||||
doc.save('Daftar Gangguan Diselesaikan Mobile APKT.pdf')
|
||||
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 Gangguan Diselesaikan Mobile APKT.pdf', { returnPromise: true })
|
||||
.then(() => {
|
||||
console.log('pdf berhasil disimpan')
|
||||
})
|
||||
} else {
|
||||
const workbook = new Workbook()
|
||||
const worksheet = workbook.addWorksheet('Daftar Gangguan Diselesaikan Mobile APKT')
|
||||
@ -324,6 +451,13 @@ const onExporting = (e: any) => {
|
||||
}
|
||||
|
||||
const filters = ref()
|
||||
const reportMeta = ref({
|
||||
uid: { id: 0, name: 'Semua Unit Induk Distribusi/Wilayah' },
|
||||
up3: { id: 0, name: 'Semua Unit Pelaksanaan Pelayanan Pelanggan' },
|
||||
posko: { id: 0, name: 'Semua Posko' },
|
||||
periode: ''
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
if (import.meta.env.DEV) {
|
||||
data.value = dummyData.gangguan.daftar.daftarGangguanDiselesaikanMobileAPKT
|
||||
|
Loading…
x
Reference in New Issue
Block a user