feat(specialist): finishing integrate specialist
This commit is contained in:
@@ -4,7 +4,7 @@ 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'
|
||||
import Combobox from '~/components/pub/custom-ui/form/combobox.vue'
|
||||
// import Combobox from '~/components/pub/custom-ui/form/combobox.vue'
|
||||
|
||||
// Types
|
||||
import type { SpecialistFormData } from '~/schemas/specialist.schema.ts'
|
||||
@@ -89,8 +89,8 @@ function onCancelForm() {
|
||||
</Cell>
|
||||
<Cell>
|
||||
<Label height="compact">Unit</Label>
|
||||
<Field :errMessage="errors.uom_code">
|
||||
<Combobox
|
||||
<Field :errMessage="errors.unit">
|
||||
<!-- <Combobox
|
||||
id="unit"
|
||||
placeholder="Pilih Unit"
|
||||
search-placeholder="Cari unit"
|
||||
@@ -99,6 +99,15 @@ function onCancelForm() {
|
||||
v-bind="unitAttrs"
|
||||
:items="units"
|
||||
:disabled="isLoading || isReadonly"
|
||||
/> -->
|
||||
<Select
|
||||
id="unit"
|
||||
icon-name="i-lucide-chevron-down"
|
||||
placeholder="Pilih unit"
|
||||
v-model="unit"
|
||||
v-bind="unitAttrs"
|
||||
:items="units"
|
||||
:disabled="isLoading || isReadonly"
|
||||
/>
|
||||
</Field>
|
||||
</Cell>
|
||||
|
||||
@@ -28,6 +28,10 @@ export const funcParsed: RecStrFuncUnknown = {
|
||||
const recX = rec as SmallDetailDto
|
||||
return `${recX.name}`.trim()
|
||||
},
|
||||
unit: (rec: unknown): unknown => {
|
||||
const recX = rec as SmallDetailDto
|
||||
return `${recX.unit_id}`
|
||||
},
|
||||
}
|
||||
|
||||
export const funcComponent: RecStrFuncComponent = {
|
||||
|
||||
@@ -97,7 +97,7 @@ const getUnitList = async () => {
|
||||
const result = await getUnits()
|
||||
if (result.success) {
|
||||
const currentUnits = result.body?.data || []
|
||||
units.value = currentUnits.map((item: Unit) => ({ value: item.code, label: item.name }))
|
||||
units.value = currentUnits.map((item: Unit) => ({ value: item.id ? Number(item.id) : item.code, label: item.name }))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export interface Specialist {
|
||||
code: string
|
||||
name: string
|
||||
unit_id: number
|
||||
unit_id: number | string
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
export interface Unit {
|
||||
id?: number
|
||||
code: string
|
||||
name: string
|
||||
installation?: string | number
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { Specialist } from '~/models/specialist'
|
||||
const SpecialistSchema = z.object({
|
||||
code: z.string({ required_error: 'Kode harus diisi' }).min(1, 'Kode minimum 1 karakter'),
|
||||
name: z.string({ required_error: 'Nama harus diisi' }).min(1, 'Nama minimum 1 karakter'),
|
||||
unit_id: z.number().optional(),
|
||||
unit_id: z.number().positive('Unit harus diisi'),
|
||||
})
|
||||
|
||||
type SpecialistFormData = z.infer<typeof SpecialistSchema> & Specialist
|
||||
|
||||
Reference in New Issue
Block a user