⚙️ chore (general-consent): adjust general consent list and form component

This commit is contained in:
Abizrh
2025-11-20 00:13:44 +07:00
parent cf4f5574d3
commit 0d821cbe31
3 changed files with 71 additions and 19 deletions
+30 -5
View File
@@ -18,12 +18,41 @@ export const config: Config = {
{ label: '' },
],
],
keys: ['date', 'dstUnit.name', 'dstDoctor.name', 'responsible', 'problem', 'solution', 'action'],
keys: ['date', 'relatives', 'responsible', 'informant', 'witness1', 'witness2', 'action'],
delKeyNames: [
{ key: 'data', label: 'Tanggal' },
{ key: 'dstDoctor.name', label: 'Dokter' },
],
parses: {
date(rec) {
const recX = rec as GeneralConsent
return recX?.createdAt?.substring(0, 10) || '-'
},
relatives(rec) {
const recX = rec as GeneralConsent
const parsed = JSON.parse(recX?.value || '{}')
return parsed?.relatives?.join(', ') || '-'
},
responsible(rec) {
const recX = rec as GeneralConsent
const parsed = JSON.parse(recX?.value || '{}')
return parsed?.responsible || '-'
},
informant(rec) {
const recX = rec as GeneralConsent
const parsed = JSON.parse(recX?.value || '{}')
return parsed?.informant || '-'
},
witness1(rec) {
const recX = rec as GeneralConsent
const parsed = JSON.parse(recX?.value || '{}')
return parsed?.witness1 || '-'
},
witness2(rec) {
const recX = rec as GeneralConsent
const parsed = JSON.parse(recX?.value || '{}')
return parsed?.witness2 || '-'
},
action(rec, idx) {
const res: RecComponent = {
idx,
@@ -35,10 +64,6 @@ export const config: Config = {
}
return res
},
date(rec) {
const recX = rec as GeneralConsent
return recX.date?.substring(0, 10) || '-'
},
},
components: {
action(rec, idx) {
@@ -8,6 +8,8 @@ import { GeneralConsentSchema } from '~/schemas/general-consent.schema'
import { toast } from '~/components/pub/ui/toast'
import { handleActionSave, handleActionEdit } from '~/handlers/general-consent.handler'
import { create } from '~/services/generate-file.service'
// Services
import { getDetail } from '~/services/general-consent.service'
const { backToList } = useQueryMode('mode')
const route = useRoute()
@@ -57,10 +59,26 @@ async function getProcedures() {
}
onMounted(() => {
getProcedures()
getDiagnoses()
const mode = route.query.mode
const recordId = route.query['record-id']
if (mode === 'entry' && recordId) {
loadEntryForEdit(+recordId)
}
})
// TODO: mapping data detail when edit
const loadEntryForEdit = async (id: number) => {
const result = await getDetail(id)
if (result?.success) {
const data = result.body?.data || {}
console.log('Mapping data:', data)
// Set state utk form
}
}
function handleClick(type: string) {
if (type === 'prosedur') {
isOpenProcedure.value = true
+21 -12
View File
@@ -28,7 +28,7 @@ import {
handleActionEdit,
handleActionRemove,
handleCancelForm,
} from '~/handlers/consultation.handler'
} from '~/handlers/general-consent.handler'
// Services
import { getList, getDetail } from '~/services/general-consent.service'
@@ -42,8 +42,9 @@ interface Props {
}
const props = defineProps<Props>()
const emits = defineEmits(['add', 'edit'])
const router = useRouter()
const route = useRoute()
const { recordId } = useQueryCRUDRecordId()
const { goToEntry, backToList } = useQueryCRUDMode('mode')
let units = ref<{ value: string; label: string }[]>([])
@@ -93,6 +94,17 @@ const headerPrep: HeaderPrep = {
},
}
const goEdit = (id: string) => {
router.replace({
path: route.path,
query: {
...route.query,
mode: 'entry',
'record-id': id,
},
})
}
const today = new Date()
provide('rec_id', recId)
@@ -110,16 +122,13 @@ const getMyDetail = async (id: number | string) => {
}
// Watch for row actions when recId or recAction changes
watch([recId, recAction], () => {
switch (recAction.value) {
case ActionEvents.showDetail:
getMyDetail(recId.value)
title.value = 'Detail Konsultasi'
isReadonly.value = true
break
case ActionEvents.showConfirmDelete:
isRecordConfirmationOpen.value = true
break
watch(recId, () => {
console.log('recId', recId.value)
if (recAction.value === ActionEvents.showEdit) {
goEdit(recId.value)
return
} else {
isRecordConfirmationOpen.value = true
}
})