feat: create export pdf, xlsx and lihat laporan in monalisa laporan kpi

This commit is contained in:
kur0nek-o
2024-04-03 21:02:54 +07:00
parent efd316d90e
commit 0114347427
16 changed files with 3935 additions and 234 deletions

View File

@@ -1,5 +1,6 @@
<template>
<Filters
@run-report="() => exportToPDF(reportMeta, data, true)"
@reset-form="data = []"
@run-search="() => filterData(filters)"
:report-button="true"
@@ -353,16 +354,14 @@ import {
DxGroupItem,
DxGrouping
} from 'devextreme-vue/data-grid'
import { jsPDF } from 'jspdf'
import { exportDataGrid as exportToPdf } from 'devextreme/pdf_exporter'
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 { getMonthName, getMonthNameShort } from '@/utils/texts'
import { formatNumber, formatPercentage, isNumber } from '@/utils/numbers'
import BufferDialog from '@/components/Dialogs/BufferDialog.vue'
import {
exportToPDF,
exportToXLSX
} from '@/report/Monalisa/Laporan/Kumulatif/MonalisaLK_AgingComplaint'
const position = { of: '#data' }
const showIndicator = ref(true)
@@ -378,33 +377,24 @@ const loadingData = ref(false)
const loadingSubData = ref(false)
const currentYear = ref(new Date().getFullYear())
const currentMonth = ref(new Date().getMonth() + 1)
const reportMeta = ref({
regional: { id: 0, name: 'Semua Regional' },
uid: { id: 0, name: 'Semua Unit Induk Distribusi/Wilayah' },
up3: { id: 0, name: 'Semua Unit Pelaksanaan Pelayanan Pelanggan' },
ulp: { id: 0, name: 'Semua Unit Layanan Pelanggan' },
bulan: { id: new Date().getMonth(), name: getMonthName(new Date().getMonth()) },
tahun: { id: new Date().getFullYear(), name: new Date().getFullYear().toString() },
periode: '',
currentMonth: currentMonth.value,
currentYear: currentYear.value
})
const onExporting = (e: any) => {
if (e.format === 'pdf') {
const doc = new jsPDF()
exportToPdf({
jsPDFDocument: doc,
component: e.component,
indent: 5
}).then(() => {
doc.save(`.pdf`)
})
exportToPDF(reportMeta.value, data.value)
} else if (e.format === 'xlsx') {
exportToXLSX(reportMeta.value, e)
} else {
const workbook = new Workbook()
const worksheet = workbook.addWorksheet('Employees')
exportToExcel({
component: e.component,
worksheet,
autoFilterEnabled: true
}).then(() => {
workbook.xlsx.writeBuffer().then((buffer: any) => {
saveAs(new Blob([buffer], { type: 'application/octet-stream' }), 'DataGrid.xlsx')
})
})
e.cancel = true
}
}
const getDetail = async () => {
@@ -491,6 +481,18 @@ const filterData = async (params: any) => {
} else {
data.value = []
}
reportMeta.value = {
regional: regional,
uid: uid,
up3: up3,
ulp: ulp,
bulan: bulan,
tahun: tahun,
periode: `${bulan.name} ${tahun.name}`,
currentMonth: currentMonth.value,
currentYear: currentYear.value
}
})
.catch((err) => {
console.error(err)