From 1733c67b9e0b79dfcc1f5d158086446d01aeb99e Mon Sep 17 00:00:00 2001 From: bagus-arie05 Date: Tue, 4 Nov 2025 08:49:41 +0700 Subject: [PATCH] update logic payment based on SIMRS --- pages/index.vue | 50 +++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/pages/index.vue b/pages/index.vue index bc1bdd8..d127207 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -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; } } - \ No newline at end of file +