update logic payment based on SIMRS

This commit is contained in:
bagus-arie05
2025-11-04 08:49:41 +07:00
parent bb66cf4a2a
commit 1733c67b9e

View File

@@ -80,7 +80,6 @@ watch(
{ immediate: true }
);
// script page index:
watch(
wsData,
(newStatus) => {
@@ -88,51 +87,55 @@ watch(
const posDevices = newStatus?.data?.posdevice || [];
if (!newStatus || !payloadData) {
console.log("📭 WS: No valid payload data in message. Skipping state change.");
console.log(
"📭 WS: No valid payload data in message. Skipping state change."
);
return;
}
// ... (console.log yang ada) ...
const isTargetDevice = payloadData.ip === localIpAddress.value;
const isPosDevice = posDevices.includes(localIpAddress.value);
const isRelevantDevice = isTargetDevice || isPosDevice; // Kita gunakan ini
// --- LOGIKA BARU DITAMBAHKAN DI SINI ---
// Jika kita di Step 3 (Sukses) atau 4 (Gagal) DAN ada transaksi BARU (status "1")
if (
(paymentStore.currentStep === 3 || paymentStore.currentStep === 4) &&
isRelevantDevice &&
payloadData.status === "1"
) {
console.log("🔄 [WS] New transaction received on end screen. Resetting state...");
// 1. Reset store secara paksa (ini akan membersihkan timer dan kembali ke step 1)
paymentStore.reset();
// 2. Sekarang proses data baru seolah-olah kita berada di Step 1
console.log(
"🔄 [WS] New transaction received on end screen. Resetting state..."
);
paymentStore.reset();
paymentStore.updatePayment({ data: [payloadData] });
paymentStore.setStep(2);
}
// --- AKHIR LOGIKA BARU ---
// Logika Anda yang sudah ada
else if (paymentStore.currentStep === 1) {
} else if (paymentStore.currentStep === 1) {
console.log("🔍 Step 1 (WS): Looking for IP:", localIpAddress.value);
if (isRelevantDevice && payloadData.status === "1") {
console.log("✅ WS Data found for IP (New Transaction). Moving to Step 2.");
console.log(
"✅ WS Data found for IP (New Transaction). Moving to Step 2."
);
paymentStore.updatePayment({ data: [payloadData] });
paymentStore.setStep(2);
} else {
console.log(`⏳ No relevant data found for IP ${localIpAddress.value} in this broadcast.`);
console.log(
`⏳ No relevant data found for IP ${localIpAddress.value} in this broadcast.`
);
}
} else if (paymentStore.currentStep === 2) {
if (isRelevantDevice &&
payloadData.display_nobill === paymentStore.qrData.display_nobill) {
console.log("🔄 WS Update received for current patient in Step 2. Updating store...");
if (isRelevantDevice) {
console.log(
"🔄 WS Update received for current patient in Step 2. Updating store..."
);
paymentStore.updatePayment({ data: [payloadData] });
}
// if (isRelevantDevice &&
// payloadData.display_nobill === paymentStore.qrData.display_nobill) {
// console.log("🔄 WS Update received for current patient in Step 2. Updating store...");
// paymentStore.updatePayment({ data: [payloadData] });
// }
}
},
{ deep: true }
@@ -235,7 +238,6 @@ onUnmounted(() => {
}
}
/* Large tablet portrait */
@media (min-width: 769px) and (max-width: 1024px) and (orientation: portrait) {
.payment-centered {
@@ -285,4 +287,4 @@ onUnmounted(() => {
min-height: 600px;
}
}
</style>
</style>