fix: adjust logic to filter tabs

This commit is contained in:
riefive
2025-11-13 15:54:22 +07:00
parent 5af84a8dc2
commit 8547373a17
+20 -3
View File
@@ -22,13 +22,15 @@ const authStore = useUserStore()
const route = useRoute()
const router = useRouter()
const activeRole = authStore.getActiveRole()
const activePosition = getPositionAs(activeRole)
const props = defineProps<{
classCode?: 'ambulatory' | 'emergency' | 'inpatient' | 'outpatient'
subClassCode?: 'reg' | 'rehab' | 'chemo' | 'emg' | 'eon' | 'op' | 'icu' | 'hcu' | 'vk'
}>()
const activeRole = authStore.getActiveRole()
const activePosition = getPositionAs(activeRole)
const tabs = ref([] as any)
// activeTab selalu sinkron dengan query param
const activeTab = computed({
get: () => (route.query?.tab && typeof route.query.tab === 'string' ? route.query.tab : 'status'),
@@ -291,12 +293,27 @@ const tabsRaws: TabItem[] = [
},
]
const tabs = computed(() => {
function getTabs() {
return tabsRaws
.filter((tab: TabItem) => (tab.groups ? tab.groups.some((group: string) => group?.includes(activePosition)) : true))
.filter((tab: TabItem) => (tab.classCode && props.classCode ? tab.classCode.includes(props.classCode) : true))
.filter((tab: TabItem) => (tab.subClassCode && props.subClassCode ? tab.subClassCode.includes(props.subClassCode) : true))
.map((tab: TabItem) => {
return { ...tab, props: { ...tab.props, encounter: data } }
})
}
watch(
() => activePosition,
() => {
if (activePosition) {
tabs.value = getTabs()
}
}
)
onMounted(() => {
tabs.value = getTabs()
})
</script>