|
|
|
@ -2577,10 +2577,39 @@ function getAssociatedFormsCurrentFieldTree1() { |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
function removeTreeNode(tree: any, targetId: any) { |
|
|
|
// 深拷贝原始树结构避免污染原数据 |
|
|
|
const clonedTree = JSON.parse(JSON.stringify(tree)); |
|
|
|
|
|
|
|
// 递归处理节点 |
|
|
|
function processNode(node) { |
|
|
|
// 命中目标节点时返回null进行过滤 |
|
|
|
if (node.id === targetId) return null; |
|
|
|
|
|
|
|
// 递归处理子节点并过滤空值 |
|
|
|
if (node.children?.length) { |
|
|
|
node.children = node.children |
|
|
|
.map(child => processNode(child)) |
|
|
|
.filter(Boolean); |
|
|
|
} |
|
|
|
|
|
|
|
return node; |
|
|
|
} |
|
|
|
|
|
|
|
// 处理单根或多根树结构 |
|
|
|
const result = Array.isArray(clonedTree) |
|
|
|
? clonedTree.map(node => processNode(node)).filter(Boolean) |
|
|
|
: processNode(clonedTree); |
|
|
|
|
|
|
|
return result || null; |
|
|
|
} |
|
|
|
|
|
|
|
const customerFormTree = ref<Tree[]>(); |
|
|
|
getCustomerFormList().then(({ data }) => { |
|
|
|
let resData = ref(data.children); |
|
|
|
/* console.log(data.children) |
|
|
|
console.log(props.customerformid) */ |
|
|
|
let datachildrenWithoutSelf = removeTreeNode(data.children,props.customerformid) |
|
|
|
let resData = ref(datachildrenWithoutSelf); |
|
|
|
customerFormTree.value = [ |
|
|
|
{ |
|
|
|
id: data.id, |
|
|
|
|