[update] 授权部门先勾选复选框再切换树操作,显示子节点选中实际没选中的问题
This commit is contained in:
@@ -304,9 +304,39 @@ export default {
|
|||||||
}
|
}
|
||||||
return rows
|
return rows
|
||||||
},
|
},
|
||||||
|
// 获取currKeys及其子节点
|
||||||
|
getChildrenTreeData (currKeys, treeData) {
|
||||||
|
const childrenKeys = []
|
||||||
|
for (let i = 0; i < treeData.length; i++) {
|
||||||
|
if (currKeys.includes(treeData[i].key)) {
|
||||||
|
childrenKeys.push(treeData[i].key)
|
||||||
|
if (treeData[i].children) {
|
||||||
|
const childrenKeysArr = this.getChildrenKeys(treeData[i].children)
|
||||||
|
childrenKeys.push(...childrenKeysArr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (treeData[i].children) {
|
||||||
|
childrenKeys.push(...this.getChildrenTreeData(currKeys, treeData[i].children))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return childrenKeys
|
||||||
|
},
|
||||||
|
// 把传入的树结构key值全部存成一个数组
|
||||||
|
getChildrenKeys (treeData) {
|
||||||
|
const arr = []
|
||||||
|
for (const item of treeData) {
|
||||||
|
arr.push(item.key)
|
||||||
|
if (item.children) {
|
||||||
|
arr.push(...this.getChildrenKeys(item.children))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return arr
|
||||||
|
},
|
||||||
switchCheckStrictly (v) {
|
switchCheckStrictly (v) {
|
||||||
if (v === 1) {
|
if (v === 1) {
|
||||||
this.checkStrictly = false
|
this.checkStrictly = false
|
||||||
|
this.checkedKeys = this.getChildrenTreeData(this.checkedKeys, this.treeData)
|
||||||
|
this.checkedRows = this.getCheckedRows(this.checkedKeys)
|
||||||
} else if (v === 2) {
|
} else if (v === 2) {
|
||||||
this.checkStrictly = true
|
this.checkStrictly = true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user