From be1b86141f6755dabb505714725de738966827dd Mon Sep 17 00:00:00 2001 From: Khafid Prayoga Date: Mon, 1 Dec 2025 19:50:43 +0700 Subject: [PATCH] impl: form entry with source of add,edit feat(treatment-report): add history list component and dialog integration - Create new list-history.vue component for displaying treatment report history - Add configuration file for history list data table - Integrate history list into main treatment report view with dialog - Replace simple filter button with action buttons including history view feat(treatment-report): implement crud navigation and form actions - Add new entry component for treatment report with list and form views - Implement back navigation using useQueryCRUDMode - Replace form submit button with action footer component - Update dropdown action component for detail view refactor(treatment-report): restructure form components and update mode handling - Rename 'add.vue' to 'form.vue' for better clarity - Update form mode types from 'create|update|view' to 'add|edit|view' - Implement proper reactive state handling for form modes - Add new form component with loading states and mock data - Enhance list component with action handlers and navigation fix default calculated hours --- .../app/treatment-report/entry-form.vue | 35 ++-- .../app/treatment-report/list-history.cfg.ts | 88 ++++++++++ .../app/treatment-report/list-history.vue | 39 +++++ app/components/content/encounter/process.vue | 2 +- .../content/treatment-report/edit.vue | 7 +- .../content/treatment-report/entry.vue | 31 ++++ .../treatment-report/{add.vue => form.vue} | 40 +++++ .../content/treatment-report/list.vue | 151 +++++++++++++++++- .../pub/my-ui/data/dropdown-action-d.vue | 66 ++++++++ app/components/pub/my-ui/nav-footer/index.ts | 1 + 10 files changed, 442 insertions(+), 18 deletions(-) create mode 100644 app/components/app/treatment-report/list-history.cfg.ts create mode 100644 app/components/app/treatment-report/list-history.vue create mode 100644 app/components/content/treatment-report/entry.vue rename app/components/content/treatment-report/{add.vue => form.vue} (52%) create mode 100644 app/components/pub/my-ui/data/dropdown-action-d.vue create mode 100644 app/components/pub/my-ui/nav-footer/index.ts diff --git a/app/components/app/treatment-report/entry-form.vue b/app/components/app/treatment-report/entry-form.vue index 98eafbad..52dfba14 100644 --- a/app/components/app/treatment-report/entry-form.vue +++ b/app/components/app/treatment-report/entry-form.vue @@ -8,11 +8,13 @@ import { type TreatmentReportFormData, TreatmentReportSchema } from '~/schemas/t // type import type { Doctor } from '~/models/doctor' +import { type ClickType as ActionClickType } from '~/components/pub/my-ui/nav-footer/index' // components import * as DE from '~/components/pub/my-ui/doc-entry' import Separator from '~/components/pub/ui/separator/Separator.vue' import { ArrayMessage } from '~/components/pub/ui/form' +import ActionForm from '~/components/pub/my-ui/nav-footer/ba-dr-su.vue' // form field components import { @@ -39,7 +41,7 @@ interface FormData extends TreatmentReportFormData { interface Props { isLoading: boolean - mode?: 'create' | 'update' | 'view' + mode: 'add' | 'edit' | 'view' initialValues?: Partial // form related @@ -49,17 +51,20 @@ interface Props { const props = defineProps() const emit = defineEmits<{ (e: 'submit', payload: FormData): void + (e: 'back'): void (e: 'error', errors: Error): void }>() const tissueNotesLimit = 5 -const { isLoading, mode = 'create' } = props +const mode = toRef(props, 'mode') +const isLoading = toRef(props, 'isLoading') + const isReadonly = computed(() => { - if (isLoading) { + if (isLoading.value === true) { return true } - if (mode === 'view') { + if (mode.value === 'view') { return true } @@ -93,7 +98,17 @@ defineExpose({ // #endregion region // #region Utilities & event handlers -// const onSubmit = handleSubmit((formValues: FormData) => emit('submit', formValues)) +const onFormActionClicked = (action: ActionClickType) => { + if (action === 'back') { + emit('back') + return + } + if (action === 'submit') { + onSubmit() + return + } +} + const onSubmit = handleSubmit( (values) => { console.log(JSON.stringify(values)) @@ -126,6 +141,7 @@ watch( setFieldValue('_operationDuration', formatTime(res)) }, + { immediate: true } ) watch( @@ -147,6 +163,7 @@ watch( setFieldValue('_anesthesiaDuration', formatTime(res)) }, + { immediate: true } ) // #endregion @@ -445,13 +462,7 @@ watch( />
- +
diff --git a/app/components/app/treatment-report/list-history.cfg.ts b/app/components/app/treatment-report/list-history.cfg.ts new file mode 100644 index 00000000..25f2acc3 --- /dev/null +++ b/app/components/app/treatment-report/list-history.cfg.ts @@ -0,0 +1,88 @@ +import { defineAsyncComponent } from 'vue' + +import { format } from 'date-fns' +import { id } from 'date-fns/locale' + +import type { Config, RecComponent } from '~/components/pub/my-ui/data-table' +import type { TreatmentReportData } from '~/components/app/treatment-report/sample' +const action = defineAsyncComponent(() => import('~/components/pub/my-ui/data/dropdown-action-d.vue')) + +export const config: Config = { + cols: [ + { width: 120 }, + { width: 120 }, + { width: 120 }, + { width: 120 }, + { width: 120 }, + { width: 120 }, + { width: 120 }, + { width: 50 }, + ], + + headers: [ + [ + { label: 'TANGGAL LAPORAN' }, + { label: 'DPJP' }, + { label: 'OPERATOR' }, + { label: 'TANGGAL PEMBEDAHAN' }, + { label: 'JENIS OPERASI' }, + { label: 'KODE BILLING' }, + { label: 'SISTEM OPERASI' }, + { label: 'AKSI' }, + ], + ], + + keys: ['reportAt', 'dpjp', 'operator', 'operationAt', 'operationType', 'billing', 'system', 'action'], + + delKeyNames: [ + { key: 'code', label: 'Kode' }, + { key: 'name', label: 'Nama' }, + ], + + parses: { + reportAt: (rec: unknown): unknown => { + const attr = (rec as TreatmentReportData).reportAt + const result = format(new Date(attr), 'd MMMM yyyy, HH:mm', { locale: id }) + + return result + }, + operationAt: (rec: unknown): unknown => { + const attr = (rec as TreatmentReportData).operationAt + const result = format(new Date(attr), 'd MMMM yyyy', { locale: id }) + + return result + }, + system: (rec: unknown): unknown => { + return 'Cito' + }, + operator: (rec: unknown): unknown => { + return 'dr. Dewi Arum Sawitri, Sp.An' + }, + billing: (rec: unknown): unknown => { + return 'General' + }, + operationType: (rec: unknown): unknown => { + return 'Besar' + }, + dpjp: (rec: unknown): unknown => { + return 'dr. Irwansyah Kurniawan Sp.Bo' + }, + parent: (rec: unknown): unknown => { + const recX = rec as any + return recX.parent?.name || '-' + }, + }, + + components: { + action(rec, idx) { + const res: RecComponent = { + idx, + rec: rec as object, + component: action, + } + return res + }, + }, + + htmls: {}, +} diff --git a/app/components/app/treatment-report/list-history.vue b/app/components/app/treatment-report/list-history.vue new file mode 100644 index 00000000..6ad7dd81 --- /dev/null +++ b/app/components/app/treatment-report/list-history.vue @@ -0,0 +1,39 @@ + + + diff --git a/app/components/content/encounter/process.vue b/app/components/content/encounter/process.vue index 43b0f55b..4efa840b 100644 --- a/app/components/content/encounter/process.vue +++ b/app/components/content/encounter/process.vue @@ -22,7 +22,7 @@ import CpLabOrder from '~/components/content/cp-lab-order/main.vue' import Radiology from '~/components/content/radiology-order/main.vue' import Consultation from '~/components/content/consultation/list.vue' import Cprj from '~/components/content/cprj/entry.vue' -import TreatmentReport from '~/components/content/treatment-report/list.vue' +import TreatmentReport from '~/components/content/treatment-report/entry.vue' import DocUploadList from '~/components/content/document-upload/list.vue' import GeneralConsentList from '~/components/content/general-consent/entry.vue' import ResumeList from '~/components/content/resume/list.vue' diff --git a/app/components/content/treatment-report/edit.vue b/app/components/content/treatment-report/edit.vue index fe6d5200..e35325fe 100644 --- a/app/components/content/treatment-report/edit.vue +++ b/app/components/content/treatment-report/edit.vue @@ -15,8 +15,9 @@ interface Props { } const props = defineProps() -const detail = ref(null) +const { backToList } = useQueryCRUDMode('mode') +const detail = ref({} as unknown as TreatmentReportFormData) const doctors = ref([]) // TODO: dummy data @@ -36,7 +37,9 @@ onMounted(() => {