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