fix: [bpm] web-ele版本 流程表单字典选择器下拉无法选中问题
parent
4ba9390f25
commit
7ad2d43121
|
|
@ -2,7 +2,7 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { DictSelectProps } from '../typing';
|
import type { DictSelectProps } from '../typing';
|
||||||
|
|
||||||
import { computed, useAttrs } from 'vue';
|
import { computed, ref, useAttrs, watch } from 'vue';
|
||||||
|
|
||||||
import { getDictOptions } from '@vben/hooks';
|
import { getDictOptions } from '@vben/hooks';
|
||||||
|
|
||||||
|
|
@ -22,8 +22,24 @@ const props = withDefaults(defineProps<DictSelectProps>(), {
|
||||||
selectType: 'select',
|
selectType: 'select',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'update:modelValue', value: any): void;
|
||||||
|
}>();
|
||||||
|
|
||||||
const attrs = useAttrs();
|
const attrs = useAttrs();
|
||||||
|
|
||||||
|
/** 内部选中值 */
|
||||||
|
const selectedValue = ref<any>();
|
||||||
|
|
||||||
|
/** 同步 modelValue 到内部选中值 */
|
||||||
|
watch(
|
||||||
|
() => props.modelValue,
|
||||||
|
(newVal) => {
|
||||||
|
selectedValue.value = newVal;
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
);
|
||||||
|
|
||||||
/** 获得字典配置 */
|
/** 获得字典配置 */
|
||||||
const getDictOption = computed(() => {
|
const getDictOption = computed(() => {
|
||||||
switch (props.valueType) {
|
switch (props.valueType) {
|
||||||
|
|
@ -31,20 +47,30 @@ const getDictOption = computed(() => {
|
||||||
return getDictOptions(props.dictType, 'boolean');
|
return getDictOptions(props.dictType, 'boolean');
|
||||||
}
|
}
|
||||||
case 'int': {
|
case 'int': {
|
||||||
return getDictOptions(props.dictType);
|
return getDictOptions(props.dictType, 'number');
|
||||||
}
|
}
|
||||||
case 'str': {
|
case 'str': {
|
||||||
return getDictOptions(props.dictType);
|
return getDictOptions(props.dictType, 'string');
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function handleChange(value: any) {
|
||||||
|
emit('update:modelValue', value);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<ElSelect v-if="selectType === 'select'" class="w-1/1" v-bind="attrs">
|
<ElSelect
|
||||||
|
v-if="selectType === 'select'"
|
||||||
|
v-model="selectedValue"
|
||||||
|
class="w-full"
|
||||||
|
v-bind="attrs"
|
||||||
|
@change="handleChange"
|
||||||
|
>
|
||||||
<ElOption
|
<ElOption
|
||||||
v-for="(dict, index) in getDictOption"
|
v-for="(dict, index) in getDictOption"
|
||||||
:key="index"
|
:key="index"
|
||||||
|
|
@ -52,24 +78,32 @@ const getDictOption = computed(() => {
|
||||||
:label="dict.label"
|
:label="dict.label"
|
||||||
/>
|
/>
|
||||||
</ElSelect>
|
</ElSelect>
|
||||||
<ElRadioGroup v-if="selectType === 'radio'" class="w-1/1" v-bind="attrs">
|
<ElRadioGroup
|
||||||
|
v-if="selectType === 'radio'"
|
||||||
|
v-model="selectedValue"
|
||||||
|
class="w-full"
|
||||||
|
v-bind="attrs"
|
||||||
|
@change="handleChange"
|
||||||
|
>
|
||||||
<ElRadio
|
<ElRadio
|
||||||
v-for="(dict, index) in getDictOption"
|
v-for="(dict, index) in getDictOption"
|
||||||
:key="index"
|
:key="index"
|
||||||
:label="dict.value"
|
:value="dict.value"
|
||||||
>
|
>
|
||||||
{{ dict.label }}
|
{{ dict.label }}
|
||||||
</ElRadio>
|
</ElRadio>
|
||||||
</ElRadioGroup>
|
</ElRadioGroup>
|
||||||
<ElCheckboxGroup
|
<ElCheckboxGroup
|
||||||
v-if="selectType === 'checkbox'"
|
v-if="selectType === 'checkbox'"
|
||||||
class="w-1/1"
|
v-model="selectedValue"
|
||||||
|
class="w-full"
|
||||||
v-bind="attrs"
|
v-bind="attrs"
|
||||||
|
@change="handleChange"
|
||||||
>
|
>
|
||||||
<ElCheckbox
|
<ElCheckbox
|
||||||
v-for="(dict, index) in getDictOption"
|
v-for="(dict, index) in getDictOption"
|
||||||
:key="index"
|
:key="index"
|
||||||
:label="dict.value"
|
:value="dict.value"
|
||||||
>
|
>
|
||||||
{{ dict.label }}
|
{{ dict.label }}
|
||||||
</ElCheckbox>
|
</ElCheckbox>
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ export interface DictSelectProps {
|
||||||
dictType: string; // 字典类型
|
dictType: string; // 字典类型
|
||||||
valueType?: 'bool' | 'int' | 'str'; // 字典值类型
|
valueType?: 'bool' | 'int' | 'str'; // 字典值类型
|
||||||
selectType?: 'checkbox' | 'radio' | 'select'; // 选择器类型,下拉框 select、多选框 checkbox、单选框 radio
|
selectType?: 'checkbox' | 'radio' | 'select'; // 选择器类型,下拉框 select、多选框 checkbox、单选框 radio
|
||||||
|
modelValue?: any; // 选中值,由 form-create 通过 modelField 绑定
|
||||||
formCreateInject?: any;
|
formCreateInject?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue