a-tree-select组件的change修改事件名
This commit is contained in:
@@ -21,7 +21,11 @@
|
||||
|
||||
export default {
|
||||
name: 'JCategorySelect',
|
||||
props:{
|
||||
props: {
|
||||
value:{
|
||||
// type: String,
|
||||
required: false
|
||||
},
|
||||
placeholder:{
|
||||
type: String,
|
||||
default: '请选择',
|
||||
@@ -52,7 +56,7 @@
|
||||
default:'',
|
||||
required:false
|
||||
},
|
||||
pcode:{
|
||||
pCode:{
|
||||
type:String,
|
||||
default:'',
|
||||
required:false
|
||||
@@ -72,13 +76,14 @@
|
||||
tableName:"",
|
||||
text:"",
|
||||
code:"",
|
||||
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
value () {
|
||||
this.loadItemByCode()
|
||||
},
|
||||
pcode(){
|
||||
pCode(){
|
||||
this.loadRoot();
|
||||
}
|
||||
},
|
||||
@@ -100,7 +105,7 @@
|
||||
loadRoot(){
|
||||
let param = {
|
||||
pid:this.pid,
|
||||
pcode:!this.pcode?'0':this.pcode,
|
||||
pcode:!this.pCode?'0':this.pCode,
|
||||
condition:this.condition
|
||||
}
|
||||
getAction(this.url,param).then(res=>{
|
||||
@@ -127,13 +132,15 @@
|
||||
}else{
|
||||
getAction(this.view,{ids:this.value}).then(res=>{
|
||||
if(res.success){
|
||||
let values = this.value.split(',')
|
||||
this.treeValue = res.result.map((item, index) => ({
|
||||
key: values[index],
|
||||
value: values[index],
|
||||
label: item
|
||||
}))
|
||||
this.onLoadTriggleChange(res.result[0]);
|
||||
if (res.result && res.result.length > 0) {
|
||||
let values = this.value.split(',')
|
||||
this.treeValue = res.result.map((item, index) => ({
|
||||
key: values[index],
|
||||
value: values[index],
|
||||
label: item
|
||||
}))
|
||||
this.onLoadTriggleChange(res.result[0]);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -145,12 +152,14 @@
|
||||
}
|
||||
},
|
||||
backValue(value,label){
|
||||
console.log(label)
|
||||
let obj = {}
|
||||
if(this.back){
|
||||
obj[this.back] = label
|
||||
}
|
||||
// this.$emit('change', value, obj)
|
||||
/*
|
||||
* 使用$listeners向上暴露事件---和$emit一起使用出现的问题:change事件会执行两遍
|
||||
* 解决办法:改变选中时提交的事件名*/
|
||||
this.$emit('changeValue', value, obj)
|
||||
},
|
||||
asyncLoadTreeData (treeNode) {
|
||||
return new Promise((resolve) => {
|
||||
@@ -199,7 +208,10 @@
|
||||
|
||||
onChange(value){
|
||||
if(!value){
|
||||
// this.$emit('change', '');
|
||||
/*
|
||||
* 使用$listeners向上暴露事件---和$emit一起使用出现的问题:change事件会执行两遍
|
||||
* 解决办法:改变选中时提交的事件名*/
|
||||
this.$emit('changeValue', '');
|
||||
this.treeValue = ''
|
||||
} else if (Array.isArray(value)) {
|
||||
let labels = []
|
||||
@@ -218,13 +230,13 @@
|
||||
return this.treeData
|
||||
},
|
||||
validateProp(){
|
||||
let mycondition = this.condition
|
||||
let myCondition = this.condition
|
||||
return new Promise((resolve,reject)=>{
|
||||
if(!mycondition){
|
||||
if(!myCondition){
|
||||
resolve();
|
||||
}else{
|
||||
try {
|
||||
let test=JSON.parse(mycondition);
|
||||
let test=JSON.parse(myCondition);
|
||||
if(typeof test == 'object' && test){
|
||||
resolve()
|
||||
}else{
|
||||
|
||||
Reference in New Issue
Block a user