refactor:修改父ID取值逻辑

This commit is contained in:
DosLin
2018-06-25 10:53:10 +08:00
committed by GitHub
parent 6dffa7378c
commit 69571f2916
+6 -4
View File
@@ -98,8 +98,12 @@ const Menus = ({
let result = [String(current[id])]
const getPath = (item) => {
if (item && item[pid]) {
result.unshift(String(item[pid]))
getPath(queryArray(array, item[pid], id))
if (item[pid] === '-1') {
result.unshift(String(item['bpid']))
} else {
result.unshift(String(item[pid]))
getPath(queryArray(array, item[pid], id))
}
}
}
getPath(current)
@@ -111,8 +115,6 @@ const Menus = ({
if (!defaultSelectedKeys) {
defaultSelectedKeys = ['1']
} else if(defaultSelectedKeys[0] === '-1') {
defaultSelectedKeys = [defaultSelectedKeys[1].toString()[0]]
}
return (