form-create: 封装通用选择器 hook
parent
c1c21d826d
commit
b4d85b782e
@ -1,3 +0,0 @@
|
|||||||
import DictSelect from './src/DictSelect.vue'
|
|
||||||
|
|
||||||
export { DictSelect }
|
|
||||||
@ -1,46 +0,0 @@
|
|||||||
<!-- 数据字典 Select 选择器 -->
|
|
||||||
<template>
|
|
||||||
<el-select class="w-1/1" v-bind="attrs">
|
|
||||||
<template v-if="valueType === 'int'">
|
|
||||||
<el-option
|
|
||||||
v-for="(dict, index) in getIntDictOptions(dictType)"
|
|
||||||
:key="index"
|
|
||||||
:label="dict.label"
|
|
||||||
:value="dict.value"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
<template v-if="valueType === 'str'">
|
|
||||||
<el-option
|
|
||||||
v-for="(dict, index) in getStrDictOptions(dictType)"
|
|
||||||
:key="index"
|
|
||||||
:label="dict.label"
|
|
||||||
:value="dict.value"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
<template v-if="valueType === 'bool'">
|
|
||||||
<el-option
|
|
||||||
v-for="(dict, index) in getBoolDictOptions(dictType)"
|
|
||||||
:key="index"
|
|
||||||
:label="dict.label"
|
|
||||||
:value="dict.value"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</el-select>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
|
||||||
import { getBoolDictOptions, getIntDictOptions, getStrDictOptions } from '@/utils/dict'
|
|
||||||
|
|
||||||
// 接受父组件参数
|
|
||||||
interface Props {
|
|
||||||
dictType: string // 字典类型
|
|
||||||
valueType: string // 字典值类型
|
|
||||||
}
|
|
||||||
|
|
||||||
withDefaults(defineProps<Props>(), {
|
|
||||||
dictType: '',
|
|
||||||
valueType: 'str'
|
|
||||||
})
|
|
||||||
const attrs = useAttrs()
|
|
||||||
defineOptions({ name: 'DictSelect' })
|
|
||||||
</script>
|
|
||||||
Loading…
Reference in New Issue