107 lines
2.9 KiB
Vue
107 lines
2.9 KiB
Vue
<script lang="ts" setup>
|
|
//
|
|
import { LucideCheck } from 'lucide-vue-next';
|
|
import { useForm } from 'vee-validate'
|
|
import { toTypedSchema } from '@vee-validate/zod'
|
|
|
|
// Components
|
|
import type z from 'zod'
|
|
import ComboBox from '~/components/pub/my-ui/combobox/combobox.vue'
|
|
import * as DE from '~/components/pub/my-ui/doc-entry'
|
|
import type { CheckInFormData } from '~/schemas/encounter.schema'
|
|
import type { Encounter } from '~/models/encounter'
|
|
|
|
interface Props {
|
|
schema: z.ZodSchema<any>
|
|
values: any
|
|
doctors: { value: string; label: string }[]
|
|
employees: { value: string; label: string }[]
|
|
encounter: Encounter
|
|
isLoading?: boolean
|
|
isReadonly?: boolean
|
|
}
|
|
const props = defineProps<Props>()
|
|
|
|
const emit = defineEmits<{
|
|
submit: [values: CheckInFormData]
|
|
cancel: [resetForm: () => void]
|
|
}>()
|
|
|
|
const { defineField, errors, meta } = useForm({
|
|
validationSchema: toTypedSchema(props.schema),
|
|
initialValues: {
|
|
responsible_doctor_id: 0,
|
|
adm_employee_id: 0,
|
|
registeredAt: props.values.values?.registeredAt || '',
|
|
} as Partial<CheckInFormData>,
|
|
})
|
|
|
|
const [responsible_doctor_id, responsible_doctor_idAttrs] = defineField('responsible_doctor_id')
|
|
const [adm_employee_id, adm_employee_idAttrs] = defineField('discharge_method_code')
|
|
const [registeredAt, registeredAtAttrs] = defineField('registeredAt')
|
|
|
|
function submitForm() {
|
|
const formData: CheckInFormData = {
|
|
responsible_doctor_id: responsible_doctor_id.value,
|
|
adm_employee_id: adm_employee_id.value,
|
|
// registeredAt: registeredAt.value || '',
|
|
}
|
|
emit('submit', formData)
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<DE.Block :cell-flex="false">
|
|
<DE.Cell>
|
|
<DE.Label>Dokter</DE.Label>
|
|
<DE.Field>
|
|
<ComboBox
|
|
id="doctor"
|
|
v-model="responsible_doctor_id"
|
|
v-bind="responsible_doctor_idAttrs"
|
|
:items="doctors"
|
|
:disabled="isLoading || isReadonly"
|
|
placeholder="Pilih Dokter DPJP"
|
|
search-placeholder="Pilih DPJP"
|
|
empty-message="DPJP tidak ditemukan"
|
|
/>
|
|
</DE.Field>
|
|
</DE.Cell>
|
|
<DE.Cell>
|
|
<DE.Label>PJ Berkas</DE.Label>
|
|
<DE.Field>
|
|
<ComboBox
|
|
id="doctor"
|
|
v-model="adm_employee_id"
|
|
v-bind="adm_employee_idAttrs"
|
|
:items="employees"
|
|
:disabled="isLoading || isReadonly"
|
|
placeholder="Pilih Dokter DPJP"
|
|
search-placeholder="Pilih petugas"
|
|
empty-message="Petugas tidak ditemukan"
|
|
/>
|
|
</DE.Field>
|
|
</DE.Cell>
|
|
<DE.Cell>
|
|
<DE.Label>Waktu Masuk</DE.Label>
|
|
<DE.Field>
|
|
<Input
|
|
id="name"
|
|
v-model="registeredAt"
|
|
v-bind="registeredAtAttrs"
|
|
:disabled="isLoading || isReadonly"
|
|
/>
|
|
</DE.Field>
|
|
</DE.Cell>
|
|
</DE.Block>
|
|
<div class="text-center">
|
|
<Button @click="submitForm">
|
|
<LucideCheck />
|
|
Simpan
|
|
</Button>
|
|
</div>
|
|
</template>
|
|
|
|
<style>
|
|
|
|
</style> |