🐛 fix (general-consent): fix mapping data from api
This commit is contained in:
@@ -10,7 +10,8 @@ import { handleActionSave, handleActionEdit } from '~/handlers/general-consent.h
|
|||||||
import { create } from '~/services/generate-file.service'
|
import { create } from '~/services/generate-file.service'
|
||||||
// Services
|
// Services
|
||||||
import { getDetail } from '~/services/general-consent.service'
|
import { getDetail } from '~/services/general-consent.service'
|
||||||
const { backToList } = useQueryMode('mode')
|
const { backToList } = useQueryCRUDMode('mode')
|
||||||
|
const { recordId } = useQueryCRUDRecordId('record-id')
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const isOpenProcedure = ref(false)
|
const isOpenProcedure = ref(false)
|
||||||
@@ -74,8 +75,15 @@ const loadEntryForEdit = async (id: number) => {
|
|||||||
if (result?.success) {
|
if (result?.success) {
|
||||||
const data = result.body?.data || {}
|
const data = result.body?.data || {}
|
||||||
|
|
||||||
console.log('Mapping data:', data)
|
const value = JSON.parse(data.value || '{}')
|
||||||
// Set state utk form
|
console.log('Mapping data:', value)
|
||||||
|
model.value.witness1 = value?.witness1 || ''
|
||||||
|
model.value.witness2 = value?.witness2 || ''
|
||||||
|
model.value.informant = value?.informant || ''
|
||||||
|
model.value.responsibleName = value?.responsible || ''
|
||||||
|
model.value.responsiblePhone = value?.responsiblePhone || ''
|
||||||
|
model.value.relatives = value?.relatives || []
|
||||||
|
console.log('model', model.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,7 +103,6 @@ async function actionHandler(type: string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (type === 'print') {
|
if (type === 'print') {
|
||||||
console.log('print')
|
|
||||||
isOpenDiagnose.value = true
|
isOpenDiagnose.value = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,7 +89,6 @@ const headerPrep: HeaderPrep = {
|
|||||||
icon: 'i-lucide-plus',
|
icon: 'i-lucide-plus',
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
goToEntry()
|
goToEntry()
|
||||||
emits('add')
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,17 @@ export function useQueryCRUDMode(key: string = 'mode') {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const goToEntry = () => (mode.value = 'entry')
|
const goToEntry = () => (mode.value = 'entry')
|
||||||
const backToList = () =>(mode.value = 'list')
|
const backToList = () => {
|
||||||
|
router.push({
|
||||||
|
path: route.path,
|
||||||
|
query: {
|
||||||
|
...route.query,
|
||||||
|
mode: 'list',
|
||||||
|
// HAPUS record-id
|
||||||
|
'record-id': undefined,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return { mode, goToEntry, backToList }
|
return { mode, goToEntry, backToList }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user