feat: implement server side daftar keluhan berdasarkan media
This commit is contained in:
parent
b94201911f
commit
1b94c0ba74
@ -1,15 +1,16 @@
|
|||||||
<template>
|
<template>
|
||||||
<Filters @reset-form="data = []" @run-search="() => filterData(filters)" class="mb-4">
|
<Filters @reset-form="resetData" @run-search="() => filterData()" class="mb-4">
|
||||||
<Type3 @update:filters="(value) => (filters = value)" />
|
<Type3 @update:filters="(value) => (filters = value)" />
|
||||||
</Filters>
|
</Filters>
|
||||||
|
|
||||||
<div id="data">
|
<div id="data">
|
||||||
<DxDataGrid
|
<DxDataGrid
|
||||||
ref="dataGridRef"
|
ref="dataGridRef"
|
||||||
|
@option-changed="handleRequestChange"
|
||||||
:allow-column-reordering="true"
|
:allow-column-reordering="true"
|
||||||
class="max-h-[calc(100vh-140px)] mb-10"
|
class="max-h-[calc(100vh-140px)] mb-10"
|
||||||
:data-source="data"
|
:data-source="data"
|
||||||
v-if="loading == false"
|
:remote-operations="true"
|
||||||
:show-column-lines="true"
|
:show-column-lines="true"
|
||||||
:show-row-lines="false"
|
:show-row-lines="false"
|
||||||
:show-borders="true"
|
:show-borders="true"
|
||||||
@ -22,6 +23,7 @@
|
|||||||
column-resizing-mode="widget"
|
column-resizing-mode="widget"
|
||||||
:word-wrap-enabled="false"
|
:word-wrap-enabled="false"
|
||||||
>
|
>
|
||||||
|
<DxLoadPanel :enabled="true" />
|
||||||
<DxSelection mode="single" />
|
<DxSelection mode="single" />
|
||||||
<DxPaging :page-size="20" :enabled="true" />
|
<DxPaging :page-size="20" :enabled="true" />
|
||||||
<DxPager
|
<DxPager
|
||||||
@ -41,11 +43,12 @@
|
|||||||
<DxColumnFixing :enabled="true" />
|
<DxColumnFixing :enabled="true" />
|
||||||
|
|
||||||
<DxColumn
|
<DxColumn
|
||||||
css-class="custom-table-column"
|
:allow-sorting="false"
|
||||||
|
css-class="custom-table-column !text-right"
|
||||||
:width="50"
|
:width="50"
|
||||||
alignment="center"
|
alignment="center"
|
||||||
:calculate-display-value="(item: any) => data.findIndex((i) => i == item) + 1"
|
|
||||||
data-type="number"
|
data-type="number"
|
||||||
|
data-field="no"
|
||||||
caption="No"
|
caption="No"
|
||||||
/>
|
/>
|
||||||
<DxColumn
|
<DxColumn
|
||||||
@ -281,7 +284,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</DetailDialog>
|
</DetailDialog>
|
||||||
<BufferDialog v-if="loading" />
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@ -289,8 +291,10 @@ import DetailDialog from '@/components/Dialogs/DetailDialog.vue'
|
|||||||
import InputText from '@/components/InputText.vue'
|
import InputText from '@/components/InputText.vue'
|
||||||
import Filters from '@/components/Form/Filters.vue'
|
import Filters from '@/components/Form/Filters.vue'
|
||||||
import Type3 from '@/components/Form/FiltersType/Type3.vue'
|
import Type3 from '@/components/Form/FiltersType/Type3.vue'
|
||||||
|
import CustomStore from 'devextreme/data/custom_store'
|
||||||
|
|
||||||
import { formatWaktu } from '@/components/Form/FiltersType/reference'
|
import { formatWaktu } from '@/components/Form/FiltersType/reference'
|
||||||
import { onMounted, ref } from 'vue'
|
import { reactive, ref } from 'vue'
|
||||||
import { DxDataGrid } from 'devextreme-vue'
|
import { DxDataGrid } from 'devextreme-vue'
|
||||||
import {
|
import {
|
||||||
DxColumn,
|
DxColumn,
|
||||||
@ -308,59 +312,161 @@ import {
|
|||||||
exportToXLSX,
|
exportToXLSX,
|
||||||
exportToDOCX
|
exportToDOCX
|
||||||
} from '@/report/Keluhan/Daftar/DKeluhan_BerdasarMedia'
|
} from '@/report/Keluhan/Daftar/DKeluhan_BerdasarMedia'
|
||||||
import BufferDialog from '@/components/Dialogs/BufferDialog.vue'
|
|
||||||
|
|
||||||
const position = { of: '#data' }
|
import type { IRequestOptions } from '@/types/requestParams'
|
||||||
const showIndicator = ref(true)
|
|
||||||
const shading = ref(true)
|
const requestOptions = reactive<IRequestOptions>({
|
||||||
const showPane = ref(true)
|
skip: 0,
|
||||||
|
take: 20,
|
||||||
|
requireTotalCount: true,
|
||||||
|
sort: null,
|
||||||
|
filter: null
|
||||||
|
})
|
||||||
const dataSelected = ref<any>()
|
const dataSelected = ref<any>()
|
||||||
const dialogDetail = ref(false)
|
const dialogDetail = ref(false)
|
||||||
|
const reportData: any = ref(null)
|
||||||
|
const dataGridRef = ref<DxDataGrid | null>(null)
|
||||||
|
const filters = ref()
|
||||||
|
const reportMeta = ref({
|
||||||
|
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' },
|
||||||
|
periode: ''
|
||||||
|
})
|
||||||
|
|
||||||
|
const allowTableRequest = ref(false)
|
||||||
|
const data = new CustomStore({
|
||||||
|
load: async (loadOptions: any) => {
|
||||||
|
if (allowTableRequest.value) {
|
||||||
|
loadOptions.requireTotalCount = true
|
||||||
|
|
||||||
|
const query = {
|
||||||
|
skip: loadOptions.skip,
|
||||||
|
take: loadOptions.take,
|
||||||
|
sort: loadOptions.sort ? loadOptions.sort : null,
|
||||||
|
filter: loadOptions.filter ? mapSearchOptions(loadOptions.filter) : null,
|
||||||
|
requireTotalCount: loadOptions.requireTotalCount,
|
||||||
|
...createQuery(filters.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
return await requestGraphQl(queries.keluhan.daftar.ssdaftarKeluhanBerdasarkanMedia, query)
|
||||||
|
.then((result) => {
|
||||||
|
const response = result.data.data.ssdaftarKeluhanBerdasarkanMedia
|
||||||
|
|
||||||
|
let no = query.skip ?? 0
|
||||||
|
|
||||||
|
for (const data of response.data) {
|
||||||
|
data.no = ++no
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: response.data,
|
||||||
|
totalCount: response.totalCount
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
throw Error(err)
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
reportMeta.value = filters.value
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
return new Promise(function (resolve) {
|
||||||
|
resolve({
|
||||||
|
data: [],
|
||||||
|
totalCount: 0
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const closeDialog = () => {
|
const closeDialog = () => {
|
||||||
dialogDetail.value = false
|
dialogDetail.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
const dataGridRef = ref<DxDataGrid | null>(null)
|
|
||||||
const clearSelection = () => {
|
|
||||||
const dataGrid = dataGridRef.value!.instance!
|
|
||||||
dataGrid.clearSelection()
|
|
||||||
}
|
|
||||||
const showDetail = () => {
|
|
||||||
clearSelection()
|
|
||||||
dialogDetail.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
const onSelectionChanged = ({ selectedRowsData }: any) => {
|
|
||||||
if (selectedRowsData[0] != undefined) {
|
|
||||||
dataSelected.value = selectedRowsData[0]
|
|
||||||
}
|
|
||||||
showDetail()
|
|
||||||
}
|
|
||||||
|
|
||||||
const onExporting = (e: any) => {
|
|
||||||
if (e.format === 'pdf') {
|
|
||||||
exportToPDF(reportMeta, data)
|
|
||||||
} else if (e.format === 'xlsx') {
|
|
||||||
exportToXLSX(reportMeta, e)
|
|
||||||
} else {
|
|
||||||
exportToDOCX(reportMeta, data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = ref<any[]>([])
|
|
||||||
const loading = ref(false)
|
|
||||||
|
|
||||||
const resetData = () => {
|
const resetData = () => {
|
||||||
data.value = []
|
allowTableRequest.value = false
|
||||||
|
|
||||||
|
const dataGrid = dataGridRef.value!.instance!
|
||||||
|
const dataGridDataSource = dataGrid.getDataSource()
|
||||||
|
|
||||||
|
dataGridDataSource.reload()
|
||||||
}
|
}
|
||||||
|
|
||||||
const filterData = async (params: any) => {
|
const handleRequestChange = (e: any) => {
|
||||||
resetData()
|
if (e.name === 'searchPanel') {
|
||||||
|
if (e.value !== '') {
|
||||||
|
requestOptions.filter = createSearchOptions(e.value)
|
||||||
|
} else {
|
||||||
|
requestOptions.filter = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.name === 'paging') {
|
||||||
|
requestOptions.take = e.value
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.name === 'columns') {
|
||||||
|
const columnIndex = parseInt(e.fullName.match(/\[(\d+)\]/)[1])
|
||||||
|
const columnDataField = e.component.columnOption(columnIndex).dataField
|
||||||
|
|
||||||
|
requestOptions.sort = [
|
||||||
|
{
|
||||||
|
selector: columnDataField,
|
||||||
|
desc: e.value === 'desc'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const createSearchOptions = (keyword: string) => {
|
||||||
|
const dataGrid = dataGridRef.value!.instance!
|
||||||
|
const columns = dataGrid.getVisibleColumns()
|
||||||
|
|
||||||
|
const searchOptions = []
|
||||||
|
|
||||||
|
for (const column of columns) {
|
||||||
|
if (column.dataField === 'no' || !column.dataField) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
searchOptions.push({
|
||||||
|
field: column.dataField,
|
||||||
|
value: keyword
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return searchOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
const mapSearchOptions = (searchOptions: any) => {
|
||||||
|
const result = searchOptions.map((option: any) => {
|
||||||
|
if (Array.isArray(option) && option[0] !== 'no') {
|
||||||
|
return {
|
||||||
|
field: option[0],
|
||||||
|
value: option[2]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return result.filter((item: any) => item)
|
||||||
|
}
|
||||||
|
|
||||||
|
const filterData = () => {
|
||||||
|
allowTableRequest.value = true
|
||||||
|
|
||||||
|
const dataGrid = dataGridRef.value!.instance!
|
||||||
|
const dataGridDataSource = dataGrid.getDataSource()
|
||||||
|
|
||||||
|
dataGridDataSource.reload()
|
||||||
|
}
|
||||||
|
|
||||||
|
const createQuery = (params: any) => {
|
||||||
const dateValue = params.periode.split(' s/d ')
|
const dateValue = params.periode.split(' s/d ')
|
||||||
const { ulp, uid, up3 } = params
|
const { ulp, uid, up3 } = params
|
||||||
|
|
||||||
const query = {
|
return {
|
||||||
dateFrom: dateValue[0]
|
dateFrom: dateValue[0]
|
||||||
? dateValue[0].split('-').reverse().join('-')
|
? dateValue[0].split('-').reverse().join('-')
|
||||||
: new Date().toISOString().slice(0, 10),
|
: new Date().toISOString().slice(0, 10),
|
||||||
@ -371,135 +477,48 @@ const filterData = async (params: any) => {
|
|||||||
idUid: uid ? uid.id : 0,
|
idUid: uid ? uid.id : 0,
|
||||||
idUp3: up3 ? up3.id : 0
|
idUp3: up3 ? up3.id : 0
|
||||||
}
|
}
|
||||||
|
|
||||||
loading.value = true
|
|
||||||
await requestGraphQl(queries.keluhan.daftar.keluhanBerdasarkanMedia, query)
|
|
||||||
.then((result) => {
|
|
||||||
if (result.data.data != undefined) {
|
|
||||||
data.value = result.data.data.daftarKeluhanBerdasarkanMedia
|
|
||||||
} else {
|
|
||||||
data.value = []
|
|
||||||
}
|
|
||||||
|
|
||||||
reportMeta.value = filters.value
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.error(err)
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
loading.value = false
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const filters = ref()
|
const clearSelection = () => {
|
||||||
const reportMeta = ref({
|
const dataGrid = dataGridRef.value!.instance!
|
||||||
uid: { id: 0, name: 'Semua Unit Induk Distribusi/Wilayah' },
|
dataGrid.clearSelection()
|
||||||
up3: { id: 0, name: 'Semua Unit Pelaksanaan Pelayanan Pelanggan' },
|
}
|
||||||
ulp: { id: 0, name: 'Semua Unit Layanan Pelanggan' },
|
|
||||||
periode: ''
|
|
||||||
})
|
|
||||||
|
|
||||||
onMounted(() => {
|
const onSelectionChanged = ({ selectedRowsData }: any) => {
|
||||||
if (import.meta.env.DEV) {
|
if (selectedRowsData[0] != undefined) {
|
||||||
data.value = [
|
dataSelected.value = selectedRowsData[0]
|
||||||
{
|
|
||||||
no_laporan: 'K5123020100019',
|
|
||||||
waktu_lapor: '01/02/2023 01:59:02',
|
|
||||||
waktu_response: '01/02/2023 05:22:50',
|
|
||||||
waktu_recovery: '01/02/2023 08:33:38',
|
|
||||||
durasi_response_time: 12228,
|
|
||||||
durasi_recovery_time: 11448,
|
|
||||||
status_akhir: 'Selesai',
|
|
||||||
idpel_nometer: '',
|
|
||||||
nama_pelapor: 'BP AHMAD',
|
|
||||||
alamat_pelapor:
|
|
||||||
'JL BENTENGAN TIMUR NO31 RT11/03, SUNTER JAYA, TANJUNG PRIOK, KOTA ADM. JAKARTA UTARA, DKI JAKARTA',
|
|
||||||
no_telp_pelapor: '082320000152',
|
|
||||||
keterangan_pelapor:
|
|
||||||
'MOHON BANTUAN PEMBATALAN PERMOHONAN PB NO AGENDA 545109912301319203 DIKARENAKAN PELANGGAN INGIN KE DAYA 2200 VA, PELANGGAN SUDAH MELAKUKAN PEMBAYARAN MELALAUI GOPAY TANGGAL 31/01/2023 PUKUL 18:49 WIB, NAMUN PEMBAYARAN BELUM MASUK, MOHON KONFRIMASI KE PELANGGAN, TERIMA KASIH. ',
|
|
||||||
media: 'Call PLN 123',
|
|
||||||
waktu_media: '01/01/1970 00:00:00',
|
|
||||||
keterangan_media: 'x',
|
|
||||||
nama_ulp: 'UP3 TANJUNG PRIOK'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
no_laporan: 'K5123020100021',
|
|
||||||
waktu_lapor: '01/02/2023 02:04:04',
|
|
||||||
waktu_response: '01/02/2023 02:26:01',
|
|
||||||
waktu_recovery: '01/02/2023 02:34:06',
|
|
||||||
durasi_response_time: 1317,
|
|
||||||
durasi_recovery_time: 485,
|
|
||||||
status_akhir: 'Selesai',
|
|
||||||
idpel_nometer: '',
|
|
||||||
nama_pelapor: 'IBU TITIN ',
|
|
||||||
alamat_pelapor: 'TIDAK BISAMALKUKANPEMBELIAN KETMELEBIHI BATAS MAXIMUM / SISA 100 KWH ',
|
|
||||||
no_telp_pelapor: '087786974290',
|
|
||||||
keterangan_pelapor: 'TIDAK BISAMALKUKANPEMBELIAN KETMELEBIHI BATAS MAXIMUM / SISA 100 KWH ',
|
|
||||||
media: 'Call PLN 123',
|
|
||||||
waktu_media: '01/01/1970 00:00:00',
|
|
||||||
keterangan_media: 'x',
|
|
||||||
nama_ulp: 'ULP CIBITUNG'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
no_laporan: 'K1423020100022',
|
|
||||||
waktu_lapor: '01/02/2023 03:13:25',
|
|
||||||
waktu_response: '01/02/2023 04:59:44',
|
|
||||||
waktu_recovery: '01/02/2023 07:03:37',
|
|
||||||
durasi_response_time: 6379,
|
|
||||||
durasi_recovery_time: 7433,
|
|
||||||
status_akhir: 'Selesai',
|
|
||||||
idpel_nometer: '000000000000000001820788',
|
|
||||||
nama_pelapor: 'IBU IRFI ',
|
|
||||||
alamat_pelapor:
|
|
||||||
'JL NIAGA 7 PERUM KEMANG BLOK F NO 23 KEC RAWA LUMBU KEL SEPANJANG JAYA KOTA BEKASI ACUAN LOKASI DEKAT RUMAH YATIM ',
|
|
||||||
no_telp_pelapor: '62816922683',
|
|
||||||
keterangan_pelapor:
|
|
||||||
'TIDAK BISA INPUT TOKEN SETELAH UPDATE VKRN 43 (PTL TIDAK PADAM) \\nDENGAN NO METER 56700750112 DAN SISA KWH 15.1',
|
|
||||||
media: 'Call PLN 123',
|
|
||||||
waktu_media: '01/01/1970 00:00:00',
|
|
||||||
keterangan_media: 'x',
|
|
||||||
nama_ulp: 'ULP BANTARGEBANG'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
no_laporan: 'K5223020100106',
|
|
||||||
waktu_lapor: '01/02/2023 03:45:58',
|
|
||||||
waktu_response: '01/02/2023 06:24:51',
|
|
||||||
waktu_recovery: '01/02/2023 06:28:11',
|
|
||||||
durasi_response_time: 9533,
|
|
||||||
durasi_recovery_time: 200,
|
|
||||||
status_akhir: 'Selesai',
|
|
||||||
idpel_nometer: '000000000000000000943441',
|
|
||||||
nama_pelapor: 'IBU MELLY KURNIASIH',
|
|
||||||
alamat_pelapor: 'PERUMAHAN CEMPAKA ARUM JL. FLAMBOYAN 5 NO 191 CIREBON',
|
|
||||||
no_telp_pelapor: '08889353988',
|
|
||||||
keterangan_pelapor:
|
|
||||||
'LEBIH TAGIH. ST AK REK FEB 2023 (28/01/2023) = 4608, ST APP TGL 26/01/2023 = 4496. REK BELUM DILUNASI. (RUMAH TIDAK DIHUNI NAMUN PAGAR TIDAK TERKUNCI, PETUGAS TIDAK DIKETAHUI DATANG KE LOKASI). PELANGGAN MENGINGINKAN AGAR HAL TERSEBUT TIDAK TERULANG KEMBALI.',
|
|
||||||
media: 'Live Chat PLN Mobile',
|
|
||||||
waktu_media: '01/01/1970 00:00:00',
|
|
||||||
keterangan_media: 'x',
|
|
||||||
nama_ulp: 'ULP SUMBER'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
no_laporan: 'K5223020100112',
|
|
||||||
waktu_lapor: '01/02/2023 04:16:48',
|
|
||||||
waktu_response: '01/02/2023 05:58:33',
|
|
||||||
waktu_recovery: '01/02/2023 12:02:23',
|
|
||||||
durasi_response_time: 6105,
|
|
||||||
durasi_recovery_time: 21830,
|
|
||||||
status_akhir: 'Selesai',
|
|
||||||
idpel_nometer: '',
|
|
||||||
nama_pelapor: 'BP HENDRIYANTO',
|
|
||||||
alamat_pelapor:
|
|
||||||
'JL.PALEM HIJAU, COKROKONTENG, RT.04 RW.2. KEL SIDOARUM. KEC GODEAN KAB SLEMAN PROV DIY',
|
|
||||||
no_telp_pelapor: '085921182228',
|
|
||||||
keterangan_pelapor:
|
|
||||||
'PELANGGAN TIDAK BISA INPUT TOKEN SETELAH UPDATE VKRN 43. (BELUM ADA) PETUGAS YANG MELAKUKAN PENGATURAN. SISA KWH: 385.41. PTL (HAMPIR PADAM). PELANGGAN PERNAH LAPOR DENGAN NO: K5223013102183, STATUS SELESAI, PELANGGAN TIDAK DIKONFIRMASI s.d 1X6 JAM. LAPOR KEMBALI CC.54.JULIANA TGL 01/02/23 12FZUS3 08.46 085921182228',
|
|
||||||
media: 'Live Chat PLN Mobile',
|
|
||||||
waktu_media: '01/01/1970 00:00:00',
|
|
||||||
keterangan_media: 'x',
|
|
||||||
nama_ulp: 'ULP SEDAYU'
|
|
||||||
}
|
}
|
||||||
]
|
showDetail()
|
||||||
|
}
|
||||||
|
|
||||||
|
const showDetail = () => {
|
||||||
|
clearSelection()
|
||||||
|
dialogDetail.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
const onExporting = async (e: any) => {
|
||||||
|
const dataGrid = dataGridRef.value!.instance!
|
||||||
|
|
||||||
|
if (e.format === 'pdf' || e.format === 'document') {
|
||||||
|
reportData.value = await data.load()
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
if (e.format === 'pdf' && reportData.value) {
|
||||||
|
dataGrid.beginCustomLoading('')
|
||||||
|
const pdf = await exportToPDF(reportMeta, reportData)
|
||||||
|
|
||||||
|
if (pdf) {
|
||||||
|
dataGrid.endCustomLoading()
|
||||||
|
}
|
||||||
|
} else if (e.format === 'xlsx') {
|
||||||
|
exportToXLSX(reportMeta, e)
|
||||||
|
} else if (e.format === 'document' && reportData.value) {
|
||||||
|
dataGrid.beginCustomLoading('')
|
||||||
|
const doc = await exportToDOCX(reportMeta, reportData)
|
||||||
|
|
||||||
|
if (doc) {
|
||||||
|
dataGrid.endCustomLoading()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -48,12 +48,13 @@ const formatMetaData = (reportMeta: any) => {
|
|||||||
return { dateFromFormat, dateToFormat, dayTo }
|
return { dateFromFormat, dateToFormat, dayTo }
|
||||||
}
|
}
|
||||||
|
|
||||||
const exportToPDF = (reportMeta: any, data: any) => {
|
const exportToPDF = async (reportMeta: any, data: any) => {
|
||||||
const meta = formatMetaData(reportMeta)
|
const meta = formatMetaData(reportMeta)
|
||||||
const day = new Date().toLocaleString('id-ID', { weekday: 'long' })
|
const day = new Date().toLocaleString('id-ID', { weekday: 'long' })
|
||||||
const date = new Date().getDate()
|
const date = new Date().getDate()
|
||||||
const month = new Date().toLocaleString('id-ID', { month: 'long' })
|
const month = new Date().toLocaleString('id-ID', { month: 'long' })
|
||||||
const year = new Date().getFullYear()
|
const year = new Date().getFullYear()
|
||||||
|
const resultData = data.value.data
|
||||||
const doc = new jsPDF({
|
const doc = new jsPDF({
|
||||||
orientation: 'landscape'
|
orientation: 'landscape'
|
||||||
})
|
})
|
||||||
@ -129,7 +130,7 @@ const exportToPDF = (reportMeta: any, data: any) => {
|
|||||||
'Keterangan Media'
|
'Keterangan Media'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
body: data.value.map((item: any, i: any) => [
|
body: resultData.map((item: any, i: any) => [
|
||||||
{ content: ++i, styles: { halign: 'right' } },
|
{ content: ++i, styles: { halign: 'right' } },
|
||||||
item.no_laporan,
|
item.no_laporan,
|
||||||
item.nama_pelapor,
|
item.nama_pelapor,
|
||||||
@ -196,12 +197,19 @@ const exportToPDF = (reportMeta: any, data: any) => {
|
|||||||
margin: { left: 230 }
|
margin: { left: 230 }
|
||||||
})
|
})
|
||||||
|
|
||||||
doc.save(`Laporan ${reportName}.pdf`, { returnPromise: true }).then(() => {
|
await doc
|
||||||
console.log('pdf berhasil disimpan')
|
.save(`Laporan ${reportName}.pdf`, { returnPromise: true })
|
||||||
|
.then(() => {
|
||||||
|
console.log('PDF Exported')
|
||||||
})
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error('Error while exporting PDF', error)
|
||||||
|
})
|
||||||
|
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
const exportToXLSX = (reportMeta: any, e: any) => {
|
const exportToXLSX = async (reportMeta: any, e: any) => {
|
||||||
const meta = formatMetaData(reportMeta)
|
const meta = formatMetaData(reportMeta)
|
||||||
const workbook = new Workbook()
|
const workbook = new Workbook()
|
||||||
const worksheet = workbook.addWorksheet(`${reportName}`)
|
const worksheet = workbook.addWorksheet(`${reportName}`)
|
||||||
@ -254,11 +262,11 @@ const exportToXLSX = (reportMeta: any, e: any) => {
|
|||||||
worksheet.mergeCells('A6:O6')
|
worksheet.mergeCells('A6:O6')
|
||||||
worksheet.mergeCells('A7:O7')
|
worksheet.mergeCells('A7:O7')
|
||||||
|
|
||||||
exportToExcel({
|
await exportToExcel({
|
||||||
component: e.component,
|
component: e.component,
|
||||||
worksheet,
|
worksheet,
|
||||||
autoFilterEnabled: true,
|
autoFilterEnabled: true,
|
||||||
topLeftCell: { row: 9, column: 1 }
|
topLeftCell: { row: 10, column: 1 }
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
workbook.xlsx.writeBuffer().then((buffer: any) => {
|
workbook.xlsx.writeBuffer().then((buffer: any) => {
|
||||||
saveAs(new Blob([buffer], { type: 'application/octet-stream' }), `Laporan ${reportName}.xlsx`)
|
saveAs(new Blob([buffer], { type: 'application/octet-stream' }), `Laporan ${reportName}.xlsx`)
|
||||||
@ -268,15 +276,16 @@ const exportToXLSX = (reportMeta: any, e: any) => {
|
|||||||
e.cancel = true
|
e.cancel = true
|
||||||
}
|
}
|
||||||
|
|
||||||
const exportToDOCX = (reportMeta: any, data: any) => {
|
const exportToDOCX = async (reportMeta: any, data: any) => {
|
||||||
const day = new Date().toLocaleString('id-ID', { weekday: 'long' })
|
const day = new Date().toLocaleString('id-ID', { weekday: 'long' })
|
||||||
const date = new Date().getDate()
|
const date = new Date().getDate()
|
||||||
const month = new Date().toLocaleString('id-ID', { month: 'long' })
|
const month = new Date().toLocaleString('id-ID', { month: 'long' })
|
||||||
const year = new Date().getFullYear()
|
const year = new Date().getFullYear()
|
||||||
|
const resultData = data.value.data
|
||||||
const meta = formatMetaData(reportMeta)
|
const meta = formatMetaData(reportMeta)
|
||||||
|
|
||||||
const generateRows = () => {
|
const generateRows = () => {
|
||||||
return data.value.map((item: any, i: any) => {
|
return resultData.map((item: any, i: any) => {
|
||||||
return new TableRow({
|
return new TableRow({
|
||||||
children: [
|
children: [
|
||||||
{ text: `${++i}`, field: 'no' },
|
{ text: `${++i}`, field: 'no' },
|
||||||
@ -511,10 +520,17 @@ const exportToDOCX = (reportMeta: any, data: any) => {
|
|||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
Packer.toBlob(doc).then((blob) => {
|
await Packer.toBlob(doc)
|
||||||
|
.then((blob) => {
|
||||||
saveAs(blob, `Laporan ${reportName}.docx`)
|
saveAs(blob, `Laporan ${reportName}.docx`)
|
||||||
console.log('Document created successfully')
|
|
||||||
|
console.log('DOCX Exported')
|
||||||
})
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error('Error while exporting DOCX', error)
|
||||||
|
})
|
||||||
|
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
export { exportToPDF, exportToXLSX, exportToDOCX }
|
export { exportToPDF, exportToXLSX, exportToDOCX }
|
||||||
|
@ -331,6 +331,53 @@ export const queries = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
|
ssdaftarKeluhanBerdasarkanMedia: gql`
|
||||||
|
query ssdaftarKeluhanBerdasarkanMedia(
|
||||||
|
$dateFrom: Date!
|
||||||
|
$dateTo: Date!
|
||||||
|
$idUlp: Int!
|
||||||
|
$idUid: Int!
|
||||||
|
$idUp3: Int!
|
||||||
|
$skip: Int
|
||||||
|
$take: Int
|
||||||
|
$requireTotalCount: Boolean
|
||||||
|
$sort: [SortInput]
|
||||||
|
$filter: [FilterInput]
|
||||||
|
) {
|
||||||
|
ssdaftarKeluhanBerdasarkanMedia(
|
||||||
|
dateFrom: $dateFrom
|
||||||
|
dateTo: $dateTo
|
||||||
|
idUlp: $idUlp
|
||||||
|
idUid: $idUid
|
||||||
|
idUp3: $idUp3
|
||||||
|
skip: $skip
|
||||||
|
take: $take
|
||||||
|
requireTotalCount: $requireTotalCount
|
||||||
|
sort: $sort
|
||||||
|
filter: $filter
|
||||||
|
) {
|
||||||
|
totalCount
|
||||||
|
data {
|
||||||
|
no_laporan
|
||||||
|
waktu_lapor
|
||||||
|
waktu_response
|
||||||
|
waktu_recovery
|
||||||
|
durasi_response_time
|
||||||
|
durasi_recovery_time
|
||||||
|
status_akhir
|
||||||
|
idpel_nometer
|
||||||
|
nama_pelapor
|
||||||
|
alamat_pelapor
|
||||||
|
no_telp_pelapor
|
||||||
|
keterangan_pelapor
|
||||||
|
media
|
||||||
|
waktu_media
|
||||||
|
keterangan_media
|
||||||
|
nama_ulp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`,
|
||||||
keluhanBerdasarkanMedia: gql`
|
keluhanBerdasarkanMedia: gql`
|
||||||
query daftarKeluhanBerdasarkanMedia(
|
query daftarKeluhanBerdasarkanMedia(
|
||||||
$dateFrom: Date!
|
$dateFrom: Date!
|
||||||
|
Loading…
x
Reference in New Issue
Block a user