Recursive acquisition tree structure will report the following bug, with four or five layers at present. As long as you expand the node, you will report the following error. I have tried to expand the first layer without recursion, but I will report an error as soon as it is recursive
Code:
search2 (rows:any, parentId:any) {
let result:any = [];
for (var i = 0; i < rows.length; iPP) {
var row = rows[i];
if (!!parentId) {
if (row.ParentId == parentId) {
result.push(row);
}
} else {
if (!!row.ParentId && row.ParentId == 0) {
result.push(row);
}
}
}
return result;
}
createChildTree2 (rows:any, parentTree:any) {
let nodeList:any = [];
let drs = this.search2(rows, parentTree.id);
let childrenData:Array<Model.treeGridModel>=[]
for (let i = 0; i < drs.length; iPP) {
let tree = {
id:0,
code:0,
name:"",
status:"",
remark:"",
parentId:0,
_checked:false,
isChecked:false,
children:childrenData,
selected:false,
expanded:false,
load:false,
parent:parent,
level:1,
isShow:true,
spaceHtml:""
};
let dr = drs[i];
tree.id=dr["JobPositionId"]
tree.code=dr["JobPositionId"]
tree.name=dr["JobPositionName"]
tree.status=dr["JobPositionName"]
tree.remark=dr["JobPositionName"]
tree.parentId=dr["ParentId"]
tree._checked=false
tree.isChecked=false
tree.children=this.createChildTree2(rows, tree);
tree.selected=false
tree.expanded=false
tree.load=false
tree.parent=parent
tree.level=1
tree.isShow=true
tree.spaceHtml=""
nodeList.push(tree);
}
return nodeList;
}
async getPostTypeList () {
let rs=await jobService.getJobList()
let treeList:any = [];
let rows=rs!.data.data
let childrenData:Array<Model.treeGridModel>=[]
let parent:object={}
let drs = this.search2(rows, "");
for (let i = 0; i < drs.length; iPP) {
let dr = drs[i];
let tree = {
id:0,
code:0,
name:"",
status:"",
remark:"",
parentId:0,
_checked:false,
isChecked:false,
children:childrenData,
selected:false,
expanded:false,
load:false,
parent:parent,
level:1,
isShow:true,
spaceHtml:""
};
tree.id=dr["JobPositionId"]
tree.code=dr["JobPositionId"]
tree.name=dr["JobPositionName"]
tree.status=dr["JobPositionName"]
tree.remark=dr["JobPositionName"]
tree.parentId=dr["ParentId"]
tree._checked=false
tree.isChecked=false
tree.children=this.createChildTree2(rows, tree);
tree.selected=false
tree.expanded=false
tree.load=false
tree.parent=parent
tree.level=1
tree.isShow=true
tree.spaceHtml=""
treeList.push(tree);
}
return treeList
}
vue.runtime.esm.js:588 [Vue warn]: Error in render: "RangeError: Maximum call stack size exceeded"
warn @ vue.runtime.esm.js:588
logError @ vue.runtime.esm.js:1732
globalHandleError @ vue.runtime.esm.js:1727
handleError @ vue.runtime.esm.js:1716
Vue._render @ vue.runtime.esm.js:4534
updateComponent @ vue.runtime.esm.js:2783
get @ vue.runtime.esm.js:3137
run @ vue.runtime.esm.js:3214
flushSchedulerQueue @ vue.runtime.esm .js: 2976
(anonymous) @ vue.runtime.esm.js:1832
flushCallbacks @ vue.runtime.esm.js:1753
vue.runtime.esm.js:1736 RangeError: Maximum call stack size exceeded
at _traverse (vue.runtime.esm.js:1966)
at _traverse (vue.runtime.esm.js:1966)
at _traverse (vue.runtime.esm.js:1966)
at _traverse (vue.runtime.esm.js:1966)
at _traverse (vue.runtime.esm.js:1966)
at _traverse (vue.runtime.esm.js:1966)
at _traverse (vue.runtime.esm.js:1966)
at _traverse (vue.runtime.esm.js:1966)
at _traverse (vue.runtime.esm.js:1966)
at _traverse (vue.runtime.esm.js:1966)