为字典类型属性添加选项禁用逻辑,防止同一字典被多个属性重复使用

This commit is contained in:
WUSIJIAN
2025-12-29 10:18:34 +08:00
parent fc932a52f0
commit e553cd9222

View File

@@ -68,6 +68,7 @@
:key="idx"
:label="item.name || ''"
:value="item.name || ''"
:disabled="isDictOptionDisabled(item.name || '', attr)"
/>
</el-select>
</div>
@@ -249,6 +250,13 @@ const onDictKeyChange = (attr: CustomAttr) => {
attr.options = [];
};
// 判断字典选项是否应被禁用
const isDictOptionDisabled = (dictName: string, currentAttr: CustomAttr) => {
if (!dictName) return false;
// 检查该字典名称是否已被其他属性使用
return ruleForm.attrs.some((attr) => attr !== currentAttr && isDictType(attr.type) && attr.name === dictName);
};
// 添加自定义属性
const addAttr = () => {
ruleForm.attrs.push({