feat: Implement item management module and add encounter initialization handler.

This commit is contained in:
riefive
2025-12-05 14:53:31 +07:00
parent 615a7c4485
commit 4715e5330a
5 changed files with 149 additions and 47 deletions
+34
View File
@@ -41,6 +41,8 @@ const { defineField, errors, meta } = useForm({
uom_code: '',
infra_code: '',
stock: 0,
buyingPrice: 0,
sellingPrice: 0,
} as Partial<ItemFormData>,
})
@@ -50,6 +52,8 @@ const [itemGroup_code, itemGroup_codeAttrs] = defineField('itemGroup_code')
const [uom, uomAttrs] = defineField('uom_code')
const [infra_code, infra_codeAttrs] = defineField('infra_code')
const [stock, stockAttrs] = defineField('stock')
const [buyingPrice, buyingPriceAttrs] = defineField('buyingPrice')
const [sellingPrice, sellingPriceAttrs] = defineField('sellingPrice')
if (props.values) {
if (props.values.code !== undefined) code.value = props.values.code
@@ -58,6 +62,8 @@ if (props.values) {
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
if (props.values.buyingPrice !== undefined) buyingPrice.value = props.values.buyingPrice
if (props.values.sellingPrice !== undefined) sellingPrice.value = props.values.sellingPrice
}
const resetForm = () => {
@@ -67,6 +73,8 @@ const resetForm = () => {
uom.value = ''
infra_code.value = ''
stock.value = 0
buyingPrice.value = 0
sellingPrice.value = 0
}
function onSubmitForm() {
@@ -77,6 +85,8 @@ function onSubmitForm() {
uom_code: uom.value || '',
infra_code: infra_code.value || '',
stock: Number(stock.value) || 0,
buyingPrice: Number(buyingPrice.value) || 0,
sellingPrice: Number(sellingPrice.value) || 0,
}
emit('submit', formData, resetForm)
}
@@ -169,6 +179,30 @@ function onCancelForm() {
/>
</Field>
</Cell>
<Cell>
<Label height="compact">Harga Beli</Label>
<Field :errMessage="errors.buyingPrice">
<Input
id="buyingPrice"
type="number"
v-model="buyingPrice"
v-bind="buyingPriceAttrs"
:disabled="isLoading || isReadonly"
/>
</Field>
</Cell>
<Cell>
<Label height="compact">Harga Jual</Label>
<Field :errMessage="errors.sellingPrice">
<Input
id="sellingPrice"
type="number"
v-model="sellingPrice"
v-bind="sellingPriceAttrs"
:disabled="isLoading || isReadonly"
/>
</Field>
</Cell>
</Block>
<div class="my-2 flex justify-end gap-2 py-2">
<Button
+35 -3
View File
@@ -4,7 +4,17 @@ import { defineAsyncComponent } from 'vue'
const action = defineAsyncComponent(() => import('~/components/pub/my-ui/data/dropdown-action-dud.vue'))
export const config: Config = {
cols: [{}, {}, {}, {}, {}, {}, { width: 50 }],
cols: [
{ width: 100 },
{ width: 100 },
{ width: 100 },
{ width: 100 },
{ width: 100 },
{ width: 100 },
{ width: 100 },
{ width: 100 },
{ width: 50 },
],
headers: [
[
@@ -14,11 +24,13 @@ export const config: Config = {
{ label: 'UOM' },
{ label: 'Infra' },
{ label: 'Stok' },
{ label: 'Harga Beli' },
{ label: 'Harga Jual' },
{ label: 'Aksi' },
],
],
keys: ['code', 'name', 'itemGroup_code', 'uom_code', 'infra_code', 'stock', 'action'],
keys: ['code', 'name', 'itemGroup_code', 'uom_code', 'infra_code', 'stock', 'buyingPrice', 'sellingPrice', 'action'],
delKeyNames: [
{ key: 'code', label: 'Kode' },
@@ -40,7 +52,27 @@ export const config: Config = {
},
stock: (rec: unknown): unknown => {
const recX = rec as any
return recX.stock || '-'
const value = recX.stock
if (value === null || value === undefined) {
return '-'
}
return value
},
buyingPrice: (rec: unknown): unknown => {
const recX = rec as any
const value = recX.buyingPrice
if (value === null || value === undefined) {
return '-'
}
return value
},
sellingPrice: (rec: unknown): unknown => {
const recX = rec as any
const value = recX.sellingPrice
if (value === null || value === undefined) {
return '-'
}
return value
},
},
+2 -5
View File
@@ -7,7 +7,7 @@ import AppItemEntryForm from '~/components/app/item/entry-form.vue'
import RecordConfirmation from '~/components/pub/my-ui/confirmation/record-confirmation.vue'
// Constants
import { infraGroupCodesKeys } from '~/lib/constants'
import { itemGroupCodes } from '~/lib/constants'
// Helpers
import { usePaginatedList } from '~/composables/usePaginatedList'
@@ -33,9 +33,6 @@ import {
handleCancelForm,
} from '~/handlers/item.handler'
// Constants
import { itemGroupCodes } from '~/lib/constants'
// Services
import { getList, getDetail } from '~/services/item.service'
import { getValueLabelList as getUomList } from '~/services/uom.service'
@@ -171,7 +168,7 @@ onMounted(async () => {
@submit="
(values: ItemFormData | Record<string, any>, resetForm: () => void) => {
if (recId > 0) {
handleActionEdit(recId, values, getItemList, resetForm, toast)
handleActionEdit(recItem?.code ? recItem.code : recId, values, getItemList, resetForm, toast)
return
}
handleActionSave(values, getItemList, resetForm, toast)