rekap monalisa gangguan , kpi , material
This commit is contained in:
@@ -17,6 +17,7 @@ import { jsPDF } from 'jspdf'
|
||||
import autoTable from 'jspdf-autotable'
|
||||
import { Workbook } from 'exceljs'
|
||||
import { setHeaderStyle } from '@/report/utils/xlsx'
|
||||
import { exportToWord } from './doc/Material_RPM_DOC'
|
||||
|
||||
const reportName = 'Rekapitulasi Pemakaian Material'
|
||||
const fontSize = 5
|
||||
@@ -212,28 +213,25 @@ const exportToXLSX = (reportMeta: any, e: any) => {
|
||||
worksheet,
|
||||
2,
|
||||
1,
|
||||
`DISTRIBUSI/WILAYAH : ${
|
||||
reportMeta.value.uid
|
||||
? reportMeta.value.uid.name.toUpperCase()
|
||||
: 'Semua Distribusi/Wilayah'.toUpperCase()
|
||||
`DISTRIBUSI/WILAYAH : ${reportMeta.value.uid
|
||||
? reportMeta.value.uid.name.toUpperCase()
|
||||
: 'Semua Distribusi/Wilayah'.toUpperCase()
|
||||
}`
|
||||
)
|
||||
setHeaderStyle(
|
||||
worksheet,
|
||||
3,
|
||||
1,
|
||||
`AREA : ${
|
||||
reportMeta.value.up3 ? reportMeta.value.up3.name.toUpperCase() : 'Semua Area'.toUpperCase()
|
||||
`AREA : ${reportMeta.value.up3 ? reportMeta.value.up3.name.toUpperCase() : 'Semua Area'.toUpperCase()
|
||||
}`
|
||||
)
|
||||
setHeaderStyle(
|
||||
worksheet,
|
||||
4,
|
||||
1,
|
||||
`POSKO : ${
|
||||
reportMeta.value.posko
|
||||
? reportMeta.value.posko.name.toUpperCase()
|
||||
: 'Semua Posko'.toUpperCase()
|
||||
`POSKO : ${reportMeta.value.posko
|
||||
? reportMeta.value.posko.name.toUpperCase()
|
||||
: 'Semua Posko'.toUpperCase()
|
||||
}`
|
||||
)
|
||||
|
||||
@@ -270,4 +268,7 @@ const exportToXLSX = (reportMeta: any, e: any) => {
|
||||
e.cancel = true
|
||||
}
|
||||
|
||||
export { exportToPDF, exportToXLSX }
|
||||
const exportToDOCX = (reportMeta: any, rawData: any) => {
|
||||
exportToWord(reportMeta, rawData, `Laporan ${reportName}`, formatMetaData(reportMeta))
|
||||
}
|
||||
export { exportToPDF, exportToXLSX, exportToDOCX }
|
||||
|
264
src/report/Material/Rekapitulasi/doc/Material_RPM_DOC.ts
Normal file
264
src/report/Material/Rekapitulasi/doc/Material_RPM_DOC.ts
Normal file
@@ -0,0 +1,264 @@
|
||||
|
||||
const company = "PT. PLN (Persero)";
|
||||
const exportToWord = (reportMeta: any, rawData: any, filename: any, periode: any) => {
|
||||
var preHtml = `<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:w='urn:schemas-microsoft-com:office:word' xmlns='http://www.w3.org/TR/REC-html40'><head><meta charset='utf-8'><title>${filename}</title>
|
||||
<style type="text/css" media="print">
|
||||
@page Section1 {
|
||||
size:841.95pt 21.0cm;
|
||||
mso-page-orientation:landscape;
|
||||
margin:72.0pt 72.0pt 72.0pt 72.0pt;
|
||||
mso-header-margin:35.4pt;
|
||||
mso-footer-margin:35.4pt;
|
||||
mso-paper-source:0;
|
||||
}
|
||||
@page{
|
||||
size: landscape;
|
||||
font-size: 5px;
|
||||
}
|
||||
div.Section1 {
|
||||
page:Section1;
|
||||
}
|
||||
table.main {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
text-transform: uppercase;
|
||||
font-size: 8px;
|
||||
}
|
||||
table.main thead tr {
|
||||
background-color: #c0c0c0;
|
||||
}
|
||||
</style>
|
||||
</head><body>
|
||||
<div class="Section1">
|
||||
`;
|
||||
var tbody = ``;
|
||||
var column = '';
|
||||
for (let i = 0; i < rawData.value.length; i++) {
|
||||
column += '<tr>';
|
||||
const item = rawData.value[i];
|
||||
|
||||
column += `<td>${item.kode}</td>`;
|
||||
column += `<td>${item.nama_material}</td>`;
|
||||
column += `<td>${item.satuan}</td>`;
|
||||
column += `<td>${item.sumber_material}</td>`;
|
||||
for (let a = 1; a <= 31; a++) {
|
||||
column += `<td>${item[`tgl${a}`]}</td>`;
|
||||
}
|
||||
column += `<td>${item.total}</td>`;
|
||||
column += '</tr>';
|
||||
}
|
||||
tbody += column;
|
||||
var body = `
|
||||
<table border=0 style="border:none">
|
||||
<tr>
|
||||
<td colspan="3"> ${company.toUpperCase()}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> Distribusi/Wilayah </td>
|
||||
<td>:</td>
|
||||
<td> ${reportMeta.uid
|
||||
? reportMeta.uid.name.toUpperCase()
|
||||
: 'Semua Unit Induk Distribusi/Wilayah'.toUpperCase()}</td>
|
||||
<tr>
|
||||
<td> Area</td>
|
||||
<td>:</td>
|
||||
<td> ${reportMeta.up3
|
||||
? reportMeta.up3.name.toUpperCase()
|
||||
: 'Semua Unit Pelaksanaan Pelayanan Pelanggan'.toUpperCase()}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> Posko</td>
|
||||
<td>:</td>
|
||||
<td> ${reportMeta.posko ? reportMeta.posko.name.toUpperCase() : 'Semua Posko'.toUpperCase()}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<center><h6>${filename.toUpperCase()}</h6></center>
|
||||
<center><h6>Periode : ${periode.dateFromFormat} s/d ${periode.dateToFormat} (${periode.dayTo})<h6></center>
|
||||
<table class="main">
|
||||
<thead>
|
||||
<tr>
|
||||
<th rowspan="2">No</th>
|
||||
<th rowspan="2">Kode Material</th>
|
||||
<th rowspan="2">Nama Material</th>
|
||||
<th rowspan="2">Satuan</th>
|
||||
<th rowspan="2">Sumber Material</th>
|
||||
<th colspan="31">Tanggal</th>
|
||||
<th rowspan="2">Jumlah</th>
|
||||
</tr>
|
||||
<tr>
|
||||
${Array.from({ length: 31 }, (_, i) => `<th>${i + 1}</th>`).join('\n')}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
${tbody}
|
||||
</tbody>
|
||||
</table>
|
||||
`
|
||||
|
||||
var postHtml = `<br>
|
||||
<footer>
|
||||
<p style="text-align: right; font-size: 10px;">${periode.dayTo}, ${periode.dateToFormat}</p>
|
||||
<br>
|
||||
<p style="text-align: right; font-size: 10px;">(.........................................)</p>
|
||||
</footer></div></body></html>`;
|
||||
|
||||
var html = preHtml + body + postHtml;
|
||||
|
||||
var url =
|
||||
"data:application/vnd.ms-word;charset=utf-8," + encodeURIComponent(html);
|
||||
|
||||
filename = filename ? filename + ".doc" : "document.doc";
|
||||
|
||||
var downloadLink = document.createElement("a");
|
||||
|
||||
document.body.appendChild(downloadLink);
|
||||
|
||||
downloadLink.href = url;
|
||||
|
||||
downloadLink.download = filename;
|
||||
|
||||
downloadLink.click();
|
||||
|
||||
document.body.removeChild(downloadLink);
|
||||
}
|
||||
|
||||
const exportDetailToWord = (reportMeta: any, rawData: any, filename: any, periode: any) => {
|
||||
var preHtml = `<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:w='urn:schemas-microsoft-com:office:word' xmlns='http://www.w3.org/TR/REC-html40'><head><meta charset='utf-8'><title>${filename}</title>
|
||||
<style type="text/css" media="print">
|
||||
@page Section1 {
|
||||
size:841.95pt 21.0cm;
|
||||
mso-page-orientation:landscape;
|
||||
margin:72.0pt 72.0pt 72.0pt 72.0pt;
|
||||
mso-header-margin:35.4pt;
|
||||
mso-footer-margin:35.4pt;
|
||||
mso-paper-source:0;
|
||||
}
|
||||
@page{
|
||||
size: landscape;
|
||||
font-size: 5px;
|
||||
}
|
||||
div.Section1 {
|
||||
page:Section1;
|
||||
}
|
||||
table.main {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
text-transform: uppercase;
|
||||
font-size: 8px;
|
||||
}
|
||||
table.main thead tr {
|
||||
background-color: #c0c0c0;
|
||||
}
|
||||
</style>
|
||||
</head><body>
|
||||
<div class="Section1">
|
||||
`;
|
||||
var tbody = ``;
|
||||
var cr = ``;
|
||||
rawData.map((item: any, i: any) => {
|
||||
cr += '<tr>';
|
||||
cr += `<td>${i + 1}</td>`;
|
||||
cr += `<td>${item.no_laporan}</td>`;
|
||||
cr += `<td>${item.waktu_lapor}</td>`;
|
||||
cr += `<td>${item.waktu_response}</td>`;
|
||||
cr += `<td>${item.waktu_recovery}</td>`;
|
||||
cr += `<td>${item.durasi_response_time}</td>`;
|
||||
cr += `<td>${item.durasi_recovery_time}</td>`;
|
||||
cr += `<td>${item.status_akhir}</td>`;
|
||||
cr += `<td>${item.idpel_nometer}</td>`;
|
||||
cr += `<td>${item.nama_pelapor}</td>`;
|
||||
cr += `<td>${item.alamat_pelapor}</td>`;
|
||||
cr += `<td>${item.no_telp_pelapor}</td>`;
|
||||
cr += `<td>${item.keterangan_pelapor}</td>`;
|
||||
cr += `<td>${item.nama_posko}</td>`;
|
||||
cr += `<td>${item.media}</td>`;
|
||||
cr += '<td></td>';
|
||||
cr += '<td></td>';
|
||||
cr += '<td></td>';
|
||||
cr += '</tr>';
|
||||
});
|
||||
tbody += cr;
|
||||
|
||||
var body = `
|
||||
<table border=0 style="border:none">
|
||||
<tr>
|
||||
<td colspan="3"> ${company.toUpperCase()}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> Unit Induk Distribusi/Wilayah </td>
|
||||
<td>:</td>
|
||||
<td> ${reportMeta.uid
|
||||
? reportMeta.uid.name.toUpperCase()
|
||||
: 'Semua Unit Induk Distribusi/Wilayah'.toUpperCase()}</td>
|
||||
<tr>
|
||||
<td> Unit Pelaksanaan Pelayanan Pelanggan</td>
|
||||
<td>:</td>
|
||||
<td> ${reportMeta.up3
|
||||
? reportMeta.up3.name.toUpperCase()
|
||||
: 'Semua Unit Pelaksanaan Pelayanan Pelanggan'.toUpperCase()}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> Posko</td>
|
||||
<td>:</td>
|
||||
<td> ${reportMeta.posko ? reportMeta.posko.name.toUpperCase() : 'Semua Posko'.toUpperCase()}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<center><h6>${filename.toUpperCase()}</h6></center>
|
||||
<center><h6>Periode : ${periode.dateFromFormat} s/d ${periode.dateToFormat} (${periode.dayTo})<h6></center>
|
||||
<table class="main">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>No</th>
|
||||
<th>No Laporan</th>
|
||||
<th>Tgl Lapor</th>
|
||||
<th>Tgl Datang</th>
|
||||
<th>Tgl Nyala</th>
|
||||
<th>Durasi Response Time</th>
|
||||
<th>Durasi Recovery Time</th>
|
||||
<th>Status</th>
|
||||
<th>IDPEL/NO METER</th>
|
||||
<th>Nama Pelapor</th>
|
||||
<th>Alamat Pelapor</th>
|
||||
<th>No Telp Pelapor</th>
|
||||
<th>Keterangan Pelapor</th>
|
||||
<th>Posko</th>
|
||||
<th>Sumber Lapor</th>
|
||||
<th>Nama Petugas</th>
|
||||
<th>Posko Asal</th>
|
||||
<th>Posko Tujuan</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
${tbody}
|
||||
</tbody>
|
||||
</table>
|
||||
`
|
||||
|
||||
var postHtml = `<br>
|
||||
<footer>
|
||||
<p style="text-align: right; font-size: 10px;">${periode.dayTo}, ${periode.dateToFormat}</p>
|
||||
<br>
|
||||
<p style="text-align: right; font-size: 10px;">(.........................................)</p>
|
||||
</footer></div></body></html>`;
|
||||
|
||||
var html = preHtml + body + postHtml;
|
||||
|
||||
var url =
|
||||
"data:application/vnd.ms-word;charset=utf-8," + encodeURIComponent(html);
|
||||
|
||||
filename = filename ? filename + ".doc" : "document.doc";
|
||||
|
||||
var downloadLink = document.createElement("a");
|
||||
|
||||
document.body.appendChild(downloadLink);
|
||||
|
||||
downloadLink.href = url;
|
||||
|
||||
downloadLink.download = filename;
|
||||
|
||||
downloadLink.click();
|
||||
|
||||
document.body.removeChild(downloadLink);
|
||||
}
|
||||
|
||||
export { exportToWord, exportDetailToWord }
|
Reference in New Issue
Block a user