Refactor data selection and add detail view
This commit is contained in:
parent
011c8cbeb8
commit
cfe6c418a5
@ -19,7 +19,7 @@
|
|||||||
:show-borders="true"
|
:show-borders="true"
|
||||||
:row-alternation-enabled="true"
|
:row-alternation-enabled="true"
|
||||||
:hover-state-enabled="true"
|
:hover-state-enabled="true"
|
||||||
@selection-changed="onSelectionChanged"
|
@selection-changed="onDataSelectionChanged"
|
||||||
@exporting="onExporting"
|
@exporting="onExporting"
|
||||||
:allow-column-resizing="true"
|
:allow-column-resizing="true"
|
||||||
column-resizing-mode="widget"
|
column-resizing-mode="widget"
|
||||||
@ -35,8 +35,7 @@
|
|||||||
:show-indicator="showIndicator"
|
:show-indicator="showIndicator"
|
||||||
:show-pane="showPane"
|
:show-pane="showPane"
|
||||||
:shading="shading"
|
:shading="shading"
|
||||||
v-if="loading"
|
v-model:visible="loadingData"
|
||||||
v-model:visible="loading"
|
|
||||||
:enabled="true"
|
:enabled="true"
|
||||||
/>
|
/>
|
||||||
<DxSearchPanel :visible="true" :highlight-case-sensitive="true" />
|
<DxSearchPanel :visible="true" :highlight-case-sensitive="true" />
|
||||||
@ -150,7 +149,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted } from 'vue'
|
import { ref, onMounted, watch } from 'vue'
|
||||||
import Filters from '@/components/Form/Filters.vue'
|
import Filters from '@/components/Form/Filters.vue'
|
||||||
import Type2 from '@/components/Form/FiltersType/Type2.vue'
|
import Type2 from '@/components/Form/FiltersType/Type2.vue'
|
||||||
import { DxDataGrid } from 'devextreme-vue'
|
import { DxDataGrid } from 'devextreme-vue'
|
||||||
@ -174,13 +173,23 @@ import { formatNumber, formatPercentage, isNumber } from '@/utils/numbers'
|
|||||||
import { saveAs } from 'file-saver'
|
import { saveAs } from 'file-saver'
|
||||||
import { Workbook } from 'exceljs'
|
import { Workbook } from 'exceljs'
|
||||||
import { useQuery } from '@vue/apollo-composable'
|
import { useQuery } from '@vue/apollo-composable'
|
||||||
import gql from 'graphql-tag'
|
import { apolloClient, queries } from '@/utils/api/api.graphql'
|
||||||
|
import { provideApolloClient } from '@vue/apollo-composable'
|
||||||
|
|
||||||
|
const client = apolloClient()
|
||||||
|
provideApolloClient(client)
|
||||||
const position = { of: '#data' }
|
const position = { of: '#data' }
|
||||||
const showIndicator = ref(true)
|
const showIndicator = ref(true)
|
||||||
const shading = ref(true)
|
const shading = ref(true)
|
||||||
const showPane = ref(true)
|
const showPane = ref(true)
|
||||||
const data = ref<any[]>([])
|
const data = ref<any[]>([])
|
||||||
|
const dataSub = ref<any[]>([])
|
||||||
|
const dataSelected = ref<any>()
|
||||||
|
const dataSubSelected = ref<any>()
|
||||||
|
const dialogDetail = ref(false)
|
||||||
|
const closedialogDetail = () => (dialogDetail.value = false)
|
||||||
|
const loadingData = ref(false)
|
||||||
|
const loadingSubData = ref(false)
|
||||||
const currentYear = ref(new Date().getFullYear())
|
const currentYear = ref(new Date().getFullYear())
|
||||||
const currentMonth = ref(new Date().getMonth())
|
const currentMonth = ref(new Date().getMonth())
|
||||||
const lastYear = ref(currentYear.value - 1)
|
const lastYear = ref(currentYear.value - 1)
|
||||||
@ -214,55 +223,65 @@ const onExporting = (e: any) => {
|
|||||||
e.cancel = true
|
e.cancel = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const getDetail = () => {
|
||||||
|
const dateValue = filters.value.periode.split(' s/d ')
|
||||||
|
const selected = dataSelected.value
|
||||||
|
|
||||||
|
const query = {
|
||||||
|
dateFrom: dateValue[0]
|
||||||
|
? dateValue[0].split('-').reverse().join('-')
|
||||||
|
: new Date().toISOString().slice(0, 10),
|
||||||
|
dateTo: dateValue[1]
|
||||||
|
? dateValue[1].split('-').reverse().join('-')
|
||||||
|
: new Date().toISOString().slice(0, 10),
|
||||||
|
idUlp: selected?.id_ulp ? selected?.id_ulp : 0,
|
||||||
|
idUid: selected?.id_uid ? selected?.id_uid : 0,
|
||||||
|
idUp3: selected?.id_up3 ? selected?.id_up3 : 0
|
||||||
|
}
|
||||||
|
|
||||||
|
const { onResult, onError, loading } = useQuery(
|
||||||
|
queries.keluhan.rekap.rekapKeluhanAllDetail,
|
||||||
|
query
|
||||||
|
)
|
||||||
|
|
||||||
|
onResult((queryResult) => {
|
||||||
|
if (queryResult.data != undefined) {
|
||||||
|
dataSub.value = queryResult.data.detailKeluhanAll
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
onError((error) => {
|
||||||
|
console.log(error)
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(loading, (value) => {
|
||||||
|
loadingSubData.value = value
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const dataGridRef = ref<DxDataGrid | null>(null)
|
const dataGridRef = ref<DxDataGrid | null>(null)
|
||||||
const clearSelection = () => {
|
const clearSelection = () => {
|
||||||
const dataGrid = dataGridRef.value!.instance!
|
const dataGrid = dataGridRef.value!.instance!
|
||||||
dataGrid.clearSelection()
|
dataGrid.clearSelection()
|
||||||
}
|
}
|
||||||
const onSelectionChanged = ({ selectedRowsData }: any) => {
|
const showDetail = () => {
|
||||||
const data = selectedRowsData[0]
|
|
||||||
clearSelection()
|
clearSelection()
|
||||||
|
dataSubSelected.value = null
|
||||||
|
dialogDetail.value = true
|
||||||
|
getDetail()
|
||||||
}
|
}
|
||||||
|
|
||||||
const monalisaRekapitulasiKeluhanBelumSelesai = gql`
|
const onDataSelectionChanged = ({ selectedRowsData }: any) => {
|
||||||
query DaftarmonalisaRekapitulasiKeluhanBelumSelesai(
|
if (selectedRowsData[0] != undefined) {
|
||||||
#$regional: String
|
dataSelected.value = selectedRowsData[0]
|
||||||
$idUlp: Int
|
showDetail()
|
||||||
$idUid: Int
|
|
||||||
$idUp3: Int
|
|
||||||
$bulan: Int
|
|
||||||
$tahun: Int
|
|
||||||
) {
|
|
||||||
monalisaRekapitulasiKeluhanBelumSelesai(
|
|
||||||
#regional: $regional
|
|
||||||
idUlp: $idUlp
|
|
||||||
idUid: $idUid
|
|
||||||
idUp3: $idUp3
|
|
||||||
bulan: $bulan
|
|
||||||
tahun: $tahun
|
|
||||||
) {
|
|
||||||
nama_regional
|
|
||||||
id_uid
|
|
||||||
nama_uid
|
|
||||||
id_up3
|
|
||||||
nama_up3
|
|
||||||
id_ulp
|
|
||||||
nama_ulp
|
|
||||||
jumlah_keluhan
|
|
||||||
jumlah_informasi
|
|
||||||
total
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
|
||||||
|
|
||||||
const { onResult, onError, loading, refetch } = useQuery(monalisaRekapitulasiKeluhanBelumSelesai, {
|
const onDataSubSelectionChanged = ({ selectedRowsData }: any) => {
|
||||||
bulan: currentMonth.value,
|
const data = selectedRowsData[0]
|
||||||
tahun: currentYear.value,
|
dataSubSelected.value = data
|
||||||
// regional: '',
|
}
|
||||||
idUlp: 0,
|
|
||||||
idUid: 0,
|
|
||||||
idUp3: 0
|
|
||||||
})
|
|
||||||
|
|
||||||
const filterData = (params: any) => {
|
const filterData = (params: any) => {
|
||||||
const { regional, ulp, uid, up3, bulan, tahun } = params
|
const { regional, ulp, uid, up3, bulan, tahun } = params
|
||||||
@ -271,26 +290,31 @@ const filterData = (params: any) => {
|
|||||||
currentYear.value = tahun.id
|
currentYear.value = tahun.id
|
||||||
lastYear.value = tahun.id - 1
|
lastYear.value = tahun.id - 1
|
||||||
|
|
||||||
refetch({
|
const { onResult, onError, loading, refetch } = useQuery(
|
||||||
// regional: regional,
|
queries.monalisa.keluhan.rekap.keluhanBelumSelesai,
|
||||||
|
{
|
||||||
|
namaRegional: regional.name == 'Semua Regional' ? '' : regional.name,
|
||||||
idUlp: ulp ? ulp.id : 0,
|
idUlp: ulp ? ulp.id : 0,
|
||||||
idUid: uid ? uid.id : 0,
|
idUid: uid ? uid.id : 0,
|
||||||
idUp3: up3 ? up3.id : 0,
|
idUp3: up3 ? up3.id : 0,
|
||||||
bulan: bulan ? bulan.id : currentMonth.value,
|
bulan: bulan ? bulan.id : currentMonth.value,
|
||||||
tahun: bulan ? tahun.id : currentYear.value
|
tahun: bulan ? tahun.id : currentYear.value
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
onResult((queryResult) => {
|
onResult((queryResult) => {
|
||||||
if (queryResult.data != undefined) {
|
if (queryResult.data != undefined) {
|
||||||
data.value = queryResult.data.monalisaRekapitulasiKeluhanBelumSelesai
|
data.value = queryResult.data.monalisaRekapitulasiKeluhanBelumSelesai
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(queryResult.data)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
onError((error) => {
|
onError((error) => {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
watch(loading, (value) => {
|
||||||
|
loadingData.value = value
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user