⚙️ chore (general-consent): adjust general consent list and form component
This commit is contained in:
No files matched your search
@@ -18,12 +18,41 @@ export const config: Config = {
|
|||||||
{ label: '' },
|
{ label: '' },
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
keys: ['date', 'dstUnit.name', 'dstDoctor.name', 'responsible', 'problem', 'solution', 'action'],
|
keys: ['date', 'relatives', 'responsible', 'informant', 'witness1', 'witness2', 'action'],
|
||||||
delKeyNames: [
|
delKeyNames: [
|
||||||
{ key: 'data', label: 'Tanggal' },
|
{ key: 'data', label: 'Tanggal' },
|
||||||
{ key: 'dstDoctor.name', label: 'Dokter' },
|
{ key: 'dstDoctor.name', label: 'Dokter' },
|
||||||
],
|
],
|
||||||
parses: {
|
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) {
|
action(rec, idx) {
|
||||||
const res: RecComponent = {
|
const res: RecComponent = {
|
||||||
idx,
|
idx,
|
||||||
@@ -35,10 +64,6 @@ export const config: Config = {
|
|||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
},
|
},
|
||||||
date(rec) {
|
|
||||||
const recX = rec as GeneralConsent
|
|
||||||
return recX.date?.substring(0, 10) || '-'
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
action(rec, idx) {
|
action(rec, idx) {
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import { GeneralConsentSchema } from '~/schemas/general-consent.schema'
|
|||||||
import { toast } from '~/components/pub/ui/toast'
|
import { toast } from '~/components/pub/ui/toast'
|
||||||
import { handleActionSave, handleActionEdit } from '~/handlers/general-consent.handler'
|
import { handleActionSave, handleActionEdit } from '~/handlers/general-consent.handler'
|
||||||
import { create } from '~/services/generate-file.service'
|
import { create } from '~/services/generate-file.service'
|
||||||
|
// Services
|
||||||
|
import { getDetail } from '~/services/general-consent.service'
|
||||||
const { backToList } = useQueryMode('mode')
|
const { backToList } = useQueryMode('mode')
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
@@ -57,10 +59,26 @@ async function getProcedures() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getProcedures()
|
const mode = route.query.mode
|
||||||
getDiagnoses()
|
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) {
|
function handleClick(type: string) {
|
||||||
if (type === 'prosedur') {
|
if (type === 'prosedur') {
|
||||||
isOpenProcedure.value = true
|
isOpenProcedure.value = true
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import {
|
|||||||
handleActionEdit,
|
handleActionEdit,
|
||||||
handleActionRemove,
|
handleActionRemove,
|
||||||
handleCancelForm,
|
handleCancelForm,
|
||||||
} from '~/handlers/consultation.handler'
|
} from '~/handlers/general-consent.handler'
|
||||||
|
|
||||||
// Services
|
// Services
|
||||||
import { getList, getDetail } from '~/services/general-consent.service'
|
import { getList, getDetail } from '~/services/general-consent.service'
|
||||||
@@ -42,8 +42,9 @@ interface Props {
|
|||||||
}
|
}
|
||||||
const props = defineProps<Props>()
|
const props = defineProps<Props>()
|
||||||
const emits = defineEmits(['add', 'edit'])
|
const emits = defineEmits(['add', 'edit'])
|
||||||
|
const router = useRouter()
|
||||||
|
const route = useRoute()
|
||||||
|
|
||||||
const { recordId } = useQueryCRUDRecordId()
|
|
||||||
const { goToEntry, backToList } = useQueryCRUDMode('mode')
|
const { goToEntry, backToList } = useQueryCRUDMode('mode')
|
||||||
|
|
||||||
let units = ref<{ value: string; label: string }[]>([])
|
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()
|
const today = new Date()
|
||||||
|
|
||||||
provide('rec_id', recId)
|
provide('rec_id', recId)
|
||||||
@@ -110,16 +122,13 @@ const getMyDetail = async (id: number | string) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Watch for row actions when recId or recAction changes
|
// Watch for row actions when recId or recAction changes
|
||||||
watch([recId, recAction], () => {
|
watch(recId, () => {
|
||||||
switch (recAction.value) {
|
console.log('recId', recId.value)
|
||||||
case ActionEvents.showDetail:
|
if (recAction.value === ActionEvents.showEdit) {
|
||||||
getMyDetail(recId.value)
|
goEdit(recId.value)
|
||||||
title.value = 'Detail Konsultasi'
|
return
|
||||||
isReadonly.value = true
|
} else {
|
||||||
break
|
isRecordConfirmationOpen.value = true
|
||||||
case ActionEvents.showConfirmDelete:
|
|
||||||
isRecordConfirmationOpen.value = true
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user