HTML
<el-tree
:data="date"
show-checkbox
node-key="moduldCode"
ref="tree"
check-strictly
:highlight-current='true'
:check-on-click-node="true"
:accordion="true"
:default-checked-keys="[checkedkey]"
:default-expanded-keys="checkedkey"
:props="defaultProps"
:default-expand-all="true"
@check-change="parentModules"
></el-tree>
JS
data() {
return {
date: [{
moduldCode: 1,
moduleName: '一级 2',
disabled:true,
child: [{
moduldCode: 3,
moduleName: '二级 2-1',
disabled:true,
child: [{
moduldCode: 4,
moduleName: '三级 3-1-1'
}, {
moduldCode: 5,
moduleName: '三级 3-1-2',
}]
}, {
moduldCode: 2,
moduleName: '二级 2-2',
disabled:true,
child: [{
moduldCode: 6,
moduleName: '三级 3-2-1'
}, {
moduldCode: 7,
moduleName: '三级 3-2-2',
}]
}]
}],
checkedkey: [],
defaultProps: {
children: "child",
label: "moduleName",
id:'moduldCode'
},
uniqueValue:''
}
},
methods:{
parentModules(data,checkbox,node){
if(checkbox){
this.$refs.tree.setCheckedKeys([data.moduldCode]);
this.uniqueValue = this.$refs.tree.getCheckedKeys();
}else{
this.uniqueValue = this.$refs.tree.getCheckedKeys();
if(this.uniqueValue.length == 0){
this.uniqueValue = ''
}
}
},
modification() {
this.$axios.post("/admin/module/detail", {obj}).then(res => {
this.checkedkey[0] = res.date.moduleCode;
});
}
}
本文共 245个字数,平均阅读时长 ≈ 1分钟,您已阅读:0时0分6秒。
评论 (0)