push loket perbaikan sedang dilayani

This commit is contained in:
Fanrouver
2026-01-12 15:35:28 +07:00
parent 42fe62cb41
commit 48e4aabd4b
2 changed files with 205 additions and 90 deletions
+101 -31
View File
@@ -365,22 +365,55 @@ export const useQueueStore = defineStore('queue', () => {
return { success: false, message: "Tidak ada pasien yang menunggu untuk dipanggil" };
}
// Update status dari 'menunggu' menjadi 'waiting' (sudah dipanggil, bisa check-in)
// Track waktu panggilan untuk multiple calls detection
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
// 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]}`,
};
}
return {
success: true,
message: `Memanggil pasien ${nextPatient.noAntrian.split(" |")[0]}`,
};
};
const callMultiplePatients = (count, adminType = 'loket') => {
@@ -426,24 +459,61 @@ export const useQueueStore = defineStore('queue', () => {
const patientsToCall = combinedList.slice(0, maxCallable);
// Update status dari 'menunggu' menjadi 'waiting' (sudah dipanggil, bisa check-in)
// Track waktu panggilan untuk multiple calls detection - semua dipanggil dengan timestamp yang sama
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
};
}
});
// 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
};
}
});
return {
success: true,
message: `Memanggil ${patientsToCall.length} pasien ke loket`,
};
return {
success: true,
message: `Memanggil ${patientsToCall.length} pasien ke loket`,
};
}
};
const processPatient = (patient, action, adminType = 'loket') => {