From ffa4a7d19191377de6a9ca522419e17c47fd149a Mon Sep 17 00:00:00 2001 From: riefive Date: Thu, 4 Sep 2025 16:21:10 +0700 Subject: [PATCH] refactor(material): modify validation uom and item --- app/components/app/material/entry-form.vue | 30 ++++++++++--------- app/components/flow/material/entry.vue | 23 ++++++++++---- app/components/pub/ui/select/Select.vue | 3 +- .../pub/ui/select/SelectTrigger.vue | 6 ++-- app/schemas/material.ts | 6 ++-- 5 files changed, 41 insertions(+), 27 deletions(-) diff --git a/app/components/app/material/entry-form.vue b/app/components/app/material/entry-form.vue index 65dd134b..d670f60c 100644 --- a/app/components/app/material/entry-form.vue +++ b/app/components/app/material/entry-form.vue @@ -11,6 +11,7 @@ import Label from '~/components/pub/custom-ui/form/label.vue' interface Props { isLoading: boolean schema: z.ZodSchema + uoms: any[] items: any[] } @@ -20,11 +21,13 @@ const emit = defineEmits<{ submit: [data: any] }>() -const { handleSubmit, defineField, errors, meta } = useForm({ +const { handleSubmit, defineField, errors } = useForm({ validationSchema: toTypedSchema(props.schema), initialValues: { code: '', name: '', + uom_code: '', + item_id: '', stock: 0, } as Partial, }) @@ -36,7 +39,6 @@ const [item, itemAttrs] = defineField('item_id') const [stock, stockAttrs] = defineField('stock') const onSubmit = handleSubmit(async (values) => { - console.log(errors) try { emit('submit', values) } catch (error) { @@ -77,30 +79,32 @@ const onSubmit = handleSubmit(async (values) => { - - {{ errors.uom }} + + {{ errors.item_id }}
@@ -117,10 +121,8 @@ const onSubmit = handleSubmit(async (values) => { {{ errors.stock }}
-
- +
+
- + diff --git a/app/components/pub/ui/select/Select.vue b/app/components/pub/ui/select/Select.vue index 3020ed97..dfde6ef8 100644 --- a/app/components/pub/ui/select/Select.vue +++ b/app/components/pub/ui/select/Select.vue @@ -19,6 +19,7 @@ interface Item { const props = defineProps< SelectRootProps & { items: Item[] + iconName?: string placeholder?: string label?: string separator?: boolean @@ -31,7 +32,7 @@ const forwarded = useForwardPropsEmits(props, emits)