Refactor filter update in Table components

This commit is contained in:
Dede Fuji Abdul
2024-02-27 11:53:06 +07:00
parent 2cc0a1fbce
commit eb9b01cf59
30 changed files with 603 additions and 685 deletions

View File

@@ -1,9 +1,6 @@
<template>
<Filters @run-search="() => filterData(filters)" class="mb-4">
<Type2 @update:filters="(value) => {
filters = value
}
" />
<Type2 @update:filters="(value) => filters = value" />
</Filters>
<div id="data">
<DxDataGrid class="max-h-[calc(100vh-140px)]" :data-source="data" :show-column-lines="true" :show-row-lines="false"
@@ -13,8 +10,8 @@
<DxSelection mode="single" />
<DxPaging :enabled="false" />
<DxScrolling column-rendering-mode="virtual" mode="virtual" />
<DxLoadPanel :position="position" :show-indicator="showIndicator" :show-pane="showPane" :shading="shading"
v-if="loading" v-model:visible="loading" :enabled="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" />
<DxExport :enabled="true" :formats="['pdf', 'xlsx', 'document']" :allow-export-selected-data="false" />
<DxColumnFixing :enabled="true" />
@@ -32,7 +29,7 @@
</DxColumn>
<DxColumn alignment="center" caption="YoY" css-class="custom-table-column">
<DxColumn :width="150" alignment="center" data-field="jumlah_tahun" data-type="number"
:caption="`s.d ${ getMonthName(bulanSekarang)} ${tahunLalu}`" css-class="custom-table-column" />
:caption="`s.d ${getMonthName(bulanSekarang)} ${tahunLalu}`" css-class="custom-table-column" />
<DxColumn :width="150" alignment="center" data-field="jumlah_tahun_n_1" data-type="number"
:caption="`s.d ${getMonthName(bulanSekarang)} ${tahunSekarang}`" css-class="custom-table-column" />
<DxColumn :width="150" alignment="center" data-field="persen_tahun" data-type="number" caption="%"
@@ -64,7 +61,7 @@ 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'
const tahunSekarang = ref(new Date().getFullYear())
const tahunSekarang = ref(new Date().getFullYear())
const bulanSekarang = ref(new Date().getMonth())
const tahunLalu = ref(tahunSekarang.value - 1)
import { useQuery } from '@vue/apollo-composable'
@@ -113,14 +110,14 @@ const { onResult, onError, loading, refetch } = useQuery(monalisaRekapitulasiEns
idUp3: 0
})
const filterData = (params: any) => {
const {regional, posko, idUid, idUp3, bulan, tahun} = params;
const { regional, posko, idUid, idUp3, bulan, tahun } = params;
bulanSekarang.value = bulan.id;
tahunSekarang.value = tahun.id;
tahunLalu.value = tahun.id - 1;
refetch({
regional: regional,
posko: posko ? posko.id : 0,
idUid: idUid ? idUid.id : 0,
idUid: idUid ? idUid.id : 0,
idUp3: idUp3 ? idUp3.id : 0,
bulan: bulan ? bulan.id : 10,
tahun: bulan ? tahun.id : 2023