dev: hotfix, consultation
This commit is contained in:
@@ -35,24 +35,24 @@ const { defineField, errors, meta } = useForm({
|
||||
initialValues: {
|
||||
date: props.values.date || today.toISOString().slice(0, 10),
|
||||
problem: '',
|
||||
dstUnit_id: 0,
|
||||
} as Partial<ConsultationFormData>,
|
||||
dstUnit_code: '',
|
||||
} as ConsultationFormData,
|
||||
})
|
||||
|
||||
const [date, dateAttrs] = defineField('date')
|
||||
const [unit_id, unitAttrs] = defineField('unit_id')
|
||||
const [unit_code, unitAttrs] = defineField('unit_code')
|
||||
const [problem, problemAttrs] = defineField('problem')
|
||||
|
||||
// Fill fields from props.values if provided
|
||||
if (props.values) {
|
||||
if (props.values.date !== undefined) date.value = props.values.date.substring(0, 10)
|
||||
if (props.values.dstUnit_id !== undefined) unit_id.value = props.values.dstUnit_id
|
||||
if (props.values.dstUnit_code !== undefined) unit_code.value = props.values.dstUnit_code
|
||||
if (props.values.problem !== undefined) problem.value = props.values.problem
|
||||
}
|
||||
|
||||
const resetForm = () => {
|
||||
date.value = date.value ?? today.toISOString().slice(0, 10)
|
||||
unit_id.value = 0
|
||||
unit_code.value = 0
|
||||
problem.value = ''
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ function onSubmitForm(values: any) {
|
||||
encounter_id: props.encounter_id,
|
||||
date: date.value ? `${date.value}T00:00:00Z` : '',
|
||||
problem: problem.value || '',
|
||||
dstUnit_id: unit_id.value || 0,
|
||||
dstUnit_code: unit_code.value || '',
|
||||
}
|
||||
emit('submit', formData, resetForm)
|
||||
}
|
||||
@@ -89,18 +89,18 @@ function onCancelForm() {
|
||||
</DE.Cell>
|
||||
<DE.Cell>
|
||||
<DE.Label>Unit</DE.Label>
|
||||
<DE.Field :errMessage="errors.unit_id">
|
||||
{{ errors.unit_id }}
|
||||
<DE.Field :errMessage="errors.unit_code">
|
||||
{{ errors.unit_code }}
|
||||
<Select
|
||||
id="strUnit_id"
|
||||
v-model.number="unit_id"
|
||||
id="strUnit_code"
|
||||
v-model="unit_code"
|
||||
icon-name="i-lucide-chevron-down"
|
||||
placeholder="Pilih poliklinik tujuan"
|
||||
v-bind="unitAttrs"
|
||||
:items="props.units || []"
|
||||
:disabled="isLoading || isReadonly"
|
||||
/>
|
||||
<!-- <Input type="number" id="unit_id" v-model.number="unit_id" v-bind="unitAttrs" :disabled="isLoading || isReadonly" /> -->
|
||||
<!-- <Input type="number" id="unit_code" v-model.number="unit_code" v-bind="unitAttrs" :disabled="isLoading || isReadonly" /> -->
|
||||
</DE.Field>
|
||||
</DE.Cell>
|
||||
<DE.Cell :colSpan="3">
|
||||
|
||||
@@ -43,7 +43,7 @@ interface Props {
|
||||
}
|
||||
const props = defineProps<Props>()
|
||||
|
||||
let units = ref<{ value: string; label: string }[]>([])
|
||||
const units = ref<{ value: string; label: string }[]>([])
|
||||
const encounterId = ref<number>(props?.encounter?.id || 0)
|
||||
const title = ref('')
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ export interface Consultation {
|
||||
id: number
|
||||
encounter_id: number
|
||||
date?: string
|
||||
unit_id: number
|
||||
doctor_id?: number
|
||||
unit_code: number
|
||||
doctor_code?: number
|
||||
problem: string
|
||||
solution?: string
|
||||
repliedAt?: string
|
||||
@@ -13,13 +13,13 @@ export interface CreateDto {
|
||||
encounter_id: number
|
||||
date: string
|
||||
problem: string
|
||||
dstUnit_id: number
|
||||
dstUnit_code: string
|
||||
}
|
||||
|
||||
export interface UpdateDto {
|
||||
id: number
|
||||
problem: string
|
||||
unit_id: number
|
||||
unit_code: number
|
||||
}
|
||||
|
||||
export interface DeleteDto {
|
||||
@@ -31,7 +31,7 @@ export function genCreateDto(): CreateDto {
|
||||
date: '',
|
||||
encounter_id: 0,
|
||||
problem: '',
|
||||
dstUnit_id: 0,
|
||||
dstUnit_code: '',
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,8 +39,8 @@ export function genConsultation(): Consultation {
|
||||
return {
|
||||
id: 0,
|
||||
encounter_id: 0,
|
||||
unit_id: 0,
|
||||
doctor_id: 0,
|
||||
unit_code: 0,
|
||||
doctor_code: 0,
|
||||
problem: '',
|
||||
solution: '',
|
||||
repliedAt: '',
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { CreateDto } from '~/models/consultation'
|
||||
|
||||
const ConsultationSchema = z.object({
|
||||
date: z.string({ required_error: 'Tanggal harus diisi' }),
|
||||
dstUnit_id: z.number({ required_error: 'Unit harus diisi' }),
|
||||
dstUnit_code: z.string({ required_error: 'Unit harus diisi' }),
|
||||
problem: z.string({ required_error: 'Uraian harus diisi' }).min(20, 'Uraian minimum 20 karakter'),
|
||||
})
|
||||
|
||||
|
||||
@@ -27,17 +27,14 @@ export function remove(id: number | string) {
|
||||
return base.remove(path, id, name)
|
||||
}
|
||||
|
||||
export async function getValueLabelList(params: any = null, useCodeAsValue = false): Promise<{ value: string; label: string }[]> {
|
||||
export async function getValueLabelList(params: any = null, useId = false): Promise<{ value: string; label: string }[]> {
|
||||
let data: { value: string; label: string }[] = []
|
||||
const result = await getList(params)
|
||||
if (result.success) {
|
||||
const resultData = result.body?.data || []
|
||||
data = resultData.map((item: Unit) => ({
|
||||
value: useCodeAsValue ? item.code
|
||||
: item.id ? Number(item.id)
|
||||
: item.code,
|
||||
label: item.name,
|
||||
}))
|
||||
data = !useId ?
|
||||
resultData.map((item: Unit) => ({ value: item.code, label: item.name })) :
|
||||
resultData.map((item: Unit) => ({ value: item.id, label: item.name }))
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user