需要实现这样的效果,单行校验表格树
公共方法可以直接用
const findPosi = (tree, targetId, path = "") => {
for (let i = 0; i < tree.length; i++) {
const node = tree[i];
if (node.id === targetId) {
return path + i;
}
if (node.sub_parameters && node.sub_parameters.length > 0) {
const childPath = `${path}${i}.sub_parameters.`;
const result = findPosi(node.sub_parameters, targetId, childPath);
if (result !== null) {
return result;
}
}
}
return null;
};
规则对象跟输入部分表单重复了,名字没改