Commit a7409a45 authored by 前端-许佳敏's avatar 前端-许佳敏

修复选中树形根节点时出现无parentId情况

parent 56807783
...@@ -205,11 +205,11 @@ const TabTree:React.FC<TabTreeProps> = (props) => { ...@@ -205,11 +205,11 @@ const TabTree:React.FC<TabTreeProps> = (props) => {
} }
selfActions.getParent = (id) => { selfActions.getParent = (id) => {
console.log(id)
const reductData = treeReduction(treeData) const reductData = treeReduction(treeData)
const targetInfo = reductData[id] const targetInfo = reductData[id]
const parentInfo = reductData[targetInfo.parentId] const parentInfo = reductData[targetInfo.parentId]
return parentInfo || null // fixbug 当选中根节点下的节点时, 由于无parentId, 需自动补充0
return parentInfo || {id: 0}
} }
} }
......
...@@ -114,7 +114,6 @@ export const useTreeTabs = (options: useTreeTabOptions = {}) => { ...@@ -114,7 +114,6 @@ export const useTreeTabs = (options: useTreeTabOptions = {}) => {
const toolsRender = { const toolsRender = {
addNode(node) { addNode(node) {
const activeParentId = treeActions && treeActions.getParent(node.key || node.id)?.id const activeParentId = treeActions && treeActions.getParent(node.key || node.id)?.id
console.log(activeParentId)
setNodeRecord({ setNodeRecord({
...node, ...node,
parentId: activeParentId, // 添加同级的时候 使用上一级的id作为parentId parentId: activeParentId, // 添加同级的时候 使用上一级的id作为parentId
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment