【issues/5467】ApiSelect修复覆盖了用户传递的方法

pull/824/head
zhangdaiscott 2023-10-18 16:54:24 +08:00
parent 8ff3f4db25
commit 1ea4008998
1 changed files with 16 additions and 13 deletions

View File

@ -1,5 +1,5 @@
<template>
<Select @dropdownVisibleChange="handleFetch" v-bind="attrs_" @change="handleChange" :options="getOptions" v-model:value="state" :filterOption="filterOption">
<Select @dropdownVisibleChange="handleFetch" v-bind="attrs_" @change="handleChange" :options="getOptions" v-model:value="state">
<template #[item]="data" v-for="item in Object.keys($slots)">
<slot :name="item" v-bind="data || {}"></slot>
</template>
@ -66,11 +66,24 @@
// update-begin--author:liaozhiyang---date:20230830---forQQYUN-6308
let vModalValue: any;
const attrs_ = computed(() => {
let obj: any = unref(attrs);
let obj: any = unref(attrs) || {};
if (obj && obj['onUpdate:value']) {
vModalValue = obj['onUpdate:value'];
delete obj['onUpdate:value'];
}
// update-begin--author:liaozhiyang---date:20231017---forissues/5467ApiSelect
if (obj['filterOption'] === undefined) {
// update-begin--author:liaozhiyang---date:20230904---forissues/5305
obj['filterOption'] = (inputValue, option) => {
if (typeof option['label'] === 'string') {
return option['label'].toLowerCase().indexOf(inputValue.toLowerCase()) != -1;
} else {
return true;
}
};
// update-end--author:liaozhiyang---date:20230904---forissues/5305
}
// update-end--author:liaozhiyang---date:20231017---forissues/5467ApiSelect
return obj;
});
// update-begin--author:liaozhiyang---date:20230830---forQQYUN-6308
@ -154,17 +167,7 @@
emitData.value = args;
}
// update-begin--author:liaozhiyang---date:20230904---forissues/5305
const filterOption = (inputValue, option) => {
if (typeof option['label'] === 'string') {
return option['label'].toLowerCase().indexOf(inputValue.toLowerCase()) != -1;
} else {
return true;
}
};
// update-begin--author:liaozhiyang---date:20230904---forissues/5305
return { state, attrs_, attrs, getOptions, loading, t, handleFetch, handleChange, filterOption };
return { state, attrs_, attrs, getOptions, loading, t, handleFetch, handleChange };
},
});
</script>