From f3b45f2cb1dc17170354fc4517f2de822aa5a034 Mon Sep 17 00:00:00 2001 From: Munawwirul Jamal Date: Mon, 20 Oct 2025 09:34:42 +0700 Subject: [PATCH] feat/consulation-82: done --- app/components/app/consultation/entry.vue | 20 ++++---- app/components/app/consultation/list.cfg.ts | 54 ++++++++++++++++++++ app/components/app/consultation/list.ts | 40 --------------- app/components/app/consultation/list.vue | 13 ++--- app/components/content/consultation/list.vue | 8 ++- app/components/content/encounter/process.vue | 2 +- app/models/consultation.ts | 2 +- app/schemas/consultation.schema.ts | 6 +-- 8 files changed, 79 insertions(+), 66 deletions(-) create mode 100644 app/components/app/consultation/list.cfg.ts delete mode 100644 app/components/app/consultation/list.ts diff --git a/app/components/app/consultation/entry.vue b/app/components/app/consultation/entry.vue index db93e1e2..a8378b0c 100644 --- a/app/components/app/consultation/entry.vue +++ b/app/components/app/consultation/entry.vue @@ -10,10 +10,12 @@ import type z from 'zod' import { toTypedSchema } from '@vee-validate/zod' import { useForm } from 'vee-validate' import Textarea from '~/components/pub/ui/textarea/Textarea.vue' +import type { CreateDto } from '~/models/consultation' interface Props { schema: z.ZodSchema - values: any + values: CreateDto + encounter_id: number units: { value: string; label: string }[] isLoading?: boolean isReadonly?: boolean @@ -31,11 +33,9 @@ const today = new Date() const { defineField, errors, meta } = useForm({ validationSchema: toTypedSchema(props.schema), initialValues: { - id: 0, - encounter_id: 0, date: props.values.date || today.toISOString().slice(0, 10), problem: '', - unit_id: 0, + dstUnit_id: 0, } as Partial, }) @@ -45,8 +45,9 @@ const [problem, problemAttrs] = defineField('problem') // Fill fields from props.values if provided if (props.values) { - if (props.values.unit_id !== undefined) unit_id.value = props.values.unit_id - if (props.values.code !== undefined) problem.value = props.values.problem + 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.problem !== undefined) problem.value = props.values.problem } const resetForm = () => { @@ -58,11 +59,10 @@ const resetForm = () => { // Form submission handler function onSubmitForm(values: any) { const formData: ConsultationFormData = { - id: 0, - encounter_id: 0, - date: date.value || '', + encounter_id: props.encounter_id, + date: date.value ? `${date.value}T00:00:00Z` : '', problem: problem.value || '', - unit_id: unit_id.value || 0, + dstUnit_id: unit_id.value || 0, } emit('submit', formData, resetForm) } diff --git a/app/components/app/consultation/list.cfg.ts b/app/components/app/consultation/list.cfg.ts new file mode 100644 index 00000000..587ec0f8 --- /dev/null +++ b/app/components/app/consultation/list.cfg.ts @@ -0,0 +1,54 @@ +import type { Config, RecComponent, RecStrFuncComponent, RecStrFuncUnknown } from '~/components/pub/my-ui/data-table' +import { defineAsyncComponent } from 'vue' +import type { Consultation } from '~/models/consultation' + +type SmallDetailDto = any + +const action = defineAsyncComponent(() => import('~/components/pub/my-ui/data/dropdown-action-ud.vue')) +export const config: Config = { + cols: [{ width: 100 }, {}, {}, {}, { width: 50 }], + headers: [[ + { label: 'Tanggal' }, + { label: 'Tujuan' }, + { label: 'Dokter' }, + { label: 'Pertanyaan' }, + { label: 'Jawaban' }, + { label: '' }, + ]], + keys: ['date', 'dstUnit.name', 'dstDoctor.name', 'problem', 'solution', 'action'], + delKeyNames: [ + { key: 'data', label: 'Tanggal' }, + { key: 'dstDoctor.name', label: 'Dokter' }, + ], + parses: { + action(rec, idx) { + const res: RecComponent = { + idx, + rec: rec as object, + component: action, + props: { + size: 'sm', + }, + } + return res + }, + date(rec) { + const recX = rec as Consultation + return recX.date?.substring(0, 10) || '-' + } + }, + components: { + action(rec, idx) { + const res: RecComponent = { + idx, + rec: rec as object, + component: action, + props: { + size: 'sm', + }, + } + return res + }, + } as RecStrFuncComponent, + htmls: {} as RecStrFuncUnknown, +} diff --git a/app/components/app/consultation/list.ts b/app/components/app/consultation/list.ts deleted file mode 100644 index 59cebdbb..00000000 --- a/app/components/app/consultation/list.ts +++ /dev/null @@ -1,40 +0,0 @@ -import type { - Col, - KeyLabel, - RecComponent, - RecStrFuncComponent, - RecStrFuncUnknown, - Th, -} from '~/components/pub/my-ui/data/types' -import { defineAsyncComponent } from 'vue' - -type SmallDetailDto = any - -const action = defineAsyncComponent(() => import('~/components/pub/my-ui/data/dropdown-action-ud.vue')) - -export const cols: Col[] = [{ width: 100 }, {}, {}, {}, { width: 50 }] - -export const header: Th[][] = [[{ label: 'Tanggal' }, { label: 'Dokter' }, { label: 'Tujuan' }, { label: 'Pertanyaan' }, { label: 'Jawaban' }, { label: '' }]] - -export const keys = ['date', 'dstDoctor.name', 'dstUnit.name', 'case', 'solution', 'action'] - -export const delKeyNames: KeyLabel[] = [ - { key: 'data', label: 'Tanggal' }, - { key: 'dstDoctor.name', label: 'Dokter' }, -] - -export const funcComponent: RecStrFuncComponent = { - action(rec, idx) { - const res: RecComponent = { - idx, - rec: rec as object, - component: action, - props: { - size: 'sm', - }, - } - return res - }, -} - -export const funcHtml: RecStrFuncUnknown = {} diff --git a/app/components/app/consultation/list.vue b/app/components/app/consultation/list.vue index b68ea6dd..19c6a9f9 100644 --- a/app/components/app/consultation/list.vue +++ b/app/components/app/consultation/list.vue @@ -1,14 +1,13 @@