From 9ccbabadf2b2db5d61cc92a12895161ad892e861 Mon Sep 17 00:00:00 2001 From: Fanrouver Date: Tue, 13 Jan 2026 11:40:45 +0700 Subject: [PATCH] perbaikan total antrean --- pages/Anjungan/AntrianLoket/[id].vue | 44 +++------ stores/queueStore.js | 132 ++++++--------------------- 2 files changed, 44 insertions(+), 132 deletions(-) diff --git a/pages/Anjungan/AntrianLoket/[id].vue b/pages/Anjungan/AntrianLoket/[id].vue index c5d9743..cf10d13 100644 --- a/pages/Anjungan/AntrianLoket/[id].vue +++ b/pages/Anjungan/AntrianLoket/[id].vue @@ -515,10 +515,8 @@ const displayedClinics = computed(() => { } else { // Jika tidak ada di sortedQueues, gunakan langsung dari hero section // Pastikan pasien sesuai dengan filter (processStage 'loket') - // Status bisa 'di-loket', 'terlambat', 'pending', atau 'pending-call' (sudah dipanggil) - // Status 'waiting' tidak ditampilkan di antrian loket + // Status bisa 'di-loket', 'terlambat', 'pending', atau 'waiting' (sudah dipanggil) if (heroPatient.processStage === 'loket' && - heroPatient.status !== 'waiting' && heroPatient.status !== 'menunggu') { // Langsung gunakan pasien dari hero section karena sudah dipanggil currentQueue = heroPatient @@ -621,8 +619,7 @@ const isInTTSWindow = (queue) => { const _ = currentTime.value // Force reactivity - const callTime = queue.lastCalledAt ? new Date(queue.lastCalledAt) : - (queue.pendingCallAt ? new Date(queue.pendingCallAt) : null) + const callTime = queue.lastCalledAt ? new Date(queue.lastCalledAt) : null if (!callTime) return false const ttsDuration = 15000 // 15 detik @@ -646,10 +643,9 @@ const currentCalledQueue = computed(() => { } } - // Prioritas 2: Ambil semua tiket yang sudah dipanggil (status 'pending-call' saja, bukan 'waiting') - // Status 'waiting' tidak ditampilkan di antrian loket + // Prioritas 2: Ambil semua tiket yang sudah dipanggil (status 'waiting') const allCalledQueues = queueStore.allPatients.filter(p => - p.status === 'pending-call' && (p.lastCalledAt || p.pendingCallAt) + p.status === 'waiting' && p.lastCalledAt ) // Filter berdasarkan pelayanan loket jika ada @@ -678,8 +674,8 @@ const currentCalledQueue = computed(() => { // Urutkan berdasarkan waktu panggilan (yang dipanggil duluan lebih dulu) const sortedByCallTime = filteredQueues.sort((a, b) => { - const timeA = new Date(a.lastCalledAt || a.pendingCallAt || 0) - const timeB = new Date(b.lastCalledAt || b.pendingCallAt || 0) + const timeA = new Date(a.lastCalledAt || 0) + const timeB = new Date(b.lastCalledAt || 0) return timeA - timeB }) @@ -764,8 +760,7 @@ const currentMultipleCallsTimer = computed(() => { const _ = currentTime.value // Force reactivity - const callTime = currentCalledQueue.value.lastCalledAt ? new Date(currentCalledQueue.value.lastCalledAt) : - (currentCalledQueue.value.pendingCallAt ? new Date(currentCalledQueue.value.pendingCallAt) : null) + const callTime = currentCalledQueue.value.lastCalledAt ? new Date(currentCalledQueue.value.lastCalledAt) : null if (!callTime) return null const ttsDuration = 15000 // 15 detik @@ -784,22 +779,12 @@ const getTimerText = (queue) => { const _ = currentTime.value // Force reactivity - // Gunakan lastCalledAt atau pendingCallAt untuk waktu panggilan + // Gunakan lastCalledAt untuk waktu panggilan const callTime = queue.lastCalledAt ? new Date(queue.lastCalledAt) : - (queue.pendingCallAt ? new Date(queue.pendingCallAt) : - (queue.createdAt ? new Date(queue.createdAt) : null)) + (queue.createdAt ? new Date(queue.createdAt) : null) if (!callTime) return '' - // Jika status pending-call, hitung waktu sampai dipanggil (5 detik) - if (queue.status === 'pending-call') { - const elapsed = Date.now() - callTime.getTime() - const remaining = Math.max(0, 5000 - elapsed) - if (remaining <= 0) return '' - const seconds = Math.ceil(remaining / 1000) - return `Dipanggil dalam ${seconds}s` - } - - // Jika sudah dipanggil, hitung waktu text-to-speech (15 detik) + // Hitung waktu text-to-speech (15 detik) const ttsDuration = 15000 // 15 detik const elapsed = Date.now() - callTime.getTime() const remaining = Math.max(0, ttsDuration - elapsed) @@ -812,10 +797,9 @@ const getTimerText = (queue) => { // Next 5 tickets to be called - tiket yang sudah dipanggil tapi menunggu giliran TTS const nextTicketsToCall = computed(() => { - // Ambil semua tiket yang sudah dipanggil (status 'pending-call' saja, bukan 'waiting') - // Status 'waiting' tidak ditampilkan di antrian loket + // Ambil semua tiket yang sudah dipanggil (status 'waiting') const allCalledQueues = queueStore.allPatients.filter(p => - p.status === 'pending-call' && (p.lastCalledAt || p.pendingCallAt) + p.status === 'waiting' && p.lastCalledAt ) // Filter berdasarkan pelayanan loket jika ada @@ -844,8 +828,8 @@ const nextTicketsToCall = computed(() => { // Urutkan berdasarkan waktu panggilan (yang dipanggil duluan lebih dulu) const sortedByCallTime = filteredQueues.sort((a, b) => { - const timeA = new Date(a.lastCalledAt || a.pendingCallAt || 0) - const timeB = new Date(b.lastCalledAt || b.pendingCallAt || 0) + const timeA = new Date(a.lastCalledAt || 0) + const timeB = new Date(b.lastCalledAt || 0) return timeA - timeB }) diff --git a/stores/queueStore.js b/stores/queueStore.js index 7c06a4a..526a83e 100644 --- a/stores/queueStore.js +++ b/stores/queueStore.js @@ -304,7 +304,7 @@ export const useQueueStore = defineStore('queue', () => { return { all: patients, - waiting: patients.filter(p => p.status === 'waiting'), + waiting: patients.filter(p => p.status === 'waiting'), // Pasien yang sudah dipanggil, menunggu check-in menunggu: patients.filter(p => p.status === 'menunggu'), // Pasien yang belum dipanggil diLoket: patients.filter(p => p.status === 'di-loket'), terlambat: patients.filter(p => p.status === 'terlambat'), @@ -365,55 +365,21 @@ export const useQueueStore = defineStore('queue', () => { return { success: false, message: "Tidak ada pasien yang menunggu untuk dipanggil" }; } - // Untuk adminType 'loket', tambahkan delay 5 detik sebelum status berubah - // Ini untuk simulasi multiple loket memanggil bersamaan - if (adminType === 'loket') { - // Set status pending call dengan timestamp - const pendingCallTimestamp = new Date().toISOString(); - const index = allPatients.value.findIndex(p => p.no === nextPatient.no); - if (index !== -1) { - allPatients.value[index] = { - ...allPatients.value[index], - status: "pending-call", // Status sementara sebelum delay - pendingCallAt: pendingCallTimestamp - }; - } - - // Set timeout 5 detik untuk mengubah status menjadi 'waiting' - setTimeout(() => { - const patientIndex = allPatients.value.findIndex(p => p.no === nextPatient.no); - if (patientIndex !== -1 && allPatients.value[patientIndex].status === 'pending-call') { - const callTimestamp = new Date().toISOString(); - allPatients.value[patientIndex] = { - ...allPatients.value[patientIndex], - status: "waiting", - lastCalledAt: callTimestamp, // Track waktu panggilan untuk multiple calls - pendingCallAt: undefined // Clear pending call timestamp - }; - } - }, 5000); // Delay 5 detik - - return { - success: true, - message: `Memanggil pasien ${nextPatient.noAntrian.split(" |")[0]} (akan dipanggil dalam 5 detik)`, - }; - } else { - // Untuk adminType selain loket, langsung update status - const callTimestamp = new Date().toISOString(); - const index = allPatients.value.findIndex(p => p.no === nextPatient.no); - if (index !== -1) { - allPatients.value[index] = { - ...allPatients.value[index], - status: "waiting", - lastCalledAt: callTimestamp // Track waktu panggilan untuk multiple calls - }; - } - - return { - success: true, - message: `Memanggil pasien ${nextPatient.noAntrian.split(" |")[0]}`, + // Langsung update status menjadi 'waiting' + const callTimestamp = new Date().toISOString(); + const index = allPatients.value.findIndex(p => p.no === nextPatient.no); + if (index !== -1) { + allPatients.value[index] = { + ...allPatients.value[index], + status: "waiting", + lastCalledAt: callTimestamp // Track waktu panggilan untuk multiple calls }; } + + return { + success: true, + message: `Memanggil pasien ${nextPatient.noAntrian.split(" |")[0]}`, + }; }; const callMultiplePatients = (count, adminType = 'loket') => { @@ -459,61 +425,23 @@ export const useQueueStore = defineStore('queue', () => { const patientsToCall = combinedList.slice(0, maxCallable); - // Untuk adminType 'loket', tambahkan delay 5 detik sebelum status berubah - // Ini untuk simulasi multiple loket memanggil bersamaan - if (adminType === 'loket') { - // Set status pending call dengan timestamp - const pendingCallTimestamp = new Date().toISOString(); - patientsToCall.forEach((patient) => { - const index = allPatients.value.findIndex(p => p.no === patient.no); - if (index !== -1) { - allPatients.value[index] = { - ...allPatients.value[index], - status: "pending-call", // Status sementara sebelum delay - pendingCallAt: pendingCallTimestamp - }; - } - }); - - // Set timeout 5 detik untuk mengubah status menjadi 'waiting' - setTimeout(() => { - const callTimestamp = new Date().toISOString(); - patientsToCall.forEach((patient) => { - const patientIndex = allPatients.value.findIndex(p => p.no === patient.no); - if (patientIndex !== -1 && allPatients.value[patientIndex].status === 'pending-call') { - allPatients.value[patientIndex] = { - ...allPatients.value[patientIndex], - status: "waiting", - lastCalledAt: callTimestamp, // Track waktu panggilan untuk multiple calls - pendingCallAt: undefined // Clear pending call timestamp - }; - } - }); - }, 5000); // Delay 5 detik - - return { - success: true, - message: `Memanggil ${patientsToCall.length} pasien ke loket (akan dipanggil dalam 5 detik)`, - }; - } else { - // Untuk adminType selain loket, langsung update status - const callTimestamp = new Date().toISOString(); - patientsToCall.forEach((patient) => { - const index = allPatients.value.findIndex(p => p.no === patient.no); - if (index !== -1) { - allPatients.value[index] = { - ...allPatients.value[index], - status: "waiting", - lastCalledAt: callTimestamp // Track waktu panggilan untuk multiple calls - }; - } - }); + // Langsung update status menjadi 'waiting' + const callTimestamp = new Date().toISOString(); + patientsToCall.forEach((patient) => { + const index = allPatients.value.findIndex(p => p.no === patient.no); + if (index !== -1) { + allPatients.value[index] = { + ...allPatients.value[index], + status: "waiting", + lastCalledAt: callTimestamp // Track waktu panggilan untuk multiple calls + }; + } + }); - return { - success: true, - message: `Memanggil ${patientsToCall.length} pasien ke loket`, - }; - } + return { + success: true, + message: `Memanggil ${patientsToCall.length} pasien`, + }; }; const processPatient = (patient, action, adminType = 'loket') => {