diff --git a/app/components/app/item/entry-form.vue b/app/components/app/item/entry-form.vue index 67f12f50..5e2ab11a 100644 --- a/app/components/app/item/entry-form.vue +++ b/app/components/app/item/entry-form.vue @@ -16,12 +16,15 @@ import { toTypedSchema } from '@vee-validate/zod' interface Props { schema: z.ZodSchema + itemGroups: any[] + uoms: any[] values: any isLoading?: boolean isReadonly?: boolean } const props = defineProps() +const isShowInfra = false; const isLoading = props.isLoading !== undefined ? props.isLoading : false const isReadonly = props.isReadonly !== undefined ? props.isReadonly : false const emit = defineEmits<{ @@ -44,7 +47,7 @@ const { defineField, errors, meta } = useForm({ const [code, codeAttrs] = defineField('code') const [name, nameAttrs] = defineField('name') const [itemGroup_code, itemGroup_codeAttrs] = defineField('itemGroup_code') -const [uom_code, uom_codeAttrs] = defineField('uom_code') +const [uom, uomAttrs] = defineField('uom_code') const [infra_code, infra_codeAttrs] = defineField('infra_code') const [stock, stockAttrs] = defineField('stock') @@ -52,7 +55,7 @@ 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.itemGroup_code !== undefined) itemGroup_code.value = props.values.itemGroup_code - if (props.values.uom_code !== undefined) uom_code.value = props.values.uom_code + if (props.values.uom_code !== undefined) uom.value = props.values.uom_code if (props.values.infra_code !== undefined) infra_code.value = props.values.infra_code if (props.values.stock !== undefined) stock.value = props.values.stock } @@ -61,7 +64,7 @@ const resetForm = () => { code.value = '' name.value = '' itemGroup_code.value = '' - uom_code.value = '' + uom.value = '' infra_code.value = '' stock.value = 0 } @@ -71,7 +74,7 @@ function onSubmitForm() { code: code.value || '', name: name.value || '', itemGroup_code: itemGroup_code.value || '', - uom_code: uom_code.value || '', + uom_code: uom.value || '', infra_code: infra_code.value || '', stock: Number(stock.value) || 0, } @@ -118,10 +121,13 @@ function onCancelForm() { - @@ -129,15 +135,18 @@ function onCancelForm() { - - + { + const recX = rec as any + return recX.itemGroup_code || '-' + }, + uom_code: (rec: unknown): unknown => { + const recX = rec as any + return recX.uom?.name || '-' + }, + infra_code: (rec: unknown): unknown => { + const recX = rec as any + return recX.infra_code || '-' + }, + stock: (rec: unknown): unknown => { + const recX = rec as any + return recX.stock || '-' + }, + }, components: { action(rec, idx) { diff --git a/app/components/content/item-price/list.vue b/app/components/content/item-price/list.vue index aa277b71..1e4de55f 100644 --- a/app/components/content/item-price/list.vue +++ b/app/components/content/item-price/list.vue @@ -1,70 +1,194 @@ diff --git a/app/components/content/item/list.vue b/app/components/content/item/list.vue index 15887985..c17ef3dd 100644 --- a/app/components/content/item/list.vue +++ b/app/components/content/item/list.vue @@ -1,70 +1,208 @@ diff --git a/app/pages/(features)/item-price/index.vue b/app/pages/(features)/item-price/index.vue new file mode 100644 index 00000000..b97966e5 --- /dev/null +++ b/app/pages/(features)/item-price/index.vue @@ -0,0 +1,29 @@ + + + diff --git a/app/pages/(features)/item/index.vue b/app/pages/(features)/item/index.vue new file mode 100644 index 00000000..33fc9b23 --- /dev/null +++ b/app/pages/(features)/item/index.vue @@ -0,0 +1,29 @@ + + + diff --git a/app/schemas/item.schema.ts b/app/schemas/item.schema.ts index 11b597e0..9e74ad70 100644 --- a/app/schemas/item.schema.ts +++ b/app/schemas/item.schema.ts @@ -5,8 +5,8 @@ const ItemSchema = z.object({ name: z.string({ required_error: 'Nama harus diisi' }).min(1, 'Nama minimum 1 karakter'), itemGroup_code: z.string({ required_error: 'Item Group harus diisi' }).min(1, 'Item Group harus diisi'), uom_code: z.string({ required_error: 'UOM harus diisi' }).min(1, 'UOM harus diisi'), - infra_code: z.string({ required_error: 'Infra harus diisi' }).min(1, 'Infra harus diisi'), - stock: z.number({ required_error: 'Stok harus diisi' }).min(0, 'Stok tidak boleh kurang dari 0'), + infra_code: z.string({ required_error: 'Infra harus diisi' }).optional(), + stock: z.number({ required_error: 'Stok harus diisi' }).min(0, 'Stok tidak boleh kurang dari 0').optional(), }) type ItemFormData = z.infer diff --git a/app/services/item-group.service.ts b/app/services/item-group.service.ts new file mode 100644 index 00000000..c7c2d82b --- /dev/null +++ b/app/services/item-group.service.ts @@ -0,0 +1,41 @@ +// Base +import * as base from './_crud-base' + +const path = '/api/v1/item-group' +const name = 'item-group' + +export function create(data: any) { + return base.create(path, data, name) +} + +export function getList(params: any = null) { + return base.getList(path, params, name) +} + +export function getDetail(id: number | string) { + return base.getDetail(path, id, name) +} + +export function update(id: number | string, data: any) { + return base.update(path, id, data, name) +} + +export function remove(id: number | string) { + return base.remove(path, id, name) +} + +export async function getValueLabelList( + params: any = null, + useCodeAsValue = false, +): Promise<{ value: string; label: string }[]> { + let data: { value: string; label: string }[] = [] + const result = await getList(params) + if (result.success) { + const resultData = result.body?.data || [] + data = resultData.map((item: any) => ({ + value: useCodeAsValue ? item.code : item.id ? Number(item.id) : item.code, + label: item.name, + })) + } + return data +} diff --git a/app/services/item.service.ts b/app/services/item.service.ts index 8b44acd8..7d135201 100644 --- a/app/services/item.service.ts +++ b/app/services/item.service.ts @@ -24,13 +24,16 @@ export function remove(id: number | string) { return base.remove(path, id, name) } -export async function getValueLabelList(params: any = null): Promise<{ value: string; label: string }[]> { +export async function getValueLabelList( + params: any = null, + useCodeAsValue = false, +): Promise<{ value: string; label: string }[]> { let data: { value: string; label: string }[] = [] const result = await getList(params) if (result.success) { const resultData = result.body?.data || [] data = resultData.map((item: any) => ({ - value: item.id ? Number(item.id) : item.code, + value: useCodeAsValue ? item.code : item.id ? Number(item.id) : item.code, label: item.name, })) }