为字典类型属性添加选项禁用逻辑,防止同一字典被多个属性重复使用
This commit is contained in:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user