只有点击父级的时候才会触发懒加载的函数,现在我想添加修改的时候也触发这个函数,不过这个load函数中的resolve我不知道怎么传?还是用什么其他办法解决???
:data="tableData"
row-key="id"
lazy
:load="load"
border>
prop="name"
label="类目名称"
width="180">
prop="categoryLevel"
label="类目层级"
width="180">
prop="categoryType"
label="类目类型">
//树型懒加载,加载层级类目
load(tree, treeNode, resolve) {
//tree为点击那一行的数据
let value = tree
console.log(tree)
if(tree.categoryLevel < 3){
api.listByLevel({
pid:tree.id,
categoryLevel:tree.categoryLevel+1
}).then((res)=>{
console.log(res)
var levelData = res.data.data
if(tree.categoryLevel < 2){
for(let i in levelData){
levelData[i].hasChildren = true
}
}
resolve(levelData)
})
}
},
//确认添加商品类目
addCommodityCategory(){
api.addCommodityCategory({
name:this.formLevel.name,
imagePath:this.formLevel.imagePath,
categoryLevel:this.formLevel.categoryLevel,
pid:this.formLevel.id,
icon:this.formLevel.icon,
categoryType:this.formLevel.categoryType,
thirdPartyCategoryId:this.formLevel.thirdPartyCategoryId,
thirdPartyCategoryName:this.formLevel.thirdPartyCategoryName,
enabled:this.formLevel.enabled,
}).then((res)=>{
console.log(res)
var code = res.data.code
if(code == 10000){
this.$message.success("添加成功")
if(this.formLevel.categoryLevel == 1){
this.getListByLevel(0,1)
}else{
this.load(this.formLevel,)
}
}
})
},