Merge branch 'dev' of github.com:dikstub-rssa/simrs-fe into feat/laporan-tindakan-185
This commit is contained in:
@@ -35,24 +35,24 @@ const { defineField, errors, meta } = useForm({
|
|||||||
initialValues: {
|
initialValues: {
|
||||||
date: props.values.date || today.toISOString().slice(0, 10),
|
date: props.values.date || today.toISOString().slice(0, 10),
|
||||||
problem: '',
|
problem: '',
|
||||||
dstUnit_id: 0,
|
dstUnit_code: '',
|
||||||
} as Partial<ConsultationFormData>,
|
} as ConsultationFormData,
|
||||||
})
|
})
|
||||||
|
|
||||||
const [date, dateAttrs] = defineField('date')
|
const [date, dateAttrs] = defineField('date')
|
||||||
const [unit_id, unitAttrs] = defineField('unit_id')
|
const [unit_code, unitAttrs] = defineField('unit_code')
|
||||||
const [problem, problemAttrs] = defineField('problem')
|
const [problem, problemAttrs] = defineField('problem')
|
||||||
|
|
||||||
// Fill fields from props.values if provided
|
// Fill fields from props.values if provided
|
||||||
if (props.values) {
|
if (props.values) {
|
||||||
if (props.values.date !== undefined) date.value = props.values.date.substring(0, 10)
|
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
|
if (props.values.problem !== undefined) problem.value = props.values.problem
|
||||||
}
|
}
|
||||||
|
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
date.value = date.value ?? today.toISOString().slice(0, 10)
|
date.value = date.value ?? today.toISOString().slice(0, 10)
|
||||||
unit_id.value = 0
|
unit_code.value = 0
|
||||||
problem.value = ''
|
problem.value = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ function onSubmitForm(values: any) {
|
|||||||
encounter_id: props.encounter_id,
|
encounter_id: props.encounter_id,
|
||||||
date: date.value ? `${date.value}T00:00:00Z` : '',
|
date: date.value ? `${date.value}T00:00:00Z` : '',
|
||||||
problem: problem.value || '',
|
problem: problem.value || '',
|
||||||
dstUnit_id: unit_id.value || 0,
|
dstUnit_code: unit_code.value || '',
|
||||||
}
|
}
|
||||||
emit('submit', formData, resetForm)
|
emit('submit', formData, resetForm)
|
||||||
}
|
}
|
||||||
@@ -89,18 +89,18 @@ function onCancelForm() {
|
|||||||
</DE.Cell>
|
</DE.Cell>
|
||||||
<DE.Cell>
|
<DE.Cell>
|
||||||
<DE.Label>Unit</DE.Label>
|
<DE.Label>Unit</DE.Label>
|
||||||
<DE.Field :errMessage="errors.unit_id">
|
<DE.Field :errMessage="errors.unit_code">
|
||||||
{{ errors.unit_id }}
|
{{ errors.unit_code }}
|
||||||
<Select
|
<Select
|
||||||
id="strUnit_id"
|
id="strUnit_code"
|
||||||
v-model.number="unit_id"
|
v-model="unit_code"
|
||||||
icon-name="i-lucide-chevron-down"
|
icon-name="i-lucide-chevron-down"
|
||||||
placeholder="Pilih poliklinik tujuan"
|
placeholder="Pilih poliklinik tujuan"
|
||||||
v-bind="unitAttrs"
|
v-bind="unitAttrs"
|
||||||
:items="props.units || []"
|
:items="props.units || []"
|
||||||
:disabled="isLoading || isReadonly"
|
: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.Field>
|
||||||
</DE.Cell>
|
</DE.Cell>
|
||||||
<DE.Cell :colSpan="3">
|
<DE.Cell :colSpan="3">
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ interface Props {
|
|||||||
}
|
}
|
||||||
const props = defineProps<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 encounterId = ref<number>(props?.encounter?.id || 0)
|
||||||
const title = ref('')
|
const title = ref('')
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { cn } from '~/lib/utils'
|
import { cn } from '~/lib/utils'
|
||||||
|
|
||||||
import { type Item } from './index'
|
import { type Item } from './index'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
@@ -14,6 +13,8 @@ const props = defineProps<{
|
|||||||
isDisabled?: boolean
|
isDisabled?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
const model = defineModel()
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
'update:modelValue': [value: string | number]
|
'update:modelValue': [value: string | number]
|
||||||
'update:searchText': [value: string | number]
|
'update:searchText': [value: string | number]
|
||||||
@@ -57,6 +58,7 @@ const searchableItems = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
function onSelect(item: Item) {
|
function onSelect(item: Item) {
|
||||||
|
model.value = item.value
|
||||||
emit('update:modelValue', item.value)
|
emit('update:modelValue', item.value)
|
||||||
open.value = false
|
open.value = false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ export interface Consultation {
|
|||||||
id: number
|
id: number
|
||||||
encounter_id: number
|
encounter_id: number
|
||||||
date?: string
|
date?: string
|
||||||
unit_id: number
|
unit_code: number
|
||||||
doctor_id?: number
|
doctor_code?: number
|
||||||
problem: string
|
problem: string
|
||||||
solution?: string
|
solution?: string
|
||||||
repliedAt?: string
|
repliedAt?: string
|
||||||
@@ -13,13 +13,13 @@ export interface CreateDto {
|
|||||||
encounter_id: number
|
encounter_id: number
|
||||||
date: string
|
date: string
|
||||||
problem: string
|
problem: string
|
||||||
dstUnit_id: number
|
dstUnit_code: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UpdateDto {
|
export interface UpdateDto {
|
||||||
id: number
|
id: number
|
||||||
problem: string
|
problem: string
|
||||||
unit_id: number
|
unit_code: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DeleteDto {
|
export interface DeleteDto {
|
||||||
@@ -31,7 +31,7 @@ export function genCreateDto(): CreateDto {
|
|||||||
date: '',
|
date: '',
|
||||||
encounter_id: 0,
|
encounter_id: 0,
|
||||||
problem: '',
|
problem: '',
|
||||||
dstUnit_id: 0,
|
dstUnit_code: '',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,8 +39,8 @@ export function genConsultation(): Consultation {
|
|||||||
return {
|
return {
|
||||||
id: 0,
|
id: 0,
|
||||||
encounter_id: 0,
|
encounter_id: 0,
|
||||||
unit_id: 0,
|
unit_code: 0,
|
||||||
doctor_id: 0,
|
doctor_code: 0,
|
||||||
problem: '',
|
problem: '',
|
||||||
solution: '',
|
solution: '',
|
||||||
repliedAt: '',
|
repliedAt: '',
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import type { CreateDto } from '~/models/consultation'
|
|||||||
|
|
||||||
const ConsultationSchema = z.object({
|
const ConsultationSchema = z.object({
|
||||||
date: z.string({ required_error: 'Tanggal harus diisi' }),
|
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'),
|
problem: z.string({ required_error: 'Uraian harus diisi' }).min(20, 'Uraian minimum 20 karakter'),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -27,17 +27,14 @@ export function remove(id: number | string) {
|
|||||||
return base.remove(path, id, name)
|
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 }[] = []
|
let data: { value: string; label: string }[] = []
|
||||||
const result = await getList(params)
|
const result = await getList(params)
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
const resultData = result.body?.data || []
|
const resultData = result.body?.data || []
|
||||||
data = resultData.map((item: Unit) => ({
|
data = !useId ?
|
||||||
value: useCodeAsValue ? item.code
|
resultData.map((item: Unit) => ({ value: item.code, label: item.name })) :
|
||||||
: item.id ? Number(item.id)
|
resultData.map((item: Unit) => ({ value: item.id, label: item.name }))
|
||||||
: item.code,
|
|
||||||
label: item.name,
|
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user