c98018bb4e
commitbcfb4c1456Merge:1cbde57975c87dAuthor: Munawwirul Jamal <57973347+munaja@users.noreply.github.com> Date: Mon Nov 17 11:15:14 2025 +0700 Merge pull request #147 from dikstub-rssa/feat/surat-kontrol-135 Feat: Integration Rehab Medik - Surat Kontrol commit975c87d99aMerge:f5820901cbde57Author: hasyim_kai <muhammad.hasyim.c.a@gmail.com> Date: Mon Nov 17 10:58:10 2025 +0700 Merge branch 'dev' into feat/surat-kontrol-135 commitf582090d18Author: hasyim_kai <muhammad.hasyim.c.a@gmail.com> Date: Thu Nov 13 11:56:21 2025 +0700 Fix: Refactor surat kontrol commita14c4a5d3cAuthor: hasyim_kai <muhammad.hasyim.c.a@gmail.com> Date: Tue Nov 11 14:21:58 2025 +0700 Fix: Refactor Surat Kontrol CRUD {id} to {code} commit24313adef6Author: hasyim_kai <muhammad.hasyim.c.a@gmail.com> Date: Fri Nov 7 10:35:46 2025 +0700 Fix: debug back btn in add, edit, detail content page commit59b44b5729Merge:99a61a0db15ec9Author: Muhammad Hasyim Chaidir Ali <68959522+Hasyim-Kai@users.noreply.github.com> Date: Fri Nov 7 09:11:10 2025 +0700 Merge branch 'dev' into feat/surat-kontrol-135 commit99a61a0bf2Author: hasyim_kai <muhammad.hasyim.c.a@gmail.com> Date: Thu Nov 6 08:06:01 2025 +0700 Feat: add right & bottom label in input base component commitdb48919325Author: hasyim_kai <muhammad.hasyim.c.a@gmail.com> Date: Wed Nov 5 13:53:43 2025 +0700 Feat: add banner in List if requirement not met commitbd57250f7eAuthor: hasyim_kai <muhammad.hasyim.c.a@gmail.com> Date: Wed Nov 5 13:26:48 2025 +0700 Fix: refactor getDetail url param commita361922e32Author: hasyim_kai <muhammad.hasyim.c.a@gmail.com> Date: Wed Nov 5 13:19:07 2025 +0700 Feat: Add & integrate add, edit, detail page commit331f4a6b20Author: hasyim_kai <muhammad.hasyim.c.a@gmail.com> Date: Tue Nov 4 16:56:08 2025 +0700 Feat: Integrate Control Letter commit2275f4dc99Author: hasyim_kai <muhammad.hasyim.c.a@gmail.com> Date: Mon Oct 27 14:01:58 2025 +0700 Feat: add UI BPJS > Surat Kontrol commit89e0e7a2c8Author: hasyim_kai <muhammad.hasyim.c.a@gmail.com> Date: Mon Oct 27 10:21:59 2025 +0700 Feat: add UI CRUD Surat Kontrol at Rehab Medik > kunjungan > Proses
221 lines
5.8 KiB
Vue
221 lines
5.8 KiB
Vue
<script setup lang="ts">
|
|
import type { HeaderPrep, RefExportNav, RefSearchNav } from '~/components/pub/my-ui/data/types'
|
|
import type { Summary } from '~/components/pub/my-ui/summary-card/type'
|
|
|
|
// #region Imports
|
|
import { Calendar, Hospital, UserCheck, UsersRound } from 'lucide-vue-next'
|
|
import RecordConfirmation from '~/components/pub/my-ui/confirmation/record-confirmation.vue'
|
|
import { ActionEvents } from '~/components/pub/my-ui/data/types'
|
|
|
|
import Header from '~/components/pub/my-ui/nav-header/prep.vue'
|
|
import Filter from '~/components/pub/my-ui/nav-header/filter.vue'
|
|
import Dialog from '~/components/pub/my-ui/modal/dialog.vue'
|
|
import SummaryCard from '~/components/pub/my-ui/summary-card/summary-card.vue'
|
|
import { usePaginatedList } from '~/composables/usePaginatedList'
|
|
|
|
import { getPatients, removePatient } from '~/services/patient.service'
|
|
import FilterDialog from '~/components/pub/my-ui/nav-header/filter-dialog.vue'
|
|
|
|
// #endregion
|
|
|
|
// #region State
|
|
const { data, isLoading, paginationMeta, searchInput, handlePageChange, handleSearch, fetchData } = usePaginatedList({
|
|
fetchFn: (params) => getPatients({ ...params, includes: ['person', 'person-Addresses'] }),
|
|
entityName: 'patient',
|
|
})
|
|
|
|
const refSearchNav: RefSearchNav = {
|
|
onClick: () => {
|
|
// open filter modal
|
|
isFormEntryDialogOpen.value = true
|
|
},
|
|
onInput: (val: string) => {
|
|
searchInput.value = val
|
|
},
|
|
onClear: () => {
|
|
searchInput.value = ''
|
|
},
|
|
}
|
|
|
|
const refExportNav: RefExportNav = {
|
|
onExportCsv: () => {
|
|
// open filter modal
|
|
console.log(`Export CSV Clicked`)
|
|
},
|
|
}
|
|
|
|
const isFormEntryDialogOpen = ref(false)
|
|
const isHistoryDialogOpen = ref(false)
|
|
const isRecordConfirmationOpen = ref(false)
|
|
const summaryLoading = ref(false)
|
|
|
|
const recId = ref<number>(0)
|
|
const recAction = ref<string>('')
|
|
const recItem = ref<any>(null)
|
|
|
|
const headerPrep: HeaderPrep = {
|
|
title: "Surat Kontrol",
|
|
icon: 'i-lucide-newspaper',
|
|
}
|
|
|
|
const filterPrep: HeaderPrep = {
|
|
title: "Surat Kontrol",
|
|
icon: 'i-lucide-newspaper',
|
|
}
|
|
// #endregion
|
|
|
|
// #region Lifecycle Hooks
|
|
onMounted(() => {
|
|
getPatientSummary()
|
|
})
|
|
// #endregion
|
|
|
|
// #region Functions
|
|
async function getPatientSummary() {
|
|
try {
|
|
summaryLoading.value = true
|
|
await new Promise((resolve) => setTimeout(resolve, 500))
|
|
} catch (error) {
|
|
console.error('Error fetching patient summary:', error)
|
|
} finally {
|
|
summaryLoading.value = false
|
|
}
|
|
}
|
|
|
|
function handleFiltering() {
|
|
console.log('Confirmed action: Filter')
|
|
}
|
|
|
|
// Handle confirmation result
|
|
async function handleConfirmDelete(record: any, action: string) {
|
|
console.log('Confirmed action:', action, 'for record:', record)
|
|
|
|
if (action === 'delete' && record?.id) {
|
|
try {
|
|
const result = await removePatient(record.id)
|
|
if (result.success) {
|
|
console.log('Patient deleted successfully')
|
|
// Refresh the list
|
|
await fetchData()
|
|
} else {
|
|
console.error('Failed to delete patient:', result)
|
|
// Handle error - show error message to user
|
|
}
|
|
} catch (error) {
|
|
console.error('Error deleting patient:', error)
|
|
// Handle error - show error message to user
|
|
}
|
|
}
|
|
}
|
|
|
|
function handleCancelConfirmation() {
|
|
// Reset record state when cancelled
|
|
recId.value = 0
|
|
recAction.value = ''
|
|
recItem.value = null
|
|
}
|
|
|
|
function exportCsv() {
|
|
console.log('Ekspor CSV dipilih')
|
|
// tambahkan logic untuk generate CSV
|
|
}
|
|
|
|
function exportExcel() {
|
|
console.log('Ekspor Excel dipilih')
|
|
// tambahkan logic untuk generate Excel
|
|
}
|
|
// #endregion
|
|
|
|
// #region Provide
|
|
provide('rec_id', recId)
|
|
provide('rec_action', recAction)
|
|
provide('rec_item', recItem)
|
|
provide('table_data_loader', isLoading)
|
|
// #endregion
|
|
|
|
// #region Watchers
|
|
watch([recId, recAction], () => {
|
|
switch (recAction.value) {
|
|
case ActionEvents.showProcess:
|
|
navigateTo('https://google.com', { external: true, open: { target: '_blank' } });
|
|
break
|
|
|
|
case ActionEvents.showDetail:
|
|
isHistoryDialogOpen.value = true
|
|
break
|
|
|
|
case ActionEvents.showConfirmDelete:
|
|
// Trigger confirmation modal open
|
|
isRecordConfirmationOpen.value = true
|
|
break
|
|
}
|
|
})
|
|
// #endregion
|
|
</script>
|
|
|
|
<template>
|
|
<Header :prep="{ ...headerPrep }" />
|
|
|
|
<!-- Disable dulu, ayahab kalo diminta beneran -->
|
|
<!-- <div class="my-4 flex flex-1 flex-col gap-4 md:gap-8">
|
|
<div class="grid gap-4 md:grid-cols-2 md:gap-8 lg:grid-cols-4">
|
|
<template v-if="summaryLoading">
|
|
<SummaryCard
|
|
v-for="n in 4"
|
|
:key="n"
|
|
is-skeleton
|
|
/>
|
|
</template>
|
|
<template v-else>
|
|
<SummaryCard
|
|
v-for="card in summaryData"
|
|
:key="card.title"
|
|
:stat="card"
|
|
/>
|
|
</template>
|
|
</div>
|
|
</div>
|
|
-->
|
|
|
|
<FilterDialog :prep="{ ...filterPrep }"
|
|
:ref-search-nav="refSearchNav"
|
|
:ref-export-nav="refExportNav"
|
|
:enable-search="false"
|
|
:enable-date-range="false"/>
|
|
|
|
<AppBpjsControlLetterList :data="data" :pagination-meta="paginationMeta" @page-change="handlePageChange" />
|
|
|
|
<Dialog
|
|
v-model:open="isFormEntryDialogOpen"
|
|
title="Filter"
|
|
>
|
|
<AppBpjsControlLetterFilter @submit="handleFiltering" />
|
|
</Dialog>
|
|
|
|
<Dialog
|
|
v-model:open="isHistoryDialogOpen"
|
|
title="Log History Surat Kontrol">
|
|
<AppBpjsControlLetterCommonHistoryDialog />
|
|
</Dialog>
|
|
|
|
<RecordConfirmation v-model:open="isRecordConfirmationOpen" action="delete" :record="recItem"
|
|
@confirm="handleConfirmDelete" @cancel="handleCancelConfirmation">
|
|
<template #default="{ record }">
|
|
<div class="text-sm">
|
|
<p>
|
|
<strong>ID:</strong>
|
|
{{ record?.id }}
|
|
</p>
|
|
<p v-if="record?.firstName">
|
|
<strong>Nama:</strong>
|
|
{{ record.firstName }}
|
|
</p>
|
|
<p v-if="record?.code">
|
|
<strong>Kode:</strong>
|
|
{{ record.cellphone }}
|
|
</p>
|
|
</div>
|
|
</template>
|
|
</RecordConfirmation>
|
|
</template>
|