🍓 feat(sysDict): 优化字典组件功能

This commit is contained in:
喵你个汪呀 2025-08-23 22:41:05 +08:00
parent 89533cb060
commit 0c4dd289d3

View File

@ -270,7 +270,7 @@ const currentDictItems = computed(() => {
if (!state.value) return null;
if (Array.isArray(state.value)) {
//
//
const uniqueValues = [...new Set(state.value)];
return formattedDictData.value.filter((item) => uniqueValues.includes(item.value));
}
@ -296,7 +296,7 @@ const getDataList = (): DictItem[] => {
return data.map((item: any) => ({
...item,
label: item[props.propLabel] ?? item.name,
label: item[props.propLabel] ?? [item.name, item.desc].filter(x => x).join("-"),
value: item[props.propValue] ?? item.code,
}));
} catch (error) {
@ -445,7 +445,7 @@ const updateValue = (newValue: any) => {
state.value = processedValue;
emit('update:modelValue', emitValue === '' ? undefined : emitValue);
emit('change', state.value, state.dictData);
emit('change', state.value, currentDictItems, state.dictData);
};
/**
@ -539,7 +539,7 @@ watch(() => [userStore.dictList, userStore.constList, state], initData, { immedi
</template>
<!-- 渲染选择器 -->
<el-select v-else-if="props.renderAs === 'select'" v-model="state.value" v-bind="$attrs" :multiple="props.multiple" @change="updateValue" clearable>
<el-select v-else-if="props.renderAs === 'select'" v-model="state.value" v-bind="$attrs" :multiple="props.multiple" @change="updateValue">
<el-option v-for="(item, index) in formattedDictData" :key="index" :label="getDisplayText(item)" :value="item.value" :disabled="item.disabled" />
</el-select>