增加checkStrictly属性可以取消级联选择

This commit is contained in:
malin 2018-11-23 16:17:02 +08:00
parent d411992d07
commit b84c8cc4a4

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;
@ -145,7 +149,7 @@
for (let key in changes) { for (let key in changes) {
this.$set(node, key, changes[key]); this.$set(node, key, changes[key]);
} }
if (node[this.childrenKey]) { if (node[this.childrenKey] && !this.checkStrictly) {
node[this.childrenKey].forEach(child => { node[this.childrenKey].forEach(child => {
this.updateTreeDown(child, changes); this.updateTreeDown(child, changes);
}); });