提交 56cec615 编写于 作者: F FateRiddle

fix 表达式解析逻辑

上级 fe250b01
......@@ -3,6 +3,8 @@
### 1.4.3
- [!] 修复了 range 元素的校验,清空后不再会通不过校验
- [!] 修复了 hidden 是表达式时,即使隐藏也还是会被校验的问题
- [!] 修复了复制后的元素与原元素值同步的问题
### 1.4.2
......@@ -29,7 +31,6 @@
- [!] fix 了列表元素上下移动后校验信息展示有误的问题(一个简单 fix,还需后续优化)
- [!] fix 了列表中非 string 类型的元素类型校验一直不通过的问题
- [!] 修复了 hidden 是表达式时,即使隐藏也还是会被校验的问题
- [!] fix 了 min = 0 时,校验信息错误的问题
#### 其他
......
......@@ -424,7 +424,7 @@ export function parseSingleExpression(func, formData = {}, dataPath) {
try {
return Function(str)();
} catch (error) {
console.log(error);
console.log(error, func, dataPath);
return func;
}
// const funcBody = func.substring(2, func.length - 2);
......@@ -479,16 +479,21 @@ export const parseAllExpression = (_schema, formData, dataPath) => {
const schema = clone(_schema);
Object.keys(schema).forEach(key => {
const value = schema[key];
if (isExpression(value)) {
if (isObject(value)) {
// TODO: dataPath 这边要处理一下,否则rootValue类的没有效果
schema[key] = parseAllExpression(value, formData, dataPath);
} else if (isExpression(value)) {
schema[key] = parseSingleExpression(value, formData, dataPath);
// console.log(
// formData.materialType,
// dataPath,
// parseSingleExpression(value, formData, dataPath)
// );
}
// 有可能叫 xxxProps
if (typeof key === 'string' && key.toLowerCase().indexOf('props') > -1) {
} else if (
typeof key === 'string' &&
key.toLowerCase().indexOf('props') > -1
) {
// 有可能叫 xxxProps
const propsObj = schema[key];
if (isObject(propsObj)) {
Object.keys(propsObj).forEach(k => {
......@@ -499,9 +504,6 @@ export const parseAllExpression = (_schema, formData, dataPath) => {
);
});
}
} else if (isObject(value)) {
// TODO: dataPath 这边要处理一下,否则rootValue类的没有效果
schema[key] = parseAllExpression(value, formData, dataPath);
}
});
return schema;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册