后台系统修改权限回显,设置this.$refs.tree.setChecked(设置的唯一key, true)
handleEdit (index, row) {
this.basic = {}
this.checkArr = []
this.dialogTitle = '修改角色权限'
this.dialogFormVisible = true
this.updataDisable = true
this.defaultCheckedArr = []
//回显数据
this.basic = {
roleId: row.id,
id: row.id,
name: row.name,
description: row.description
}
// 获取树形结构
getMenuTree(row.id).then(res => {
console.log(res)
if (res.code === 0) {
// 设置默认选中的
for (const v of res.data) {
if (v.checked === true) {
console.log(v.id)
this.$refs.tree.setChecked(v.id, true)
}
}
}
})
}
当选中改变的时候 设置check-change方法就可以拿到
cheChange (data, ischecked, checked) {
this.checkArr = this.$refs.tree.getCheckedKeys().concat(this.$refs.tree.getHalfCheckedKeys()).join(',')
console.log(this.checkArr)
},
网友评论