32972bd9db
commit 8e3ea9e8d1d7e3b06bc6e53e0b97f62222276171 Author: hasyim_kai <muhammad.hasyim.c.a@gmail.com> Date: Thu Nov 20 16:14:03 2025 +0700 Feat: UI control letter history commit f11f97f936447bdb225918abb43313f8db540d67 Author: hasyim_kai <muhammad.hasyim.c.a@gmail.com> Date: Thu Nov 20 15:18:25 2025 +0700 Squashed commit of the following: commitdab6adc4a9Author: hasyim_kai <muhammad.hasyim.c.a@gmail.com> Date: Tue Nov 18 11:19:48 2025 +0700 Fix: add role authorization in Resume commitc28fc8f7aaMerge:7ed1cc8bcfb4c1Author: Muhammad Hasyim Chaidir Ali <68959522+Hasyim-Kai@users.noreply.github.com> Date: Tue Nov 18 09:02:16 2025 +0700 Merge branch 'dev' into feat/resume-81 commit7ed1cc83bfAuthor: hasyim_kai <muhammad.hasyim.c.a@gmail.com> Date: Mon Nov 17 15:04:01 2025 +0700 Feat: add doc preview in Resume List 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 commit15ab43c1b1Author: hasyim_kai <muhammad.hasyim.c.a@gmail.com> Date: Mon Nov 17 10:38:21 2025 +0700 Feat: add verification capthca and form adjustment commit53bd8e7f6eAuthor: hasyim_kai <muhammad.hasyim.c.a@gmail.com> Date: Fri Nov 7 08:55:23 2025 +0700 Fix: refactor rehab medik - Resume UI commitfc308809b8Author: hasyim_kai <muhammad.hasyim.c.a@gmail.com> Date: Wed Oct 29 14:57:19 2025 +0700 Feat: add UI Rehab Medik > Proses > Resume commit9b383a5437Merge:a4dc7d7831749aAuthor: Muhammad Hasyim Chaidir Ali <68959522+Hasyim-Kai@users.noreply.github.com> Date: Wed Oct 29 13:32:47 2025 +0700 Merge pull request #139 from dikstub-rssa/dev Update branch feat/resume-81 commit 2b7bea70d66e8472220a2a2406889fc489cc1ebd Author: hasyim_kai <muhammad.hasyim.c.a@gmail.com> Date: Tue Nov 18 11:20:51 2025 +0700 Fix: Typo in Control Letter commit 808e91527cf95de2a47387bb792a3af2e16d907b Author: hasyim_kai <muhammad.hasyim.c.a@gmail.com> Date: Tue Nov 18 10:59:50 2025 +0700 Fix: add role authorization in Control Letter
225 lines
6.8 KiB
Vue
225 lines
6.8 KiB
Vue
<script setup lang="ts">
|
|
import type { HeaderPrep, RefSearchNav } from '~/components/pub/my-ui/data/types'
|
|
|
|
// #region Imports
|
|
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 { usePaginatedList } from '~/composables/usePaginatedList'
|
|
import { getList, remove } from '~/services/control-letter.service'
|
|
import { toast } from '~/components/pub/ui/toast'
|
|
import type { Encounter } from '~/models/encounter'
|
|
import WarningAlert from '~/components/pub/my-ui/alert/warning-alert.vue'
|
|
// import type { PagePermission } from '~/models/role'
|
|
import { PAGE_PERMISSIONS } from '~/lib/page-permission'
|
|
import { permissions } from '~/const/page-permission/chemoteraphy'
|
|
import { unauthorizedToast } from '~/lib/utils'
|
|
import Dialog from '~/components/pub/my-ui/modal/dialog.vue'
|
|
import DocPreviewDialog from '~/components/pub/my-ui/modal/doc-preview-dialog.vue'
|
|
import HistoryDialog from '~/components/app/control-letter/history-dialog.vue'
|
|
// #endregion
|
|
|
|
// #region Permission
|
|
const roleAccess = permissions['/rehab/encounter'] || {}
|
|
const { getPagePermissions } = useRBAC()
|
|
const pagePermission = getPagePermissions(roleAccess)
|
|
|
|
// #region State
|
|
const props = defineProps<{
|
|
encounter?: Encounter
|
|
}>()
|
|
const route = useRoute()
|
|
const encounterId = typeof route.params.id == 'string' ? parseInt(route.params.id) : 0
|
|
|
|
const { data, isLoading, paginationMeta, searchInput, handlePageChange, handleSearch, fetchData } = usePaginatedList({
|
|
fetchFn: (params) => getList({ ...params, includes: 'specialist,subspecialist,doctor-employee-person', }),
|
|
entityName: 'control-letter',
|
|
})
|
|
const historyData = usePaginatedList({
|
|
fetchFn: (params) => getList({ ...params, includes: ['person', 'person-Addresses'] }),
|
|
entityName: 'control-letter-history',
|
|
})
|
|
|
|
const refSearchNav: RefSearchNav = {
|
|
onClick: () => {
|
|
// open filter modal
|
|
},
|
|
onInput: (val: string) => {
|
|
searchInput.value = val
|
|
},
|
|
onClear: () => {
|
|
searchInput.value = ''
|
|
},
|
|
}
|
|
|
|
const isHistoryDialogOpen = ref(false)
|
|
provide('isHistoryDialogOpen', isHistoryDialogOpen)
|
|
|
|
const isDocPreviewDialogOpen = ref(false)
|
|
const isRecordConfirmationOpen = ref(false)
|
|
const summaryLoading = ref(false)
|
|
const isRequirementsMet = ref(true)
|
|
|
|
const recId = ref<number>(0)
|
|
const recAction = ref<string>('')
|
|
const recItem = ref<any>(null)
|
|
const timestamp = ref(new Date().toISOString())
|
|
|
|
const headerPrep: HeaderPrep = {
|
|
title: "Surat Kontrol",
|
|
icon: 'i-lucide-newspaper',
|
|
}
|
|
if (pagePermission.canCreate) {
|
|
headerPrep.addNav = {
|
|
label: "Surat Kontrol",
|
|
onClick: () => navigateTo({
|
|
name: 'rehab-encounter-id-control-letter-add',
|
|
params: { id: encounterId },
|
|
}),
|
|
}
|
|
}
|
|
// #endregion
|
|
|
|
// #region Lifecycle Hooks
|
|
onMounted(() => {
|
|
getListData()
|
|
})
|
|
// #endregion
|
|
|
|
// #region Functions
|
|
async function getListData() {
|
|
try {
|
|
summaryLoading.value = true
|
|
await new Promise((resolve) => setTimeout(resolve, 500))
|
|
} catch (error) {
|
|
console.error('Error fetching Data:', error)
|
|
} finally {
|
|
summaryLoading.value = false
|
|
}
|
|
}
|
|
|
|
// Handle confirmation result
|
|
async function handleConfirmDelete(record: any, action: string) {
|
|
if (action === 'delete' && record?.id) {
|
|
try {
|
|
const result = await remove(record.id)
|
|
if (result.success) {
|
|
toast({ title: 'Berhasil', description: 'Data berhasil dihapus', variant: 'default' })
|
|
await fetchData()
|
|
} else {
|
|
toast({ title: 'Gagal', description: `Data gagal dihapus`, variant: 'destructive' })
|
|
}
|
|
} catch (error) {
|
|
toast({ title: 'Gagal', description: `Something went wrong`, variant: 'destructive' })
|
|
}
|
|
}
|
|
}
|
|
|
|
function handleCancelConfirmation() {
|
|
// Reset record state when cancelled
|
|
recId.value = 0
|
|
recAction.value = ''
|
|
recItem.value = null
|
|
}
|
|
// #endregion
|
|
|
|
// #region Provide
|
|
provide('rec_id', recId)
|
|
provide('rec_action', recAction)
|
|
provide('rec_item', recItem)
|
|
provide('timestamp', isLoading)
|
|
provide('table_data_loader', isLoading)
|
|
// #endregion
|
|
|
|
// #region Watchers
|
|
watch([recId, recAction, timestamp], () => {
|
|
switch (recAction.value) {
|
|
case ActionEvents.showDetail:
|
|
navigateTo({
|
|
name: 'rehab-encounter-id-control-letter-control_letter_id',
|
|
params: { id: encounterId, "control_letter_id": recId.value },
|
|
})
|
|
break
|
|
|
|
case ActionEvents.showEdit:
|
|
if(pagePermission.canUpdate){
|
|
navigateTo({
|
|
name: 'rehab-encounter-id-control-letter-control_letter_id-edit',
|
|
params: { id: encounterId, "control_letter_id": recId.value },
|
|
})
|
|
} else {
|
|
unauthorizedToast()
|
|
}
|
|
break
|
|
|
|
case ActionEvents.showConfirmDelete:
|
|
if(pagePermission.canDelete){
|
|
isRecordConfirmationOpen.value = true
|
|
} else {
|
|
unauthorizedToast()
|
|
}
|
|
break
|
|
}
|
|
})
|
|
// #endregion
|
|
</script>
|
|
|
|
<template>
|
|
<WarningAlert v-if="!isRequirementsMet"
|
|
class="mb-5"
|
|
text="Syarat pembuatan surat kontrol belum terpenuhi"
|
|
:description="[
|
|
'Lanjutan Penatalaksanaan Pasien harus pulang/KRS.',
|
|
'Status Resume Medis harus tervalidasi.'
|
|
]" />
|
|
|
|
<div v-else>
|
|
<Header v-model:search="searchInput"
|
|
:prep="{ ...headerPrep }"
|
|
:ref-search-nav="refSearchNav"
|
|
@search="handleSearch" />
|
|
|
|
<div class="mb-3 flex justify-end items-center">
|
|
<Button variant="outline"
|
|
class="gap-1 bg-transparent items-center text-orange-400 border-orange-400"
|
|
@click="isHistoryDialogOpen = true">
|
|
<Icon name="i-lucide-history" class="h-4 w-4" /> Riwayat Program Nasional</Button>
|
|
</div>
|
|
|
|
<AppControlLetterList :data="data" :pagination-meta="paginationMeta" @page-change="handlePageChange" />
|
|
|
|
<Dialog v-model:open="isDocPreviewDialogOpen" title="Preview Dokumen" size="2xl">
|
|
<DocPreviewDialog :link="`https://www.antennahouse.com/hubfs/xsl-fo-sample/pdf/basic-link-1.pdf`" />
|
|
</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>
|
|
|
|
<HistoryDialog
|
|
v-model:is-modal-open="isHistoryDialogOpen"
|
|
:data="historyData.data.value"
|
|
:pagination-meta="historyData.paginationMeta"
|
|
@page-change="historyData.handlePageChange"
|
|
/>
|
|
|
|
</div>
|
|
</template>
|