Merge branch 'dev' of github.com:dikstub-rssa/simrs-fe into feat/laporan-tindakan-185

This commit is contained in:
Khafid Prayoga
2025-12-03 17:16:32 +07:00
6 changed files with 27 additions and 28 deletions
+11 -11
View File
@@ -35,24 +35,24 @@ const { defineField, errors, meta } = useForm({
initialValues: {
date: props.values.date || today.toISOString().slice(0, 10),
problem: '',
dstUnit_id: 0,
} as Partial<ConsultationFormData>,
dstUnit_code: '',
} as ConsultationFormData,
})
const [date, dateAttrs] = defineField('date')
const [unit_id, unitAttrs] = defineField('unit_id')
const [unit_code, unitAttrs] = defineField('unit_code')
const [problem, problemAttrs] = defineField('problem')
// Fill fields from props.values if provided
if (props.values) {
if (props.values.date !== undefined) date.value = props.values.date.substring(0, 10)
if (props.values.dstUnit_id !== undefined) unit_id.value = props.values.dstUnit_id
if (props.values.dstUnit_code !== undefined) unit_code.value = props.values.dstUnit_code
if (props.values.problem !== undefined) problem.value = props.values.problem
}
const resetForm = () => {
date.value = date.value ?? today.toISOString().slice(0, 10)
unit_id.value = 0
unit_code.value = 0
problem.value = ''
}
@@ -62,7 +62,7 @@ function onSubmitForm(values: any) {
encounter_id: props.encounter_id,
date: date.value ? `${date.value}T00:00:00Z` : '',
problem: problem.value || '',
dstUnit_id: unit_id.value || 0,
dstUnit_code: unit_code.value || '',
}
emit('submit', formData, resetForm)
}
@@ -89,18 +89,18 @@ function onCancelForm() {
</DE.Cell>
<DE.Cell>
<DE.Label>Unit</DE.Label>
<DE.Field :errMessage="errors.unit_id">
{{ errors.unit_id }}
<DE.Field :errMessage="errors.unit_code">
{{ errors.unit_code }}
<Select
id="strUnit_id"
v-model.number="unit_id"
id="strUnit_code"
v-model="unit_code"
icon-name="i-lucide-chevron-down"
placeholder="Pilih poliklinik tujuan"
v-bind="unitAttrs"
:items="props.units || []"
:disabled="isLoading || isReadonly"
/>
<!-- <Input type="number" id="unit_id" v-model.number="unit_id" v-bind="unitAttrs" :disabled="isLoading || isReadonly" /> -->
<!-- <Input type="number" id="unit_code" v-model.number="unit_code" v-bind="unitAttrs" :disabled="isLoading || isReadonly" /> -->
</DE.Field>
</DE.Cell>
<DE.Cell :colSpan="3">
+1 -1
View File
@@ -43,7 +43,7 @@ interface Props {
}
const props = defineProps<Props>()
let units = ref<{ value: string; label: string }[]>([])
const units = ref<{ value: string; label: string }[]>([])
const encounterId = ref<number>(props?.encounter?.id || 0)
const title = ref('')
@@ -1,6 +1,5 @@
<script setup lang="ts">
import { cn } from '~/lib/utils'
import { type Item } from './index'
const props = defineProps<{
@@ -14,6 +13,8 @@ const props = defineProps<{
isDisabled?: boolean
}>()
const model = defineModel()
const emit = defineEmits<{
'update:modelValue': [value: string | number]
'update:searchText': [value: string | number]
@@ -57,6 +58,7 @@ const searchableItems = computed(() => {
})
function onSelect(item: Item) {
model.value = item.value
emit('update:modelValue', item.value)
open.value = false
}
+7 -7
View File
@@ -2,8 +2,8 @@ export interface Consultation {
id: number
encounter_id: number
date?: string
unit_id: number
doctor_id?: number
unit_code: number
doctor_code?: number
problem: string
solution?: string
repliedAt?: string
@@ -13,13 +13,13 @@ export interface CreateDto {
encounter_id: number
date: string
problem: string
dstUnit_id: number
dstUnit_code: string
}
export interface UpdateDto {
id: number
problem: string
unit_id: number
unit_code: number
}
export interface DeleteDto {
@@ -31,7 +31,7 @@ export function genCreateDto(): CreateDto {
date: '',
encounter_id: 0,
problem: '',
dstUnit_id: 0,
dstUnit_code: '',
}
}
@@ -39,8 +39,8 @@ export function genConsultation(): Consultation {
return {
id: 0,
encounter_id: 0,
unit_id: 0,
doctor_id: 0,
unit_code: 0,
doctor_code: 0,
problem: '',
solution: '',
repliedAt: '',
+1 -1
View File
@@ -3,7 +3,7 @@ import type { CreateDto } from '~/models/consultation'
const ConsultationSchema = z.object({
date: z.string({ required_error: 'Tanggal harus diisi' }),
dstUnit_id: z.number({ required_error: 'Unit harus diisi' }),
dstUnit_code: z.string({ required_error: 'Unit harus diisi' }),
problem: z.string({ required_error: 'Uraian harus diisi' }).min(20, 'Uraian minimum 20 karakter'),
})
+4 -7
View File
@@ -27,17 +27,14 @@ 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 }[]> {
export async function getValueLabelList(params: any = null, useId = 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: Unit) => ({
value: useCodeAsValue ? item.code
: item.id ? Number(item.id)
: item.code,
label: item.name,
}))
data = !useId ?
resultData.map((item: Unit) => ({ value: item.code, label: item.name })) :
resultData.map((item: Unit) => ({ value: item.id, label: item.name }))
}
return data
}