feat(medicine-method): refactor + integrate
This commit is contained in:
@@ -6,10 +6,10 @@ import Field from '~/components/pub/custom-ui/doc-entry/field.vue'
|
||||
import Label from '~/components/pub/custom-ui/doc-entry/label.vue'
|
||||
|
||||
// Types
|
||||
import type z from 'zod'
|
||||
import type { MaterialFormData } from '~/schemas/material.schema'
|
||||
|
||||
// Helpers
|
||||
import type z from 'zod'
|
||||
import { useForm } from 'vee-validate'
|
||||
import { toTypedSchema } from '@vee-validate/zod'
|
||||
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import type z from 'zod'
|
||||
import { useForm } from 'vee-validate'
|
||||
import { toTypedSchema } from '@vee-validate/zod'
|
||||
// Components
|
||||
import Block from '~/components/pub/custom-ui/doc-entry/block.vue'
|
||||
import Cell from '~/components/pub/custom-ui/doc-entry/cell.vue'
|
||||
import Field from '~/components/pub/custom-ui/doc-entry/field.vue'
|
||||
import Label from '~/components/pub/custom-ui/doc-entry/label.vue'
|
||||
import Button from '~/components/pub/ui/button/Button.vue'
|
||||
|
||||
// Types
|
||||
import type { MedicineBaseFormData } from '~/schemas/medicine.schema'
|
||||
|
||||
// Helpers
|
||||
import type z from 'zod'
|
||||
import { useForm } from 'vee-validate'
|
||||
import { toTypedSchema } from '@vee-validate/zod'
|
||||
|
||||
interface Props {
|
||||
schema?: z.ZodSchema<any>
|
||||
values?: any
|
||||
@@ -20,7 +26,7 @@ const props = defineProps<Props>()
|
||||
const isLoading = props.isLoading !== undefined ? props.isLoading : false
|
||||
const isReadonly = props.isReadonly !== undefined ? props.isReadonly : false
|
||||
const emit = defineEmits<{
|
||||
submit: [values: any, resetForm: () => void]
|
||||
submit: [values: MedicineBaseFormData, resetForm: () => void]
|
||||
cancel: [resetForm: () => void]
|
||||
}>()
|
||||
|
||||
@@ -64,13 +70,13 @@ function onCancelForm() {
|
||||
<Cell>
|
||||
<Label height="">Kode</Label>
|
||||
<Field :errMessage="errors.code">
|
||||
<input id="code" v-model="code" v-bind="codeAttrs" :disabled="isLoading || isReadonly" class="input input-bordered w-full" />
|
||||
<Input id="code" v-model="code" v-bind="codeAttrs" :disabled="isLoading || isReadonly" />
|
||||
</Field>
|
||||
</Cell>
|
||||
<Cell>
|
||||
<Label height="compact">Nama</Label>
|
||||
<Field :errMessage="errors.name">
|
||||
<input id="name" v-model="name" v-bind="nameAttrs" :disabled="isLoading || isReadonly" class="input input-bordered w-full" />
|
||||
<Input id="name" v-model="name" v-bind="nameAttrs" :disabled="isLoading || isReadonly" />
|
||||
</Field>
|
||||
</Cell>
|
||||
</Block>
|
||||
|
||||
@@ -5,14 +5,14 @@ import Cell from '~/components/pub/custom-ui/doc-entry/cell.vue'
|
||||
import Field from '~/components/pub/custom-ui/doc-entry/field.vue'
|
||||
import Label from '~/components/pub/custom-ui/doc-entry/label.vue'
|
||||
|
||||
// Types
|
||||
import type { DeviceFormData } from '~/schemas/device.schema'
|
||||
|
||||
// Helpers
|
||||
import type z from 'zod'
|
||||
import { toTypedSchema } from '@vee-validate/zod'
|
||||
import { useForm } from 'vee-validate'
|
||||
|
||||
// Types
|
||||
import type z from 'zod'
|
||||
import type { DeviceFormData } from '~/schemas/device.schema'
|
||||
|
||||
interface Props {
|
||||
schema: z.ZodSchema<any>
|
||||
uoms: any[]
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
// Components
|
||||
import Dialog from '~/components/pub/base/modal/dialog.vue'
|
||||
@@ -84,23 +83,23 @@ provide('table_data_loader', isLoading)
|
||||
watch([recId, recAction], () => {
|
||||
switch (recAction.value) {
|
||||
case ActionEvents.showDetail:
|
||||
getMedicineMethodDetail(recId.value).then(result => {
|
||||
getMedicineMethodDetail(recId.value).then((result) => {
|
||||
if (result.success) {
|
||||
recItem.value = result.body?.data || {}
|
||||
isFormEntryDialogOpen.value = true
|
||||
}
|
||||
})
|
||||
title.value = 'Detail Metode Pemberian'
|
||||
title.value = 'Detail Metode Obat'
|
||||
isReadonly.value = true
|
||||
break
|
||||
case ActionEvents.showEdit:
|
||||
getMedicineMethodDetail(recId.value).then(result => {
|
||||
getMedicineMethodDetail(recId.value).then((result) => {
|
||||
if (result.success) {
|
||||
recItem.value = result.body?.data || {}
|
||||
isFormEntryDialogOpen.value = true
|
||||
}
|
||||
})
|
||||
title.value = 'Edit Metode Pemberian'
|
||||
title.value = 'Edit Metode Obat'
|
||||
isReadonly.value = false
|
||||
break
|
||||
case ActionEvents.showConfirmDelete:
|
||||
@@ -123,16 +122,17 @@ onMounted(async () => {
|
||||
|
||||
<Dialog
|
||||
v-model:open="isFormEntryDialogOpen"
|
||||
:title="!!recItem ? title : 'Tambah Metode Pemberian'"
|
||||
:title="!!recItem ? title : 'Tambah Metode Obat'"
|
||||
size="lg"
|
||||
prevent-outside
|
||||
>
|
||||
<AppMedicineMethodEntryForm
|
||||
:model-value="recItem"
|
||||
:schema="MedicineBaseSchema"
|
||||
:values="recItem"
|
||||
:is-loading="isProcessing"
|
||||
:is-readonly="isReadonly"
|
||||
@submit="
|
||||
(values: Record<string, any>, resetForm: () => void) => {
|
||||
(values: MedicineBaseFormData | Record<string, any>, resetForm: () => void) => {
|
||||
if (recId > 0) {
|
||||
handleActionEdit(recId, values, getMedicineMethodList, resetForm, toast)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user