fix: data-mapping, fixed no data source (#1315)
Reviewed-on: daoyoucloud/tachybase#1315 Co-authored-by: bai.zixv <bai.zixv@foxmail.com> Co-committed-by: bai.zixv <bai.zixv@foxmail.com>
This commit is contained in:
parent
0a11007dea
commit
d026303395
@ -12,7 +12,20 @@ export class DataMappingInstruction extends Instruction {
|
|||||||
const { sourceArray, type, code = '', model } = node.config;
|
const { sourceArray, type, code = '', model } = node.config;
|
||||||
// 1. 获取数据源
|
// 1. 获取数据源
|
||||||
let data = {};
|
let data = {};
|
||||||
if (sourceArray.length > 1) {
|
|
||||||
|
switch (sourceArray.length) {
|
||||||
|
case 0: {
|
||||||
|
// 无数据源,使用默认值
|
||||||
|
data = {};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1: {
|
||||||
|
// 单数据源, 平铺为单对象; 忽略keyName
|
||||||
|
const source = sourceArray[0]['sourcePath'];
|
||||||
|
data = processor.getParsedValue(source, node.id);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
// 多个数据源, 进行合并
|
// 多个数据源, 进行合并
|
||||||
data = sourceArray.reduce(
|
data = sourceArray.reduce(
|
||||||
(cookedData, { keyName, sourcePath }) => ({
|
(cookedData, { keyName, sourcePath }) => ({
|
||||||
@ -21,10 +34,7 @@ export class DataMappingInstruction extends Instruction {
|
|||||||
}),
|
}),
|
||||||
{},
|
{},
|
||||||
);
|
);
|
||||||
} else {
|
}
|
||||||
// 单数据源, 平铺为单对象
|
|
||||||
const source = sourceArray[0]['sourcePath'];
|
|
||||||
data = processor.getParsedValue(source, node.id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user