layar baru antrean klinik dan masuk
This commit is contained in:
+50
-3
@@ -3,10 +3,19 @@ import { defineStore } from 'pinia';
|
||||
import { ref, computed } from 'vue';
|
||||
import { useClinicStore } from './clinicStore';
|
||||
import { usePenunjangStore } from './penunjangStore';
|
||||
import { useLoketStore } from './loketStore';
|
||||
|
||||
export const useQueueStore = defineStore('queue', () => {
|
||||
const clinicStore = useClinicStore();
|
||||
const penunjangStore = usePenunjangStore();
|
||||
const loketStore = useLoketStore();
|
||||
|
||||
// Helper function untuk mendapatkan loket default (Loket 1)
|
||||
const getDefaultLoket = () => {
|
||||
const allLokets = loketStore.loketData?.value || loketStore.loketData || [];
|
||||
const loket1 = allLokets.find(l => l.id === 1 || l.no === 1);
|
||||
return loket1 ? loket1.namaLoket : 'Loket 1';
|
||||
};
|
||||
// Seed data for easy reset during dev
|
||||
const seedPatients = [
|
||||
{
|
||||
@@ -418,7 +427,7 @@ export const useQueueStore = defineStore('queue', () => {
|
||||
message = `Pasien ${patientCode} di-pending`;
|
||||
break;
|
||||
|
||||
case "aktifkan":
|
||||
case "aktifkan": {
|
||||
const currentStatus = allPatients.value[patientIndex].status;
|
||||
if (currentStatus === "terlambat" || currentStatus === "pending") {
|
||||
// PERBAIKAN: Update dengan cara yang Vue reactive
|
||||
@@ -431,12 +440,39 @@ export const useQueueStore = defineStore('queue', () => {
|
||||
message = `Pasien ${patientCode} tidak dapat diaktifkan (status: ${currentStatus})`;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case "proses":
|
||||
case "proses": {
|
||||
// Ambil data terbaru dari array
|
||||
currentProcessingPatient.value[adminType] = allPatients.value[patientIndex];
|
||||
const patient = allPatients.value[patientIndex];
|
||||
|
||||
// Jika adminType adalah 'loket', pastikan ada loket assignment
|
||||
if (adminType === 'loket') {
|
||||
// Pastikan antrian yang diproses memiliki loket assignment
|
||||
const currentLoket = patient.loket || getDefaultLoket();
|
||||
const currentLoketId = patient.loketId || 1;
|
||||
|
||||
// Update patient dengan loket assignment (jika belum ada)
|
||||
if (!patient.loket || !patient.loketId) {
|
||||
const updatedPatient = {
|
||||
...patient,
|
||||
loket: currentLoket,
|
||||
loketId: currentLoketId
|
||||
};
|
||||
allPatients.value[patientIndex] = updatedPatient;
|
||||
// Set currentProcessingPatient dengan loket assignment
|
||||
currentProcessingPatient.value[adminType] = updatedPatient;
|
||||
} else {
|
||||
// Jika sudah ada loket assignment, langsung set currentProcessingPatient
|
||||
currentProcessingPatient.value[adminType] = patient;
|
||||
}
|
||||
} else {
|
||||
// Untuk adminType selain loket, langsung set currentProcessingPatient
|
||||
currentProcessingPatient.value[adminType] = patient;
|
||||
}
|
||||
message = `Memproses pasien ${patientCode}`;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return { success: true, message };
|
||||
@@ -779,5 +815,16 @@ export const useQueueStore = defineStore('queue', () => {
|
||||
key: 'queue-store-state',
|
||||
storage: typeof window !== 'undefined' ? localStorage : undefined,
|
||||
paths: ['allPatients', 'quotaUsed', 'currentProcessingPatient'],
|
||||
serializer: {
|
||||
deserialize: JSON.parse,
|
||||
serialize: JSON.stringify,
|
||||
},
|
||||
restore: (value) => {
|
||||
// Ensure allPatients is always an array
|
||||
if (value && value.allPatients && !Array.isArray(value.allPatients)) {
|
||||
value.allPatients = [];
|
||||
}
|
||||
return value;
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user