修复资产元数据回显问题
This commit is contained in:
@@ -964,7 +964,16 @@ const openDialog = (row?: any, edit?: boolean) => {
|
|||||||
if (Array.isArray(data.metadata)) {
|
if (Array.isArray(data.metadata)) {
|
||||||
data.metadata.forEach((item: any) => {
|
data.metadata.forEach((item: any) => {
|
||||||
if (item.name) {
|
if (item.name) {
|
||||||
ruleForm.metadata[item.name] = item.value;
|
let val = item.value;
|
||||||
|
// 修复回显问题:如果 value 不存在但 options 存在,尝试从 options 恢复值
|
||||||
|
if ((val === undefined || val === null) && item.options && item.options.length > 0) {
|
||||||
|
if (item.type === 'multi_select') {
|
||||||
|
val = item.options.map((opt: any) => opt.value);
|
||||||
|
} else if (item.type === 'select') {
|
||||||
|
val = item.options[0].value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ruleForm.metadata[item.name] = val;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user