tambahan subspesialis tapi masih pisah

This commit is contained in:
Fanrouver
2026-05-20 08:51:52 +07:00
parent bc74b98cfd
commit 1446e87bba
8 changed files with 2840 additions and 10 deletions

No files matched your search

+3
View File
@@ -16,9 +16,12 @@ export const useAuth = () => {
isLoading.value = true
clearError()
const headers = import.meta.server ? useRequestHeaders(['cookie']) as Record<string, string> : {}
// The session API returns SessionResponse, or throws 401 if not authenticated
// $fetch automatically sends cookies for same-origin requests
const response = await $fetch<SessionResponse>('/api/auth/session', {
headers,
credentials: 'include' // Explicitly include cookies (though $fetch does this by default)
})
+4 -2
View File
@@ -42,8 +42,9 @@ export const useHakAkses = () => {
}
try {
const headers = import.meta.server ? useRequestHeaders(['cookie']) as Record<string, string> : {}
// Fetch all hak akses data
const response = await $fetch<{ success: boolean, data: HakAkses[] }>('/api/hak-akses');
const response = await $fetch<{ success: boolean, data: HakAkses[] }>('/api/hak-akses', { headers });
if (response && response.success && Array.isArray(response.data)) {
const hakAksesList = response.data;
@@ -95,7 +96,8 @@ export const useHakAkses = () => {
const fetchHakAkses = async () => {
isLoading.value = true;
try {
const response = await $fetch<{ success: boolean, data: HakAkses[] }>('/api/hak-akses');
const headers = import.meta.server ? useRequestHeaders(['cookie']) as Record<string, string> : {}
const response = await $fetch<{ success: boolean, data: HakAkses[] }>('/api/hak-akses', { headers });
if (response && response.success) {
allHakAksesData.value = response.data;
}
+13 -3
View File
@@ -10,6 +10,13 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
return;
}
// On server-side, skip access check - let client handle it
// This matches auth.ts behavior and prevents SSR failures when cookie context is missing
if (process.server) {
console.log('⏭️ Server-side: Skipping page access check (will verify on client)');
return;
}
// Import useAuth and useHakAkses
const { user, checkAuth } = useAuth();
const { getAllowedPages } = useHakAkses();
@@ -27,14 +34,17 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
try {
const allowedPages = await getAllowedPages();
// Normalize paths for comparison (optional, but good for robustness)
const targetPath = to.path.endsWith('/') && to.path.length > 1 ? to.path.slice(0, -1) : to.path;
const targetPathLower = targetPath.toLowerCase();
const toPathLower = to.path.toLowerCase();
// Check if user has access to this page
// We also check against the raw path just in case
// We also check against the raw path just in case, case-insensitive
const isAllowed = allowedPages.some(path => {
const normalizedAllowed = path.endsWith('/') && path.length > 1 ? path.slice(0, -1) : path;
return normalizedAllowed === targetPath || path === to.path;
const normalizedAllowedLower = normalizedAllowed.toLowerCase();
const pathLower = path.toLowerCase();
return normalizedAllowedLower === targetPathLower || pathLower === toPathLower;
});
if (!isAllowed) {
+2 -1
View File
@@ -27,8 +27,9 @@ export default defineNuxtRouteMiddleware(async (to) => {
try {
console.log('🔍 Checking if user is already authenticated...');
const headers = import.meta.server ? useRequestHeaders(['cookie']) as Record<string, string> : {}
// The $fetch will automatically send the new user_session cookie
const session = await $fetch<{ user: any } | null>('/api/auth/session').catch(() => null);
const session = await $fetch<{ user: any } | null>('/api/auth/session', { headers }).catch(() => null);
if (session && session.user) {
console.log('✅ User already authenticated, redirecting to dashboard');
File diff suppressed because it is too large Load diff
+387
View File
@@ -0,0 +1,387 @@
<!-- pages/Anjungan/Anjungan/index.vue -->
<template>
<div>
<div class="selection-header">
<div class="header-icon">
<img
src="/RSSA logo 1.png"
alt="RSUD Logo"
class="header-logo"
width="40"
height="40"
style="width: 40px; height: 40px; object-fit: contain;"
/>
</div>
<div class="header-content">
<h1 class="main-title">Pilih Anjungan</h1>
<p class="subtitle">RSUD dr. Saiful Anwar Provinsi Jawa Timur</p>
</div>
</div>
<div class="anjungan-selection-container">
<div class="anjungan-grid">
<div
v-for="anj in paginatedAnjungan"
:key="anj.id"
class="anjungan-card"
@click="navigateToAnjungan(anj.id)"
>
<div class="anjungan-card-header">
<v-icon size="28" color="primary">mdi-monitor</v-icon>
<div class="anjungan-info">
<h3 class="anjungan-name">{{ anj.namaAnjungan }}</h3>
<p class="anjungan-type">{{ anj.jenisPasien }}</p>
</div>
</div>
<div class="anjungan-klinik-preview">
<div class="klinik-count">
<v-icon size="16" color="primary-600">mdi-hospital-box</v-icon>
<span>{{ anj.klinik.length }} Klinik</span>
</div>
<div class="klinik-tags">
<v-chip
v-for="(kode, idx) in anj.klinik.slice(0, 4)"
:key="idx"
size="small"
class="ma-1 chip-preview"
>
{{ masterStore.getKlinikNameByKode(kode) }}
</v-chip>
<v-chip
v-if="anj.klinik.length > 4"
size="small"
class="ma-1 chip-more"
>
+{{ anj.klinik.length - 4 }}
</v-chip>
</div>
</div>
<div class="anjungan-card-footer">
<v-btn
color="primary"
variant="flat"
size="large"
block
class="btn-view"
>
<v-icon left size="20">mdi-eye</v-icon>
Tampilkan
</v-btn>
</div>
</div>
</div>
<div v-if="anjunganList.length === 0" class="empty-state">
<v-icon size="48" color="grey-lighten-1">mdi-monitor-off</v-icon>
<h3>Tidak Ada Anjungan Tersedia</h3>
<p>Silakan tambah anjungan terlebih dahulu di halaman master</p>
<v-btn
color="primary"
variant="flat"
@click="navigateToSettings"
class="mt-4"
>
<v-icon left size="20">mdi-cog</v-icon>
Ke Halaman Master Anjungan
</v-btn>
</div>
<div v-else-if="totalPages > 1" class="pagination">
<v-btn variant="outlined" @click="goPrev" :disabled="page <= 1">Prev</v-btn>
<span class="page-info">Page {{ page }} / {{ totalPages }}</span>
<v-btn variant="outlined" @click="goNext" :disabled="page >= totalPages">Next</v-btn>
</div>
</div>
</div>
</template>
<script setup>
import { computed } from 'vue';
import { useAnjunganStore } from '@/stores/anjunganStore';
import { useMasterStore } from '@/stores/masterStore';
import { useRoute } from '#app';
definePageMeta({
layout: false,
});
const anjunganStore = useAnjunganStore();
const masterStore = useMasterStore();
const route = useRoute();
// Safeguard supaya tidak undefined saat store belum terisi
const anjunganList = computed(() => {
const fromGetter = anjunganStore.getAllAnjungan?.value;
const fromState = anjunganStore.anjunganItems?.value || anjunganStore.anjunganItems || [];
return Array.isArray(fromGetter) ? fromGetter : Array.isArray(fromState) ? fromState : [];
});
// Pagination
const itemsPerPage = 10;
const page = computed({
get: () => Number(route.query.page || 1),
set: (val) => navigateTo({ query: { ...route.query, page: val } }),
});
const totalPages = computed(() => Math.max(1, Math.ceil(anjunganList.value.length / itemsPerPage)));
const paginatedAnjungan = computed(() => {
const start = (page.value - 1) * itemsPerPage;
return anjunganList.value.slice(start, start + itemsPerPage);
});
const goPrev = () => {
if (page.value > 1) page.value = page.value - 1;
};
const goNext = () => {
if (page.value < totalPages.value) page.value = page.value + 1;
};
const navigateToAnjungan = (anjunganId) => {
const id = typeof anjunganId === 'number' ? anjunganId : parseInt(anjunganId, 10);
if (isNaN(id)) {
console.error('Invalid anjungan ID:', anjunganId);
return;
}
navigateTo(`/anjungan/anjungancopy/${id}`);
};
const navigateToSettings = () => {
navigateTo('/setting/masteranjungan');
};
</script>
<style scoped lang="scss">
.anjungan-selection-container {
background: var(--color-neutral-300);
min-height: calc(100vh - 80px);
padding: 16px;
font-family: 'Inter', 'Roboto', sans-serif;
}
.selection-header {
background: linear-gradient(135deg, var(--color-primary-600) 0%, var(--color-primary-700) 100%);
border-radius: 0 !important;
padding: 16px 28px;
margin-bottom: 0;
display: flex;
align-items: center;
gap: 16px;
height: 80px;
box-shadow: 0 4px 16px rgba(33, 150, 243, 0.2);
}
.header-icon {
background: rgba(255, 255, 255, 0.9);
border-radius: 50%;
padding: 6px;
display: flex;
align-items: center;
justify-content: center;
width: 54px;
height: 54px;
backdrop-filter: blur(10px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.header-logo {
width: 40px;
height: 40px;
object-fit: contain;
}
.header-content {
flex: 1;
color: var(--color-neutral-100);
}
.main-title {
font-size: 32px;
font-weight: 600;
margin: 0;
color: var(--color-neutral-100);
line-height: 40px;
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.subtitle {
font-size: 15px;
font-weight: 400;
margin: 2px 0 0 0;
color: var(--color-neutral-100);
opacity: 0.9;
line-height: 22px;
}
.anjungan-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
gap: 24px;
max-width: 1400px;
margin: 0 auto;
}
.anjungan-card {
background: var(--color-neutral-100);
border-radius: 16px;
padding: 24px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
border: 2px solid var(--color-neutral-400);
cursor: pointer;
transition: all 0.3s ease;
display: flex;
flex-direction: column;
gap: 16px;
&:hover {
transform: translateY(-4px);
box-shadow: 0 8px 24px rgba(6, 113, 224, 0.2);
border-color: var(--color-secondary-600);
}
}
.anjungan-card-header {
display: flex;
align-items: center;
gap: 16px;
padding-bottom: 16px;
border-bottom: 2px solid var(--color-neutral-400);
}
.anjungan-info {
flex: 1;
}
.anjungan-name {
font-size: 20px;
font-weight: 700;
margin: 0;
color: var(--color-neutral-900);
line-height: 1.2;
}
.anjungan-type {
font-size: 14px;
color: var(--color-neutral-600);
margin: 4px 0 0 0;
font-weight: 500;
}
.anjungan-klinik-preview {
flex: 1;
}
.klinik-count {
display: flex;
align-items: center;
gap: 6px;
font-size: 14px;
font-weight: 600;
color: var(--color-primary-600);
margin-bottom: 12px;
}
.klinik-tags {
display: flex;
flex-wrap: wrap;
gap: 4px;
}
.chip-preview {
background-color: var(--color-primary-600) !important;
color: var(--color-neutral-100) !important;
font-weight: 500;
font-size: 12px;
}
.chip-more {
background-color: var(--color-neutral-600) !important;
color: var(--color-neutral-100) !important;
font-weight: 600;
font-size: 12px;
}
.anjungan-card-footer {
margin-top: auto;
}
.btn-view {
font-weight: 600;
text-transform: none;
letter-spacing: 0.5px;
}
.empty-state {
text-align: center;
padding: 80px 20px;
color: var(--color-neutral-700);
h3 {
font-size: 24px;
font-weight: 700;
margin: 24px 0 8px 0;
color: var(--color-neutral-800);
}
p {
font-size: 16px;
color: var(--color-neutral-600);
}
}
.pagination {
display: flex;
align-items: center;
justify-content: center;
gap: 12px;
margin-top: 24px;
}
.page-info {
font-weight: 600;
color: var(--color-neutral-800);
}
@media (max-width: 768px) {
.anjungan-selection-container {
padding: 12px;
}
.selection-header {
flex-direction: row;
padding: 12px 16px;
height: auto;
min-height: 64px;
}
.header-icon {
padding: 6px;
width: 40px;
height: 40px;
}
.header-logo {
width: 24px;
height: 24px;
}
.main-title {
font-size: 20px;
line-height: 28px;
}
.subtitle {
font-size: 13px;
line-height: 18px;
}
.anjungan-grid {
grid-template-columns: 1fr;
gap: 16px;
}
}
</style>
+2 -1
View File
@@ -36,6 +36,7 @@ const defaultNavItems: NavItem[] = [
path: "",
children: [
{ id: 10, name: "Anjungan", path: "/Anjungan/Anjungan", icon: "mdi-circle-small" },
{ id: 11, name: "Anjungan Eksekutif", path: "/anjungan/anjungancopy", icon: "mdi-circle-small" },
// { id: 11, name: "Klinik", path: "/Anjungan/AntrianKlinik", icon: "mdi-circle-small" },
{ id: 12, name: "Klinik Ruang", path: "/Anjungan/AntrianKlinikRuang", icon: "mdi-circle-small"},
// { id: 13, name: "Penunjang", path: "/Anjungan/AntrianPenunjang", icon: "mdi-circle-small"},
@@ -63,7 +64,7 @@ const defaultNavItems: NavItem[] = [
},
];
const STORAGE_VERSION = '1.1'; // Increment this if you change structure or default paths
const STORAGE_VERSION = '1.3'; // Increment this if you change structure or default paths
export const useNavItemsStore = defineStore('navItems', () => {
const storedVersion = useLocalStorage('navItems_version', '0');
+9 -3
View File
@@ -2886,7 +2886,7 @@ const fetchPatientsForLoket = async (loketId, force = false) => {
};
// Register patient from Anjungan (onsite registration)
const registerPatientFromAnjungan = (clinic, paymentType, visitType = 'SEKARANG', visitDate = null, shift = 'Shift 1', namaDokter = null, isFastTrack = false, fastTrackData = null, loketId = null, loket = null) => {
const registerPatientFromAnjungan = (clinic, paymentType, visitType = 'SEKARANG', visitDate = null, shift = 'Shift 1', namaDokter = null, isFastTrack = false, fastTrackData = null, loketId = null, loket = null, subSpesialis = null) => {
// 1. Validasi keberadaan (prevent duplicates)
// Gunakan date today untuk check-in sync
const timestamp = new Date();
@@ -2946,6 +2946,9 @@ const fetchPatientsForLoket = async (loketId, force = false) => {
calledByAdmin: false,
penanggungJawab: (isFastTrack && fastTrackData) ? fastTrackData.penanggungJawab : null,
alasanFastTrack: (isFastTrack && fastTrackData) ? fastTrackData.alasanFastTrack : null,
ruang: subSpesialis ? subSpesialis.namaRuang : null,
nomorRuang: subSpesialis ? subSpesialis.nomorRuang : null,
kodeRuang: subSpesialis ? subSpesialis.kodeRuang : null,
};
// Auto-assign Loket ID if not provided, based on Clinic Mapping
@@ -2977,7 +2980,7 @@ const fetchPatientsForLoket = async (loketId, force = false) => {
* Register REGULER patient via API
* POST to http://10.10.123.140:8089/api/v1/tiket/generate
*/
const registerRegulerPatientViaApi = async (clinic, paymentType, visitType = 'SEKARANG', isFastTrack = false, fastTrackData = null) => {
const registerRegulerPatientViaApi = async (clinic, paymentType, visitType = 'SEKARANG', isFastTrack = false, fastTrackData = null, subSpesialis = null) => {
try {
// 1. Find appropriate idloket based on BOTH clinic code AND payment type
const apiLoketsExist = loketStore.lokets?.some(l => l.source === 'api' || l.id < 1000);
@@ -3101,7 +3104,10 @@ const fetchPatientsForLoket = async (loketId, force = false) => {
alasanFastTrack: (isFastTrack && fastTrackData) ? fastTrackData.alasanFastTrack : null,
// Additional API fields
idvisit: 1, // Default menunggu
idtiket: apiData.id
idtiket: apiData.id,
ruang: subSpesialis ? subSpesialis.namaRuang : null,
nomorRuang: subSpesialis ? subSpesialis.nomorRuang : null,
kodeRuang: subSpesialis ? subSpesialis.kodeRuang : null,
};
allPatients.value.push(newPatient);