feat (initial-nursing): add initial nursing entry form and preview

This commit is contained in:
Abizrh
2025-12-02 16:48:24 +07:00
parent ff4aefa593
commit 3038448f4a
5 changed files with 86 additions and 117 deletions
@@ -23,6 +23,7 @@ const payload = ref({
typeCode: 'early-nursery',
value: '',
})
const listProblem = ref([])
const model = ref({
'pri-complain': '',
@@ -54,9 +55,11 @@ const isLoading = reactive<DataTableLoader>({
isTableLoading: false,
})
function handleOpen(type: string) {
if (type === 'fungsional') {
isOpenDiagnose.value = true
function handleOpen(event: any) {
console.log('handleOpen', event.type)
const type = event.type
if (type === 'add-problem') {
listProblem.value = event.data
}
}
@@ -68,8 +71,8 @@ async function actionHandler(type: string) {
}
const result = await entryRehabRef.value?.validate()
if (result?.valid) {
if (selectedDiagnose.value?.length > 0) {
result.data.diagnose = selectedDiagnose.value || []
if (listProblem.value?.length > 0) {
result.data.listProblem = listProblem.value || []
}
console.log('data', result.data)
handleActionSave(
@@ -79,7 +82,8 @@ async function actionHandler(type: string) {
encounter_id: +route.params.id,
time: new Date().toISOString(),
},
{},
() => {},
() => {},
toast,
)
@@ -50,6 +50,7 @@ let units = ref<{ value: string; label: string }[]>([])
const encounterId = ref<number>(props?.encounter?.id || 0)
const title = ref('')
const id = route.params.id
const descData = ref({})
const {
data,
@@ -68,6 +69,7 @@ const {
search,
page,
})
console.log('masukkk', result)
if (result.success) {
data.value = result.body.data
}
@@ -116,6 +118,30 @@ const getMyDetail = async (id: number | string) => {
}
}
const mappedData = computed(() => {
if (!data.value || data.value.length === 0) return []
const raw = data.value[0]
// Pastikan raw.value adalah string JSON
let parsed: any = {}
try {
parsed = JSON.parse(raw.value || '{}')
} catch (err) {
console.error('JSON parse error:', err)
return []
}
// Ambil listProblem
const list = parsed.listProblem || []
const textData = parsed
// Untuk keamanan: pastikan selalu array
if (!Array.isArray(list)) return []
return { list, textData }
})
// Watch for row actions when recId or recAction changes
watch([recId, recAction], () => {
switch (recAction.value) {
@@ -149,14 +175,12 @@ onMounted(async () => {
class="mb-4 xl:mb-5"
/>
<Preview />
<Preview :preview="mappedData.textData" />
<h2 class="my-3 p-1 font-semibold">C. Daftar Masalah Keperawatan</h2>
<List
:data="data"
:pagination-meta="paginationMeta"
@page-change="handlePageChange"
/>
<List :data="mappedData.list || []" />
<!-- :pagination-meta="paginationMeta" -->
<!-- @page-change="handlePageChange" -->
<!-- Record Confirmation Modal -->
<RecordConfirmation