|
@@ -74,7 +74,12 @@
|
|
type: Boolean,
|
|
type: Boolean,
|
|
default: false,
|
|
default: false,
|
|
required:false
|
|
required:false
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+ // 是否只选择子节点,为True时只有叶子节点可以选择
|
|
|
|
+ chooseChild: {
|
|
|
|
+ type: Boolean,
|
|
|
|
+ default: false,
|
|
|
|
+ },
|
|
},
|
|
},
|
|
data () {
|
|
data () {
|
|
return {
|
|
return {
|
|
@@ -156,8 +161,14 @@
|
|
i.value = i.key
|
|
i.value = i.key
|
|
if(i.leaf==false){
|
|
if(i.leaf==false){
|
|
i.isLeaf=false
|
|
i.isLeaf=false
|
|
|
|
+ if(this.chooseChild) {
|
|
|
|
+ i.selectable = false;
|
|
|
|
+ }
|
|
}else if(i.leaf==true){
|
|
}else if(i.leaf==true){
|
|
i.isLeaf=true
|
|
i.isLeaf=true
|
|
|
|
+ if(this.chooseChild && i.parentId ==='0') {
|
|
|
|
+ i.selectable = false;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
this.addChildren(pid,res.result,this.treeData)
|
|
this.addChildren(pid,res.result,this.treeData)
|
|
@@ -173,14 +184,24 @@
|
|
if(item.key == pid){
|
|
if(item.key == pid){
|
|
if(!children || children.length==0){
|
|
if(!children || children.length==0){
|
|
item.isLeaf=true
|
|
item.isLeaf=true
|
|
|
|
+ if(this.chooseChild && item.parentId ==='0') {
|
|
|
|
+ children.selectable = false;
|
|
|
|
+ }
|
|
}else{
|
|
}else{
|
|
item.children = children
|
|
item.children = children
|
|
|
|
+ if(this.chooseChild) {
|
|
|
|
+ item.selectable = false;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
break
|
|
break
|
|
}else{
|
|
}else{
|
|
this.addChildren(pid,children,item.children)
|
|
this.addChildren(pid,children,item.children)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ if(this.chooseChild && children.parentId ==='0') {
|
|
|
|
+ children.selectable = false;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
},
|
|
},
|
|
loadRoot(){
|
|
loadRoot(){
|
|
@@ -199,8 +220,14 @@
|
|
i.value = i.key
|
|
i.value = i.key
|
|
if(i.leaf==false){
|
|
if(i.leaf==false){
|
|
i.isLeaf=false
|
|
i.isLeaf=false
|
|
|
|
+ if(this.chooseChild) {
|
|
|
|
+ i.selectable = false;
|
|
|
|
+ }
|
|
}else if(i.leaf==true){
|
|
}else if(i.leaf==true){
|
|
i.isLeaf=true
|
|
i.isLeaf=true
|
|
|
|
+ if(this.chooseChild && i.parentId ==='0') {
|
|
|
|
+ i.selectable = false;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
this.treeData = [...res.result]
|
|
this.treeData = [...res.result]
|