mirror of
https://git.hmsn.ink/kospo/svcm/oa.git
synced 2026-03-20 04:22:25 +09:00
com:remove: update에서만 쓰던 컴포넌트 공통 컴포넌트로 사용가능하여 제거 - 근태 selectBox
This commit is contained in:
@@ -1,84 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import {useCodes} from '/src/stores/codeStore.ts'
|
||||
|
||||
const detailCode = useCodes()
|
||||
export interface VSelectProps {
|
||||
raw?: boolean
|
||||
multiple?: boolean
|
||||
cd_grp?: string
|
||||
placeholder?: string
|
||||
}
|
||||
|
||||
defineOptions({
|
||||
inheritAttrs: false,
|
||||
})
|
||||
|
||||
const modelValue = defineModel<any>({
|
||||
default: '',
|
||||
})
|
||||
const props = defineProps<VSelectProps>()
|
||||
const attrs = useAttrs()
|
||||
|
||||
const { field, id } = useVFieldContext({
|
||||
create: false,
|
||||
help: 'VSelect',
|
||||
})
|
||||
|
||||
const internal = computed({
|
||||
get() {
|
||||
if (field?.value) {
|
||||
return field.value.value
|
||||
}
|
||||
else {
|
||||
return modelValue.value
|
||||
}
|
||||
},
|
||||
set(value: any) {
|
||||
if (field?.value) {
|
||||
field.value.setValue(value)
|
||||
}
|
||||
modelValue.value = value
|
||||
},
|
||||
})
|
||||
|
||||
const classes = computed(() => {
|
||||
if (props.raw) return []
|
||||
|
||||
return ['select', props.multiple && 'is-multiple']
|
||||
})
|
||||
|
||||
const cdItems = ref<Array<{ cd: string; nm: string }>>([])
|
||||
|
||||
watch(() => props.cd_grp, async (newVal) => {
|
||||
if (newVal) {
|
||||
await detailCode.setDetailCode(newVal)
|
||||
cdItems.value = detailCode.getCodeList(newVal)
|
||||
}
|
||||
}, { immediate: true })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div :class="classes">
|
||||
<select
|
||||
:id="id"
|
||||
v-bind="attrs"
|
||||
v-model="internal"
|
||||
:name="id"
|
||||
:multiple="props.multiple"
|
||||
@change="field?.handleChange"
|
||||
@blur="field?.handleBlur"
|
||||
>
|
||||
<option value="null">{{ props.placeholder || '선택하세요' }}</option>
|
||||
<option value="">{{ props.placeholder || '선택하세요' }}</option>
|
||||
<option
|
||||
v-for="item in cdItems"
|
||||
:key="item.cd"
|
||||
:value="item.cd"
|
||||
>
|
||||
<slot name="code" :item="item">
|
||||
{{ item.nm }}
|
||||
</slot>
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user