@@ -400,12 +407,14 @@ const headers = ref([
{ title: 'No', value: 'no', sortable: true },
{ title: 'Nama Klinik', value: 'namaKlinik', sortable: true },
{ title: 'Kode', value: 'kodeKlinik', sortable: true },
- { title: 'Nama Ruang', value: 'namaRuang', sortable: true },
+ { title: 'Jumlah Ruang', value: 'jumlahRuang', sortable: true },
+ { title: 'Daftar Ruang', value: 'namaRuang', sortable: true },
{ title: 'Jenis Layanan', value: 'jenisLayanan', sortable: true },
{ title: 'Layar Informasi', value: 'layarInformasi', sortable: false, width: '150px' },
{ title: 'Aksi', value: 'aksi', sortable: false },
]);
+
const pageCount = computed(() => {
return Math.ceil(filteredTotal.value / itemsPerPage.value) || 1;
});
@@ -536,109 +545,31 @@ const closePreviewDialog = () => {
previewUrl.value = '';
};
-// Generate rooms from clinics based on spesialis field
-const generateRoomsFromClinics = () => {
- console.log('π Generating rooms from clinics...');
- const allRooms = [];
- let roomIdCounter = 1;
-
- // Get all clinics (Reguler from API + Eksekutif from seed)
- const allClinics = clinicStore.clinics;
- console.log('π Total clinics:', allClinics.length);
- console.log('π Clinics by type:', {
- Reguler: allClinics.filter(c => c.jenisLayanan === 'Reguler').length,
- Eksekutif: allClinics.filter(c => c.jenisLayanan === 'Eksekutif').length
- });
-
- allClinics.forEach(clinic => {
- console.log(`\n Processing clinic: ${clinic.name} (${clinic.kode}) - ${clinic.jenisLayanan}`);
-
- if (clinic.jenisLayanan === 'Reguler') {
- // For Reguler: check spesialis from API
- if (clinic.spesialis && Array.isArray(clinic.spesialis) && clinic.spesialis.length > 0) {
- // Create room ONLY for each specialist (no duplicate clinic-name room)
- console.log(` β
Has ${clinic.spesialis.length} specialists - creating rooms ONLY from specialists`);
- clinic.spesialis.forEach((spec, index) => {
- allRooms.push({
- id: roomIdCounter++,
- kodeKlinik: clinic.kode,
- namaKlinik: clinic.name,
- kodeRuang: `${clinic.kode}-${spec.idspesialis}`,
- namaRuang: spec.Spesialis,
- nomorRuang: (index + 1).toString(),
- nomorScreen: `${clinic.kode}${index + 1}`,
- jenisLayanan: 'Reguler'
- });
- console.log(` β Room: ${spec.Spesialis}`);
- });
- } else {
- // Only create 1 room with clinic name when NO spesialis
- console.log(' β οΈ No specialists, creating 1 room with clinic name');
- allRooms.push({
- id: roomIdCounter++,
- kodeKlinik: clinic.kode,
- namaKlinik: clinic.name,
- kodeRuang: clinic.kode,
- namaRuang: clinic.name,
- nomorRuang: '1',
- nomorScreen: `${clinic.kode}1`,
- jenisLayanan: 'Reguler'
- });
- }
- } else if (clinic.jenisLayanan === 'Eksekutif') {
- // For Eksekutif: always 1 room (no spesialis in seed data)
- console.log(' π¦ Eksekutif clinic, creating 1 room');
- allRooms.push({
- id: roomIdCounter++,
- kodeKlinik: clinic.kode,
- namaKlinik: clinic.name,
- kodeRuang: clinic.kode,
- namaRuang: clinic.name,
- nomorRuang: '1',
- nomorScreen: `${clinic.kode}1`,
- jenisLayanan: 'Eksekutif'
- });
- } else {
- console.log(` β οΈ Unknown jenisLayanan: ${clinic.jenisLayanan}`);
- }
- });
-
- console.log(`\nβ
Generated ${allRooms.length} rooms from ${allClinics.length} clinics`);
- console.log('π Rooms by Jenis Layanan:');
- console.log(' - Reguler:', allRooms.filter(r => r.jenisLayanan === 'Reguler').length);
- console.log(' - Eksekutif:', allRooms.filter(r => r.jenisLayanan === 'Eksekutif').length);
-
- // Update ruangStore with generated rooms
- const result = ruangStore.replaceAllRooms(allRooms);
- console.log('πΎ Rooms saved to ruangStore:', result.message);
-
- return result;
-};
-
-// Fetch clinics and generate rooms on mount
+// Fetch clinics and sync rooms on mount
onMounted(async () => {
- console.log('π MasterKlinikRuang mounted, fetching clinics...');
+ console.log('π MasterKlinikRuang mounted, syncing data...');
try {
- // Fetch clinics from API (uses cache if available)
- const fetchResult = await clinicStore.fetchRegulerClinics();
- console.log('π₯ Fetch result:', fetchResult);
+ // 1. Fetch clinics from API (uses cache if available)
+ const fetchClinicResult = await clinicStore.fetchRegulerClinics();
+ console.log('π₯ Clinic fetch result:', fetchClinicResult);
- if (!fetchResult.success) {
+ if (!fetchClinicResult.success) {
snackbar.value = {
show: true,
- message: fetchResult.message,
+ message: `Klinik: ${fetchClinicResult.message}`,
color: 'warning'
};
}
- // Generate rooms based on fetched data
- const generateResult = generateRoomsFromClinics();
+ // 2. Fetch and merge rooms from API
+ const syncRuangResult = await ruangStore.fetchRuangFromAPI();
+ console.log('π Room sync result:', syncRuangResult);
snackbar.value = {
show: true,
- message: generateResult.message,
- color: 'success'
+ message: syncRuangResult.message,
+ color: syncRuangResult.success ? 'success' : 'error'
};
} catch (error) {
console.error('β Error in onMounted:', error);
@@ -649,6 +580,7 @@ onMounted(async () => {
};
}
});
+