feat: create pdf export in daftar keluhan dialihkan ke posko lain
This commit is contained in:
parent
e9b05e76d0
commit
f3dfec2dd0
@ -1,56 +1,175 @@
|
|||||||
<template>
|
<template>
|
||||||
<Filters @reset-form="data = []" @run-search="() => filterData(filters)" class="mb-4">
|
<Filters @reset-form="data = []" @run-search="() => filterData(filters)" class="mb-4">
|
||||||
<Type3 @update:filters="(value) => filters = value" />
|
<Type3 @update:filters="(value) => (filters = value)" />
|
||||||
</Filters>
|
</Filters>
|
||||||
|
|
||||||
<div id="data">
|
<div id="data">
|
||||||
<DxDataGrid class="max-h-[calc(100vh-140px)] mb-10" :data-source="data" :show-column-lines="true"
|
<DxDataGrid
|
||||||
:show-row-lines="false" :show-borders="true" :row-alternation-enabled="true" :hover-state-enabled="true"
|
class="max-h-[calc(100vh-140px)] mb-10"
|
||||||
@selection-changed="onSelectionChanged" :column-width="100" @exporting="onExporting" :allow-column-resizing="true"
|
:data-source="data"
|
||||||
column-resizing-mode="widget" :word-wrap-enabled="true">
|
:show-column-lines="true"
|
||||||
|
:show-row-lines="false"
|
||||||
|
:show-borders="true"
|
||||||
|
:row-alternation-enabled="true"
|
||||||
|
:hover-state-enabled="true"
|
||||||
|
@selection-changed="onSelectionChanged"
|
||||||
|
:column-width="100"
|
||||||
|
@exporting="onExporting"
|
||||||
|
:allow-column-resizing="true"
|
||||||
|
column-resizing-mode="widget"
|
||||||
|
:word-wrap-enabled="true"
|
||||||
|
>
|
||||||
<DxSelection mode="single" />
|
<DxSelection mode="single" />
|
||||||
<DxPaging :page-size="5" :enabled="true" />
|
<DxPaging :page-size="5" :enabled="true" />
|
||||||
<DxPager :visible="true" :allowed-page-sizes="[5, 10, 20]" display-mode="full" :show-page-size-selector="true"
|
<DxPager
|
||||||
:show-info="true" :show-navigation-buttons="true" />
|
:visible="true"
|
||||||
<DxLoadPanel :position="position" :show-indicator="showIndicator" :show-pane="showPane" :shading="shading"
|
:allowed-page-sizes="[5, 10, 20]"
|
||||||
v-if="loading" v-model:visible="loading" :enabled="true" />
|
display-mode="full"
|
||||||
|
:show-page-size-selector="true"
|
||||||
|
:show-info="true"
|
||||||
|
:show-navigation-buttons="true"
|
||||||
|
/>
|
||||||
|
<DxLoadPanel
|
||||||
|
:position="position"
|
||||||
|
:show-indicator="showIndicator"
|
||||||
|
:show-pane="showPane"
|
||||||
|
:shading="shading"
|
||||||
|
v-if="loading"
|
||||||
|
v-model:visible="loading"
|
||||||
|
:enabled="true"
|
||||||
|
/>
|
||||||
<DxSearchPanel :visible="true" :highlight-case-sensitive="true" />
|
<DxSearchPanel :visible="true" :highlight-case-sensitive="true" />
|
||||||
<DxExport :enabled="true" :formats="['pdf', 'xlsx', 'document']" :allow-export-selected-data="false" />
|
<DxExport
|
||||||
|
:enabled="true"
|
||||||
|
:formats="['pdf', 'xlsx', 'document']"
|
||||||
|
:allow-export-selected-data="false"
|
||||||
|
/>
|
||||||
<DxColumnFixing :enabled="true" />
|
<DxColumnFixing :enabled="true" />
|
||||||
|
|
||||||
<DxColumn css-class="custom-table-column !align-top" :width="50" alignment="center"
|
<DxColumn
|
||||||
:calculateCellValue="(item: any) => data.findIndex((i) => i == item) + 1" data-type="number" caption="No"
|
css-class="custom-table-column !align-top"
|
||||||
cell-template="cellRight" />
|
:width="50"
|
||||||
<DxColumn :width="170" alignment="center" data-field="no_laporan" caption="No Laporan"
|
alignment="center"
|
||||||
css-class="custom-table-column !align-top" cell-template="cellLeft" />
|
:calculateCellValue="(item: any) => data.findIndex((i) => i == item) + 1"
|
||||||
<DxColumn :width="170" alignment="center" data-field="pembuat_laporan" caption="Pembuat Laporan"
|
data-type="number"
|
||||||
css-class="custom-table-column !align-top" cell-template="cellLeft" />
|
caption="No"
|
||||||
<DxColumn :width="170" alignment="center" data-field="waktu_lapor" caption="Tgl Lapor"
|
cell-template="cellRight"
|
||||||
css-class="custom-table-column !align-top" />
|
/>
|
||||||
<DxColumn :width="170" alignment="center" data-field="waktu_dialihkan" caption="Tgl Dialihkan"
|
<DxColumn
|
||||||
css-class="custom-table-column !align-top" />
|
:width="170"
|
||||||
<DxColumn :width="170" alignment="center" data-field="waktu_response" caption="Tgl Response"
|
alignment="center"
|
||||||
css-class="custom-table-column !align-top" />
|
data-field="no_laporan"
|
||||||
<DxColumn :width="170" alignment="center" data-field="waktu_recovery" caption="Tgl Recovery"
|
caption="No Laporan"
|
||||||
css-class="custom-table-column !align-top" />
|
css-class="custom-table-column !align-top"
|
||||||
<DxColumn :width="170" alignment="center" data-field="durasi_response_time" caption="Durasi Response Time"
|
cell-template="cellLeft"
|
||||||
css-class="custom-table-column !align-top" cell-template="data-waktu" />
|
/>
|
||||||
<DxColumn :width="170" alignment="center" data-field="durasi_recovery_time" caption="Durasi Recovery Time"
|
<DxColumn
|
||||||
css-class="custom-table-column !align-top" cell-template="data-waktu" />
|
:width="170"
|
||||||
<DxColumn :width="170" alignment="center" data-field="nama_unit_lama" caption="Unit Asal"
|
alignment="center"
|
||||||
css-class="custom-table-column !align-top" cell-template="cellLeft" />
|
data-field="pembuat_laporan"
|
||||||
<DxColumn :width="120" alignment="center" data-field="status_akhir" caption="Status"
|
caption="Pembuat Laporan"
|
||||||
css-class="custom-table-column !align-top" cell-template="cellLeft" />
|
css-class="custom-table-column !align-top"
|
||||||
<DxColumn :width="170" alignment="center" data-field="idpel_nometer" caption="IDPEL/NO METER"
|
cell-template="cellLeft"
|
||||||
css-class="custom-table-column !align-top" />
|
/>
|
||||||
<DxColumn :width="170" alignment="center" data-field="nama_pelapor" caption="Nama Pelapor"
|
<DxColumn
|
||||||
css-class="custom-table-column !align-top" cell-template="cellLeft" />
|
:width="170"
|
||||||
<DxColumn :width="170" alignment="center" data-field="alamat_pelapor" caption="Alamat Pelapor"
|
alignment="center"
|
||||||
css-class="custom-table-column !align-top" cell-template="cellLeft" />
|
data-field="waktu_lapor"
|
||||||
<DxColumn :width="170" alignment="center" data-field="no_telp_pelapor" caption="No Telp Pelapor"
|
caption="Tgl Lapor"
|
||||||
css-class="custom-table-column !align-top" cell-template="cellLeft" />
|
css-class="custom-table-column !align-top"
|
||||||
<DxColumn :width="170" alignment="center" data-field="keterangan_pelapor" caption="Keterangan Pelapor"
|
/>
|
||||||
css-class="custom-table-column !align-top" cell-template="cellLeft" />
|
<DxColumn
|
||||||
|
:width="170"
|
||||||
|
alignment="center"
|
||||||
|
data-field="waktu_dialihkan"
|
||||||
|
caption="Tgl Dialihkan"
|
||||||
|
css-class="custom-table-column !align-top"
|
||||||
|
/>
|
||||||
|
<DxColumn
|
||||||
|
:width="170"
|
||||||
|
alignment="center"
|
||||||
|
data-field="waktu_response"
|
||||||
|
caption="Tgl Response"
|
||||||
|
css-class="custom-table-column !align-top"
|
||||||
|
/>
|
||||||
|
<DxColumn
|
||||||
|
:width="170"
|
||||||
|
alignment="center"
|
||||||
|
data-field="waktu_recovery"
|
||||||
|
caption="Tgl Recovery"
|
||||||
|
css-class="custom-table-column !align-top"
|
||||||
|
/>
|
||||||
|
<DxColumn
|
||||||
|
:width="170"
|
||||||
|
alignment="center"
|
||||||
|
data-field="durasi_response_time"
|
||||||
|
caption="Durasi Response Time"
|
||||||
|
css-class="custom-table-column !align-top"
|
||||||
|
cell-template="data-waktu"
|
||||||
|
/>
|
||||||
|
<DxColumn
|
||||||
|
:width="170"
|
||||||
|
alignment="center"
|
||||||
|
data-field="durasi_recovery_time"
|
||||||
|
caption="Durasi Recovery Time"
|
||||||
|
css-class="custom-table-column !align-top"
|
||||||
|
cell-template="data-waktu"
|
||||||
|
/>
|
||||||
|
<DxColumn
|
||||||
|
:width="170"
|
||||||
|
alignment="center"
|
||||||
|
data-field="nama_unit_lama"
|
||||||
|
caption="Unit Asal"
|
||||||
|
css-class="custom-table-column !align-top"
|
||||||
|
cell-template="cellLeft"
|
||||||
|
/>
|
||||||
|
<DxColumn
|
||||||
|
:width="120"
|
||||||
|
alignment="center"
|
||||||
|
data-field="status_akhir"
|
||||||
|
caption="Status"
|
||||||
|
css-class="custom-table-column !align-top"
|
||||||
|
cell-template="cellLeft"
|
||||||
|
/>
|
||||||
|
<DxColumn
|
||||||
|
:width="170"
|
||||||
|
alignment="center"
|
||||||
|
data-field="idpel_nometer"
|
||||||
|
caption="IDPEL/NO METER"
|
||||||
|
css-class="custom-table-column !align-top"
|
||||||
|
/>
|
||||||
|
<DxColumn
|
||||||
|
:width="170"
|
||||||
|
alignment="center"
|
||||||
|
data-field="nama_pelapor"
|
||||||
|
caption="Nama Pelapor"
|
||||||
|
css-class="custom-table-column !align-top"
|
||||||
|
cell-template="cellLeft"
|
||||||
|
/>
|
||||||
|
<DxColumn
|
||||||
|
:width="170"
|
||||||
|
alignment="center"
|
||||||
|
data-field="alamat_pelapor"
|
||||||
|
caption="Alamat Pelapor"
|
||||||
|
css-class="custom-table-column !align-top"
|
||||||
|
cell-template="cellLeft"
|
||||||
|
/>
|
||||||
|
<DxColumn
|
||||||
|
:width="170"
|
||||||
|
alignment="center"
|
||||||
|
data-field="no_telp_pelapor"
|
||||||
|
caption="No Telp Pelapor"
|
||||||
|
css-class="custom-table-column !align-top"
|
||||||
|
cell-template="cellLeft"
|
||||||
|
/>
|
||||||
|
<DxColumn
|
||||||
|
:width="170"
|
||||||
|
alignment="center"
|
||||||
|
data-field="keterangan_pelapor"
|
||||||
|
caption="Keterangan Pelapor"
|
||||||
|
css-class="custom-table-column !align-top"
|
||||||
|
cell-template="cellLeft"
|
||||||
|
/>
|
||||||
|
|
||||||
<template #cellCenter="{ data }">
|
<template #cellCenter="{ data }">
|
||||||
<p class="cursor-pointer">
|
<p class="cursor-pointer">
|
||||||
@ -66,9 +185,13 @@
|
|||||||
|
|
||||||
<template #cellRight="{ data }">
|
<template #cellRight="{ data }">
|
||||||
<p class="text-right cursor-pointer">
|
<p class="text-right cursor-pointer">
|
||||||
{{ isNumber(data.text) ? data.column.caption == '%' ? formatPercentage(data.text) :
|
{{
|
||||||
formatNumber(data.text) :
|
isNumber(data.text)
|
||||||
data.text }}
|
? data.column.caption == '%'
|
||||||
|
? formatPercentage(data.text)
|
||||||
|
: formatNumber(data.text)
|
||||||
|
: data.text
|
||||||
|
}}
|
||||||
</p>
|
</p>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -97,7 +220,6 @@ import {
|
|||||||
DxSearchPanel,
|
DxSearchPanel,
|
||||||
DxSelection
|
DxSelection
|
||||||
} from 'devextreme-vue/data-grid'
|
} from 'devextreme-vue/data-grid'
|
||||||
import { jsPDF } from 'jspdf'
|
|
||||||
import { exportDataGrid as exportToPdf } from 'devextreme/pdf_exporter'
|
import { exportDataGrid as exportToPdf } from 'devextreme/pdf_exporter'
|
||||||
import { exportDataGrid as exportToExcel } from 'devextreme/excel_exporter'
|
import { exportDataGrid as exportToExcel } from 'devextreme/excel_exporter'
|
||||||
import { saveAs } from 'file-saver'
|
import { saveAs } from 'file-saver'
|
||||||
@ -106,6 +228,8 @@ import { useQuery } from '@vue/apollo-composable'
|
|||||||
import { queries } from '@/utils/api/api.graphql'
|
import { queries } from '@/utils/api/api.graphql'
|
||||||
import { dummyData } from '@/utils/dummy'
|
import { dummyData } from '@/utils/dummy'
|
||||||
import { formatNumber, formatPercentage, isNumber } from '@/utils/numbers'
|
import { formatNumber, formatPercentage, isNumber } from '@/utils/numbers'
|
||||||
|
import { jsPDF } from 'jspdf'
|
||||||
|
import autoTable from 'jspdf-autotable'
|
||||||
|
|
||||||
const position = { of: '#data' }
|
const position = { of: '#data' }
|
||||||
const showIndicator = ref(true)
|
const showIndicator = ref(true)
|
||||||
@ -114,18 +238,58 @@ const showPane = ref(true)
|
|||||||
|
|
||||||
const onExporting = (e: any) => {
|
const onExporting = (e: any) => {
|
||||||
if (e.format === 'pdf') {
|
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 Laporan',
|
||||||
|
'Pembuat Laporan',
|
||||||
|
'Tgl Lapor',
|
||||||
|
'Tgl Dialihkan',
|
||||||
|
'Tgl Response',
|
||||||
|
'Tgl Recovery',
|
||||||
|
'Durasi Response Time',
|
||||||
|
'Durasi Recovery Time',
|
||||||
|
'Posko Asal',
|
||||||
|
'Posko Tujuan',
|
||||||
|
'Status',
|
||||||
|
'IDPEL/NO METER',
|
||||||
|
'Nama Pelapor',
|
||||||
|
'Alamat Pelapor',
|
||||||
|
'No Telp Pelapor',
|
||||||
|
'Keterangan Pelapor'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
body: data.value.map((item: any) => [
|
||||||
|
item.no_laporan,
|
||||||
|
item.pembuat_laporan,
|
||||||
|
item.waktu_lapor,
|
||||||
|
item.waktu_dialihkan,
|
||||||
|
item.waktu_response,
|
||||||
|
item.waktu_recovery,
|
||||||
|
item.durasi_response_time,
|
||||||
|
item.durasi_recovery_time,
|
||||||
|
item.nama_unit_lama,
|
||||||
|
item.nama_unit_tujuan,
|
||||||
|
item.status_akhir,
|
||||||
|
item.idpel_nometer,
|
||||||
|
item.nama_pelapor,
|
||||||
|
item.alamat_pelapor,
|
||||||
|
item.no_telp_pelapor,
|
||||||
|
item.keterangan_pelapor
|
||||||
|
]),
|
||||||
|
styles: {
|
||||||
|
fontSize: 4
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
doc.save('Daftar Gangguan Dialihkan Ke Posko Lain.pdf')
|
||||||
} else {
|
} else {
|
||||||
const workbook = new Workbook()
|
const workbook = new Workbook()
|
||||||
const worksheet = workbook.addWorksheet('Employees')
|
const worksheet = workbook.addWorksheet('Daftar Gangguan Dialihkan Ke Posko Lain')
|
||||||
|
|
||||||
exportToExcel({
|
exportToExcel({
|
||||||
component: e.component,
|
component: e.component,
|
||||||
@ -133,7 +297,10 @@ const onExporting = (e: any) => {
|
|||||||
autoFilterEnabled: true
|
autoFilterEnabled: true
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
workbook.xlsx.writeBuffer().then((buffer: any) => {
|
workbook.xlsx.writeBuffer().then((buffer: any) => {
|
||||||
saveAs(new Blob([buffer], { type: 'application/octet-stream' }), 'DataGrid.xlsx')
|
saveAs(
|
||||||
|
new Blob([buffer], { type: 'application/octet-stream' }),
|
||||||
|
'Daftar Gangguan Dialihkan Ke Posko Lain.xlsx'
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user