引用模板做选择导入的时候自动选中复选框
//引入子模板时每次都自动运行methods里面的loadData方法加载数据,只需将ID给加到selectedRowKeys中即可
//请求后台
getAction(this.url.list,params).then(res=>{
this.dataSource = this.getDataByResult(res.result.records)
//循环取出数据
this.dataSource.forEach(function(val){
v isCheck = val.isCheck;
if(isCheck == 0){//如果为0默认选中
let id = val.id;
that.selectedRowKeys.push(id)
}
});
})
getDataByResult(result){
if(result){
return result.map(item=>{
//判断是否标记了带有子节点
if(item[this.hasChildrenField]=='1'){
let loadChild = { id: item.id+'_loadChild', name: 'loading...', isLoading: true }
item.children = [loadChild]
}
return item
})
}
}