Merge pull request #4893 from qq240814476/treecheck

Tree add checkStrictly prop
This commit is contained in:
Aresn 2018-12-17 10:32:02 +08:00 committed by GitHub
commit 01702799f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -38,6 +38,10 @@
type: Boolean, type: Boolean,
default: false default: false
}, },
checkStrictly:{
type:Boolean,
default:false
},
emptyText: { emptyText: {
type: String type: String
}, },
@ -103,7 +107,7 @@
}, },
updateTreeUp(nodeKey){ updateTreeUp(nodeKey){
const parentKey = this.flatState[nodeKey].parent; const parentKey = this.flatState[nodeKey].parent;
if (typeof parentKey == 'undefined') return; if (typeof parentKey == 'undefined' || this.checkStrictly) return;
const node = this.flatState[nodeKey].node; const node = this.flatState[nodeKey].node;
const parent = this.flatState[parentKey].node; const parent = this.flatState[parentKey].node;
@ -146,6 +150,8 @@
return this.flatState.filter(obj => (obj.node.checked || obj.node.indeterminate)).map(obj => obj.node); return this.flatState.filter(obj => (obj.node.checked || obj.node.indeterminate)).map(obj => obj.node);
}, },
updateTreeDown(node, changes = {}) { updateTreeDown(node, changes = {}) {
if (this.checkStrictly) return;
for (let key in changes) { for (let key in changes) {
this.$set(node, key, changes[key]); this.$set(node, key, changes[key]);
} }