权限设置 element - ui 树形控件 父级半选状态id和选中子级id一起传给后台 回显去掉父级半选状态id
element
A Vue.js 2.0 UI Toolkit for Web
项目地址:https://gitcode.com/gh_mirrors/eleme/element
免费下载资源
·
< el - tree
default - expand - all
:data = "treeData"
show - checkbox
node - key = "id"
:filter - node - method = "filterNode"
:default - checked - keys = "checkedKeys"
ref = "menuTree"
@check - change = "getNodeData"
:props = "defaultProps" >
</el - tree >
//传给后台
var parentArr = this.$refs.menuTree.getHalfCheckedKeys();
var childeArr = this.$refs.menuTree.getCheckedKeys();
var arr = childeArr.concat(parentArr);
//更新数据时的树形显示 (去掉半选状态id避免视图半选状态id下全选)
var arr = response.data; //后台返回的id组成的数组
var newArr = [];
var item = '';
arr.forEach(item=>{
checked(item,this.treeData,newArr)
})
this.checkedKeys = newArr;
function checked(id,data,newArr){
data.forEach(item => {
if(item.id == id){
if( item.children.length == 0 ){
newArr.push(item.id)
}
}else{
if( item.children.length !=0 ){
checked(id,item.children,newArr)
}
}
});
};
GitHub 加速计划 / eleme / element
54.06 K
14.63 K
下载
A Vue.js 2.0 UI Toolkit for Web
最近提交(Master分支:2 个月前 )
c345bb45
6 个月前
a07f3a59
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update table.md
* Update transition.md
* Update popover.md 7 个月前
更多推荐
已为社区贡献3条内容
所有评论(0)