🍓 feat(sysDict): 优化字典组件功能
This commit is contained in:
parent
89533cb060
commit
0c4dd289d3
@ -270,7 +270,7 @@ const currentDictItems = computed(() => {
|
|||||||
if (!state.value) return null;
|
if (!state.value) return null;
|
||||||
|
|
||||||
if (Array.isArray(state.value)) {
|
if (Array.isArray(state.value)) {
|
||||||
// 确保回显时也去重
|
// 去重
|
||||||
const uniqueValues = [...new Set(state.value)];
|
const uniqueValues = [...new Set(state.value)];
|
||||||
return formattedDictData.value.filter((item) => uniqueValues.includes(item.value));
|
return formattedDictData.value.filter((item) => uniqueValues.includes(item.value));
|
||||||
}
|
}
|
||||||
@ -296,7 +296,7 @@ const getDataList = (): DictItem[] => {
|
|||||||
|
|
||||||
return data.map((item: any) => ({
|
return data.map((item: any) => ({
|
||||||
...item,
|
...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,
|
value: item[props.propValue] ?? item.code,
|
||||||
}));
|
}));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -445,7 +445,7 @@ const updateValue = (newValue: any) => {
|
|||||||
|
|
||||||
state.value = processedValue;
|
state.value = processedValue;
|
||||||
emit('update:modelValue', emitValue === '' ? undefined : emitValue);
|
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>
|
</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-option v-for="(item, index) in formattedDictData" :key="index" :label="getDisplayText(item)" :value="item.value" :disabled="item.disabled" />
|
||||||
</el-select>
|
</el-select>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user