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
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'
interface Props {
schema: z.ZodSchema<any>
@@ -18,7 +23,7 @@ const emit = defineEmits<{
cancel: [resetForm: () => void]
}>()
const { handleSubmit, defineField, errors } = useForm({
const { handleSubmit, defineField, errors, meta } = useForm({
validationSchema: toTypedSchema(props.schema),
initialValues: {
code: '',
@@ -40,12 +45,12 @@ const resetForm = () => {
stock.value = 0
}
function onSubmitForm(values: any) {
function onSubmitForm() {
const formData: MaterialFormData = {
name: values.name || '',
code: values.code || '',
uom_code: values.uom_code || '',
stock: values.stock || 0,
name: name.value || '',
code: code.value || '',
uom_code: uom.value || '',
stock: stock.value || 0,
}
emit('submit', formData, resetForm)
}
@@ -57,27 +62,17 @@ function onCancelForm() {
<template>
<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>
<Label height="compact">Kode</Label>
<Label height="">Kode</Label>
<Field :errMessage="errors.code">
<Input
id="code"
v-model="code"
v-bind="codeAttrs"
:disabled="isLoading"
/>
<Input id="code" v-model="code" v-bind="codeAttrs" :disabled="isLoading" />
</Field>
</Cell>
<Cell>
<Label height="compact">Nama</Label>
<Field :errMessage="errors.name">
<Input
id="name"
v-model="name"
v-bind="nameAttrs"
:disabled="isLoading"
/>
<Input id="name" v-model="name" v-bind="nameAttrs" :disabled="isLoading" />
</Field>
</Cell>
<Cell>
@@ -97,13 +92,7 @@ function onCancelForm() {
<Cell>
<Label height="compact">Stok</Label>
<Field :errMessage="errors.stock">
<Input
id="stock"
v-model="stock"
type="number"
v-bind="stockAttrs"
:disabled="isLoading"
/>
<Input id="stock" v-model="stock" type="number" v-bind="stockAttrs" :disabled="isLoading" />
</Field>
</Cell>
</Block>
@@ -112,8 +101,8 @@ function onCancelForm() {
<Button
type="button"
class="w-[120px]"
:disabled="isLoading"
@click="handleSubmit(onSubmitForm)"
:disabled="isLoading || !meta.valid"
@click="onSubmitForm"
>
Simpan
</Button>
+6 -14
View File
@@ -1,21 +1,17 @@
import type {
Col,
KeyLabel,
RecComponent,
RecStrFuncComponent,
Th,
} from '~/components/pub/custom-ui/data/types'
import type { Col, KeyLabel, RecComponent, RecStrFuncComponent, Th } from '~/components/pub/custom-ui/data/types'
import { defineAsyncComponent } from 'vue'
type SmallDetailDto = any
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[] = [
{ key: 'code', label: 'Kode' },
@@ -27,10 +23,6 @@ export const funcParsed: Record<string, (row: any, ...args: any[]) => any> = {
const recX = rec as SmallDetailDto
return `${recX.name}`.trim()
},
item_id: (rec: unknown): unknown => {
const recX = rec as SmallDetailDto
return recX.item_id
},
uom_code: (rec: unknown): unknown => {
const recX = rec as SmallDetailDto
return recX.uom_code
+5
View File
@@ -5,6 +5,11 @@ import { useForm } from 'vee-validate'
// types
import type z from 'zod'
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 {
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'))
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[] = [
{ key: 'code', label: 'Kode' },
+3 -2
View File
@@ -55,7 +55,7 @@ const {
} = usePaginatedList({
fetchFn: async ({ page }) => {
const result = await getSourceMaterials({ page })
return result.data || []
return { success: result.success || false, body: { data: result.data || [], meta: result.meta || {} } }
},
entityName: 'equipment',
})
@@ -105,7 +105,8 @@ watch(recId, () => {
})
onMounted(async () => {
await getUomList();
await getUomList()
await getEquipmentList()
})
</script>