diff --git a/app/components/app/specialist-position/entry-form.vue b/app/components/app/specialist-position/entry-form.vue index da4782c0..be031219 100644 --- a/app/components/app/specialist-position/entry-form.vue +++ b/app/components/app/specialist-position/entry-form.vue @@ -7,18 +7,18 @@ import Label from '~/components/pub/my-ui/doc-entry/label.vue' import Combobox from '~/components/pub/my-ui/combobox/combobox.vue' // Types -import type { DivisionPositionFormData } from '~/schemas/division-position.schema' +import type { SpecialistPositionFormData } from '~/schemas/specialist-position.schema' // Helpers import type z from 'zod' import { toTypedSchema } from '@vee-validate/zod' import { useForm } from 'vee-validate' import { genBase } from '~/models/_base' -import { genDivisionPosition } from '~/models/division-position' +import { genSpecialistPosition } from '~/models/specialist-position' interface Props { schema: z.ZodSchema - divisionId: number + specialists: any[] employees: any[] values: any isLoading?: boolean @@ -26,21 +26,21 @@ interface Props { } const props = defineProps() - const isLoading = props.isLoading !== undefined ? props.isLoading : false const isReadonly = props.isReadonly !== undefined ? props.isReadonly : false const emit = defineEmits<{ - submit: [values: DivisionPositionFormData, resetForm: () => void] + submit: [values: SpecialistPositionFormData, resetForm: () => void] cancel: [resetForm: () => void] }>() const { defineField, errors, meta } = useForm({ validationSchema: toTypedSchema(props.schema), - initialValues: genDivisionPosition() as Partial, + initialValues: genSpecialistPosition() as Partial, }) const [code, codeAttrs] = defineField('code') const [name, nameAttrs] = defineField('name') +const [specialist, specialistAttrs] = defineField('specialist_id') const [employee, employeeAttrs] = defineField('employee_id') const [headStatus, headStatusAttrs] = defineField('headStatus') @@ -62,6 +62,8 @@ const headStatusStr = computed({ if (props.values) { if (props.values.code !== undefined) code.value = props.values.code if (props.values.name !== undefined) name.value = props.values.name + if (props.values.specialist_id !== undefined) + specialist.value = props.values.specialist_id ? Number(props.values.specialist_id) : null if (props.values.employee_id !== undefined) employee.value = props.values.employee_id ? Number(props.values.employee_id) : null if (props.values.headStatus !== undefined) headStatus.value = !!props.values.headStatus @@ -70,20 +72,18 @@ if (props.values) { const resetForm = () => { code.value = '' name.value = '' + specialist.value = null employee.value = null headStatus.value = false } // Form submission handler function onSubmitForm() { - const formData: DivisionPositionFormData = { + const formData: SpecialistPositionFormData = { ...genBase(), name: name.value || '', code: code.value || '', - - // readonly based on detail division - division_id: props.divisionId, - + specialist_id: specialist.value || null, employee_id: employee.value || null, headStatus: headStatus.value !== undefined ? headStatus.value : undefined, } @@ -98,7 +98,7 @@ function onCancelForm() {