fix: change integrate material

This commit is contained in:
riefive
2025-09-24 16:37:03 +07:00
parent fcabbc25ff
commit 93a5abba36
4 changed files with 52 additions and 38 deletions
+10 -1
View File
@@ -14,6 +14,7 @@ import Label from '~/components/pub/custom-ui/doc-entry/label.vue'
interface Props {
schema: z.ZodSchema<any>
uoms: any[]
values: any
}
const isLoading = ref(false)
@@ -23,7 +24,7 @@ const emit = defineEmits<{
cancel: [resetForm: () => void]
}>()
const { handleSubmit, defineField, errors, meta } = useForm({
const { defineField, errors, meta } = useForm({
validationSchema: toTypedSchema(props.schema),
initialValues: {
code: '',
@@ -38,6 +39,14 @@ const [name, nameAttrs] = defineField('name')
const [uom, uomAttrs] = defineField('uom_code')
const [stock, stockAttrs] = defineField('stock')
// Fill fields from props.values if provided
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.uom_code !== undefined) uom.value = props.values.uom_code
if (props.values.stock !== undefined) stock.value = props.values.stock
}
const resetForm = () => {
code.value = ''
name.value = ''