CondorDictSelect
CondorDictSelect 是一个基于字典数据的选择器组件,支持单选和多选模式。该组件与字典存储(Pinia Store)集成,自动加载指定字典编码的数据并渲染为下拉选项。
组件 Props
| 参数名 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| code | string | - | 必需 字典编码,用于从字典存储中获取对应的字典数据列表 |
| value | string / number / Array<string , number> / null | null | 绑定的值,支持字符串、数字、数组或null |
| type | 'number' / 'string' | 'string' | 值的类型,指定组件内部处理值的类型格式 |
| multiple | boolean | false | 是否多选模式 |
| format | 'string' / 'array' | 'string' | 多选模式下的输出格式,控制组件输出的值是字符串(逗号分隔)还是数组 |
| clearable | boolean | true | 是否显示清空按钮 |
组件事件
| 事件名 | 说明 | 参数 |
|---|---|---|
| update:value | 当下拉选择变化时触发 | 更新后的值(根据multiple和format格式返回对应类型) |
基本用法
1. 基本单选(字符串类型)
vue
<template>
<CondorDictSelect
code="gender"
v-model:value="selectedGender"
/>
</template>
<script setup lang="ts">
import { ref } from 'vue';
// 值为字符串类型
const selectedGender = ref('male');
</script>2. 多选模式(字符串格式)
vue
<template>
<CondorDictSelect
code="education"
v-model:value="selectedEducation"
multiple
/>
</template>
<script setup lang="ts">
import { ref } from 'vue';
// 输出格式为字符串(默认):"1,2,3"
const selectedEducation = ref('1,3');
</script>3. 多选模式(数组格式)
vue
<template>
<CondorDictSelect
code="education"
v-model:value="selectedEducation"
multiple
format="array"
/>
</template>
<script setup lang="ts">
import { ref } from 'vue';
// 输出格式为数组:["1", "3"]
const selectedEducation = ref(['1', '3']);
</script>4. 数字类型值
vue
<template>
<CondorDictSelect
code="status"
v-model:value="statusValue"
type="number"
/>
</template>
<script setup lang="ts">
import { ref } from 'vue';
// 值为数字类型
const statusValue = ref(1);
</script>