fix: sep searching
This commit is contained in:
No files matched your search
@@ -20,6 +20,7 @@ import type { TreeItem } from '~/components/pub/my-ui/select-tree/type'
|
|||||||
// Helpers
|
// Helpers
|
||||||
import { toTypedSchema } from '@vee-validate/zod'
|
import { toTypedSchema } from '@vee-validate/zod'
|
||||||
import { useForm } from 'vee-validate'
|
import { useForm } from 'vee-validate'
|
||||||
|
import { refDebounced } from '@vueuse/core'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
isLoading?: boolean
|
isLoading?: boolean
|
||||||
@@ -92,8 +93,9 @@ watch(subSpecialistId, async (newValue) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// Watch SEP number changes to notify parent
|
// Debounced SEP number watcher: emit change only after user stops typing
|
||||||
watch(sepNumber, (newValue) => {
|
const debouncedSepNumber = refDebounced(sepNumber, 500)
|
||||||
|
watch(debouncedSepNumber, (newValue) => {
|
||||||
emit('event', 'sep-number-changed', newValue)
|
emit('event', 'sep-number-changed', newValue)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -259,9 +259,9 @@ async function handleEvent(menu: string, value?: any) {
|
|||||||
})
|
})
|
||||||
} else if (menu === 'sep-number-changed') {
|
} else if (menu === 'sep-number-changed') {
|
||||||
// Update sepNumber when it changes in form (only if different to prevent loop)
|
// Update sepNumber when it changes in form (only if different to prevent loop)
|
||||||
if (sepNumber.value !== value) {
|
// When SEP number changes from child form, trigger validation/getList immediately
|
||||||
sepNumber.value = value || ''
|
// so parent can react (this will also be picked up by the debounced watcher)
|
||||||
}
|
await validateSepNumber(String(value || ''))
|
||||||
} else if (menu === 'save') {
|
} else if (menu === 'save') {
|
||||||
await handleSaveEncounter(value)
|
await handleSaveEncounter(value)
|
||||||
} else if (menu === 'cancel') {
|
} else if (menu === 'cancel') {
|
||||||
@@ -298,26 +298,15 @@ async function validateSepNumber(sepNumberValue: string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only check if payment type is JKN
|
|
||||||
// We need to check from formObjects
|
|
||||||
const paymentType = formObjects.value?.paymentType
|
|
||||||
if (paymentType !== 'jkn') {
|
|
||||||
isSepValid.value = false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
isSepValid.value = false
|
||||||
isCheckingSep.value = true
|
isCheckingSep.value = true
|
||||||
const result = await getSepList({ number: sepNumberValue.trim() })
|
const result = await getSepList({ number: sepNumberValue.trim() })
|
||||||
|
|
||||||
// Check if SEP is found
|
// Check if SEP is found
|
||||||
// If response is not null, SEP is found
|
// If response is not null, SEP is found
|
||||||
// If response is null with metaData code "201", SEP is not found
|
// If response is null with metaData code "201", SEP is not found
|
||||||
if (result.success && result.body?.response !== null) {
|
if (result.success && result.body?.response !== null) {
|
||||||
isSepValid.value = true
|
isSepValid.value = result.body?.response?.metaData?.code === '200'
|
||||||
} else {
|
|
||||||
// SEP not found (response null with metaData code "201")
|
|
||||||
isSepValid.value = false
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error checking SEP:', error)
|
console.error('Error checking SEP:', error)
|
||||||
|
|||||||
@@ -386,6 +386,9 @@ async function handleEvent(menu: string, value: any) {
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (menu === 'sep-number-changed') {
|
||||||
|
// Update sepNumber when it changes in form (only if different to prevent loop)
|
||||||
|
}
|
||||||
if (menu === 'back') {
|
if (menu === 'back') {
|
||||||
navigateTo('/integration/bpjs/sep')
|
navigateTo('/integration/bpjs/sep')
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user