fix: adjustment list and entry for material

This commit is contained in:
riefive
2025-09-24 15:34:38 +07:00
parent d0b3d28cdd
commit fcabbc25ff
5 changed files with 35 additions and 48 deletions
+18 -29
View File
@@ -5,6 +5,11 @@ import type { MaterialFormData } from '~/schemas/material'
// helpers // helpers
import { useForm } from 'vee-validate' import { useForm } from 'vee-validate'
import { toTypedSchema } from '@vee-validate/zod' 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'
interface Props { interface Props {
schema: z.ZodSchema<any> schema: z.ZodSchema<any>
@@ -18,7 +23,7 @@ const emit = defineEmits<{
cancel: [resetForm: () => void] cancel: [resetForm: () => void]
}>() }>()
const { handleSubmit, defineField, errors } = useForm({ const { handleSubmit, defineField, errors, meta } = useForm({
validationSchema: toTypedSchema(props.schema), validationSchema: toTypedSchema(props.schema),
initialValues: { initialValues: {
code: '', code: '',
@@ -40,12 +45,12 @@ const resetForm = () => {
stock.value = 0 stock.value = 0
} }
function onSubmitForm(values: any) { function onSubmitForm() {
const formData: MaterialFormData = { const formData: MaterialFormData = {
name: values.name || '', name: name.value || '',
code: values.code || '', code: code.value || '',
uom_code: values.uom_code || '', uom_code: uom.value || '',
stock: values.stock || 0, stock: stock.value || 0,
} }
emit('submit', formData, resetForm) emit('submit', formData, resetForm)
} }
@@ -57,27 +62,17 @@ function onCancelForm() {
<template> <template>
<form id="form-equipment"> <form id="form-equipment">
<Block labelSize="thin" class="!mb-2.5 xl:!mb-3 !pt-0" :colCount="1"> <Block labelSize="thin" class="!mb-2.5 !pt-0 xl:!mb-3" :colCount="1">
<Cell> <Cell>
<Label height="compact">Kode</Label> <Label height="">Kode</Label>
<Field :errMessage="errors.code"> <Field :errMessage="errors.code">
<Input <Input id="code" v-model="code" v-bind="codeAttrs" :disabled="isLoading" />
id="code"
v-model="code"
v-bind="codeAttrs"
:disabled="isLoading"
/>
</Field> </Field>
</Cell> </Cell>
<Cell> <Cell>
<Label height="compact">Nama</Label> <Label height="compact">Nama</Label>
<Field :errMessage="errors.name"> <Field :errMessage="errors.name">
<Input <Input id="name" v-model="name" v-bind="nameAttrs" :disabled="isLoading" />
id="name"
v-model="name"
v-bind="nameAttrs"
:disabled="isLoading"
/>
</Field> </Field>
</Cell> </Cell>
<Cell> <Cell>
@@ -97,13 +92,7 @@ function onCancelForm() {
<Cell> <Cell>
<Label height="compact">Stok</Label> <Label height="compact">Stok</Label>
<Field :errMessage="errors.stock"> <Field :errMessage="errors.stock">
<Input <Input id="stock" v-model="stock" type="number" v-bind="stockAttrs" :disabled="isLoading" />
id="stock"
v-model="stock"
type="number"
v-bind="stockAttrs"
:disabled="isLoading"
/>
</Field> </Field>
</Cell> </Cell>
</Block> </Block>
@@ -112,8 +101,8 @@ function onCancelForm() {
<Button <Button
type="button" type="button"
class="w-[120px]" class="w-[120px]"
:disabled="isLoading" :disabled="isLoading || !meta.valid"
@click="handleSubmit(onSubmitForm)" @click="onSubmitForm"
> >
Simpan Simpan
</Button> </Button>
+6 -14
View File
@@ -1,21 +1,17 @@
import type { import type { Col, KeyLabel, RecComponent, RecStrFuncComponent, Th } from '~/components/pub/custom-ui/data/types'
Col,
KeyLabel,
RecComponent,
RecStrFuncComponent,
Th,
} from '~/components/pub/custom-ui/data/types'
import { defineAsyncComponent } from 'vue' import { defineAsyncComponent } from 'vue'
type SmallDetailDto = any type SmallDetailDto = any
const action = defineAsyncComponent(() => import('~/components/pub/custom-ui/data/dropdown-action-dud.vue')) const action = defineAsyncComponent(() => import('~/components/pub/custom-ui/data/dropdown-action-dud.vue'))
export const cols: Col[] = [{ width: 100 }, { width: 250 }, { width: 100 }, { width: 100 }, { width: 100 }, { width: 50 }] export const cols: Col[] = [{ width: 100 }, { width: 250 }, { width: 100 }, { width: 100 }, { width: 50 }]
export const header: Th[][] = [[{ label: 'Kode' }, { label: 'Nama' }, { label: 'Stok' }, { label: 'Item' }, { label: 'Satuan' }]] export const header: Th[][] = [
[{ label: 'Kode' }, { label: 'Nama' }, { label: 'Stok' }, { label: 'Satuan' }, { label: '' }],
]
export const keys = ['code', 'name', 'stock', 'item_id', 'uom_code', 'action'] export const keys = ['code', 'name', 'stock', 'uom_code', 'action']
export const delKeyNames: KeyLabel[] = [ export const delKeyNames: KeyLabel[] = [
{ key: 'code', label: 'Kode' }, { key: 'code', label: 'Kode' },
@@ -27,10 +23,6 @@ export const funcParsed: Record<string, (row: any, ...args: any[]) => any> = {
const recX = rec as SmallDetailDto const recX = rec as SmallDetailDto
return `${recX.name}`.trim() return `${recX.name}`.trim()
}, },
item_id: (rec: unknown): unknown => {
const recX = rec as SmallDetailDto
return recX.item_id
},
uom_code: (rec: unknown): unknown => { uom_code: (rec: unknown): unknown => {
const recX = rec as SmallDetailDto const recX = rec as SmallDetailDto
return recX.uom_code return recX.uom_code
+5
View File
@@ -5,6 +5,11 @@ import { useForm } from 'vee-validate'
// types // types
import type z from 'zod' import type z from 'zod'
import type { DeviceFormData } from '~/schemas/device' import type { DeviceFormData } from '~/schemas/device'
// 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'
interface Props { interface Props {
schema: z.ZodSchema<any> schema: z.ZodSchema<any>
+3 -3
View File
@@ -12,11 +12,11 @@ type SmallDetailDto = any
const action = defineAsyncComponent(() => import('~/components/pub/custom-ui/data/dropdown-action-dud.vue')) const action = defineAsyncComponent(() => import('~/components/pub/custom-ui/data/dropdown-action-dud.vue'))
export const cols: Col[] = [{ width: 100 }, { width: 250 }, { width: 100 }, { width: 100 }, { width: 50 }] export const cols: Col[] = [{ width: 100 }, { width: 250 }, { width: 100 }, { width: 50 }]
export const header: Th[][] = [[{ label: 'Kode' }, { label: 'Nama' }, { label: 'Item' }, { label: 'Satuan' }]] export const header: Th[][] = [[{ label: 'Kode' }, { label: 'Nama' }, { label: 'Satuan' }]]
export const keys = ['code', 'name', 'item_id', 'uom_code', 'action'] export const keys = ['code', 'name', 'uom_code', 'action']
export const delKeyNames: KeyLabel[] = [ export const delKeyNames: KeyLabel[] = [
{ key: 'code', label: 'Kode' }, { key: 'code', label: 'Kode' },
+3 -2
View File
@@ -55,7 +55,7 @@ const {
} = usePaginatedList({ } = usePaginatedList({
fetchFn: async ({ page }) => { fetchFn: async ({ page }) => {
const result = await getSourceMaterials({ page }) const result = await getSourceMaterials({ page })
return result.data || [] return { success: result.success || false, body: { data: result.data || [], meta: result.meta || {} } }
}, },
entityName: 'equipment', entityName: 'equipment',
}) })
@@ -105,7 +105,8 @@ watch(recId, () => {
}) })
onMounted(async () => { onMounted(async () => {
await getUomList(); await getUomList()
await getEquipmentList()
}) })
</script> </script>